From 43555a4e2533cbe9e49aa49f5330c91340609977 Mon Sep 17 00:00:00 2001 From: BC Date: Thu, 20 Sep 2018 18:40:02 -0700 Subject: [PATCH 1/2] Fixed issue with duplicate import problem. Which account that was used for import is important. --- src/clj/auto_ap/yodlee/import.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clj/auto_ap/yodlee/import.clj b/src/clj/auto_ap/yodlee/import.clj index b36ed7d6..31e9112c 100644 --- a/src/clj/auto_ap/yodlee/import.clj +++ b/src/clj/auto_ap/yodlee/import.clj @@ -100,7 +100,7 @@ (mapcat (fn [transaction-group] (map (fn [index {:keys [date description-original high-level-category amount account-id] :as transaction}] - {:id (str date "-" description-original "-" amount "-" index "-" company-id) + {:id (str date "-" account-id "-" description-original "-" amount "-" index "-" company-id) :bank-account-id account-id :date (time/unparse date "YYYY-MM-dd") :amount {:amount amount} From 6c6ed0ebb7c540510d109cfae5ac0b4bc58abf86 Mon Sep 17 00:00:00 2001 From: BC Date: Thu, 20 Sep 2018 18:56:02 -0700 Subject: [PATCH 2/2] including a more verbose description. --- src/clj/auto_ap/routes/checks.clj | 26 +++++++++++++------------- src/clj/auto_ap/routes/exports.clj | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/clj/auto_ap/routes/checks.clj b/src/clj/auto_ap/routes/checks.clj index e35e9f96..61bc2400 100644 --- a/src/clj/auto_ap/routes/checks.clj +++ b/src/clj/auto_ap/routes/checks.clj @@ -189,10 +189,17 @@ (s3/put-object :bucket-name (:data-bucket env) :key (str "merged-checks/" uuid ".pdf") :input-stream (io/make-input-stream (.toByteArray merged-pdf-stream) {}) - :metadata {:content-length (count (.toByteArray merged-pdf-stream)) + :metadata {:content-length (count (.toByteArray merged-pdf-stream)) :content-type "application/pdf"}) (str "http://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/merged-checks/" uuid ".pdf"))) +(defn get-memo [invoices invoice-amounts] + (str "Invoice #'s: " + (str/join ", " + (map (fn [i] + (str (:invoice-number i) "(" (invoice-amounts (:id i)) ")")) + invoices)))) + (defmulti check-for-invoices (fn [invoices vendor-id vendors company bank-account type index invoice-amounts] @@ -200,14 +207,7 @@ (defmethod check-for-invoices "check" [invoices vendor-id vendors company bank-account type index invoice-amounts] (let [uuid (str (UUID/randomUUID)) - vendor (vendors vendor-id) - - - memo (str "Invoice #'s: " - (str/join ", " - (map (fn [i] - (str (:invoice-number i) "(" (invoice-amounts (:id i)) ")")) - invoices)))] + vendor (vendors vendor-id)] {:s3-uuid uuid :s3-key (str "checks/" uuid ".pdf") :s3-url (str "http://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/checks/" uuid ".pdf") @@ -215,7 +215,7 @@ :type "check" :bank-account-id (:id bank-account) :amount (reduce + 0 (map (comp invoice-amounts :id) invoices)) - :memo memo + :memo (get-memo invoices invoice-amounts) :vendor-id (:id vendor) :company-id (:id company) :date (time/now) @@ -223,7 +223,7 @@ :paid-to (:name vendor) :amount (reduce + 0 (map (comp invoice-amounts :id) invoices)) :check (str (+ index (:check-number bank-account))) - :memo memo + :memo (get-memo invoices invoice-amounts) :date (date->str (local-now)) :company {:name (:name company) :address (:address company) @@ -241,7 +241,7 @@ :bank-account-id (:id bank-account) :amount (reduce + 0 (map (comp invoice-amounts :id) invoices)) :status "cleared" - :memo "Debit" + :memo (str "Debit " (get-memo invoices invoice-amounts)) :vendor-id (:id vendor) :company-id (:id company) :date (time/now) @@ -253,7 +253,7 @@ :bank-account-id (:id bank-account) :amount (reduce + 0 (map (comp invoice-amounts :id) invoices)) :status "cleared" - :memo "Cash" + :memo (str "Cash " (get-memo invoices invoice-amounts)) :vendor-id (:id vendor) :company-id (:id company) :date (time/now) diff --git a/src/clj/auto_ap/routes/exports.clj b/src/clj/auto_ap/routes/exports.clj index 5bcb76c4..e14e5989 100644 --- a/src/clj/auto_ap/routes/exports.clj +++ b/src/clj/auto_ap/routes/exports.clj @@ -39,7 +39,7 @@ (assert-admin identity) (let [query [[:all_checks {:company-id (query-params "company")} - [:id :check-number :amount :memo :date :status + [:id :check-number :amount :memo :date :status :type [:invoices [:invoice-id :amount]] [:bank-account [:number :bank-name :bank-code :id]] [:vendor [:name :id :primary-contact :primary-email :primary-phone :default-expense-account [:address [:street1 :city :state :zip]]]]