Vendor autopay re-instated.

This commit is contained in:
Bryce Covert
2020-11-16 19:28:04 -08:00
parent be1d5997b9
commit e53ee46b3c
4 changed files with 23 additions and 2 deletions

View File

@@ -98,3 +98,13 @@
first
:vendor-account-override/account)
(:vendor/default-account vendor)))
(defn automatically-paid-for-client-id? [vendor client-id]
(->>
(:vendor/automatically-paid-when-due vendor)
(filter
(fn [client]
(= (:db/id client)
client-id)))
first
boolean))

View File

@@ -62,6 +62,13 @@
(defn add-invoice-transaction [{:keys [total invoice_number location scheduled_payment client_id vendor_id vendor_name date due expense_accounts] :as in}]
(let [vendor (d-vendors/get-by-id vendor_id)
account (:vendor/default-account vendor)
due (or (and (:vendor/terms vendor)
(coerce/to-date
(time/plus date (time/days (d-vendors/terms-for-client-id vendor client_id)))))
due)
scheduled_payment (or scheduled_payment
(and (d-vendors/automatically-paid-for-client-id? vendor client_id)
due))
_ (when-not (:db/id account)
(throw (ex-info (str "Vendor '" (:vendor/name vendor) "' does not have a default expense acount.") {:vendor-id vendor_id} )))]
(cond->
@@ -76,8 +83,6 @@
:invoice/date (coerce/to-date date)
:invoice/expense-accounts (map expense-account->entity
expense_accounts)}
(:vendor/terms vendor) (assoc :invoice/due (coerce/to-date
(time/plus date (time/days (d-vendors/terms-for-client-id vendor client_id)))))
due (assoc :invoice/due (coerce/to-date due))
scheduled_payment (assoc :invoice/scheduled-payment (coerce/to-date scheduled_payment)))))

View File

@@ -119,6 +119,7 @@
:keywords [#"GOLDEN BRANDS"]
:extract {:date #"(?:.*\n){4}(.*)" ;; HOW TO GO TO SPCIFIC LINE
:customer-identifier #"Account:(?:.*\n)(.*(?=\s{2,}))"
:account-number #"Account:\s*(.*?)\n"
:invoice-number #"Invoice#: (\d+)"
:total #"Invoice Total\s+([0-9,]+\.[0-9]{2})"}
:parser {:date [:clj-time "EEE MMM dd, yyyy HH:mm aa"]