adding ignore.
This commit is contained in:
@@ -137,7 +137,9 @@
|
|||||||
:auto-ap/add-client-identifier2 {:txes add-client-identifier :requires [:auto-ap/make-every-account-visible]}
|
:auto-ap/add-client-identifier2 {:txes add-client-identifier :requires [:auto-ap/make-every-account-visible]}
|
||||||
:auto-ap/add-transaction-rules {:txes add-general-ledger/add-transaction-rules :requires [:auto-ap/add-exclude-to-transaction]}
|
:auto-ap/add-transaction-rules {:txes add-general-ledger/add-transaction-rules :requires [:auto-ap/add-exclude-to-transaction]}
|
||||||
:auto-ap/add-bank-account-locations {:txes add-general-ledger/add-bank-account-locations :requires [:auto-ap/add-transaction-rules]}
|
:auto-ap/add-bank-account-locations {:txes add-general-ledger/add-bank-account-locations :requires [:auto-ap/add-transaction-rules]}
|
||||||
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions :requires [:auto-ap/add-bank-account-locations]}}]
|
|
||||||
|
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions :requires [:auto-ap/add-bank-account-locations]}
|
||||||
|
:auto-ap/add-exclude-to-invoice {:txes add-general-ledger/add-exclude-to-invoice :requires [:auto-ap/convert-transactions]}}]
|
||||||
(println "Conforming database...")
|
(println "Conforming database...")
|
||||||
(c/ensure-conforms conn norms-map)
|
(c/ensure-conforms conn norms-map)
|
||||||
(when (not (seq args))
|
(when (not (seq args))
|
||||||
|
|||||||
@@ -313,6 +313,12 @@
|
|||||||
:db/cardinality :db.cardinality/one
|
:db/cardinality :db.cardinality/one
|
||||||
:db/doc "Whether to exclude from the ledger"}]])
|
:db/doc "Whether to exclude from the ledger"}]])
|
||||||
|
|
||||||
|
(def add-exclude-to-invoice
|
||||||
|
[[{:db/ident :invoice/exclude-from-ledger
|
||||||
|
:db/valueType :db.type/boolean
|
||||||
|
:db/cardinality :db.cardinality/one
|
||||||
|
:db/doc "Whether to exclude from the ledger"}]])
|
||||||
|
|
||||||
(def add-transaction-rules
|
(def add-transaction-rules
|
||||||
[[{:db/ident :transaction-rule/client
|
[[{:db/ident :transaction-rule/client
|
||||||
:db/valueType :db.type/ref
|
:db/valueType :db.type/ref
|
||||||
|
|||||||
@@ -34,25 +34,26 @@
|
|||||||
(defmethod entity-change->ledger :invoice
|
(defmethod entity-change->ledger :invoice
|
||||||
[db [type id]]
|
[db [type id]]
|
||||||
(let [entity (d/pull db ['* {:invoice/vendor '[*] :invoice/payment '[*]}] id)]
|
(let [entity (d/pull db ['* {:invoice/vendor '[*] :invoice/payment '[*]}] id)]
|
||||||
(remove-nils
|
(when-not (= true (:invoice/exclude-from-ledger entity))
|
||||||
{:journal-entry/source "invoice"
|
(remove-nils
|
||||||
:journal-entry/client (:db/id (:invoice/client entity))
|
{:journal-entry/source "invoice"
|
||||||
:journal-entry/date (:invoice/date entity)
|
:journal-entry/client (:db/id (:invoice/client entity))
|
||||||
:journal-entry/original-entity (:db/id entity)
|
:journal-entry/date (:invoice/date entity)
|
||||||
:journal-entry/vendor (:db/id (:invoice/vendor entity))
|
:journal-entry/original-entity (:db/id entity)
|
||||||
:journal-entry/amount (:invoice/total entity)
|
:journal-entry/vendor (:db/id (:invoice/vendor entity))
|
||||||
|
:journal-entry/amount (:invoice/total entity)
|
||||||
|
|
||||||
:journal-entry/line-items (into [{:journal-entry-line/account (a/get-account-by-numeric-code-and-sets 2110 ["default"])
|
:journal-entry/line-items (into [{:journal-entry-line/account (a/get-account-by-numeric-code-and-sets 2110 ["default"])
|
||||||
:journal-entry-line/location "A"
|
:journal-entry-line/location "A"
|
||||||
:journal-entry-line/credit (:invoice/total entity)}]
|
:journal-entry-line/credit (:invoice/total entity)}]
|
||||||
(map (fn [ea]
|
(map (fn [ea]
|
||||||
(remove-nils {:journal-entry-line/account (:db/id (:invoice-expense-account/account ea))
|
(remove-nils {:journal-entry-line/account (:db/id (:invoice-expense-account/account ea))
|
||||||
: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))
|
||||||
)})))
|
)}))))
|
||||||
|
|
||||||
(defmethod entity-change->ledger :transaction
|
(defmethod entity-change->ledger :transaction
|
||||||
[db [type id]]
|
[db [type id]]
|
||||||
@@ -126,6 +127,7 @@
|
|||||||
(group-by :e)
|
(group-by :e)
|
||||||
(mapcat #(datums->impacted-entity db %))
|
(mapcat #(datums->impacted-entity db %))
|
||||||
(set))
|
(set))
|
||||||
|
_ (println "affected" (count affected-entities))
|
||||||
d-txs (->> affected-entities
|
d-txs (->> affected-entities
|
||||||
(map #(entity-change->ledger db %))
|
(map #(entity-change->ledger db %))
|
||||||
(filter seq))
|
(filter seq))
|
||||||
|
|||||||
51
src/clj/user.clj
Normal file
51
src/clj/user.clj
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
(ns user
|
||||||
|
(:require [auto-ap.datomic :refer [uri]]
|
||||||
|
[datomic.api :as d]
|
||||||
|
|
||||||
|
[clj-time.coerce :as c]
|
||||||
|
[clj-time.core :as t]))
|
||||||
|
|
||||||
|
(defn exclude-until-date [client end]
|
||||||
|
(let [conn (d/connect uri)]
|
||||||
|
(doseq [p (->>
|
||||||
|
(d/query {:query {:find '[?e]
|
||||||
|
:in '[$ ?client ?end ]
|
||||||
|
:where [
|
||||||
|
'[?e :invoice/client ?c]
|
||||||
|
'[?c :client/code ?client]
|
||||||
|
'[?e :invoice/date ?d ]
|
||||||
|
'[(<= ?d ?end) ]]}
|
||||||
|
:args [(d/db conn)
|
||||||
|
client
|
||||||
|
(c/to-date end)]})
|
||||||
|
(mapv first)
|
||||||
|
(mapv (fn [i]
|
||||||
|
{:db/id i
|
||||||
|
:invoice/exclude-from-ledger true}))
|
||||||
|
(partition-all 100))]
|
||||||
|
|
||||||
|
@(d/transact conn p)
|
||||||
|
(println "process 100"))
|
||||||
|
|
||||||
|
(doseq [p (->>
|
||||||
|
(d/query {:query {:find '[?e]
|
||||||
|
:in '[$ ?client ?end ]
|
||||||
|
:where [
|
||||||
|
'[?e :transaction/client ?c]
|
||||||
|
'[?c :client/code ?client]
|
||||||
|
'[?e :transaction/date ?d ]
|
||||||
|
'[(<= ?d ?end) ]]}
|
||||||
|
:args [(d/db conn)
|
||||||
|
client
|
||||||
|
(c/to-date end)]})
|
||||||
|
(mapv first)
|
||||||
|
(mapv (fn [i]
|
||||||
|
{:db/id i
|
||||||
|
:transaction/approval-status :transaction-approval-status/excluded}))
|
||||||
|
(partition-all 100))]
|
||||||
|
|
||||||
|
@(d/transact conn p)
|
||||||
|
(println "process 100"))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user