made report changes.
This commit is contained in:
@@ -485,11 +485,16 @@
|
|||||||
(let [data (with-open [reader (io/reader (char-array tsv))]
|
(let [data (with-open [reader (io/reader (char-array tsv))]
|
||||||
(doall (csv/read-csv reader :separator \tab)))
|
(doall (csv/read-csv reader :separator \tab)))
|
||||||
db (d/db auto-ap.datomic/conn)
|
db (d/db auto-ap.datomic/conn)
|
||||||
|
i->invoice-id (fn [i]
|
||||||
|
(try (Long/parseLong i)
|
||||||
|
(catch Exception e
|
||||||
|
(:db/id (d/pull db '[:db/id]
|
||||||
|
[:invoice/original-id (Long/parseLong (first (str/split i #"-")))])))))
|
||||||
invoice-totals (->> data
|
invoice-totals (->> data
|
||||||
(drop 1)
|
(drop 1)
|
||||||
(group-by first)
|
(group-by first)
|
||||||
(map (fn [[k values]]
|
(map (fn [[k values]]
|
||||||
[(Long/parseLong k)
|
[(i->invoice-id k)
|
||||||
(reduce + 0.0
|
(reduce + 0.0
|
||||||
(->> values
|
(->> values
|
||||||
(map (fn [[_ _ _ _ amount]]
|
(map (fn [[_ _ _ _ amount]]
|
||||||
@@ -497,9 +502,9 @@
|
|||||||
]))
|
]))
|
||||||
(into {}))]
|
(into {}))]
|
||||||
(->>
|
(->>
|
||||||
(for [[invoice-id invoice-expense-account-id target-account target-date amount _ location] (drop 1 data)
|
(for [[i invoice-expense-account-id target-account target-date amount _ location] (drop 1 data)
|
||||||
:let [
|
:let [
|
||||||
invoice-id (Long/parseLong invoice-id)
|
invoice-id (i->invoice-id i)
|
||||||
|
|
||||||
invoice (d/entity db invoice-id)
|
invoice (d/entity db invoice-id)
|
||||||
current-total (:invoice/total invoice)
|
current-total (:invoice/total invoice)
|
||||||
@@ -511,7 +516,8 @@
|
|||||||
(:db/id (first (:invoice/expense-accounts invoice)))
|
(:db/id (first (:invoice/expense-accounts invoice)))
|
||||||
(d/tempid :db.part/user))
|
(d/tempid :db.part/user))
|
||||||
invoice-expense-account (when-not new-account?
|
invoice-expense-account (when-not new-account?
|
||||||
(d/entity db invoice-expense-account-id))
|
(or (d/entity db invoice-expense-account-id)
|
||||||
|
(d/entity db [:invoice-expense-account/original-id invoice-expense-account-id])))
|
||||||
current-account-id (:db/id (:invoice-expense-account/account invoice-expense-account))
|
current-account-id (:db/id (:invoice-expense-account/account invoice-expense-account))
|
||||||
target-account-id (Long/parseLong (str/trim target-account))
|
target-account-id (Long/parseLong (str/trim target-account))
|
||||||
|
|
||||||
@@ -519,7 +525,7 @@
|
|||||||
current-date (:invoice/date invoice)
|
current-date (:invoice/date invoice)
|
||||||
|
|
||||||
|
|
||||||
current-expense-account-amount (:invoice-expense-account/amount invoice-expense-account)
|
current-expense-account-amount (:invoice-expense-account/amount invoice-expense-account 0.0)
|
||||||
target-expense-account-amount (- (Double/parseDouble amount))
|
target-expense-account-amount (- (Double/parseDouble amount))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -566,15 +566,11 @@
|
|||||||
(into rows
|
(into rows
|
||||||
;; TODO colspan ?
|
;; TODO colspan ?
|
||||||
(concat (when (seq (:journal-entries category))
|
(concat (when (seq (:journal-entries category))
|
||||||
[[{:value (str "Total" )
|
[[{:value (str "" )}
|
||||||
:bold true}
|
{:value (str (client-codes (:client-id category)) " - " (:location category) " - " (:name (:account category)))}
|
||||||
{:value (str (client-codes (:client-id category)) " - " (:location category) " - " (:name (:account category)))
|
|
||||||
:bold true}
|
|
||||||
{:value ""}
|
{:value ""}
|
||||||
{:value ""}
|
{:value ""}
|
||||||
{:value (:total category)
|
{:value ""}]])
|
||||||
:format :dollar
|
|
||||||
:bold true}]])
|
|
||||||
(map
|
(map
|
||||||
(fn [je]
|
(fn [je]
|
||||||
[{:value (user-friendly-date (:date je))}
|
[{:value (user-friendly-date (:date je))}
|
||||||
@@ -588,18 +584,18 @@
|
|||||||
(:journal-entries category))
|
(:journal-entries category))
|
||||||
[[{:value (str "Total" )
|
[[{:value (str "Total" )
|
||||||
:bold true
|
:bold true
|
||||||
:border [:bottom]}
|
:border [:top]}
|
||||||
{:value (str (client-codes (:client-id category)) " - " (:location category) " - " (:name (:account category)))
|
{:value (str (client-codes (:client-id category)) " - " (:location category) " - " (:name (:account category)))
|
||||||
:bold true
|
:bold true
|
||||||
:border [:bottom]}
|
:border [:top]}
|
||||||
{:value ""
|
{:value ""
|
||||||
:border [:bottom]}
|
:border [:top]}
|
||||||
{:value ""
|
{:value ""
|
||||||
:border [:bottom]}
|
:border [:top]}
|
||||||
{:value (:total category)
|
{:value (:total category)
|
||||||
:format :dollar
|
:format :dollar
|
||||||
:bold true
|
:bold true
|
||||||
:border [:bottom]}]]))
|
:border [:top]}]]))
|
||||||
|
|
||||||
)
|
)
|
||||||
[]
|
[]
|
||||||
|
|||||||
Reference in New Issue
Block a user