mirror of
https://github.com/mruwnik/invoices.git
synced 2025-06-08 21:34:44 +02:00
Add by vat sections
This commit is contained in:
parent
6a851a6ff1
commit
63d80ddc1a
@ -5,9 +5,11 @@
|
|||||||
[clojure.string :as str])
|
[clojure.string :as str])
|
||||||
(:import [java.awt Font]))
|
(:import [java.awt Font]))
|
||||||
|
|
||||||
|
(defn total [items getter]
|
||||||
|
(->> items (map getter) (reduce +) round str))
|
||||||
|
|
||||||
(defn format-total [items getter]
|
(defn format-total [items getter]
|
||||||
[:cell {:background-color [216 247 249]}
|
[:cell {:background-color [216 247 249]} (total items getter)])
|
||||||
(->> items (map getter) (reduce +) round str)])
|
|
||||||
|
|
||||||
(defn format-param [param] [:cell.param {:align :right} (str param ": ")])
|
(defn format-param [param] [:cell.param {:align :right} (str param ": ")])
|
||||||
(defn format-value [value] [:cell {:colspan 2} (str value)])
|
(defn format-value [value] [:cell {:colspan 2} (str value)])
|
||||||
@ -21,6 +23,17 @@
|
|||||||
(-> item vat round str)
|
(-> item vat round str)
|
||||||
(brutto item)])))
|
(brutto item)])))
|
||||||
|
|
||||||
|
(defn format-summary
|
||||||
|
([items vat-level] (format-summary (filter #(= (:vat %) vat-level) items) vat-level ""))
|
||||||
|
([items vat-level text]
|
||||||
|
[[:cell {:background-color [84 219 229] :set-border [] :colspan 5 :align :center} text]
|
||||||
|
(format-total items (constantly 1))
|
||||||
|
(format-total items :netto)
|
||||||
|
({:total "wszystkie" nil "zw."} vat-level (str vat-level "%"))
|
||||||
|
(format-total items vat)
|
||||||
|
(format-total items brutto)
|
||||||
|
]))
|
||||||
|
|
||||||
(defn format-notes
|
(defn format-notes
|
||||||
"Adds an `Uwagi` section with the given notes, one per line."
|
"Adds an `Uwagi` section with the given notes, one per line."
|
||||||
[notes]
|
[notes]
|
||||||
@ -89,12 +102,14 @@
|
|||||||
(->> items
|
(->> items
|
||||||
(map format-product)
|
(map format-product)
|
||||||
(map-indexed #(concat [(inc %1)] %2)))
|
(map-indexed #(concat [(inc %1)] %2)))
|
||||||
[[[:cell {:background-color [84 219 229] :colspan 5 :align :center} "Razem"]
|
[(format-summary items :total (str "Razem do zapłaty: " (total items brutto) " PLN"))]
|
||||||
(format-total items (constantly 1))
|
(->> items (map :vat) distinct sort (map (partial format-summary items))))
|
||||||
(format-total items :netto)
|
|
||||||
""
|
[:table {:border false :padding 0 :spacing 0 :num-cols 6}
|
||||||
(format-total items vat)
|
[(format-param "Zapłacono") (format-value "0.00 PLN")
|
||||||
(format-total items brutto)]])])
|
(format-param "Do zapłaty") (format-value (str (total items brutto) " PLN"))]]
|
||||||
|
|
||||||
|
])
|
||||||
|
|
||||||
(defn add-notes
|
(defn add-notes
|
||||||
"Some items require extra notes to be added (for various legal reasons)"
|
"Some items require extra notes to be added (for various legal reasons)"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user