You can update locations
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
-- 1529091932 DOWN add-location-to-expense-account
|
||||||
|
|
||||||
|
ALTER TABLE invoices_expense_accounts drop COLUMN location ;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- 1529091932 UP add-location-to-expense-account
|
||||||
|
ALTER TABLE invoices_expense_accounts ADD COLUMN location varchar(255);
|
||||||
@@ -107,6 +107,7 @@
|
|||||||
{:fields {:id {:type 'Int}
|
{:fields {:id {:type 'Int}
|
||||||
:invoice_id {:type 'Int}
|
:invoice_id {:type 'Int}
|
||||||
:expense_account_id {:type 'Int}
|
:expense_account_id {:type 'Int}
|
||||||
|
:location {:type 'String}
|
||||||
:expense_account {:type :expense_account
|
:expense_account {:type :expense_account
|
||||||
:resolve :get-expense-account}
|
:resolve :get-expense-account}
|
||||||
:amount {:type 'String}}}
|
:amount {:type 'String}}}
|
||||||
@@ -213,6 +214,7 @@
|
|||||||
:edit_expense_account
|
:edit_expense_account
|
||||||
{:fields {:id {:type 'Int}
|
{:fields {:id {:type 'Int}
|
||||||
:expense_account_id {:type 'Int}
|
:expense_account_id {:type 'Int}
|
||||||
|
:location {:type 'String}
|
||||||
:amount {:type 'String}}}
|
:amount {:type 'String}}}
|
||||||
|
|
||||||
:add_invoice
|
:add_invoice
|
||||||
|
|||||||
@@ -29,9 +29,10 @@
|
|||||||
(invoices-expense-accounts/get-for-invoice (:id value))))
|
(invoices-expense-accounts/get-for-invoice (:id value))))
|
||||||
|
|
||||||
(defn edit-expense-accounts [context args value]
|
(defn edit-expense-accounts [context args value]
|
||||||
(invoices-expense-accounts/replace-for-invoice (:invoice_id args) (map (fn [{:keys [id expense_account_id amount]}]
|
(invoices-expense-accounts/replace-for-invoice (:invoice_id args) (map (fn [{:keys [id expense_account_id amount location]}]
|
||||||
{
|
{
|
||||||
:expense-account-id expense_account_id
|
:expense-account-id expense_account_id
|
||||||
|
:location location
|
||||||
:amount (Double/parseDouble amount)} )
|
:amount (Double/parseDouble amount)} )
|
||||||
(:expense_accounts args)))
|
(:expense_accounts args)))
|
||||||
(->graphql
|
(->graphql
|
||||||
|
|||||||
@@ -6,5 +6,6 @@
|
|||||||
(s/def ::vendor-id int?)
|
(s/def ::vendor-id int?)
|
||||||
(s/def ::expense-account-id int?)
|
(s/def ::expense-account-id int?)
|
||||||
(s/def ::amount ::shared/money)
|
(s/def ::amount ::shared/money)
|
||||||
|
(s/def ::location string?)
|
||||||
|
|
||||||
(s/def ::invoices-expense-account (s/keys :opt-un [::vendor-id ::expense-account-id ::amount]))
|
(s/def ::invoices-expense-account (s/keys :opt-un [::vendor-id ::expense-account-id ::amount ::location]))
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
:company-id (:id @(re-frame/subscribe [::subs/company])))
|
:company-id (:id @(re-frame/subscribe [::subs/company])))
|
||||||
[[:invoices [:id :total :outstanding-balance :invoice-number :date
|
[[:invoices [:id :total :outstanding-balance :invoice-number :date
|
||||||
[:vendor [:name :id]]
|
[:vendor [:name :id]]
|
||||||
[:expense_accounts [:amount :id :expense_account_id
|
[:expense_accounts [:amount :id :expense_account_id :location
|
||||||
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
||||||
[:company [:name :id]]
|
[:company [:name :id :locations]]
|
||||||
[:checks [:amount [:check [:amount :s3_url :check_number ]]]]
|
[:checks [:amount [:check [:amount :s3_url :check_number ]]]]
|
||||||
]]
|
]]
|
||||||
:total
|
:total
|
||||||
|
|||||||
@@ -250,13 +250,14 @@
|
|||||||
{:invoice-id id
|
{:invoice-id id
|
||||||
:expense-accounts (map (fn [ea] {:id (:id ea)
|
:expense-accounts (map (fn [ea] {:id (:id ea)
|
||||||
:amount (:amount ea)
|
:amount (:amount ea)
|
||||||
|
:location (:location ea)
|
||||||
:expense-account-id (:expense-account-id ea)})
|
:expense-account-id (:expense-account-id ea)})
|
||||||
expense-accounts)}
|
expense-accounts)}
|
||||||
[:id :total :outstanding-balance :invoice-number :date
|
[:id :total :outstanding-balance :invoice-number :date
|
||||||
[:vendor [:name :id]]
|
[:vendor [:name :id]]
|
||||||
[:expense_accounts [:amount :id :expense_account_id
|
[:expense_accounts [:amount :id :location :expense_account_id
|
||||||
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
||||||
[:company [:name :id]]
|
[:company [:name :id :locations]]
|
||||||
[:checks [:amount [:check [:amount :s3_url :check_number ]]]]
|
[:checks [:amount [:check [:amount :s3_url :check_number ]]]]
|
||||||
]]}]}
|
]]}]}
|
||||||
:on-success [::expense-accounts-updated]}})))
|
:on-success [::expense-accounts-updated]}})))
|
||||||
@@ -290,7 +291,8 @@
|
|||||||
(drop (inc index) expense-accounts))))))
|
(drop (inc index) expense-accounts))))))
|
||||||
|
|
||||||
(defn change-expense-accounts-modal []
|
(defn change-expense-accounts-modal []
|
||||||
(let [{{:keys [expense-accounts total] :or {expense-accounts [] total 0}} :invoice :as data} @(re-frame/subscribe [::change-expense-accounts])
|
(let [{{:keys [expense-accounts total ] :or {expense-accounts [] total 0} {:keys [locations]} :company} :invoice :as data} @(re-frame/subscribe [::change-expense-accounts])
|
||||||
|
should-select-location? (> (count locations) 1)
|
||||||
change-event [::events/change-form [::change-expense-accounts]]
|
change-event [::events/change-form [::change-expense-accounts]]
|
||||||
expense-accounts-total (->> expense-accounts
|
expense-accounts-total (->> expense-accounts
|
||||||
(map :amount)
|
(map :amount)
|
||||||
@@ -311,6 +313,8 @@
|
|||||||
[:thead
|
[:thead
|
||||||
[:tr
|
[:tr
|
||||||
[:th {:style {:width "500px"}} "Expense Account"]
|
[:th {:style {:width "500px"}} "Expense Account"]
|
||||||
|
(when should-select-location?
|
||||||
|
[:th {:style {:width "500px"}} "Location"])
|
||||||
[:th {:style {:width "300px"}} "Amount"]
|
[:th {:style {:width "300px"}} "Amount"]
|
||||||
[:th {:style {:width "5em"}}]]]
|
[:th {:style {:width "5em"}}]]]
|
||||||
[:tbody
|
[:tbody
|
||||||
@@ -325,6 +329,17 @@
|
|||||||
:spec ::invoice/vendor-id
|
:spec ::invoice/vendor-id
|
||||||
:subscription data}]]]]
|
:subscription data}]]]]
|
||||||
|
|
||||||
|
(when should-select-location?
|
||||||
|
[:td
|
||||||
|
[:div.select
|
||||||
|
[bind-field
|
||||||
|
[:select {:type "select"
|
||||||
|
:field [:invoice :expense-accounts index :location]
|
||||||
|
:spec (set locations)
|
||||||
|
:event change-event
|
||||||
|
:subscription data}
|
||||||
|
(map (fn [l] [:option {:value l} l]) locations)]]]
|
||||||
|
])
|
||||||
|
|
||||||
[:td
|
[:td
|
||||||
[:div.control
|
[:div.control
|
||||||
|
|||||||
Reference in New Issue
Block a user