Merge branch 'master' into side-panel
This commit is contained in:
@@ -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