supports bulk voiding invoices, searches for iol duplicates.
This commit is contained in:
@@ -20,31 +20,34 @@
|
||||
[auto-ap.views.components.expense-accounts-dialog :as expense-accounts-dialog]
|
||||
[auto-ap.views.pages.data-page :as data-page]))
|
||||
|
||||
(defn data-params->query-params [params]
|
||||
{:exact-match-id (some-> params :exact-match-id str)
|
||||
:start (:start params 0)
|
||||
:sort (:sort params)
|
||||
:per-page (:per-page params)
|
||||
|
||||
:vendor-id (:id (:vendor params))
|
||||
:date-range (:date-range params)
|
||||
:due-range (:due-range params)
|
||||
:amount-gte (:amount-gte (:amount-range params))
|
||||
:amount-lte (:amount-lte (:amount-range params))
|
||||
:location (:location params)
|
||||
:unresolved (:unresolved params)
|
||||
:scheduled-payments (:scheduled-payments params)
|
||||
:invoice-number-like (:invoice-number-like params)
|
||||
:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||
:import-status (:import-status params)
|
||||
:status (condp = @(re-frame/subscribe [::subs/active-page])
|
||||
:invoices nil
|
||||
:import-invoices nil
|
||||
:unpaid-invoices :unpaid
|
||||
:paid-invoices :paid
|
||||
:voided-invoices :voided)})
|
||||
|
||||
(defn query [params]
|
||||
{:venia/queries [[:invoice_page
|
||||
{
|
||||
:exact-match-id (some-> params :exact-match-id str)
|
||||
:start (:start params 0)
|
||||
:sort (:sort params)
|
||||
:per-page (:per-page params)
|
||||
|
||||
:vendor-id (:id (:vendor params))
|
||||
:date-range (:date-range params)
|
||||
:due-range (:due-range params)
|
||||
:amount-gte (:amount-gte (:amount-range params))
|
||||
:amount-lte (:amount-lte (:amount-range params))
|
||||
:location (:location params)
|
||||
:unresolved (:unresolved params)
|
||||
:scheduled-payments (:scheduled-payments params)
|
||||
:invoice-number-like (:invoice-number-like params)
|
||||
:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||
:import-status (:import-status params)
|
||||
:status (condp = @(re-frame/subscribe [::subs/active-page])
|
||||
:invoices nil
|
||||
:import-invoices nil
|
||||
:unpaid-invoices :unpaid
|
||||
:paid-invoices :paid
|
||||
:voided-invoices :voided)}
|
||||
{:filters (data-params->query-params params)}
|
||||
|
||||
[[:invoices [:id :total :outstanding-balance :invoice-number :date :due :status :client-identifier :scheduled-payment :source-url :similarity
|
||||
[:vendor [:name :id]]
|
||||
[:expense_accounts [:amount :id :location
|
||||
@@ -229,7 +232,7 @@
|
||||
|
||||
(defn invoice-table [{:keys [id check-boxes overrides actions data-page checkable-fn]}]
|
||||
(let [selected-client @(re-frame/subscribe [::subs/client])
|
||||
{:keys [data status table-params]} @(re-frame/subscribe [::data-page/page data-page])
|
||||
{:keys [data status params table-params]} @(re-frame/subscribe [::data-page/page data-page])
|
||||
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
is-loading? (= :loading (:state status))
|
||||
@@ -261,7 +264,8 @@
|
||||
^{:key (or (:id (first invoices)) "init")}
|
||||
[grid/table {:fullwidth true}
|
||||
[grid/header {}
|
||||
[grid/row {}
|
||||
[grid/row {:id "header"
|
||||
:entity params}
|
||||
(when-not selected-client
|
||||
[grid/sortable-header-cell {:sort-key "client" :sort-name "Client"} "Client"])
|
||||
[grid/sortable-header-cell {:sort-key "vendor" :sort-name "Vendor"}
|
||||
|
||||
@@ -95,7 +95,6 @@
|
||||
(for [{:keys [client account vendor approval-status payment expected-deposit status bank-account description-original date amount id yodlee-merchant ] :as i} (:data data)]
|
||||
^{:key id}
|
||||
[grid/row {:class (:class i) :id id :entity i}
|
||||
(println expected-deposit)
|
||||
(when-not selected-client
|
||||
[grid/cell {} (:name client)])
|
||||
|
||||
|
||||
@@ -1,38 +1,35 @@
|
||||
(ns auto-ap.views.pages.unpaid-invoices
|
||||
(:require [auto-ap.effects.forward :as forward]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.dropdown :refer [drop-down]]
|
||||
[auto-ap.views.components.expense-accounts-dialog
|
||||
:as
|
||||
expense-accounts-dialog]
|
||||
[auto-ap.views.components.invoice-table :as table]
|
||||
[auto-ap.views.components.invoices.side-bar
|
||||
:as
|
||||
side-bar
|
||||
:refer
|
||||
[invoices-side-bar]]
|
||||
[auto-ap.views.components.layouts
|
||||
:refer
|
||||
[appearing-side-bar side-bar-layout]]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[auto-ap.views.pages.invoices.advanced-print-checks
|
||||
:as
|
||||
advanced-print-checks]
|
||||
[auto-ap.views.pages.invoices.common :refer [invoice-read]]
|
||||
[auto-ap.views.pages.invoices.form :as form]
|
||||
[auto-ap.views.pages.invoices.handwritten-checks :as handwritten-checks]
|
||||
[auto-ap.views.utils :refer [dispatch-event dispatch-event-with-propagation with-user]]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[goog.string :as gstring]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as r]
|
||||
[vimsical.re-frame.fx.track :as track]
|
||||
[auto-ap.views.components.buttons :as buttons]))
|
||||
(:require
|
||||
[auto-ap.effects.forward :as forward]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.buttons :as buttons]
|
||||
[auto-ap.views.components.dropdown :refer [drop-down]]
|
||||
[auto-ap.views.components.expense-accounts-dialog
|
||||
:as expense-accounts-dialog]
|
||||
[auto-ap.views.components.invoice-table :as table]
|
||||
[auto-ap.views.components.invoices.side-bar
|
||||
:as side-bar
|
||||
:refer [invoices-side-bar]]
|
||||
[auto-ap.views.components.layouts
|
||||
:refer [appearing-side-bar side-bar-layout]]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[auto-ap.views.pages.invoices.advanced-print-checks
|
||||
:as advanced-print-checks]
|
||||
[auto-ap.views.pages.invoices.common :refer [invoice-read]]
|
||||
[auto-ap.views.pages.invoices.form :as form]
|
||||
[auto-ap.views.pages.invoices.handwritten-checks :as handwritten-checks]
|
||||
[auto-ap.views.utils
|
||||
:refer [dispatch-event dispatch-event-with-propagation with-user]]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[goog.string :as gstring]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as r]
|
||||
[vimsical.re-frame.fx.track :as track]))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::params-change
|
||||
@@ -131,15 +128,68 @@
|
||||
:status :unpaid
|
||||
#_#_:date (date->str (c/now) standard)
|
||||
:location (first (:locations @(re-frame/subscribe [::subs/client])))}]}))
|
||||
(re-frame/reg-event-fx
|
||||
::voided-selected
|
||||
(fn [cofx [_]]
|
||||
{:dispatch-n [[::modal/modal-closed]
|
||||
[::params-change @(re-frame/subscribe [::data-page/params ::page])]]}))
|
||||
(re-frame/reg-event-fx
|
||||
::void-selected
|
||||
(fn [cofx [_ which]]
|
||||
(let [checked-params (get which "header")
|
||||
specific-invoices (map :id (vals (dissoc which "header")))]
|
||||
{:graphql {:token (-> cofx :db :user)
|
||||
:owns-state {:single ::void-selected}
|
||||
:query-obj
|
||||
{:venia/operation {:operation/type :mutation
|
||||
:operation/name "DeleteTransactions"}
|
||||
:venia/queries [{:query/data
|
||||
[:void-invoices
|
||||
{:filters (some-> checked-params table/data-params->query-params)
|
||||
:ids specific-invoices}
|
||||
[:message]]}]}
|
||||
:on-success (fn [result]
|
||||
[::voided-selected])}
|
||||
:dispatch [::data-page/reset-checked ::page]})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::void-selected-requested
|
||||
(fn [_ [_ which]]
|
||||
(let [to-delete (if (get which "header")
|
||||
"all visible invoices"
|
||||
(str (count which) " invoices"))]
|
||||
|
||||
|
||||
{:dispatch [::modal/modal-requested {:title "Confirmation"
|
||||
:body [:div (str "Are you sure you want to void " to-delete "?")]
|
||||
:cancel? true
|
||||
:confirm {:value "Void"
|
||||
:class "is-danger"
|
||||
:status-from [::status/single ::void-selected]
|
||||
:on-click (dispatch-event [::void-selected which] )}
|
||||
:close-event [::status/completed ::void-selected]}]})))
|
||||
|
||||
(defn void-selected-button []
|
||||
(let [status @(re-frame/subscribe [::status/single ::void-selected])
|
||||
checked-invoices @(re-frame/subscribe [::data-page/checked :invoices])
|
||||
is-admin? @(re-frame/subscribe [::subs/is-admin?])]
|
||||
(when is-admin?
|
||||
[:button.button.is-danger {:on-click (dispatch-event [::void-selected-requested checked-invoices])
|
||||
:class (status/class-for status)
|
||||
:disabled (or (status/disabled-for status)
|
||||
(not (seq checked-invoices)))}
|
||||
"Void"])))
|
||||
|
||||
|
||||
(defn pay-button []
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||
checked-invoices (vals @(re-frame/subscribe [::data-page/checked :invoices]))
|
||||
checked-invoices @(re-frame/subscribe [::data-page/checked :invoices])
|
||||
print-checks-status @(re-frame/subscribe [::status/single ::print-checks])]
|
||||
[:div
|
||||
[:div.is-pulled-right
|
||||
[:div.buttons
|
||||
[void-selected-button]
|
||||
|
||||
[buttons/new-button {:event [::new-invoice-clicked]
|
||||
:name "Invoice"
|
||||
:class "is-primary"}]
|
||||
@@ -172,7 +222,7 @@
|
||||
(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]
|
||||
:disabled (status/disabled-for print-checks-status)} "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
|
||||
@@ -181,18 +231,23 @@
|
||||
(when (> balance 0.001)
|
||||
^{:key "advanced-divider"} [:hr.dropdown-divider])
|
||||
|
||||
(when (and (= 1 (count (set (map (comp :id :vendor) checked-invoices))))
|
||||
(when (and (= 1 (count (set (map (comp :id :vendor) (vals checked-invoices)))))
|
||||
(> balance 0.001))
|
||||
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::handwritten-checks/show checked-invoices])
|
||||
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::handwritten-checks/show (vals 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])
|
||||
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::advanced-print-checks/show (vals 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
|
||||
[:button.delete.is-small {:on-click
|
||||
(dispatch-event [::data-page/remove-check :invoices id])}]]) checked-invoices))]]))
|
||||
(into [:div.tags ] (map (fn [[z {:keys [id invoice-number]}]]
|
||||
(if (= z "header")
|
||||
[:span.tag.is-medium "All visible invoices"
|
||||
[:button.delete.is-small {:on-click
|
||||
(dispatch-event [::data-page/remove-check :invoices z])}]]
|
||||
[:span.tag.is-medium invoice-number
|
||||
[:button.delete.is-small {:on-click
|
||||
(dispatch-event [::data-page/remove-check :invoices id])}]]))
|
||||
checked-invoices))]]))
|
||||
|
||||
|
||||
(defn unpaid-invoices-content [{:keys [status]}]
|
||||
|
||||
Reference in New Issue
Block a user