mirror of
https://github.com/mruwnik/invoices.git
synced 2025-06-28 15:14:50 +02:00
add list worklogs
This commit is contained in:
parent
433a03cc30
commit
14776e196d
21
README.md
21
README.md
@ -66,9 +66,9 @@ The buyer can have the following keys
|
||||
|
||||
### Items
|
||||
|
||||
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),
|
||||
:notes (a list of extra notes to be added at the bottom of the invoice) and a key providing the cost of the item.
|
||||
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),
|
||||
`:notes` (a list of extra notes to be added at the bottom of the invoice) 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
|
||||
@ -117,6 +117,19 @@ must contain a `:type` key that describes the provider, and a `:ids` list, which
|
||||
should contain all worklog ids that can be found in the given worklog. These ids
|
||||
are used to link worklog values with items via the `:worklog` key of items.
|
||||
|
||||
#### Simple lists
|
||||
|
||||
This is the basic worklog, i.e. a list of months with the amount worked provided (hours by default).
|
||||
The unit can be changed via the `unit` key and can be one of `:hour` or `:day`. Below is an example:
|
||||
|
||||
:worklogs [{:type :list
|
||||
:ids [:cows-R-us]
|
||||
:worklogs {"2020-09" {:count 12 :unit :day}
|
||||
"2020-10" {:count 12 :unit :day}
|
||||
"2020-11" {:count 54 :unit :hour}
|
||||
"2020-12" {:count 5 :unit :day}
|
||||
"2021-02" {:count 20 :unit :day}}}]
|
||||
|
||||
#### Jira
|
||||
|
||||
See [Jira's](https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/)
|
||||
@ -175,6 +188,8 @@ have an :email key set and a :smtp key with the :smtp settings for the email ser
|
||||
:pass "asd;l;kjsdfkljld"
|
||||
:ssl true}}]
|
||||
|
||||
The `:email` value can be a string (i.e. a single email address) or a list of strings.
|
||||
|
||||
## Callbacks
|
||||
|
||||
A list of additional commands can be added to each invoice. Each command will be called with
|
||||
|
@ -30,12 +30,18 @@
|
||||
(clojure.core/when (:jira-user credentials)
|
||||
(jira-timesheet (me credentials) (prev-month when) credentials)))
|
||||
|
||||
(defn hours-from-list [date {:keys [ids worklogs]}]
|
||||
(let [month (-> date (.toString) (subs 0 7))
|
||||
{:keys [count unit]} (get worklogs month)
|
||||
worklog {:worked (and count (* count ({:hour 1 :day 8} unit 1)))}]
|
||||
(map (partial assoc worklog :id) ids)))
|
||||
|
||||
(defn get-timesheet [month {type :type offset :month-offset :as creds}]
|
||||
(let [month (-> month (.plusMonths (or offset 0)))]
|
||||
(condp = type
|
||||
:jira (jira-timesheet (me creds) month creds)
|
||||
:imap (email/get-worklogs month creds))))
|
||||
:imap (email/get-worklogs month creds)
|
||||
:list (hours-from-list month creds))))
|
||||
|
||||
(defn timesheets
|
||||
"Return timesheets for the given month from the given worklogs."
|
||||
|
Loading…
x
Reference in New Issue
Block a user