transaction date range. Need to generalize filter changing.
This commit is contained in:
12
resources/sample-ledger.csv
Normal file
12
resources/sample-ledger.csv
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Id Client Source Vendor Date Account Location Debit Credit
|
||||||
|
ABC DEMO Payroll Dummy 12/19/2018 5310 HQ 100 0
|
||||||
|
ABC DEMO Payroll 123551123 12/19/2018 DEMO-1 HQ 0 50
|
||||||
|
ABC DEMO Payroll 123551123 12/19/2018 DEMO-1 HQ 0 50
|
||||||
|
DEF DEMO Payroll 223551123 12/19/2018 2950 HQ 0 50
|
||||||
|
GHI DEMO Payroll 123551123 12/19/2018 21550 HQ 100 0
|
||||||
|
1 DEMO Payroll 123551123 12/19/2018 21550 HQ 100 0
|
||||||
|
234 DEMO Payroll 123551123 12/19/2018 21550 HQ 100 0
|
||||||
|
8912 DEMO Payroll 123551123 12/19/2018 21550 HQ 100 0
|
||||||
|
aosentuh DEMO Payroll 123551123 12/19/2018 21550 HQ 100 0
|
||||||
|
aonet DEMO Payroll 123551123 12/19/2018 2750 HQ 0 50
|
||||||
|
1923 DEMO Payroll 123551123 12/19/2018 2950 HQ 0 50
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
(:require [datomic.api :as d]
|
(:require [datomic.api :as d]
|
||||||
[auto-ap.datomic :refer [uri merge-query apply-sort-2 apply-sort apply-pagination add-sorter-field]]
|
[auto-ap.datomic :refer [uri merge-query apply-sort-2 apply-sort apply-pagination add-sorter-field]]
|
||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||||
[clj-time.coerce :as c]))
|
[clj-time.coerce :as c]
|
||||||
|
[clj-time.coerce :as coerce]))
|
||||||
|
|
||||||
(defn sort-fn [sort-by]
|
(defn sort-fn [sort-by]
|
||||||
(cond
|
(cond
|
||||||
@@ -51,6 +52,17 @@
|
|||||||
(merge-query {:query {:in ['?client-id]
|
(merge-query {:query {:in ['?client-id]
|
||||||
:where ['[?e :transaction/client ?client-id]]}
|
:where ['[?e :transaction/client ?client-id]]}
|
||||||
:args [(:client-id args)]})
|
:args [(:client-id args)]})
|
||||||
|
(:start (:date-range args))
|
||||||
|
(merge-query {:query {:in ['?start-date]
|
||||||
|
:where ['[?e :transaction/date ?date]
|
||||||
|
'[(>= ?date ?start-date)]]}
|
||||||
|
:args [(coerce/to-date (:start (:date-range args)))]})
|
||||||
|
|
||||||
|
(:end (:date-range args))
|
||||||
|
(merge-query {:query {:in ['?end-date]
|
||||||
|
:where ['[?e :transaction/date ?date]
|
||||||
|
'[(<= ?date ?end-date)]]}
|
||||||
|
:args [(coerce/to-date (:end (:date-range args)))]})
|
||||||
|
|
||||||
(:client-code args)
|
(:client-code args)
|
||||||
(merge-query {:query {:in ['?client-code]
|
(merge-query {:query {:in ['?client-code]
|
||||||
|
|||||||
@@ -325,6 +325,7 @@
|
|||||||
:transaction_page {:type '(list :transaction_page)
|
:transaction_page {:type '(list :transaction_page)
|
||||||
:args {:client_id {:type :id}
|
:args {:client_id {:type :id}
|
||||||
:bank_account_id {:type :id}
|
:bank_account_id {:type :id}
|
||||||
|
:date_range {:type :date_range}
|
||||||
:start {:type 'Int}
|
:start {:type 'Int}
|
||||||
:sort_by {:type 'String}
|
:sort_by {:type 'String}
|
||||||
:asc {:type 'Boolean}}
|
:asc {:type 'Boolean}}
|
||||||
@@ -368,6 +369,9 @@
|
|||||||
:invoice_payment_amount {:fields {:invoice_id {:type :id}
|
:invoice_payment_amount {:fields {:invoice_id {:type :id}
|
||||||
:amount {:type 'Float}}}
|
:amount {:type 'Float}}}
|
||||||
|
|
||||||
|
:date_range {:fields {:start {:type :iso_date}
|
||||||
|
:end {:type :iso_date}}}
|
||||||
|
|
||||||
:import_ledger_line_item {:fields {:account_identifier {:type 'String}
|
:import_ledger_line_item {:fields {:account_identifier {:type 'String}
|
||||||
:location {:type 'String}
|
:location {:type 'String}
|
||||||
:debit {:type 'String}
|
:debit {:type 'String}
|
||||||
|
|||||||
38
src/cljs/auto_ap/views/components/date_range_filter.cljs
Normal file
38
src/cljs/auto_ap/views/components/date_range_filter.cljs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
(ns auto-ap.views.components.date-range-filter
|
||||||
|
(:require
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
|
[auto-ap.entities.invoice :as invoice]
|
||||||
|
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||||
|
[auto-ap.views.utils :refer [bind-field date-picker]]))
|
||||||
|
|
||||||
|
(defn date-range-filter [{:keys [value on-change-event]}]
|
||||||
|
[:div.field
|
||||||
|
[:div.control
|
||||||
|
[:div.columns.is-variable.is-1
|
||||||
|
[:div.column
|
||||||
|
[bind-field
|
||||||
|
[date-picker {:class-name "input is-fullwidth"
|
||||||
|
:class "input"
|
||||||
|
:format-week-number (fn [] "")
|
||||||
|
:previous-month-button-label ""
|
||||||
|
:placeholder "Start Date mm/dd/yyyy"
|
||||||
|
:next-month-button-label ""
|
||||||
|
:next-month-label ""
|
||||||
|
:event on-change-event
|
||||||
|
:type "date"
|
||||||
|
:field [:start]
|
||||||
|
:subscription value}]]]
|
||||||
|
[:div.column.is-narrow " to "]
|
||||||
|
[:div.column
|
||||||
|
[bind-field
|
||||||
|
[date-picker {:class-name "input is-fullwidth"
|
||||||
|
:class "input"
|
||||||
|
:format-week-number (fn [] "")
|
||||||
|
:previous-month-button-label ""
|
||||||
|
:placeholder "Start Date mm/dd/yyyy"
|
||||||
|
:next-month-button-label ""
|
||||||
|
:event on-change-event
|
||||||
|
:next-month-label ""
|
||||||
|
:type "date"
|
||||||
|
:field [:end]
|
||||||
|
:subscription value}]]]]]])
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
[auto-ap.forms :as forms]
|
[auto-ap.forms :as forms]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.views.components.bank-account-filter :refer [bank-account-filter]]
|
[auto-ap.views.components.bank-account-filter :refer [bank-account-filter]]
|
||||||
|
[auto-ap.views.components.date-range-filter :refer [date-range-filter]]
|
||||||
[auto-ap.views.components.layouts :refer [appearing-side-bar side-bar-layout]]
|
[auto-ap.views.components.layouts :refer [appearing-side-bar side-bar-layout]]
|
||||||
[auto-ap.views.components.modal :refer [action-modal]]
|
[auto-ap.views.components.modal :refer [action-modal]]
|
||||||
[auto-ap.views.components.paginator :refer [paginator]]
|
[auto-ap.views.components.paginator :refer [paginator]]
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
|
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
|
||||||
[auto-ap.utils :refer [replace-by]]
|
[auto-ap.utils :refer [replace-by]]
|
||||||
[auto-ap.views.pages.transactions.manual :as manual]
|
[auto-ap.views.pages.transactions.manual :as manual]
|
||||||
[auto-ap.views.utils :refer [bind-field date->str dispatch-event nf]]
|
[auto-ap.views.utils :refer [bind-field date->str dispatch-event nf date-picker]]
|
||||||
[goog.string :as gstring]
|
[goog.string :as gstring]
|
||||||
[re-frame.core :as re-frame]))
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@
|
|||||||
::received
|
::received
|
||||||
(fn [db [_ data]]
|
(fn [db [_ data]]
|
||||||
(-> db
|
(-> db
|
||||||
(assoc ::transaction-page (first (:transaction-page data)))
|
(update ::transaction-page merge (first (:transaction-page data)))
|
||||||
(assoc-in [:status :loading] false))))
|
(assoc-in [:status :loading] false))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
@@ -78,6 +79,17 @@
|
|||||||
(assoc-in updated [::params :bank-account-id] value))
|
(assoc-in updated [::params :bank-account-id] value))
|
||||||
updated))))
|
updated))))
|
||||||
|
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::change-selected-date-range
|
||||||
|
(fn [{:keys [db]} [_ key value]]
|
||||||
|
(let [[key] key
|
||||||
|
updated (-> db
|
||||||
|
(assoc-in [::transaction-page :date-range-filter key] value)
|
||||||
|
(assoc-in [::params :date-range key] value))]
|
||||||
|
{:dispatch [::params-change (::params updated)]
|
||||||
|
:db updated})))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::notification
|
::notification
|
||||||
(fn [db]
|
(fn [db]
|
||||||
@@ -130,7 +142,12 @@
|
|||||||
[bank-account-filter
|
[bank-account-filter
|
||||||
{:on-change-event [::change-selected-bank-account]
|
{:on-change-event [::change-selected-bank-account]
|
||||||
:value (:bank-acount-filter @(re-frame/subscribe [::transaction-page]))
|
:value (:bank-acount-filter @(re-frame/subscribe [::transaction-page]))
|
||||||
:bank-accounts @(re-frame/subscribe [::subs/bank-accounts])}]]]
|
:bank-accounts @(re-frame/subscribe [::subs/bank-accounts])}]]
|
||||||
|
[:p.menu-label "Date Range"]
|
||||||
|
[:div
|
||||||
|
[date-range-filter
|
||||||
|
{:on-change-event [::change-selected-date-range]
|
||||||
|
:value (:date-range-filter @(re-frame/subscribe [::transaction-page]))}]]]
|
||||||
:main [transactions-content]
|
:main [transactions-content]
|
||||||
:right-side-bar [appearing-side-bar
|
:right-side-bar [appearing-side-bar
|
||||||
{:visible? transaction-bar-active?}
|
{:visible? transaction-bar-active?}
|
||||||
|
|||||||
@@ -123,7 +123,8 @@
|
|||||||
[drop-down {:id [::expense-accounts id ]
|
[drop-down {:id [::expense-accounts id ]
|
||||||
:header [:a.button {:aria-haspopup true
|
:header [:a.button {:aria-haspopup true
|
||||||
:on-click (dispatch-event [::events/toggle-menu [::expense-accounts id]])
|
:on-click (dispatch-event [::events/toggle-menu [::expense-accounts id]])
|
||||||
:tab-index "0"} "i"]}
|
:tab-index "0"}
|
||||||
|
[:span.icon-saving-bank-1]]}
|
||||||
[drop-down-contents
|
[drop-down-contents
|
||||||
[:div
|
[:div
|
||||||
[:span.dropdown-item description-original ]]]]
|
[:span.dropdown-item description-original ]]]]
|
||||||
|
|||||||
Reference in New Issue
Block a user