diff --git a/config/staging-background-worker.edn b/config/staging-background-worker.edn index 0ac53bc4..8d9ad394 100644 --- a/config/staging-background-worker.edn +++ b/config/staging-background-worker.edn @@ -26,7 +26,9 @@ :yodlee2-fastlink "https://fl4.preprod.yodlee.com/authenticate/USDevexPreProd2-195/fastlink/?channelAppName=usdevexpreprod2" :yodlee2-proxy-host "172.31.10.83" :yodlee2-proxy-port 8888 - + :plaid {:base-url "https://development.plaid.com" + :client-id "61bfab05f7e762001b323f79" + :secret-key "637432f4c967bda8b5d77a1dc67e5c"} :square-config {"NGE1" {:square-location "SCX0Y8CTGM1S0", :location "UC", diff --git a/config/staging.edn b/config/staging.edn index b2fa839f..1842a62c 100644 --- a/config/staging.edn +++ b/config/staging.edn @@ -26,4 +26,7 @@ :yodlee2-fastlink "https://fl4.preprod.yodlee.com/authenticate/USDevexPreProd2-195/fastlink/?channelAppName=usdevexpreprod2" :yodlee2-proxy-host "172.31.10.83" :yodlee2-proxy-port 8888 + :plaid {:base-url "https://development.plaid.com" + :client-id "61bfab05f7e762001b323f79" + :secret-key "637432f4c967bda8b5d77a1dc67e5c"} } diff --git a/src/clj/auto_ap/datomic/migrate/sales.clj b/src/clj/auto_ap/datomic/migrate/sales.clj index 1c26f98d..9c3ad46e 100644 --- a/src/clj/auto_ap/datomic/migrate/sales.clj +++ b/src/clj/auto_ap/datomic/migrate/sales.clj @@ -205,5 +205,17 @@ {:db/ident :transaction/expected-deposit :db/doc "If this transaction is a deposit, the deposit that we anticipated" :db/valueType :db.type/ref - :db/cardinality :db.cardinality/one}]]}}) + :db/cardinality :db.cardinality/one}]]} + :add-vendor-for-sales-stuff {:txes [[{:db/ident :expected-deposit/vendor + :db/doc "Which vendor is this deposit for? CCP Square?" + :db/valueType :db.type/ref + :db/cardinality :db.cardinality/one} + {:db/ident :sales-order/vendor + :db/doc "Which vendor is this sales-order for? CCP Square?" + :db/valueType :db.type/ref + :db/cardinality :db.cardinality/one} + {:db/ident :sales-refund/vendor + :db/doc "Which vendor is this refund for? CCP Square?" + :db/valueType :db.type/ref + :db/cardinality :db.cardinality/one}]]}}) diff --git a/src/clj/auto_ap/import/transactions.clj b/src/clj/auto_ap/import/transactions.clj index 3101928d..850f9afe 100644 --- a/src/clj/auto_ap/import/transactions.clj +++ b/src/clj/auto_ap/import/transactions.clj @@ -230,7 +230,7 @@ :transaction-account/amount amount :transaction-account/location "A"}] :transaction/approval-status :transaction-approval-status/approved - :transaction/vendor :vendor/ccp-square + :transaction/vendor (:expected-deposit/vendor expected-deposit) )))) (defn maybe-code [{:transaction/keys [client amount] :as transaction} apply-rules valid-locations] diff --git a/src/clj/auto_ap/square/core.clj b/src/clj/auto_ap/square/core.clj index cfc297ad..c40e0e73 100644 --- a/src/clj/auto_ap/square/core.clj +++ b/src/clj/auto_ap/square/core.clj @@ -165,6 +165,7 @@ :client [:client/code client] :location location :external-id (str "square/order/" client "-" location "-" (:id order)) + :vendor :vendor/ccp-square :total (-> order :net_amounts :total_money amount->money) :tax (-> order :net_amounts :tax_money amount->money) :tip (-> order :net_amounts :tip_money amount->money) @@ -332,6 +333,7 @@ ([client location-id] (->> (for [settlement (settlements client location-id)] #:expected-deposit {:external-id (str "square/settlement/" (:id settlement)) + :vendor :vendor/ccp-square :total (amount->money (:total_money settlement)) :client [:client/code client] :location (get-in env [:square-config client :location]) @@ -362,6 +364,7 @@ (filter (fn [r] (= "COMPLETED" (:status r)))) (map (fn [r] #:sales-refund {:external-id (str "square/refund/" (:id r)) + :vendor :vendor/ccp-square :total (amount->money (:amount_money r)) :fee (transduce (comp (filter #(= "ADJUSTMENT" (:type %))) diff --git a/test/clj/auto_ap/import/transactions_test.clj b/test/clj/auto_ap/import/transactions_test.clj index 47e5eba5..3273fcb3 100644 --- a/test/clj/auto_ap/import/transactions_test.clj +++ b/test/clj/auto_ap/import/transactions_test.clj @@ -143,6 +143,7 @@ (t/testing "Should match expected-deposits" (let [{:strs [bank-account-id client-id expected-deposit-id]} (->> [#:expected-deposit {:client "client-id" :date #inst "2021-07-01T00:00:00-08:00" + :vendor :vendor/ccp-square :total 100.0 :location "MF" :status :expected-deposit-status/pending @@ -171,6 +172,14 @@ :expected-deposit/status :expected-deposit-status/cleared} (:transaction/expected-deposit transaction-result))))) + (t/testing "Should copy vendor from expected-depoisit" + (let [[transaction-result] (sut/transaction->txs (assoc base-transaction + :transaction/vendor :vendor/ccp-square) + (d/entity (d/db conn) bank-account-id) + noop-rule)] + (t/is (= :vendor/ccp-square + (:transaction/vendor transaction-result))))) + (t/testing "Should credit CCP" (let [[transaction-result] (sut/transaction->txs (assoc base-transaction :transaction/date #inst "2021-07-03T00:00:00-08:00"