several fixes.
This commit is contained in:
@@ -25,9 +25,9 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
config: /usr/local/config/staging.edn
|
config: /usr/local/config/staging.edn
|
||||||
VIRTUAL_HOST: staging2.app.integreatconsult.com
|
VIRTUAL_HOST: staging.app.integreatconsult.com
|
||||||
VIRTUAL_PORT: 3000
|
VIRTUAL_PORT: 3000
|
||||||
LETSENCRYPT_HOST: staging2.app.integreatconsult.com
|
LETSENCRYPT_HOST: staging.app.integreatconsult.com
|
||||||
LETSENCRYPT_EMAIL: le@brycecovertoperations.com
|
LETSENCRYPT_EMAIL: le@brycecovertoperations.com
|
||||||
database:
|
database:
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
(defn sort-fn [sort-by]
|
(defn sort-fn [sort-by]
|
||||||
(cond
|
(cond
|
||||||
(= "client" sort-by)
|
(= "client" sort-by)
|
||||||
#(-> % :transaction/client :client/name)
|
#(-> % :journal-entry/client :client/name)
|
||||||
|
|
||||||
(= "account" sort-by)
|
(= "vendor" sort-by)
|
||||||
#(vector (-> % :transaction/account :account/name) (-> % :db/id))
|
#(-> % :journal-entry/vendor :vendor/name)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(keyword "transaction" sort-by)))
|
(keyword "journal-entry" sort-by)))
|
||||||
|
|
||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids [db args]
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
(:sort-by args) (add-sorter-field {"client" ['[?e :journal-entry/client ?c]
|
(:sort-by args) (add-sorter-field {"client" ['[?e :journal-entry/client ?c]
|
||||||
'[?c :client/name ?sorter]]
|
'[?c :client/name ?sorter]]
|
||||||
"date" ['[?e :journal-entry/date ?sorter]]
|
"date" ['[?e :journal-entry/date ?sorter]]
|
||||||
|
"vendor" ['[?e :journal-entry/vendor ?sorter]]
|
||||||
"amount" ['[?e :journal-entry/amount ?sorter]]}
|
"amount" ['[?e :journal-entry/amount ?sorter]]}
|
||||||
args)
|
args)
|
||||||
|
|
||||||
@@ -75,7 +76,6 @@
|
|||||||
|
|
||||||
true
|
true
|
||||||
(merge-query {:query {:find ['?e] :where ['[?e :journal-entry/date]]}}))]
|
(merge-query {:query {:find ['?e] :where ['[?e :journal-entry/date]]}}))]
|
||||||
(println query)
|
|
||||||
(cond->> query
|
(cond->> query
|
||||||
true (d/query)
|
true (d/query)
|
||||||
(:sort-by args) (apply-sort-2 args)
|
(:sort-by args) (apply-sort-2 args)
|
||||||
|
|||||||
@@ -129,8 +129,8 @@
|
|||||||
:auto-ap/add-external-id-to-ledger {:txes add-general-ledger/add-external-id-to-ledger :requires [:auto-ap/add-yodlee-merchant2]}
|
:auto-ap/add-external-id-to-ledger {:txes add-general-ledger/add-external-id-to-ledger :requires [:auto-ap/add-yodlee-merchant2]}
|
||||||
:auto-ap/add-exclude-to-transaction {:txes add-general-ledger/add-exclude-to-transaction :requires [:auto-ap/add-external-id-to-ledger]}
|
:auto-ap/add-exclude-to-transaction {:txes add-general-ledger/add-exclude-to-transaction :requires [:auto-ap/add-external-id-to-ledger]}
|
||||||
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions :requires [:auto-ap/add-external-id-to-ledger]}
|
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions :requires [:auto-ap/add-external-id-to-ledger]}
|
||||||
:auto-ap/bulk-load-invoice-ledger3 {:txes-fn `add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/convert-transactions]}
|
#_#_:auto-ap/bulk-load-invoice-ledger3 {:txes-fn `add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/convert-transactions]}
|
||||||
:auto-ap/bulk-load-transaction-ledger3 {:txes-fn `add-general-ledger/bulk-load-transaction-ledger :requires [:auto-ap/convert-transactions]}
|
#_#_:auto-ap/bulk-load-transaction-ledger3 {:txes-fn `add-general-ledger/bulk-load-transaction-ledger :requires [:auto-ap/convert-transactions]}
|
||||||
|
|
||||||
}]
|
}]
|
||||||
(println "Conforming database...")
|
(println "Conforming database...")
|
||||||
|
|||||||
@@ -160,7 +160,20 @@
|
|||||||
(mapv
|
(mapv
|
||||||
(fn [[numeric {:keys [name location]}]]
|
(fn [[numeric {:keys [name location]}]]
|
||||||
(remove-nils
|
(remove-nils
|
||||||
{:account/type :account-type/expense
|
{:account/type (cond (<= 1000 numeric 1999)
|
||||||
|
:account-type/asset
|
||||||
|
|
||||||
|
(<= 2000 numeric 2999)
|
||||||
|
:account-type/liability
|
||||||
|
|
||||||
|
(<= 3000 numeric 3999)
|
||||||
|
:account-type/equity
|
||||||
|
|
||||||
|
(<= 4000 numeric 4999)
|
||||||
|
:account-type/revenue
|
||||||
|
|
||||||
|
:else
|
||||||
|
:account-type/expense)
|
||||||
:account/numeric-code numeric
|
:account/numeric-code numeric
|
||||||
:account/code (str numeric)
|
:account/code (str numeric)
|
||||||
:account/name name
|
:account/name name
|
||||||
@@ -186,7 +199,8 @@
|
|||||||
:where ['[?e :invoice/total]]}
|
:where ['[?e :invoice/total]]}
|
||||||
:args [(d/db conn)]}))
|
:args [(d/db conn)]}))
|
||||||
z (->> invoice-ids
|
z (->> invoice-ids
|
||||||
(mapv #(vector (ledger/entity-change->ledger (d/db conn) [:invoice %]))))]
|
(map #(ledger/entity-change->ledger (d/db conn) [:invoice %]))
|
||||||
|
(partition-all 100))]
|
||||||
z))
|
z))
|
||||||
|
|
||||||
|
|
||||||
@@ -199,11 +213,13 @@
|
|||||||
z (->> transaction-ids
|
z (->> transaction-ids
|
||||||
(map #(ledger/entity-change->ledger (d/db conn) [:transaction %]))
|
(map #(ledger/entity-change->ledger (d/db conn) [:transaction %]))
|
||||||
(filter identity)
|
(filter identity)
|
||||||
(mapv #(vector %)))]
|
(partition-all 100)
|
||||||
|
#_(mapv #(vector %)))]
|
||||||
z))
|
z))
|
||||||
|
|
||||||
#_(test-run (bulk-load-transaction-ledger (d/connect auto-ap.datomic/uri)))
|
#_(test-run (bulk-load-transaction-ledger (d/connect auto-ap.datomic/uri)))
|
||||||
#_(test-run (bulk-load-invoice-ledger (d/connect auto-ap.datomic/uri)))
|
#_(test-run (bulk-load-invoice-ledger (d/connect auto-ap.datomic/uri)))
|
||||||
|
#_(test-run (reset-ledger (d/connect auto-ap.datomic/uri)))
|
||||||
|
|
||||||
#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))]
|
#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))]
|
||||||
@(d/transact (d/connect auto-ap.datomic/uri) tran))
|
@(d/transact (d/connect auto-ap.datomic/uri) tran))
|
||||||
@@ -294,6 +310,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(defn reset-ledger [conn]
|
||||||
|
(let [results (->> (d/query {:query {:find '[?e]
|
||||||
|
:in '[$]
|
||||||
|
:where ['[?e :journal-entry/original-entity ]]}
|
||||||
|
:args [(d/db conn)]})
|
||||||
|
(mapv (fn [[id]]
|
||||||
|
[:db/retractEntity id]))
|
||||||
|
(partition-all 100))]
|
||||||
|
results))
|
||||||
|
|
||||||
#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))]
|
#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))]
|
||||||
@(d/transact (d/connect auto-ap.datomic/uri) tran))
|
@(d/transact (d/connect auto-ap.datomic/uri) tran))
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
(map :a)
|
(map :a)
|
||||||
(map namespace)
|
(map namespace)
|
||||||
set)]
|
set)]
|
||||||
|
|
||||||
(cond (namespaces "invoice" ) [[:invoice e]]
|
(cond (namespaces "invoice" ) [[:invoice e]]
|
||||||
(namespaces "invoice-expense-account" ) [[:invoice (:db/id (:invoice/_expense-accounts entity))]]
|
(namespaces "invoice-expense-account" ) [[:invoice (:db/id (:invoice/_expense-accounts entity))]]
|
||||||
(namespaces "transaction-account" ) [[:transaction (:db/id (:transaction/_accounts entity))]]
|
(namespaces "transaction-account" ) [[:transaction (:db/id (:transaction/_accounts entity))]]
|
||||||
@@ -24,7 +23,6 @@
|
|||||||
(map :a)
|
(map :a)
|
||||||
(map namespace)
|
(map namespace)
|
||||||
set)]
|
set)]
|
||||||
|
|
||||||
(cond (namespaces "invoice" ) :invoice
|
(cond (namespaces "invoice" ) :invoice
|
||||||
(namespaces "invoice-expense-account" ) :invoice-expense-account
|
(namespaces "invoice-expense-account" ) :invoice-expense-account
|
||||||
(namespaces "transaction-account" ) :transaction-account
|
(namespaces "transaction-account" ) :transaction-account
|
||||||
@@ -52,7 +50,6 @@
|
|||||||
:journal-entry-line/location (or (:invoice-expense-account/location ea) "HQ") ;; TODO?
|
:journal-entry-line/location (or (:invoice-expense-account/location ea) "HQ") ;; TODO?
|
||||||
:journal-entry-line/debit (:invoice-expense-account/amount ea)}))
|
:journal-entry-line/debit (:invoice-expense-account/amount ea)}))
|
||||||
(:invoice/expense-accounts entity)))
|
(:invoice/expense-accounts entity)))
|
||||||
|
|
||||||
:journal-entry/cleared (and (< (:invoice/outstanding-balance entity) 0.01)
|
:journal-entry/cleared (and (< (:invoice/outstanding-balance entity) 0.01)
|
||||||
(every? #(= :payment-status/cleared (:payment/status %)) (:invoice/payments entity))
|
(every? #(= :payment-status/cleared (:payment/status %)) (:invoice/payments entity))
|
||||||
)})))
|
)})))
|
||||||
@@ -68,7 +65,6 @@
|
|||||||
decreasing? (< (:transaction/amount entity) 0.0)
|
decreasing? (< (:transaction/amount entity) 0.0)
|
||||||
credit-from-bank? decreasing?
|
credit-from-bank? decreasing?
|
||||||
debit-from-bank? (not decreasing?)]
|
debit-from-bank? (not decreasing?)]
|
||||||
|
|
||||||
(when-not (:transaction/exclude-from-ledger entity)
|
(when-not (:transaction/exclude-from-ledger entity)
|
||||||
(remove-nils
|
(remove-nils
|
||||||
{:journal-entry/source "transaction"
|
{:journal-entry/source "transaction"
|
||||||
@@ -93,7 +89,9 @@
|
|||||||
(Math/abs (:transaction-account/amount a)))
|
(Math/abs (:transaction-account/amount a)))
|
||||||
:journal-entry-line/credit (when debit-from-bank?
|
:journal-entry-line/credit (when debit-from-bank?
|
||||||
(Math/abs (:transaction-account/amount a)))}))
|
(Math/abs (:transaction-account/amount a)))}))
|
||||||
(:transaction/accounts entity)))
|
(if (seq (:transaction/accounts entity))
|
||||||
|
(:transaction/accounts entity)
|
||||||
|
[{:transaction-account/amount (:transaction/amount entity)}])))
|
||||||
|
|
||||||
:journal-entry/cleared true}))))
|
:journal-entry/cleared true}))))
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,6 @@
|
|||||||
[paginator {:start start :end end :count count :total total
|
[paginator {:start start :end end :count count :total total
|
||||||
:on-change (fn [p ]
|
:on-change (fn [p ]
|
||||||
(on-params-change (merge @params p) ))}]
|
(on-params-change (merge @params p) ))}]
|
||||||
"Showing " (inc start) "-" end "/" total
|
|
||||||
|
|
||||||
[:table.table.is-fullwidth
|
[:table.table.is-fullwidth
|
||||||
[:thead
|
[:thead
|
||||||
[:tr
|
[:tr
|
||||||
|
|||||||
@@ -51,4 +51,5 @@
|
|||||||
[:ul.pagination-list
|
[:ul.pagination-list
|
||||||
extended-first-page-button
|
extended-first-page-button
|
||||||
(apply list (subvec all-buttons first-page-button last-page-button))
|
(apply list (subvec all-buttons first-page-button last-page-button))
|
||||||
extended-last-page-button]]))
|
extended-last-page-button
|
||||||
|
"Showing " (Math/min (inc start) total) "-" end "/" total]]))
|
||||||
|
|||||||
@@ -136,8 +136,6 @@
|
|||||||
[paginator {:start start :end end :count count :total total
|
[paginator {:start start :end end :count count :total total
|
||||||
:on-change (fn [p ]
|
:on-change (fn [p ]
|
||||||
(on-params-change (merge @params p)))}]
|
(on-params-change (merge @params p)))}]
|
||||||
"Showing " (inc start) "-" end "/" total
|
|
||||||
|
|
||||||
[:table.table.is-fullwidth
|
[:table.table.is-fullwidth
|
||||||
[:thead
|
[:thead
|
||||||
[:tr
|
[:tr
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::params-change
|
::params-change
|
||||||
(fn [cofx [_ params]]
|
(fn [cofx [_ params]]
|
||||||
|
|
||||||
{:db (-> (:db cofx)
|
{:db (-> (:db cofx)
|
||||||
(assoc-in [:status :loading] true)
|
(assoc-in [:status :loading] true)
|
||||||
(assoc-in [::params] params))
|
(assoc-in [::params] params))
|
||||||
|
|||||||
@@ -134,6 +134,8 @@
|
|||||||
[:comparable-balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]]]]}
|
[:comparable-balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]]]]}
|
||||||
:on-success [::received]}}))
|
:on-success [::received]}}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::date-picked
|
::date-picked
|
||||||
(fn [cofx [_ f date]]
|
(fn [cofx [_ f date]]
|
||||||
@@ -149,26 +151,17 @@
|
|||||||
:to-date to
|
:to-date to
|
||||||
:selected selected)]}))
|
:selected selected)]}))
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::investigate-clicked
|
::ledger-params-changed
|
||||||
(fn [{:keys [db] } [_ location from-numeric-code to-numeric-code which]]
|
(fn [{:keys [db]} [_ params]]
|
||||||
|
|
||||||
{:db (assoc db
|
{:db (assoc db
|
||||||
::ledger-list-active? true
|
::ledger-list-loading true
|
||||||
::ledger-list-loading true)
|
::ledger-params params)
|
||||||
:graphql {:token (-> db :user)
|
:graphql {:token (-> db :user)
|
||||||
:query-obj {:venia/queries [[:ledger-page
|
:query-obj {:venia/queries [[:ledger-page
|
||||||
{:client-id (:id @(re-frame/subscribe [::subs/client]))
|
params
|
||||||
:from-numeric-code from-numeric-code
|
|
||||||
:to-numeric-code to-numeric-code
|
|
||||||
:location location
|
|
||||||
:from-date (if (= :current which)
|
|
||||||
(:from-date (::params db))
|
|
||||||
(date->str (t/minus (str->date (:from-date (::params db)) standard) (t/years 1))
|
|
||||||
standard))
|
|
||||||
:to-date (if (= :current which)
|
|
||||||
(:to-date (::params db))
|
|
||||||
(date->str (t/minus (str->date (:to-date (::params db)) standard) (t/years 1))
|
|
||||||
standard))}
|
|
||||||
[[:journal-entries [:id
|
[[:journal-entries [:id
|
||||||
:source
|
:source
|
||||||
:amount
|
:amount
|
||||||
@@ -185,6 +178,28 @@
|
|||||||
:end]]]}
|
:end]]]}
|
||||||
:on-success [::ledger-list-received]}}))
|
:on-success [::ledger-list-received]}}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::investigate-clicked
|
||||||
|
(fn [{:keys [db] } [_ location from-numeric-code to-numeric-code which]]
|
||||||
|
|
||||||
|
{:db (assoc db
|
||||||
|
::ledger-list-active? true
|
||||||
|
::ledger-list-loading true)
|
||||||
|
|
||||||
|
:dispatch [::ledger-params-changed (assoc (::ledger-params db)
|
||||||
|
:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||||
|
:from-numeric-code from-numeric-code
|
||||||
|
:to-numeric-code to-numeric-code
|
||||||
|
:location location
|
||||||
|
:from-date (if (= :current which)
|
||||||
|
(:from-date (::params db))
|
||||||
|
(date->str (t/minus (str->date (:from-date (::params db)) standard) (t/years 1))
|
||||||
|
standard))
|
||||||
|
:to-date (if (= :current which)
|
||||||
|
(:to-date (::params db))
|
||||||
|
(date->str (t/minus (str->date (:to-date (::params db)) standard) (t/years 1))
|
||||||
|
standard)))]}))
|
||||||
|
|
||||||
(def groupings
|
(def groupings
|
||||||
|
|
||||||
{:expense [["1100 Cash and Bank Accounts" 1100 1199]
|
{:expense [["1100 Cash and Bank Accounts" 1100 1199]
|
||||||
@@ -408,10 +423,13 @@
|
|||||||
[:div [:a.delete.is-pulled-right {:on-click (dispatch-event [::ledger-list-closing])}]
|
[:div [:a.delete.is-pulled-right {:on-click (dispatch-event [::ledger-list-closing])}]
|
||||||
[:div
|
[:div
|
||||||
[:h1.title "Ledger entries"]
|
[:h1.title "Ledger entries"]
|
||||||
[table {:ledger-page ledger-page
|
[table {:id :ledger
|
||||||
|
:ledger-page ledger-page
|
||||||
:status? false
|
:status? false
|
||||||
:status (re-frame/subscribe [::ledger-list-loading])
|
:status (re-frame/subscribe [::ledger-list-loading])
|
||||||
:params (re-frame/subscribe [::ledger-params])} ]]]))
|
:params (re-frame/subscribe [::ledger-params])
|
||||||
|
:on-params-change (fn [params]
|
||||||
|
(re-frame/dispatch [::ledger-params-changed params]))}]]]))
|
||||||
|
|
||||||
(defn profit-and-loss-page []
|
(defn profit-and-loss-page []
|
||||||
(let [ledger-list-active? @(re-frame/subscribe [::ledger-list-active?])]
|
(let [ledger-list-active? @(re-frame/subscribe [::ledger-list-active?])]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
[paginator {:start start :end end :count count :total total
|
[paginator {:start start :end end :count count :total total
|
||||||
:on-change (fn [p ]
|
:on-change (fn [p ]
|
||||||
(on-params-change (merge @params p)))}]
|
(on-params-change (merge @params p)))}]
|
||||||
"Showing " (inc start) "-" end "/" total
|
|
||||||
|
|
||||||
[:table.table.is-fullwidth.compact
|
[:table.table.is-fullwidth.compact
|
||||||
[:thead
|
[:thead
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
[sorted-column {:on-sort opc
|
[sorted-column {:on-sort opc
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
:style {:width percentage-size :cursor "pointer"}
|
||||||
:sort-key "description-original"
|
:sort-key "vendor"
|
||||||
:sort-by sort-by
|
:sort-by sort-by
|
||||||
:asc asc}
|
:asc asc}
|
||||||
"Vendor"]
|
"Vendor"]
|
||||||
@@ -48,11 +48,8 @@
|
|||||||
:sort-by sort-by
|
:sort-by sort-by
|
||||||
:asc asc}
|
:asc asc}
|
||||||
"Date"]
|
"Date"]
|
||||||
[sorted-column {:on-sort opc
|
[:th
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
{:style {:width percentage-size }}
|
||||||
:sort-key "account"
|
|
||||||
:sort-by sort-by
|
|
||||||
:asc asc}
|
|
||||||
"Account"]
|
"Account"]
|
||||||
[sorted-column {:on-sort opc
|
[sorted-column {:on-sort opc
|
||||||
:style {:width "8em" :cursor "pointer"}
|
:style {:width "8em" :cursor "pointer"}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
[paginator {:start start :end end :count count :total total
|
[paginator {:start start :end end :count count :total total
|
||||||
:on-change (fn [p ]
|
:on-change (fn [p ]
|
||||||
(on-params-change (merge @params p)))}]
|
(on-params-change (merge @params p)))}]
|
||||||
"Showing " (inc start) "-" end "/" total
|
|
||||||
|
|
||||||
[:table.table.is-fullwidth
|
[:table.table.is-fullwidth
|
||||||
[:thead
|
[:thead
|
||||||
|
|||||||
Reference in New Issue
Block a user