add list worklogs

This commit is contained in:
Daniel O'Connell 2020-10-07 17:21:09 +02:00
parent 433a03cc30
commit 14776e196d
2 changed files with 25 additions and 4 deletions

View File

@ -66,9 +66,9 @@ The buyer can have the following keys
### Items ### Items
The list of items should contain maps with a required :title, optional :vat (if not provided it is assumed that 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), 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. `: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: The price can be provided in one of the following ways:
* :netto - is a set price and will be displayed as provided * :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 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. 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 #### Jira
See [Jira's](https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/) 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" :pass "asd;l;kjsdfkljld"
:ssl true}}] :ssl true}}]
The `:email` value can be a string (i.e. a single email address) or a list of strings.
## Callbacks ## Callbacks
A list of additional commands can be added to each invoice. Each command will be called with A list of additional commands can be added to each invoice. Each command will be called with

View File

@ -30,12 +30,18 @@
(clojure.core/when (:jira-user credentials) (clojure.core/when (:jira-user credentials)
(jira-timesheet (me credentials) (prev-month when) 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}] (defn get-timesheet [month {type :type offset :month-offset :as creds}]
(let [month (-> month (.plusMonths (or offset 0)))] (let [month (-> month (.plusMonths (or offset 0)))]
(condp = type (condp = type
:jira (jira-timesheet (me creds) month creds) :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 (defn timesheets
"Return timesheets for the given month from the given worklogs." "Return timesheets for the given month from the given worklogs."