Merge branch 'master' into side-panel
This commit is contained in:
@@ -9,10 +9,42 @@
|
||||
<link rel="stylesheet" href="style.css"></head>
|
||||
<body>
|
||||
<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 class="clearfix mhl ptl">
|
||||
<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="clearfix bshadow0 pbs">
|
||||
<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-family: 'icomoon';
|
||||
src: url('fonts/icomoon.eot?fy2oti');
|
||||
src: url('fonts/icomoon.eot?fy2oti#iefix') format('embedded-opentype'),
|
||||
url('fonts/icomoon.ttf?fy2oti') format('truetype'),
|
||||
url('fonts/icomoon.woff?fy2oti') format('woff'),
|
||||
url('fonts/icomoon.svg?fy2oti#icomoon') format('svg');
|
||||
src: url('fonts/icomoon.eot?hut0vm');
|
||||
src: url('fonts/icomoon.eot?hut0vm#iefix') format('embedded-opentype'),
|
||||
url('fonts/icomoon.ttf?hut0vm') format('truetype'),
|
||||
url('fonts/icomoon.woff?hut0vm') format('woff'),
|
||||
url('fonts/icomoon.svg?hut0vm#icomoon') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@@ -24,6 +24,12 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-bin-2:before {
|
||||
content: "\e95e";
|
||||
}
|
||||
.icon-skull-2:before {
|
||||
content: "\e95d";
|
||||
}
|
||||
.icon-cash-payment-bag-1:before {
|
||||
content: "\e900";
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
(defn -main [& args]
|
||||
(println "Creating database...")
|
||||
#_(d/delete-database uri)
|
||||
(d/create-database uri)
|
||||
|
||||
(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-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/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 (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
|
||||
:args {:invoice_id {:type :id}}
|
||||
:resolve :mutation/void-invoice}
|
||||
:unvoid_invoice {:type :invoice
|
||||
:args {:invoice_id {:type :id}}
|
||||
:resolve :mutation/unvoid-invoice}
|
||||
|
||||
:void_payment {:type :payment
|
||||
:args {:payment_id {:type :id}}
|
||||
:resolve :mutation/void-payment}
|
||||
@@ -483,6 +487,7 @@
|
||||
:mutation/edit-client gq-clients/edit-client
|
||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||
:mutation/void-invoice gq-invoices/void-invoice
|
||||
:mutation/unvoid-invoice gq-invoices/unvoid-invoice
|
||||
:mutation/void-payment gq-checks/void-check
|
||||
:mutation/edit-expense-accounts gq-invoices/edit-expense-accounts
|
||||
:get-vendor get-vendor
|
||||
|
||||
@@ -254,7 +254,6 @@
|
||||
|
||||
(-> []
|
||||
(conj payment)
|
||||
(conj [:inc (:db/id bank-account) :bank-account/check-number 1])
|
||||
(into (invoice-payments invoices invoice-amounts)))))
|
||||
|
||||
|
||||
@@ -289,7 +288,10 @@
|
||||
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))
|
||||
(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)
|
||||
(make-pdfs (filter #(= :payment-type/check (:payment/type %)) checks)))
|
||||
@(d/transact (d/connect uri) checks)
|
||||
|
||||
@@ -110,6 +110,36 @@
|
||||
(->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]
|
||||
@@ -147,3 +177,4 @@
|
||||
|
||||
(->graphql
|
||||
(d-invoices/get-by-id (:invoice_id args)))))
|
||||
|
||||
|
||||
@@ -17,5 +17,6 @@
|
||||
"import" :import-invoices
|
||||
"unpaid" :unpaid-invoices
|
||||
"paid" :paid-invoices
|
||||
"voided" :voided-invoices
|
||||
"new" :new-invoice}
|
||||
"transactions/" {"" :transactions}}])
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
{:venia/queries [[:invoice_page
|
||||
(assoc params
|
||||
: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]]
|
||||
[:expense_accounts [:amount :id :expense_account_id :location
|
||||
[: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])
|
||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
@@ -133,7 +133,7 @@
|
||||
}
|
||||
""]]]
|
||||
[:tbody
|
||||
(println checked)
|
||||
|
||||
(if (:loading @status)
|
||||
[:tr
|
||||
[:td {:col-span 5}
|
||||
@@ -148,7 +148,7 @@
|
||||
"checked"
|
||||
"")
|
||||
:on-change (fn [x e] (when on-check-changed
|
||||
(println id i)
|
||||
|
||||
(on-check-changed id i)))} ]])
|
||||
(when-not selected-client
|
||||
[:td (:name client)])
|
||||
@@ -184,10 +184,13 @@
|
||||
(when expense-event
|
||||
[:a.dropdown-item.is-primary {:on-click (dispatch-event (conj expense-event i))} "Change"])]]])
|
||||
[: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]]])
|
||||
(when (and on-void-invoice (= (:outstanding-balance i) (:total i)))
|
||||
[:button.button.is-warning.is-outlined {:on-click (fn [] (on-void-invoice i))} [:span [:span.icon [:i.fa.fa-minus-circle]]]])
|
||||
(when (and on-void-invoice (= (:outstanding-balance i) (:total i)) (not= ":voided" (:status i)))
|
||||
[: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)
|
||||
|
||||
[:div.dropdown.is-right {:class (if (= id visible-checks)
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
[auto-ap.events :as events]))
|
||||
|
||||
(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 [:p.menu-label "Type"]
|
||||
[:ul.menu-list
|
||||
@@ -29,12 +30,20 @@
|
||||
|
||||
[:span {:class "name"} "Paid Invoices"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :import-invoices)
|
||||
:class [(active-when ap = :import-invoices)]}
|
||||
[:a.item {:href (bidi/path-for routes/routes :voided-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
|
||||
rest]
|
||||
[:div {:class "compose has-text-centered"}
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
(defmethod page :paid-invoices [_]
|
||||
(unpaid-invoices-page {:status "paid"}))
|
||||
|
||||
(defmethod page :voided-invoices [_]
|
||||
(unpaid-invoices-page {:status "voided"}))
|
||||
|
||||
|
||||
(defmethod page :checks [_]
|
||||
(checks-page))
|
||||
|
||||
|
||||
@@ -26,7 +26,13 @@
|
||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||
[auto-ap.subs :as subs]
|
||||
[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
|
||||
::invoice-page
|
||||
(fn [db]
|
||||
@@ -172,7 +178,7 @@
|
||||
:type type
|
||||
:bank_account_id bank-account-id
|
||||
:client_id client-id}
|
||||
[[:invoices [:id :outstanding-balance [:payments [:amount [:payment [:amount :s3_url :check_number ]]]]]]
|
||||
[[:invoices invoice-read]
|
||||
:pdf_url]]]})
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
@@ -267,6 +273,8 @@
|
||||
{:dispatch [::events/modal-status ::edit-invoice {:visible? true}]
|
||||
:db (assoc-in db [::edit-invoice] edit-invoice)})))
|
||||
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::create-invoice
|
||||
(fn [{:keys [db]} _]
|
||||
@@ -278,16 +286,12 @@
|
||||
|
||||
:venia/queries [{:query/data [:add-invoice
|
||||
{:invoice new-invoice}
|
||||
[:id :total :outstanding-balance :date :invoice-number
|
||||
[:client [:id :name :locations]]
|
||||
[:vendor [:id :name]]
|
||||
[:expense_accounts [:amount :id :expense_account_id
|
||||
:location
|
||||
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
||||
]]}]}
|
||||
invoice-read]}]}
|
||||
:on-success [::invoice-created]
|
||||
:on-error [::invoice-create-failed]}})))
|
||||
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::edit-invoice-save
|
||||
(fn [{:keys [db]} _]
|
||||
@@ -299,15 +303,22 @@
|
||||
|
||||
:venia/queries [{:query/data [:edit-invoice
|
||||
{:invoice {:id id :invoice-number invoice-number :date date :total total}}
|
||||
[:id :total :outstanding-balance :date :invoice-number
|
||||
[:client [:id :name :locations]]
|
||||
[:vendor [:id :name]]
|
||||
[:expense_accounts [:amount :id :expense_account_id
|
||||
:location
|
||||
[:expense_account [:id :name [:parent [:id :name]]]]]]]]}]}
|
||||
invoice-read]}]}
|
||||
:on-success [::invoice-edited]
|
||||
: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
|
||||
::void-invoice
|
||||
@@ -319,12 +330,7 @@
|
||||
|
||||
:venia/queries [{:query/data [:void-invoice
|
||||
{:invoice-id id}
|
||||
[:id :total :outstanding-balance :date :invoice-number
|
||||
[:client [:id :name :locations]]
|
||||
[:vendor [:id :name]]
|
||||
[:expense_accounts [:amount :id :expense_account_id
|
||||
:location
|
||||
[:expense_account [:id :name [:parent [:id :name]]]]]]]]}]}
|
||||
invoice-read]}]}
|
||||
:on-success [::invoice-voided]}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
@@ -343,7 +349,7 @@
|
||||
:bank-account-id bank-account-id
|
||||
:invoice_id (:id invoice)
|
||||
}
|
||||
[[:invoices [:id :outstanding-balance [:payments [:amount [:payment [:amount :s3_url :check_number ]]]]]]]]}]}
|
||||
[[:invoices invoice-read]]]}]}
|
||||
:on-success [::handwrite-checks-succeeded]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
@@ -394,6 +400,17 @@
|
||||
(fn [{:keys [db]} [_ data]]
|
||||
{: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
|
||||
::invoice-voided
|
||||
(fn [{:keys [db]} [_ {:keys [void-invoice]}]]
|
||||
@@ -787,6 +804,8 @@
|
||||
:status (re-frame/subscribe [::subs/status])
|
||||
:on-edit-invoice (fn [which]
|
||||
(re-frame/dispatch [::edit-invoice which]))
|
||||
:on-unvoid-invoice (fn [which]
|
||||
(re-frame/dispatch [::unvoid-invoice which]))
|
||||
|
||||
:on-void-invoice (fn [which]
|
||||
(re-frame/dispatch [::void-invoice which]))
|
||||
|
||||
Reference in New Issue
Block a user