First step in coding sales.
This commit is contained in:
@@ -17,10 +17,12 @@
|
||||
(map :a)
|
||||
(map namespace)
|
||||
set)]
|
||||
(println namespaces changes)
|
||||
(cond (namespaces "invoice" ) [[:invoice e]]
|
||||
(namespaces "invoice-expense-account" ) [[:invoice (:db/id (:invoice/_expense-accounts entity))]]
|
||||
(namespaces "transaction-account" ) [[:transaction (:db/id (:transaction/_accounts entity))]]
|
||||
(namespaces "transaction" ) [[:transaction e]]
|
||||
(namespaces "expected-deposit" ) [[:expected-deposit e]]
|
||||
:else nil)))
|
||||
|
||||
|
||||
@@ -33,6 +35,7 @@
|
||||
(cond (namespaces "invoice" ) :invoice
|
||||
(namespaces "invoice-expense-account" ) :invoice-expense-account
|
||||
(namespaces "transaction-account" ) :transaction-account
|
||||
(namespaces "expected-deposit" ) :expected-deposit
|
||||
:else nil)))
|
||||
|
||||
(defmulti entity-change->ledger (fn [_ [type]]
|
||||
@@ -57,7 +60,7 @@
|
||||
:journal-entry/vendor (:db/id (:invoice/vendor entity))
|
||||
:journal-entry/amount (Math/abs (:invoice/total entity))
|
||||
|
||||
:journal-entry/line-items (into [(cond-> {:journal-entry-line/account (:db/id (a/get-account-by-numeric-code-and-sets 21000 ["default"]))
|
||||
:journal-entry/line-items (into [(cond-> {:journal-entry-line/account :account/accounts-payable
|
||||
:journal-entry-line/location "A"
|
||||
}
|
||||
credit-invoice? (assoc :journal-entry-line/debit (Math/abs (:invoice/total entity)))
|
||||
@@ -120,6 +123,26 @@
|
||||
|
||||
:journal-entry/cleared true}))))
|
||||
|
||||
(defmethod entity-change->ledger :expected-deposit
|
||||
[db [type id]]
|
||||
(let [{:expected-deposit/keys [total client date]} (d/pull db '[:expected-deposit/total :expected-deposit/client :expected-deposit/date] id)]
|
||||
#:journal-entry
|
||||
{:source "expected-deposit"
|
||||
:original-entity id
|
||||
|
||||
:client client
|
||||
:date date
|
||||
:amount total
|
||||
:vendor :vendor/ccp-square
|
||||
:line-items [#:journal-entry-line
|
||||
{:credit total
|
||||
:location "A"
|
||||
:account :account/receipts-split}
|
||||
#:journal-entry-line
|
||||
{:debit total
|
||||
:location "A"
|
||||
:account :account/ccp}]}))
|
||||
|
||||
(defmethod entity-change->ledger :invoice-expense-account
|
||||
[db [entity changes]]
|
||||
nil
|
||||
|
||||
Reference in New Issue
Block a user