added the ability to credit invoices. Also made it so check numbers pop up for intuit even if they're not in the description.

This commit is contained in:
2022-02-10 12:40:09 -08:00
parent 72b31fe6bd
commit e1298a1f94
5 changed files with 283 additions and 215 deletions

View File

@@ -145,42 +145,49 @@
:class "is-primary"}]
(when current-client
[drop-down {:header [:button.button.is-primary {:aria-haspopup true
:on-click (dispatch-event [::events/toggle-menu ::print-checks ])
:disabled (or (status/disabled-for print-checks-status) (not (seq checked-invoices)))
:class (status/class-for @(re-frame/subscribe [::status/single ::print-checks]))}
"Pay "
(when (> (count checked-invoices ))
(str
(count checked-invoices)
" invoices "
"(" (->> checked-invoices
(map (comp js/parseFloat :outstanding-balance))
(reduce + 0)
(gstring/format "$%.2f" ))
")"))
[:span " "]
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
:id ::print-checks
:is-right? true}
[:div
(list
(for [{:keys [id number name type]} (->> (:bank-accounts current-client) (filter :visible) (sort-by :sort-order))]
(if (= :cash type)
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :cash])
:disabled (status/disabled-for print-checks-status)} "With cash"]
(list
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :check])
:disabled (doto (status/disabled-for print-checks-status) println)} "Print checks from " name]
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :debit])
:disabled (status/disabled-for print-checks-status)} "Debit from " name])))
^{:key "advanced-divider"} [:hr.dropdown-divider]
(let [balance (->> checked-invoices
(map (comp js/parseFloat :outstanding-balance))
(reduce + 0)
)]
[drop-down {:header [:button.button.is-primary {:aria-haspopup true
:on-click (dispatch-event [::events/toggle-menu ::print-checks ])
:disabled (or (status/disabled-for print-checks-status) (not (seq checked-invoices)))
:class (status/class-for @(re-frame/subscribe [::status/single ::print-checks]))}
"Pay "
(when (> (count checked-invoices ) 0)
(str
(count checked-invoices)
" invoices "
"(" (gstring/format "$%.2f" balance ) ")"))
[:span " "]
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
:id ::print-checks
:is-right? true}
[:div
(list
(for [{:keys [id number name type]} (->> (:bank-accounts current-client) (filter :visible) (sort-by :sort-order))]
(if (= :cash type)
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :cash])
:disabled (status/disabled-for print-checks-status)} "With cash"]
(if (> balance 0.001)
(list
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :check])
:disabled (doto (status/disabled-for print-checks-status) println)} "Print checks from " name]
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :debit])
:disabled (status/disabled-for print-checks-status)} "Debit from " name])
(list
^{:key (str id "-credit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :credit])
:disabled (status/disabled-for print-checks-status)} "Credit from " name]))))
(when (> balance 0.001)
^{:key "advanced-divider"} [:hr.dropdown-divider])
(when (= 1 (count (set (map (comp :id :vendor) checked-invoices))))
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::handwritten-checks/show checked-invoices])
:disabled (status/disabled-for print-checks-status)} "Handwritten Check..."])
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::advanced-print-checks/show checked-invoices])
:disabled (status/disabled-for print-checks-status)} "Advanced..."])]])]]
(when (and (= 1 (count (set (map (comp :id :vendor) checked-invoices))))
(> balance 0.001))
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::handwritten-checks/show checked-invoices])
:disabled (status/disabled-for print-checks-status)} "Handwritten Check..."])
(when (> balance 0.001)
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::advanced-print-checks/show checked-invoices])
:disabled (status/disabled-for print-checks-status)} "Advanced..."]))]]))]]
[:div.is-pulled-right {:style {:margin-right "0.5rem"}}
(into [:div.tags ] (map (fn [{:keys [id invoice-number]}]
[:span.tag.is-medium invoice-number