payments should load again.

This commit is contained in:
2024-02-08 21:13:43 -08:00
parent f48c819a96
commit cecf021929
2 changed files with 173 additions and 168 deletions

View File

@@ -56,7 +56,7 @@
(take 6 (take 6
(concat (concat
(reduce (reduce
(fn [[line & rest ] word] (fn [[line & rest] word]
(let [line (or line "")] (let [line (or line "")]
(if (> (+ (count line) (count word)) 50) (if (> (+ (count line) (count word)) 50)
(concat [word line] rest) (concat [word line] rest)
@@ -76,19 +76,18 @@
amount (str "--" (.format df amount) "--")] amount (str "--" (.format df amount) "--")]
[:table {:num-cols 12 :border false :leading 11 :widths (distribute [2 3 3 3 3 3 3 3 3 2 2 2])} [:table {:num-cols 12 :border false :leading 11 :widths (distribute [2 3 3 3 3 3 3 3 3 2 2 2])}
[(let [{:keys [:client/name] {:keys [:address/street1 :address/city :address/state :address/zip]} :client/address} client] [(let [{:keys [:client/name] {:keys [:address/street1 :address/city :address/state :address/zip]} :client/address} client]
[:cell {:colspan 5 } [:paragraph {:leading 14} name "\n" street1 "\n" (str city ", " state " " zip)] ]) [:cell {:colspan 5} [:paragraph {:leading 14} name "\n" street1 "\n" (str city ", " state " " zip)]])
(let [{:keys [:bank-account/bank-name :bank-account/bank-code] } bank-account] (let [{:keys [:bank-account/bank-name :bank-account/bank-code]} bank-account]
[:cell {:colspan 5 :align :center} [:paragraph {:style :bold} bank-name] [:paragraph {:size 8 :leading 8} bank-code]]) [:cell {:colspan 5 :align :center} [:paragraph {:style :bold} bank-name] [:paragraph {:size 8 :leading 8} bank-code]])
[:cell {:colspan 2 :size 13} [:cell {:colspan 2 :size 13}
check]] check]]
[[:cell {:colspan 9}] [[:cell {:colspan 9}]
[:cell {:colspan 3 :leading -10} date]] [:cell {:colspan 3 :leading -10} date]]
[[:cell {:colspan 12 :size 14}] [[:cell {:colspan 12 :size 14}]]
]
[[:cell {:size 13 :leading 13} "PAY"] [[:cell {:size 13 :leading 13} "PAY"]
[:cell {:size 8 :leading 8 } "TO THE ORDER OF"] [:cell {:size 8 :leading 8} "TO THE ORDER OF"]
[:cell {:colspan 7} (if (seq print-as) [:cell {:colspan 7} (if (seq print-as)
print-as print-as
vendor-name)] vendor-name)]
@@ -107,14 +106,13 @@
[[:cell {:size 9 :leading 11.5} "\n\n\n\n\nMEMO"] [[:cell {:size 9 :leading 11.5} "\n\n\n\n\nMEMO"]
[:cell {:colspan 5 :leading 11.5} (split-memo memo) [:cell {:colspan 5 :leading 11.5} (split-memo memo)
[:line {:line-width 0.15 :color [50 50 50]}]] [:line {:line-width 0.15 :color [50 50 50]}]]
[:cell {:colspan 6 } (if (:client/signature-file client) [:cell {:colspan 6} (if (:client/signature-file client)
[:image { :top-margin 90 :xscale 0.30 :yscale 0.30 :align :center} [:image {:top-margin 90 :xscale 0.30 :yscale 0.30 :align :center}
(:client/signature-file client)] (:client/signature-file client)]
[:spacer])]] [:spacer])]]
#_[ #_[#_[:cell {:colspan 5} #_memo]
#_[:cell {:colspan 5} #_memo ]
#_[:cell {:colspan 6}]] #_[:cell {:colspan 6}]]
[[:cell {:colspan 2}] [[:cell {:colspan 2}]
@@ -125,7 +123,7 @@
(into (into
[:cell {:colspan 9}] [:cell {:colspan 9}]
(let [{:keys [:client/name] (let [{:keys [:client/name]
{:keys [:address/street1 :address/street2 :address/city :address/state :address/zip ]} :client/address} client] {:keys [:address/street1 :address/street2 :address/city :address/state :address/zip]} :client/address} client]
(filter identity (filter identity
(list (list
[:paragraph " " name] [:paragraph " " name]
@@ -143,8 +141,7 @@
" " vendor-name "\n" " " vendor-name "\n"
" " (:address/street1 (:vendor/address vendor)) "\n" " " (:address/street1 (:vendor/address vendor)) "\n"
(when (not (str/blank? (:address/street2 (:vendor/address vendor)))) (when (not (str/blank? (:address/street2 (:vendor/address vendor))))
(str " " (:address/street2 (:vendor/address vendor)) "\n") (str " " (:address/street2 (:vendor/address vendor)) "\n"))
)
" " (:address/city (:vendor/address vendor)) ", " (:address/state (:vendor/address vendor)) " " (:address/zip (:vendor/address vendor))]] " " (:address/city (:vendor/address vendor)) ", " (:address/state (:vendor/address vendor)) " " (:address/zip (:vendor/address vendor))]]
[:cell {:align :right} [:cell {:align :right}
"Paid to:\n" "Paid to:\n"
@@ -183,8 +180,7 @@
[:paragraph amount] [:paragraph amount]
[:paragraph date]]] [:paragraph date]]]
[[:cell {:colspan 3} "Memo:"] [[:cell {:colspan 3} "Memo:"]
[:cell {:colspan 9} memo]] [:cell {:colspan 9} memo]]])]
])]
output-stream) output-stream)
(.toByteArray output-stream))) (.toByteArray output-stream)))
@@ -197,8 +193,7 @@
make-check-pdf make-check-pdf)]
)]
(s3/put-object :bucket-name (:data-bucket env) (s3/put-object :bucket-name (:data-bucket env)
:key (:payment/s3-key check) :key (:payment/s3-key check)
:input-stream (io/make-input-stream check-bytes {}) :input-stream (io/make-input-stream check-bytes {})
@@ -313,8 +308,7 @@
(reduce + 0.0)) (reduce + 0.0))
0.001) 0.001)
(throw (ex-info "The selected invoices do not have an outstanding balance." (throw (ex-info "The selected invoices do not have an outstanding balance."
{:validation-error "The selected invoices do not have an outstanding balance."}))) {:validation-error "The selected invoices do not have an outstanding balance."}))))
)
(defmethod invoices->entities :payment-type/credit [invoices vendor client bank-account type index invoice-amounts] (defmethod invoices->entities :payment-type/credit [invoices vendor client bank-account type index invoice-amounts]
(when (>= (->> invoices (when (>= (->> invoices
@@ -376,12 +370,11 @@
(into (invoice-payments invoices invoice-amounts))))) (into (invoice-payments invoices invoice-amounts)))))
(defn validate-belonging [client-id invoices bank-account] (defn validate-belonging [client-id invoices bank-account]
(when-not (apply = client-id (map (comp :db/id :invoice/client) invoices )) (when-not (apply = client-id (map (comp :db/id :invoice/client) invoices))
(throw (ex-info "You can't pay for that invoice from this bank account." (throw (ex-info "You can't pay for that invoice from this bank account."
{:validation-error "You can't pay for that invoice from this bank account." {:validation-error "You can't pay for that invoice from this bank account."
:client-id client-id :client-id client-id
:invoices (map :invoice/invoice-number invoices)})) :invoices (map :invoice/invoice-number invoices)})))
)
(when-not (= client-id (:db/id (:client/_bank-accounts bank-account))) (when-not (= client-id (:db/id (:client/_bank-accounts bank-account)))
(throw (ex-info "The selected bank doesn't belong to this client" (throw (ex-info "The selected bank doesn't belong to this client"
{:validation-error "The selected bank doesn't belong to this client" {:validation-error "The selected bank doesn't belong to this client"
@@ -418,7 +411,7 @@
checks)))) checks))))
(let [result (audit-transact (map #(if (map? %) (let [result (audit-transact (map #(if (map? %)
(dissoc % :payment/pdf-data) (dissoc % :payment/pdf-data)
%) checks ) id)] %) checks) id)]
(doseq [[_ i] (:tempids result)] (doseq [[_ i] (:tempids result)]
(solr/touch-with-ledger i))) (solr/touch-with-ledger i)))
@@ -445,11 +438,11 @@
(set/rename-keys {:transaction/_payment :transaction}) (set/rename-keys {:transaction/_payment :transaction})
(update :transaction first)) (update :transaction first))
payment))) payment)))
(map ->graphql )) (map ->graphql))
:total checks-count :total checks-count
:count (count payments) :count (count payments)
:start (-> args :filters (:start 0) ) :start (-> args :filters (:start 0))
:end (+ (-> args :filters (:start 0) ) (count payments))}])) :end (+ (-> args :filters (:start 0)) (count payments))}]))
(defn get-potential-payments [context args _] (defn get-potential-payments [context args _]
(let [transaction (d-transactions/get-by-id (:transaction_id args)) (let [transaction (d-transactions/get-by-id (:transaction_id args))
@@ -534,8 +527,7 @@
[?p :payment/client ?c] [?p :payment/client ?c]
[(get-else $ ?c :client/locked-until #inst "2000-01-01") ?lu] [(get-else $ ?c :client/locked-until #inst "2000-01-01") ?lu]
[?p :payment/date ?d] [?p :payment/date ?d]
[(>= ?d ?lu)] [(>= ?d ?lu)]]
]
(dc/db conn)) (dc/db conn))
(map first) (map first)
(mapcat (fn [{:keys [:db/id] (mapcat (fn [{:keys [:db/id]
@@ -580,7 +572,8 @@
(assert-admin (:id context)) (assert-admin (:id context))
(map (map
->graphql ->graphql
(first (d-checks/get-graphql (assoc (<-graphql args) :count Integer/MAX_VALUE))))) (first (d-checks/get-graphql (assoc (<-graphql (assoc args :clients (:clients context))) :count Integer/MAX_VALUE)))))
(defn print-checks [context args _] (defn print-checks [context args _]
(assert-can-see-client (:id context) (:client_id args)) (assert-can-see-client (:id context) (:client_id args))

View File

@@ -0,0 +1,12 @@
(let [query [[:all_payments
{:client-code "VS"
:original-id nil}
[:id :check-number :amount :memo :date :status :type :original-id
[:invoices [[:invoice [:id :original-id]] :amount]]
[:bank-account [:number :code :bank-name :bank-code :id]]
[:vendor [:name :id [:primary-contact [:name :email :phone]] [:default-account [:name :numeric-code :id]] [:address [:street1 :city :state :zip]]]]
[:client [:id :name :code]]]]]
payments (auto-ap.graphql/query {:user/role "admin"} (venia/graphql-query {:venia/queries (->graphql query)}))]
{:body
(list (:all-payments (:data payments)))})