diff --git a/README.md b/README.md index 1f1df42..aea260a 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ item is VAT free), :to (the date from which this item is valid), :from (the date The price can be provided in one of the following ways: * :netto - is a set price and will be displayed as provided + * :brutto - is a set price and will be first scaled down to netto * :hourly - is an hourly price - worklogs will be queried in order to work out how many hours should be billed. If no worklog could be found (or its :worked is nil), this item will be skipped. * :base + :per-day - in the case of a variable number of hours worked. :base provides the amount that would be paid diff --git a/src/invoices/calc.clj b/src/invoices/calc.clj index 721c57d..f69cb7e 100644 --- a/src/invoices/calc.clj +++ b/src/invoices/calc.clj @@ -7,6 +7,7 @@ (if-not vat-level 0 (* netto (/ vat-level 100)))) (defn brutto [{netto :netto :as item}] (round (+ netto (vat item)))) +(defn netto [{brutto :brutto vat :vat}] (/ (* brutto 100) (+ 100 vat))) (defn parse-custom "Parse the given function definition and execute it with the given `worklog`." @@ -36,5 +37,6 @@ (contains? item :function) (assoc item :netto (calc-custom worked item)) (contains? item :hourly) (assoc item :netto (calc-hourly worked item)) (contains? item :base) (assoc item :netto (calc-part-time worked item)) + (contains? item :brutto) (assoc item :netto (netto item)) (not (contains? item :netto)) (assoc item :netto 0) :else item))