mirror of
https://github.com/mruwnik/invoices.git
synced 2025-06-08 13:24:43 +02:00
Limit items with :to and :from
This commit is contained in:
parent
ea4294f138
commit
f650d5f40e
13
README.md
13
README.md
@ -55,8 +55,9 @@ The buyer can have the following keys
|
||||
|
||||
### Items
|
||||
|
||||
The list of items should contain maps with a required :title, an optional :vat (if not provided it is assumed that
|
||||
item is VAT free), and a key providing the cost of the item. The price can be provided in one of the following ways:
|
||||
The list of items should contain maps with a required :title, optional :vat (if not provided it is assumed that
|
||||
item is VAT free), :to (the date from which this item is valid), :from (the date till which this item is valid)
|
||||
and a key providing the cost of the item. The price can be provided in one of the following ways:
|
||||
|
||||
* :netto - is a set price and will be displayed as provided
|
||||
* :hourly - is an hourly price - JIRA will be queried in order to work out how many hours should be billed
|
||||
@ -76,11 +77,11 @@ item is VAT free), and a key providing the cost of the item. The price can be pr
|
||||
|
||||
Examples:
|
||||
|
||||
; 8% VAT, and a price of 600
|
||||
{:vat 8 :netto 600 :title "Shoes"}
|
||||
; 8% VAT, and a price of 600, recurring every period before 2019-05-30
|
||||
{:vat 8 :netto 600 :title "Shoes" :to "2019-05-30"}
|
||||
|
||||
; 12% VAT, and an hourly rate of 12
|
||||
{:vat 12 :hourly 12 :title "Something worth 12/h"}
|
||||
; 12% VAT, and an hourly rate of 12, first appearing on 2019-07-01
|
||||
{:vat 12 :hourly 12 :title "Something worth 12/h" :from "2019-07-01"}
|
||||
|
||||
; 23% VAT, working part time with a base salary of 5000
|
||||
{:vat 23 :base 5000 :per-day 4 :title "Part time job at 5000"}]
|
||||
|
@ -1,7 +1,7 @@
|
||||
(ns invoices.core
|
||||
(:require [invoices.pdf :as pdf]
|
||||
[invoices.settings :refer [invoices]]
|
||||
[invoices.jira :refer [prev-timesheet]]
|
||||
[invoices.jira :refer [prev-timesheet prev-month]]
|
||||
[clojure.tools.cli :refer [parse-opts]]
|
||||
[clojure.string :as str])
|
||||
(:gen-class))
|
||||
@ -36,9 +36,15 @@
|
||||
(not (contains? item :netto)) (assoc item :netto 0)
|
||||
:else item))
|
||||
|
||||
(defn date-applies? [when {to :to from :from}]
|
||||
(and (or (nil? to) (-> when .toString (compare to) (< 0)))
|
||||
(or (nil? from) (-> when .toString (compare from) (>= 0)))))
|
||||
|
||||
(defn for-month [when {seller :seller buyer :buyer items :items creds :credentials font-path :font-path} & [number]]
|
||||
(pdf/render seller buyer
|
||||
(map (partial set-price (prev-timesheet when creds)) items)
|
||||
(->> items
|
||||
(filter (partial date-applies? when))
|
||||
(map (partial set-price (prev-timesheet when creds))))
|
||||
(pdf/last-working-day when)
|
||||
(invoice-number when number)
|
||||
font-path))
|
||||
@ -54,7 +60,7 @@
|
||||
:default 1
|
||||
:parse-fn #(Integer/parseInt %)]
|
||||
["-w" "--when DATE" "The month for which to generate the invoice"
|
||||
:default (java.time.LocalDate/now)
|
||||
:default (-> (java.time.LocalDate/now) prev-month)
|
||||
:parse-fn #(java.time.LocalDate/parse %)]
|
||||
;; A non-idempotent option (:default is applied first)
|
||||
["-c" "--company NIP" "companies for which to generate invoices. All, if not provided"
|
||||
|
Loading…
x
Reference in New Issue
Block a user