Merge branch 'master' into side-panel
This commit is contained in:
@@ -9,10 +9,42 @@
|
|||||||
<link rel="stylesheet" href="style.css"></head>
|
<link rel="stylesheet" href="style.css"></head>
|
||||||
<body>
|
<body>
|
||||||
<div class="bgc1 clearfix">
|
<div class="bgc1 clearfix">
|
||||||
<h1 class="mhmm mvm"><span class="fgc1">Font Name:</span> icomoon <small class="fgc1">(Glyphs: 93)</small></h1>
|
<h1 class="mhmm mvm"><span class="fgc1">Font Name:</span> icomoon <small class="fgc1">(Glyphs: 95)</small></h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix mhl ptl">
|
<div class="clearfix mhl ptl">
|
||||||
<h1 class="mvm mtn fgc1">Grid Size: Unknown</h1>
|
<h1 class="mvm mtn fgc1">Grid Size: Unknown</h1>
|
||||||
|
<div class="glyph fs1">
|
||||||
|
<div class="clearfix bshadow0 pbs">
|
||||||
|
<span class="icon-bin-2">
|
||||||
|
|
||||||
|
</span>
|
||||||
|
<span class="mls"> icon-bin-2</span>
|
||||||
|
</div>
|
||||||
|
<fieldset class="fs0 size1of1 clearfix hidden-false">
|
||||||
|
<input type="text" readonly value="e95e" class="unit size1of2" />
|
||||||
|
<input type="text" maxlength="1" readonly value="" class="unitRight size1of2 talign-right" />
|
||||||
|
</fieldset>
|
||||||
|
<div class="fs0 bshadow0 clearfix hidden-true">
|
||||||
|
<span class="unit pvs fgc1">liga: </span>
|
||||||
|
<input type="text" readonly value="" class="liga unitRight" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="glyph fs1">
|
||||||
|
<div class="clearfix bshadow0 pbs">
|
||||||
|
<span class="icon-skull-2">
|
||||||
|
|
||||||
|
</span>
|
||||||
|
<span class="mls"> icon-skull-2</span>
|
||||||
|
</div>
|
||||||
|
<fieldset class="fs0 size1of1 clearfix hidden-false">
|
||||||
|
<input type="text" readonly value="e95d" class="unit size1of2" />
|
||||||
|
<input type="text" maxlength="1" readonly value="" class="unitRight size1of2 talign-right" />
|
||||||
|
</fieldset>
|
||||||
|
<div class="fs0 bshadow0 clearfix hidden-true">
|
||||||
|
<span class="unit pvs fgc1">liga: </span>
|
||||||
|
<input type="text" readonly value="" class="liga unitRight" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="glyph fs1">
|
<div class="glyph fs1">
|
||||||
<div class="clearfix bshadow0 pbs">
|
<div class="clearfix bshadow0 pbs">
|
||||||
<span class="icon-cash-payment-bag-1">
|
<span class="icon-cash-payment-bag-1">
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 236 KiB After Width: | Height: | Size: 243 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1,10 +1,10 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'icomoon';
|
font-family: 'icomoon';
|
||||||
src: url('fonts/icomoon.eot?fy2oti');
|
src: url('fonts/icomoon.eot?hut0vm');
|
||||||
src: url('fonts/icomoon.eot?fy2oti#iefix') format('embedded-opentype'),
|
src: url('fonts/icomoon.eot?hut0vm#iefix') format('embedded-opentype'),
|
||||||
url('fonts/icomoon.ttf?fy2oti') format('truetype'),
|
url('fonts/icomoon.ttf?hut0vm') format('truetype'),
|
||||||
url('fonts/icomoon.woff?fy2oti') format('woff'),
|
url('fonts/icomoon.woff?hut0vm') format('woff'),
|
||||||
url('fonts/icomoon.svg?fy2oti#icomoon') format('svg');
|
url('fonts/icomoon.svg?hut0vm#icomoon') format('svg');
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,12 @@
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-bin-2:before {
|
||||||
|
content: "\e95e";
|
||||||
|
}
|
||||||
|
.icon-skull-2:before {
|
||||||
|
content: "\e95d";
|
||||||
|
}
|
||||||
.icon-cash-payment-bag-1:before {
|
.icon-cash-payment-bag-1:before {
|
||||||
content: "\e900";
|
content: "\e900";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
(defn -main [& args]
|
(defn -main [& args]
|
||||||
(println "Creating database...")
|
(println "Creating database...")
|
||||||
#_(d/delete-database uri)
|
|
||||||
(d/create-database uri)
|
(d/create-database uri)
|
||||||
|
|
||||||
(let [
|
(let [
|
||||||
@@ -62,6 +61,7 @@
|
|||||||
:auto-ap/add-default-location-2 {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-default-location-2 :requires [:auto-ap/add-default-location]}
|
:auto-ap/add-default-location-2 {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-default-location-2 :requires [:auto-ap/add-default-location]}
|
||||||
:auto-ap/add-import-status {:txes auto-ap.datomic.migrate.invoice-converter/add-import-status :requires [:auto-ap/add-default-location-2]}
|
:auto-ap/add-import-status {:txes auto-ap.datomic.migrate.invoice-converter/add-import-status :requires [:auto-ap/add-default-location-2]}
|
||||||
:auto-ap/add-import-status-existing-invoices {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-import-status-existing-invoices :requires [:auto-ap/add-import-status]}
|
:auto-ap/add-import-status-existing-invoices {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-import-status-existing-invoices :requires [:auto-ap/add-import-status]}
|
||||||
|
:auto-ap/fix-check-numbers {:txes-fn 'auto-ap.datomic.migrate.check-numbers/fix-check-numbers :requires [:auto-ap/add-import-status-existing-invoices]}
|
||||||
}]
|
}]
|
||||||
(println "Conforming database...")
|
(println "Conforming database...")
|
||||||
(println (c/ensure-conforms conn norms-map))
|
(println (c/ensure-conforms conn norms-map))
|
||||||
|
|||||||
8
src/clj/auto_ap/datomic/migrate/check_numbers.clj
Normal file
8
src/clj/auto_ap/datomic/migrate/check_numbers.clj
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
(ns auto-ap.datomic.migrate.check-numbers
|
||||||
|
(:require [datomic.api :as d]))
|
||||||
|
|
||||||
|
(defn fix-check-numbers [conn]
|
||||||
|
(let [max-check-numbers (d/query {:query {:find '[?e ?check-number (max ?d)] :in ['$] :where ['[?e :bank-account/check-number ?check-number] '[?c :payment/bank-account ?e] '[?c :payment/check-number ?d]]} :args [(d/db conn)]})]
|
||||||
|
[(for [[bank-account check-number max-check client] max-check-numbers
|
||||||
|
:when (>= max-check check-number)]
|
||||||
|
{:db/id bank-account :payment/check-number (inc max-check)})]))
|
||||||
@@ -379,6 +379,10 @@
|
|||||||
:void_invoice {:type :invoice
|
:void_invoice {:type :invoice
|
||||||
:args {:invoice_id {:type :id}}
|
:args {:invoice_id {:type :id}}
|
||||||
:resolve :mutation/void-invoice}
|
:resolve :mutation/void-invoice}
|
||||||
|
:unvoid_invoice {:type :invoice
|
||||||
|
:args {:invoice_id {:type :id}}
|
||||||
|
:resolve :mutation/unvoid-invoice}
|
||||||
|
|
||||||
:void_payment {:type :payment
|
:void_payment {:type :payment
|
||||||
:args {:payment_id {:type :id}}
|
:args {:payment_id {:type :id}}
|
||||||
:resolve :mutation/void-payment}
|
:resolve :mutation/void-payment}
|
||||||
@@ -483,6 +487,7 @@
|
|||||||
:mutation/edit-client gq-clients/edit-client
|
:mutation/edit-client gq-clients/edit-client
|
||||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||||
:mutation/void-invoice gq-invoices/void-invoice
|
:mutation/void-invoice gq-invoices/void-invoice
|
||||||
|
:mutation/unvoid-invoice gq-invoices/unvoid-invoice
|
||||||
:mutation/void-payment gq-checks/void-check
|
:mutation/void-payment gq-checks/void-check
|
||||||
:mutation/edit-expense-accounts gq-invoices/edit-expense-accounts
|
:mutation/edit-expense-accounts gq-invoices/edit-expense-accounts
|
||||||
:get-vendor get-vendor
|
:get-vendor get-vendor
|
||||||
|
|||||||
@@ -254,7 +254,6 @@
|
|||||||
|
|
||||||
(-> []
|
(-> []
|
||||||
(conj payment)
|
(conj payment)
|
||||||
(conj [:inc (:db/id bank-account) :bank-account/check-number 1])
|
|
||||||
(into (invoice-payments invoices invoice-amounts)))))
|
(into (invoice-payments invoices invoice-amounts)))))
|
||||||
|
|
||||||
|
|
||||||
@@ -289,7 +288,10 @@
|
|||||||
checks (->> (for [[[vendor-id invoices] index] (map vector invoices-grouped-by-vendor (range))]
|
checks (->> (for [[[vendor-id invoices] index] (map vector invoices-grouped-by-vendor (range))]
|
||||||
(invoices->entities invoices (vendors vendor-id) client bank-account type index invoice-amounts))
|
(invoices->entities invoices (vendors vendor-id) client bank-account type index invoice-amounts))
|
||||||
(reduce into [])
|
(reduce into [])
|
||||||
doall)]
|
doall)
|
||||||
|
checks (if (= type :payment-type/check)
|
||||||
|
(conj checks [:inc (:db/id bank-account) :bank-account/check-number (count invoices-grouped-by-vendor)])
|
||||||
|
checks)]
|
||||||
(when (= type :payment-type/check)
|
(when (= type :payment-type/check)
|
||||||
(make-pdfs (filter #(= :payment-type/check (:payment/type %)) checks)))
|
(make-pdfs (filter #(= :payment-type/check (:payment/type %)) checks)))
|
||||||
@(d/transact (d/connect uri) checks)
|
@(d/transact (d/connect uri) checks)
|
||||||
|
|||||||
@@ -110,6 +110,36 @@
|
|||||||
(->graphql))))
|
(->graphql))))
|
||||||
|
|
||||||
|
|
||||||
|
(defn unvoid-invoice [context {id :invoice_id} value]
|
||||||
|
(let [invoice (d-invoices/get-by-id id)
|
||||||
|
_ (assert-can-see-client (:id context) (:db/id (:invoice/client invoice)))
|
||||||
|
conn (d/connect uri)
|
||||||
|
history (d/history (d/db conn))
|
||||||
|
txs (d/query {:query {:find ['?tx '?e '?original-status '?original-outstanding '?total '?ea '?ea-amount]
|
||||||
|
:where ['[?e :invoice/status :invoice-status/voided ?tx true]
|
||||||
|
'[?e :invoice/status ?original-status ?tx false]
|
||||||
|
'[?e :invoice/outstanding-balance ?original-outstanding ?tx false]
|
||||||
|
'[?e :invoice/total ?total ?tx false]
|
||||||
|
'[?ea :invoice-expense-account/amount ?ea-amount ?tx false]]
|
||||||
|
:in ['$ '?e]}
|
||||||
|
:args [history id]})
|
||||||
|
[last-transaction] (->> txs (sort-by first) (last))]
|
||||||
|
@(d/transact conn [(->> txs
|
||||||
|
(filter (fn [[tx]] (= tx last-transaction)))
|
||||||
|
(reduce (fn [new-transaction [_ entity original-status original-outstanding total expense-account expense-account-amount]]
|
||||||
|
(-> new-transaction
|
||||||
|
(assoc :db/id entity
|
||||||
|
:invoice/total total
|
||||||
|
:invoice/status original-status
|
||||||
|
:invoice/outstanding-balance original-outstanding)
|
||||||
|
|
||||||
|
(update :invoice/expense-accounts conj {:db/id expense-account :invoice-expense-account/amount expense-account-amount}))
|
||||||
|
) {}))])
|
||||||
|
|
||||||
|
(-> (d-invoices/get-by-id id)
|
||||||
|
(->graphql))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn edit-expense-accounts [context args value]
|
(defn edit-expense-accounts [context args value]
|
||||||
@@ -147,3 +177,4 @@
|
|||||||
|
|
||||||
(->graphql
|
(->graphql
|
||||||
(d-invoices/get-by-id (:invoice_id args)))))
|
(d-invoices/get-by-id (:invoice_id args)))))
|
||||||
|
|
||||||
|
|||||||
@@ -17,5 +17,6 @@
|
|||||||
"import" :import-invoices
|
"import" :import-invoices
|
||||||
"unpaid" :unpaid-invoices
|
"unpaid" :unpaid-invoices
|
||||||
"paid" :paid-invoices
|
"paid" :paid-invoices
|
||||||
|
"voided" :voided-invoices
|
||||||
"new" :new-invoice}
|
"new" :new-invoice}
|
||||||
"transactions/" {"" :transactions}}])
|
"transactions/" {"" :transactions}}])
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
{:venia/queries [[:invoice_page
|
{:venia/queries [[:invoice_page
|
||||||
(assoc params
|
(assoc params
|
||||||
:client-id (:id @(re-frame/subscribe [::subs/client])))
|
:client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||||
[[:invoices [:id :total :outstanding-balance :invoice-number :date
|
[[:invoices [:id :total :outstanding-balance :invoice-number :date :status
|
||||||
[:vendor [:name :id]]
|
[:vendor [:name :id]]
|
||||||
[:expense_accounts [:amount :id :expense_account_id :location
|
[:expense_accounts [:amount :id :expense_account_id :location
|
||||||
[:expense_account [:id :name :location [:parent [:id :name]]]]]]
|
[:expense_account [:id :name :location [:parent [:id :name]]]]]]
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn invoice-table [{:keys [id invoice-page status on-params-change vendors params check-boxes checked on-check-changed on-edit-invoice on-void-invoice expense-event]}]
|
(defn invoice-table [{:keys [id invoice-page status on-params-change vendors params check-boxes checked on-check-changed on-edit-invoice on-void-invoice on-unvoid-invoice expense-event]}]
|
||||||
(let [visible-checks @(re-frame/subscribe [::visible-checks])
|
(let [visible-checks @(re-frame/subscribe [::visible-checks])
|
||||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||||
selected-client @(re-frame/subscribe [::subs/client])
|
selected-client @(re-frame/subscribe [::subs/client])
|
||||||
@@ -133,7 +133,7 @@
|
|||||||
}
|
}
|
||||||
""]]]
|
""]]]
|
||||||
[:tbody
|
[:tbody
|
||||||
(println checked)
|
|
||||||
(if (:loading @status)
|
(if (:loading @status)
|
||||||
[:tr
|
[:tr
|
||||||
[:td {:col-span 5}
|
[:td {:col-span 5}
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
"checked"
|
"checked"
|
||||||
"")
|
"")
|
||||||
:on-change (fn [x e] (when on-check-changed
|
:on-change (fn [x e] (when on-check-changed
|
||||||
(println id i)
|
|
||||||
(on-check-changed id i)))} ]])
|
(on-check-changed id i)))} ]])
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
[:td (:name client)])
|
[:td (:name client)])
|
||||||
@@ -184,10 +184,13 @@
|
|||||||
(when expense-event
|
(when expense-event
|
||||||
[:a.dropdown-item.is-primary {:on-click (dispatch-event (conj expense-event i))} "Change"])]]])
|
[:a.dropdown-item.is-primary {:on-click (dispatch-event (conj expense-event i))} "Change"])]]])
|
||||||
[:span {:style {:margin-left "1em"}}]
|
[:span {:style {:margin-left "1em"}}]
|
||||||
(when on-edit-invoice
|
|
||||||
|
(when (and on-edit-invoice (not= ":voided" (:status i)))
|
||||||
[:button.button {:on-click (fn [] (on-edit-invoice i))} [:span.icon [:i.fa.fa-pencil]]])
|
[:button.button {:on-click (fn [] (on-edit-invoice i))} [:span.icon [:i.fa.fa-pencil]]])
|
||||||
(when (and on-void-invoice (= (:outstanding-balance i) (:total i)))
|
(when (and on-void-invoice (= (:outstanding-balance i) (:total i)) (not= ":voided" (:status i)))
|
||||||
[:button.button.is-warning.is-outlined {:on-click (fn [] (on-void-invoice i))} [:span [:span.icon [:i.fa.fa-minus-circle]]]])
|
[:button.button.is-outlined {:on-click (fn [] (on-void-invoice i))} [:span.icon [:span.icon-bin-2 {:style {:font-weight "400"}}]]])
|
||||||
|
(when (and on-unvoid-invoice (= ":voided" (:status i)))
|
||||||
|
[:button.button.is-outlined {:on-click (fn [] (on-unvoid-invoice i))} [:span [:span.icon [:i.fa.fa-undo]]]])
|
||||||
(when (seq payments)
|
(when (seq payments)
|
||||||
|
|
||||||
[:div.dropdown.is-right {:class (if (= id visible-checks)
|
[:div.dropdown.is-right {:class (if (= id visible-checks)
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
[auto-ap.events :as events]))
|
[auto-ap.events :as events]))
|
||||||
|
|
||||||
(defn invoices-side-bar [params & rest]
|
(defn invoices-side-bar [params & rest]
|
||||||
(let [ap @(re-frame/subscribe [::subs/active-page])]
|
(let [ap @(re-frame/subscribe [::subs/active-page])
|
||||||
|
user @(re-frame/subscribe [::subs/user])]
|
||||||
[:div
|
[:div
|
||||||
[:div [:p.menu-label "Type"]
|
[:div [:p.menu-label "Type"]
|
||||||
[:ul.menu-list
|
[:ul.menu-list
|
||||||
@@ -29,12 +30,20 @@
|
|||||||
|
|
||||||
[:span {:class "name"} "Paid Invoices"]]]
|
[:span {:class "name"} "Paid Invoices"]]]
|
||||||
[:li.menu-item
|
[:li.menu-item
|
||||||
[:a.item {:href (bidi/path-for routes/routes :import-invoices)
|
[:a.item {:href (bidi/path-for routes/routes :voided-invoices)
|
||||||
:class [(active-when ap = :import-invoices)]}
|
:class [(active-when ap = :voided-invoices)]}
|
||||||
|
|
||||||
[:span {:class "icon icon-accounting-document" :style {:font-size "25px"}}]
|
[:span {:class "icon icon-bin-2" :style {:font-size "25px"}}]
|
||||||
|
|
||||||
[:span {:class "name"} "Import Invoices"]]]]]
|
[:span {:class "name"} "Voided Invoices"]]]
|
||||||
|
(when (= "admin" (:user/role user))
|
||||||
|
[:li.menu-item
|
||||||
|
[:a.item {:href (bidi/path-for routes/routes :import-invoices)
|
||||||
|
:class [(active-when ap = :import-invoices)]}
|
||||||
|
|
||||||
|
[:span {:class "icon icon-accounting-document" :style {:font-size "25px"}}]
|
||||||
|
|
||||||
|
[:span {:class "name"} "Import Invoices"]]])]]
|
||||||
[:div
|
[:div
|
||||||
rest]
|
rest]
|
||||||
[:div {:class "compose has-text-centered"}
|
[:div {:class "compose has-text-centered"}
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
(defmethod page :paid-invoices [_]
|
(defmethod page :paid-invoices [_]
|
||||||
(unpaid-invoices-page {:status "paid"}))
|
(unpaid-invoices-page {:status "paid"}))
|
||||||
|
|
||||||
|
(defmethod page :voided-invoices [_]
|
||||||
|
(unpaid-invoices-page {:status "voided"}))
|
||||||
|
|
||||||
|
|
||||||
(defmethod page :checks [_]
|
(defmethod page :checks [_]
|
||||||
(checks-page))
|
(checks-page))
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,13 @@
|
|||||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.events :as events]))
|
[auto-ap.events :as events]))
|
||||||
|
(def invoice-read [:id :total :outstanding-balance :date :invoice-number :status
|
||||||
|
[:client [:id :name :locations]]
|
||||||
|
[:payments [:amount [:payment [:amount :s3_url :check_number ]]]]
|
||||||
|
[:vendor [:id :name]]
|
||||||
|
[:expense_accounts [:amount :id :expense_account_id
|
||||||
|
:location
|
||||||
|
[:expense_account [:id :name [:parent [:id :name]]]]]]])
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::invoice-page
|
::invoice-page
|
||||||
(fn [db]
|
(fn [db]
|
||||||
@@ -172,7 +178,7 @@
|
|||||||
:type type
|
:type type
|
||||||
:bank_account_id bank-account-id
|
:bank_account_id bank-account-id
|
||||||
:client_id client-id}
|
:client_id client-id}
|
||||||
[[:invoices [:id :outstanding-balance [:payments [:amount [:payment [:amount :s3_url :check_number ]]]]]]
|
[[:invoices invoice-read]
|
||||||
:pdf_url]]]})
|
:pdf_url]]]})
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
@@ -267,6 +273,8 @@
|
|||||||
{:dispatch [::events/modal-status ::edit-invoice {:visible? true}]
|
{:dispatch [::events/modal-status ::edit-invoice {:visible? true}]
|
||||||
:db (assoc-in db [::edit-invoice] edit-invoice)})))
|
:db (assoc-in db [::edit-invoice] edit-invoice)})))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::create-invoice
|
::create-invoice
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
@@ -278,16 +286,12 @@
|
|||||||
|
|
||||||
:venia/queries [{:query/data [:add-invoice
|
:venia/queries [{:query/data [:add-invoice
|
||||||
{:invoice new-invoice}
|
{:invoice new-invoice}
|
||||||
[:id :total :outstanding-balance :date :invoice-number
|
invoice-read]}]}
|
||||||
[:client [:id :name :locations]]
|
|
||||||
[:vendor [:id :name]]
|
|
||||||
[:expense_accounts [:amount :id :expense_account_id
|
|
||||||
:location
|
|
||||||
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
|
||||||
]]}]}
|
|
||||||
:on-success [::invoice-created]
|
:on-success [::invoice-created]
|
||||||
:on-error [::invoice-create-failed]}})))
|
:on-error [::invoice-create-failed]}})))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::edit-invoice-save
|
::edit-invoice-save
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
@@ -299,15 +303,22 @@
|
|||||||
|
|
||||||
:venia/queries [{:query/data [:edit-invoice
|
:venia/queries [{:query/data [:edit-invoice
|
||||||
{:invoice {:id id :invoice-number invoice-number :date date :total total}}
|
{:invoice {:id id :invoice-number invoice-number :date date :total total}}
|
||||||
[:id :total :outstanding-balance :date :invoice-number
|
invoice-read]}]}
|
||||||
[:client [:id :name :locations]]
|
|
||||||
[:vendor [:id :name]]
|
|
||||||
[:expense_accounts [:amount :id :expense_account_id
|
|
||||||
:location
|
|
||||||
[:expense_account [:id :name [:parent [:id :name]]]]]]]]}]}
|
|
||||||
:on-success [::invoice-edited]
|
:on-success [::invoice-edited]
|
||||||
:on-error [::invoice-edit-failed]}})))
|
:on-error [::invoice-edit-failed]}})))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::unvoid-invoice
|
||||||
|
(fn [{:keys [db]} [_ {id :id}]]
|
||||||
|
{:graphql
|
||||||
|
{:token (-> db :user)
|
||||||
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
|
:operation/name "UnvoidInvoice"}
|
||||||
|
|
||||||
|
:venia/queries [{:query/data [:unvoid-invoice
|
||||||
|
{:invoice-id id}
|
||||||
|
invoice-read]}]}
|
||||||
|
:on-success [::invoice-unvoided]}}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::void-invoice
|
::void-invoice
|
||||||
@@ -319,12 +330,7 @@
|
|||||||
|
|
||||||
:venia/queries [{:query/data [:void-invoice
|
:venia/queries [{:query/data [:void-invoice
|
||||||
{:invoice-id id}
|
{:invoice-id id}
|
||||||
[:id :total :outstanding-balance :date :invoice-number
|
invoice-read]}]}
|
||||||
[:client [:id :name :locations]]
|
|
||||||
[:vendor [:id :name]]
|
|
||||||
[:expense_accounts [:amount :id :expense_account_id
|
|
||||||
:location
|
|
||||||
[:expense_account [:id :name [:parent [:id :name]]]]]]]]}]}
|
|
||||||
:on-success [::invoice-voided]}}))
|
:on-success [::invoice-voided]}}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
@@ -343,7 +349,7 @@
|
|||||||
:bank-account-id bank-account-id
|
:bank-account-id bank-account-id
|
||||||
:invoice_id (:id invoice)
|
:invoice_id (:id invoice)
|
||||||
}
|
}
|
||||||
[[:invoices [:id :outstanding-balance [:payments [:amount [:payment [:amount :s3_url :check_number ]]]]]]]]}]}
|
[[:invoices invoice-read]]]}]}
|
||||||
:on-success [::handwrite-checks-succeeded]}})))
|
:on-success [::handwrite-checks-succeeded]}})))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
@@ -394,6 +400,17 @@
|
|||||||
(fn [{:keys [db]} [_ data]]
|
(fn [{:keys [db]} [_ data]]
|
||||||
{:dispatch [::events/modal-failed ::edit-invoice "That invoice already exists."]}))
|
{:dispatch [::events/modal-failed ::edit-invoice "That invoice already exists."]}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::invoice-unvoided
|
||||||
|
(fn [{:keys [db]} [_ {:keys [unvoid-invoice]}]]
|
||||||
|
{:db (-> db
|
||||||
|
(update-in [::invoice-page :invoices]
|
||||||
|
(fn [is]
|
||||||
|
(mapv (fn [i]
|
||||||
|
(if (= (:id i) (:id unvoid-invoice))
|
||||||
|
(assoc unvoid-invoice :class "live-removed")
|
||||||
|
i)) is))))}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::invoice-voided
|
::invoice-voided
|
||||||
(fn [{:keys [db]} [_ {:keys [void-invoice]}]]
|
(fn [{:keys [db]} [_ {:keys [void-invoice]}]]
|
||||||
@@ -787,6 +804,8 @@
|
|||||||
:status (re-frame/subscribe [::subs/status])
|
:status (re-frame/subscribe [::subs/status])
|
||||||
:on-edit-invoice (fn [which]
|
:on-edit-invoice (fn [which]
|
||||||
(re-frame/dispatch [::edit-invoice which]))
|
(re-frame/dispatch [::edit-invoice which]))
|
||||||
|
:on-unvoid-invoice (fn [which]
|
||||||
|
(re-frame/dispatch [::unvoid-invoice which]))
|
||||||
|
|
||||||
:on-void-invoice (fn [which]
|
:on-void-invoice (fn [which]
|
||||||
(re-frame/dispatch [::void-invoice which]))
|
(re-frame/dispatch [::void-invoice which]))
|
||||||
|
|||||||
Reference in New Issue
Block a user