added the ability to credit invoices. Also made it so check numbers pop up for intuit even if they're not in the description.

This commit is contained in:
2022-02-10 12:40:09 -08:00
parent 72b31fe6bd
commit e1298a1f94
5 changed files with 283 additions and 215 deletions

View File

@@ -300,32 +300,8 @@
:charges {:type '(list :charge)}
:line_items {:type '(list :order_line_item)}}}
:check {:fields {:id {:type :id}
:type {:type 'String}
:amount {:type 'String}
:vendor {:type :vendor}
:date {:type 'String}
:bank_account {:type :bank_account}
:memo {:type 'String}
:s3_url {:type 'String}
:check_number {:type 'Int}
:status {:type 'String}
:invoices {:type '(list :invoice_payment)}}}
:payment {:fields {:id {:type :id}
:type {:type :payment_type}
:original_id {:type 'Int}
:amount {:type 'String}
:vendor {:type :vendor}
:client {:type :client}
:date {:type 'String}
:bank_account {:type :bank_account}
:memo {:type 'String}
:s3_url {:type 'String}
:check_number {:type 'Int}
:status {:type :ident}
:transaction {:type :transaction}
:invoices {:type '(list :invoice_payment)}}}
:yodlee_merchant {:fields {:id {:type :id}
:yodlee_id {:type 'String}
@@ -352,13 +328,7 @@
:accounts {:type '(list :percentage_account)}
:transaction_approval_status {:type :transaction_approval_status}}}
:invoice_payment
{:fields {:id {:type :id}
:amount {:type 'String}
:invoice_id {:type 'String}
:payment_id {:type 'String}
:payment {:type :payment}
:invoice {:type :invoice}}}
:user
{:fields {:id {:type :id}
@@ -392,11 +362,7 @@
:start {:type 'Int}
:end {:type 'Int}}}
:payment_page {:fields {:payments {:type '(list :payment)}
:count {:type 'Int}
:total {:type 'Int}
:start {:type 'Int}
:end {:type 'Int}}}
:transaction_rule_page {:fields {:transaction_rules {:type '(list :transaction_rule)}
:count {:type 'Int}
@@ -459,9 +425,7 @@
:potential_transaction_rule_matches {:type '(list :transaction_rule)
:args {:transaction_id {:type :id}}
:resolve :get-transaction-rule-matches}
:potential_payment_matches {:type '(list :payment)
:args {:transaction_id {:type :id}}
:resolve :get-potential-payments}
:test_transaction_rule {:type '(list :transaction)
:args {:transaction_rule {:type :edit_transaction_rule}}
@@ -499,12 +463,7 @@
:args {:account_set {:type 'String}}
:resolve :get-accounts}
:all_payments {:type '(list :payment)
:args {:client_id {:type :id}
:client_code {:type 'String}
:original_id {:type 'Int}
:statuses {:type '(list String)}}
:resolve :get-all-payments}
:all_sales_orders {:type '(list :sales_order)
:args {:client_id {:type :id}
@@ -546,20 +505,7 @@
:sort {:type '(list :sort_item)}}
:resolve :get-sales-order-page}
:payment_page {:type '(list :payment_page)
:args {:client_id {:type :id}
:vendor_id {:type :id}
:payment_type {:type :payment_type}
:exact_match_id {:type :id}
:date_range {:type :date_range}
:amount_lte {:type :money}
:amount_gte {:type :money}
:check_number_like {:type 'String}
:invoice_number {:type 'String}
:start {:type 'Int}
:per_page {:type 'Int}
:sort {:type '(list :sort_item)}}
:resolve :get-payment-page}
:client {:type '(list :client)
:resolve :get-client}
@@ -590,8 +536,7 @@
:only_external {:type 'Boolean}
:external_id_like {:type 'String}
:sort {:type '(list :sort_item)}}}
:invoice_payment_amount {:fields {:invoice_id {:type :id}
:amount {:type :money}}}
:edit_location_match {:fields {:location {:type 'String}
:match {:type 'String}
:id {:type :id}}}
@@ -747,10 +692,7 @@
:name {:type 'String}
:client_overrides {:type '(list :edit_account_client_override)}}}}
:enums {:payment_type {:values [{:enum-value :check}
{:enum-value :cash}
{:enum-value :debit}]}
:enums {
:processor {:values [{:enum-value :na}
{:enum-value :doordash}
{:enum-value :uber_eats}
@@ -790,19 +732,6 @@
:to {:type :id}}
:resolve :mutation/merge-vendors}
:print_checks {:type :check_result
:args {:invoice_payments {:type '(list :invoice_payment_amount)}
:bank_account_id {:type :id}
:type {:type :payment_type}
:client_id {:type :id}}
:resolve :mutation/print-checks}
:add_handwritten_check {:type :check_result
:args {:invoice_payments {:type '(list :invoice_payment_amount)}
:date {:type 'String}
:check_number {:type 'Int}
:bank_account_id {:type :id}}
:resolve :mutation/add-handwritten-check}
:edit_user {:type :user
:args {:edit_user {:type :edit_user}}
:resolve :mutation/edit-user}
@@ -827,9 +756,7 @@
:args {:account {:type :edit_account}}
:resolve :mutation/upsert-account}
:void_payment {:type :payment
:args {:payment_id {:type :id}}
:resolve :mutation/void-payment}}})
}})
(defn snake->kebab [s]
@@ -869,11 +796,7 @@
m))
(defn get-all-payments [context args value]
(assert-admin (:id context))
(map
->graphql
(first (d-checks/get-graphql (assoc (<-graphql args) :count Integer/MAX_VALUE)))))
(defn get-all-sales-orders [context args value]
(assert-admin (:id context))
@@ -889,17 +812,7 @@
(defn print-checks [context args value]
(assert-can-see-client (:id context) (:client_id args))
(->graphql
(gq-checks/print-checks (map (fn [i] {:invoice-id (:invoice_id i)
:amount (:amount i)})
(:invoice_payments args))
(:client_id args)
(:bank_account_id args)
(:type args)
(:id context))))
(defn get-expense-account-stats [context {:keys [client_id] } value]
(let [result (cond-> {:query {:find ['?account '?account-name '(sum ?amount)]
@@ -1058,12 +971,9 @@
(def schema
(-> integreat-schema
(attach-resolvers {:mutation/void-payment gq-checks/void-check
(attach-resolvers {
:get-yodlee-provider-account-page gq-yodlee2/get-yodlee-provider-account-page
:get-all-payments get-all-payments
:get-all-sales-orders get-all-sales-orders
:get-payment-page gq-checks/get-payment-page
:get-potential-payments gq-checks/get-potential-payments
:get-accounts gq-accounts/get-accounts
:get-ledger-page gq-ledger/get-ledger-page
:get-sales-order-page gq-sales-orders/get-sales-orders-page
@@ -1078,9 +988,7 @@
:get-intuit-bank-accounts gq-intuit-bank-accounts/get-intuit-bank-accounts
:get-client gq-clients/get-client
:get-user get-user
:mutation/add-handwritten-check gq-checks/add-handwritten-check
:mutation/delete-transaction-rule gq-transaction-rules/delete-transaction-rule
:mutation/print-checks print-checks
:mutation/edit-user gq-users/edit-user
:mutation/delete-external-ledger gq-ledger/delete-external-ledger
:mutation/upsert-transaction-rule gq-transaction-rules/upsert-transaction-rule
@@ -1093,6 +1001,7 @@
:mutation/import-ledger gq-ledger/import-ledger
:mutation/request-import gq-requests/request-import
:get-vendor gq-vendors/get-graphql})
gq-checks/attach
gq-plaid/attach
gq-import-batches/attach
gq-transactions/attach