Allows you to filter down to ccp-processor
This commit is contained in:
@@ -46,6 +46,13 @@
|
||||
:where ['[?e :sales-order/client ?client-id]
|
||||
'[?client-id :client/code ?client-code]]}
|
||||
:args [(:client-code args)]})
|
||||
|
||||
(:processor args)
|
||||
(merge-query {:query {:in ['?processor]
|
||||
:where ['[?e :sales-order/charges ?chg]
|
||||
'[?chg :charge/processor ?processor]]}
|
||||
:args [(keyword "ccp-processor"
|
||||
(name (:processor args)))]})
|
||||
|
||||
(:total-gte args)
|
||||
(merge-query {:query {:in ['?total-gte]
|
||||
@@ -96,13 +103,28 @@
|
||||
(mapv <-datomic))]
|
||||
payments))
|
||||
|
||||
(defn summarize-orders [ids]
|
||||
|
||||
(let [[total tax] (->>
|
||||
(d/query {:query {:find ['(sum ?t) '(sum ?tax)]
|
||||
:with ['?id]
|
||||
:in ['$ '[?id ...]]
|
||||
:where ['[?id :sales-order/total ?t]
|
||||
'[?id :sales-order/tax ?tax]]}
|
||||
:args [(d/db (d/connect uri))
|
||||
ids]})
|
||||
first)]
|
||||
{:total total
|
||||
:tax tax}))
|
||||
|
||||
(defn get-graphql [args]
|
||||
(log/info "ARGS" args)
|
||||
(let [db (d/db (d/connect uri))
|
||||
{ids-to-retrieve :ids matching-count :count} (raw-graphql-ids db args)]
|
||||
|
||||
[(->> (graphql-results ids-to-retrieve db args))
|
||||
matching-count]))
|
||||
matching-count
|
||||
(summarize-orders ids-to-retrieve)]))
|
||||
|
||||
(defn get-by-id [id]
|
||||
(->>
|
||||
|
||||
@@ -63,8 +63,8 @@
|
||||
(str %)
|
||||
|
||||
:else
|
||||
%)
|
||||
}
|
||||
%)}
|
||||
|
||||
:percentage {:parse #(cond (and (string? %)
|
||||
(not (str/blank? %)))
|
||||
(Double/parseDouble %)
|
||||
@@ -126,7 +126,7 @@
|
||||
:phone {:type 'String}}}
|
||||
|
||||
:bank_account
|
||||
{:fields {:id {:type :id }
|
||||
{:fields {:id {:type :id}
|
||||
:type {:type :ident}
|
||||
:start_date {:type :iso_date}
|
||||
:number {:type 'String}
|
||||
@@ -177,8 +177,8 @@
|
||||
:terms_override
|
||||
{:fields {:id {:type :id}
|
||||
:client {:type :client}
|
||||
:terms {:type 'Int}
|
||||
}}
|
||||
:terms {:type 'Int}}}
|
||||
|
||||
|
||||
:schedule_payment_dom
|
||||
{:fields {:id {:type :id}
|
||||
@@ -218,9 +218,9 @@
|
||||
:legal_entity_last_name {:type 'String}
|
||||
:legal_entity_tin {:type 'String}
|
||||
:legal_entity_tin_type {:type :tin_type}
|
||||
:legal_entity_1099_type {:type :type_1099}
|
||||
:legal_entity_1099_type {:type :type_1099}}}
|
||||
|
||||
}}
|
||||
|
||||
:reminder
|
||||
{:fields {:id {:type 'Int}
|
||||
:email {:type 'String}
|
||||
@@ -228,8 +228,8 @@
|
||||
:body {:type 'String}
|
||||
:scheduled {:type 'String}
|
||||
:sent {:type 'String}
|
||||
:vendor {:type :vendor}
|
||||
}}
|
||||
:vendor {:type :vendor}}}
|
||||
|
||||
|
||||
:journal_entry_line
|
||||
{:fields {:id {:type :id}
|
||||
@@ -301,24 +301,24 @@
|
||||
:s3_url {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
:status {:type 'String}
|
||||
:invoices {:type '(list :invoice_payment)}
|
||||
}}
|
||||
:invoices {:type '(list :invoice_payment)}}}
|
||||
|
||||
|
||||
:payment {:fields {:id {:type :id}
|
||||
:type {:type :payment_type}
|
||||
: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}
|
||||
: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)}
|
||||
}}
|
||||
:invoices {:type '(list :invoice_payment)}}}
|
||||
|
||||
|
||||
:yodlee_merchant {:fields {:id {:type :id}
|
||||
:yodlee_id {:type 'String}
|
||||
@@ -432,10 +432,10 @@
|
||||
:end {:type 'Int}}}
|
||||
|
||||
:payment_page {:fields {:payments {:type '(list :payment)}
|
||||
:count {:type 'Int}
|
||||
:total {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:end {:type 'Int}}}
|
||||
:count {:type 'Int}
|
||||
:total {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:end {:type 'Int}}}
|
||||
|
||||
:transaction_page {:fields {:data {:type '(list :transaction)}
|
||||
:count {:type 'Int}
|
||||
@@ -454,12 +454,16 @@
|
||||
:total {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:end {:type 'Int}}}
|
||||
|
||||
|
||||
:sales_order_page {:fields {:sales_orders {:type '(list :sales_order)}
|
||||
:count {:type 'Int}
|
||||
:total {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:end {:type 'Int}}}
|
||||
:count {:type 'Int}
|
||||
:total {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:end {:type 'Int}
|
||||
:sales_order_total {:type :money}
|
||||
:sales_order_tax {:type :money}}}
|
||||
|
||||
|
||||
|
||||
:expected_deposit_page {:fields {:expected_deposits {:type '(list :expected_deposit)}
|
||||
:count {:type 'Int}
|
||||
@@ -489,8 +493,8 @@
|
||||
:import_ledger_result {:fields {:successful {:type '(list :import_ledger_entry_result)}
|
||||
:existing {:type '(list :import_ledger_entry_result)}
|
||||
:ignored {:type '(list :import_ledger_entry_result)}
|
||||
:errors {:type '(list :import_ledger_entry_result)}
|
||||
}}
|
||||
:errors {:type '(list :import_ledger_entry_result)}}}
|
||||
|
||||
|
||||
:upcoming_transaction {:fields {:amount {:type :money}
|
||||
:identifier {:type 'String}
|
||||
@@ -500,8 +504,8 @@
|
||||
:invoices_due_soon {:type '(list :invoice)}
|
||||
:outstanding_payments {:type :money}
|
||||
:upcoming_credits {:type '(list :upcoming_transaction)}
|
||||
:upcoming_debits {:type '(list :upcoming_transaction)}}}
|
||||
}
|
||||
:upcoming_debits {:type '(list :upcoming_transaction)}}}}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -600,10 +604,10 @@
|
||||
:resolve :get-all-expected-deposits}
|
||||
|
||||
:all_sales_orders {:type '(list :sales_order)
|
||||
:args {:client_id {:type :id}
|
||||
:date_range {:type :date_range}
|
||||
:client_code {:type 'String}}
|
||||
:resolve :get-all-sales-orders}
|
||||
:args {:client_id {:type :id}
|
||||
:date_range {:type :date_range}
|
||||
:client_code {:type 'String}}
|
||||
:resolve :get-all-sales-orders}
|
||||
|
||||
:yodlee_merchants {:type '(list :yodlee_merchant)
|
||||
:args {}
|
||||
@@ -612,16 +616,16 @@
|
||||
:transaction_page {:type :transaction_page
|
||||
:args {:filters {:type :transaction_filters}}
|
||||
|
||||
:resolve :get-transaction-page}
|
||||
:resolve :get-transaction-page}
|
||||
|
||||
:transaction_rule_page {:type :transaction_rule_page
|
||||
:args {:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:start {:type 'Int}
|
||||
:per_page {:type 'Int}
|
||||
:sort {:type '(list :sort_item)}
|
||||
:asc {:type 'Boolean}}
|
||||
:resolve :get-transaction-rule-page}
|
||||
:args {:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:start {:type 'Int}
|
||||
:per_page {:type 'Int}
|
||||
:sort {:type '(list :sort_item)}
|
||||
:asc {:type 'Boolean}}
|
||||
:resolve :get-transaction-rule-page}
|
||||
|
||||
:ledger_page {:type :ledger_page
|
||||
:args {:filters {:type :ledger_filters}}
|
||||
@@ -632,6 +636,7 @@
|
||||
:date_range {:type :date_range}
|
||||
:total_lte {:type :money}
|
||||
:total_gte {:type :money}
|
||||
:processor {:type :processor}
|
||||
:start {:type 'Int}
|
||||
:per_page {:type 'Int}
|
||||
:sort {:type '(list :sort_item)}}
|
||||
@@ -670,9 +675,9 @@
|
||||
:vendor {:type '(list :vendor)
|
||||
:resolve :get-vendor}
|
||||
:user {:type '(list :user)
|
||||
:resolve :get-user}
|
||||
:resolve :get-user}}
|
||||
|
||||
}
|
||||
|
||||
|
||||
:input-objects
|
||||
{
|
||||
@@ -756,10 +761,10 @@
|
||||
:matches {:type '(list String)}
|
||||
:location_matches {:type '(list :edit_location_match)}
|
||||
:bank_accounts {:type '(list :edit_bank_account)}
|
||||
:forecasted_transactions {:type '(list :edit_forecasted_transaction)}
|
||||
}}
|
||||
:forecasted_transactions {:type '(list :edit_forecasted_transaction)}}}
|
||||
|
||||
:edit_bank_account
|
||||
{:fields {:id {:type :id }
|
||||
{:fields {:id {:type :id}
|
||||
:code {:type 'String}
|
||||
:type {:type :bank_account_type}
|
||||
:start_date {:type :iso_date}
|
||||
@@ -796,8 +801,8 @@
|
||||
:add_terms_override
|
||||
{:fields {:id {:type :id}
|
||||
:client_id {:type :id}
|
||||
:terms {:type 'Int}
|
||||
}}
|
||||
:terms {:type 'Int}}}
|
||||
|
||||
|
||||
:add_account_override
|
||||
{:fields {:id {:type :id}
|
||||
@@ -833,8 +838,8 @@
|
||||
:legal_entity_last_name {:type 'String}
|
||||
:legal_entity_tin {:type 'String}
|
||||
:legal_entity_tin_type {:type :tin_type}
|
||||
:legal_entity_1099_type {:type :type_1099}
|
||||
}}
|
||||
:legal_entity_1099_type {:type :type_1099}}}
|
||||
|
||||
|
||||
:edit_expense_account
|
||||
{:fields {:id {:type :id}
|
||||
@@ -944,8 +949,8 @@
|
||||
:resolve :mutation/reject-invoices}
|
||||
|
||||
:approve_invoices {:type '(list :id)
|
||||
:args {:invoices {:type '(list :id)}}
|
||||
:resolve :mutation/approve-invoices}
|
||||
:args {:invoices {:type '(list :id)}}
|
||||
:resolve :mutation/approve-invoices}
|
||||
|
||||
:bulk_change_transaction_status {:type :message
|
||||
:args {:filters {:type :transaction_filters}
|
||||
@@ -987,7 +992,7 @@
|
||||
:date {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
:bank_account_id {:type :id}}
|
||||
:resolve :mutation/add-handwritten-check}
|
||||
:resolve :mutation/add-handwritten-check}
|
||||
:edit_user {:type :user
|
||||
:args {:edit_user {:type :edit_user}}
|
||||
:resolve :mutation/edit-user}
|
||||
@@ -1026,9 +1031,9 @@
|
||||
:resolve :mutation/match-transaction}
|
||||
|
||||
:match_transaction_autopay_invoices {:type :transaction
|
||||
:args {:transaction_id {:type :id}
|
||||
:autopay_invoice_ids {:type '(list :id)}}
|
||||
:resolve :mutation/match-transaction-autopay-invoices}
|
||||
:args {:transaction_id {:type :id}
|
||||
:autopay_invoice_ids {:type '(list :id)}}
|
||||
:resolve :mutation/match-transaction-autopay-invoices}
|
||||
|
||||
:match_transaction_unpaid_invoices {:type :transaction
|
||||
:args {:transaction_id {:type :id}
|
||||
@@ -1052,8 +1057,8 @@
|
||||
:resolve :mutation/unvoid-invoice}
|
||||
|
||||
:void_payment {:type :payment
|
||||
:args {:payment_id {:type :id}}
|
||||
:resolve :mutation/void-payment}
|
||||
:args {:payment_id {:type :id}}
|
||||
:resolve :mutation/void-payment}
|
||||
:edit_expense_accounts {:type :invoice
|
||||
:args {:invoice_id {:type :id}
|
||||
:expense_accounts {:type '(list :edit_expense_account)}}
|
||||
@@ -1122,7 +1127,7 @@
|
||||
(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)})
|
||||
:amount (:amount i)})
|
||||
(:invoice_payments args))
|
||||
(:client_id args)
|
||||
(:bank_account_id args)
|
||||
@@ -1145,9 +1150,9 @@
|
||||
'[?account :account/name ?account-name]
|
||||
'[?expense-account :invoice-expense-account/amount ?amount]]}})
|
||||
|
||||
true (d/query ))]
|
||||
true (d/query))]
|
||||
(for [[account-id account-name total] result]
|
||||
{:account {:id account-id :name account-name} :total total })))
|
||||
{:account {:id account-id :name account-name} :total total})))
|
||||
|
||||
(defn categorize [x]
|
||||
(cond (<= x 0) :due
|
||||
@@ -1172,10 +1177,10 @@
|
||||
'[(.between java.time.temporal.ChronoUnit/DAYS (java.time.Instant/now) ?d2 ) ?d3]
|
||||
'[(auto-ap.graphql/categorize ?d3) ?name]]}})
|
||||
|
||||
true (d/query ))
|
||||
true (d/query))
|
||||
result (group-by first result)]
|
||||
|
||||
(for [[id name] [[:due "Due"] [:due-30 "0-30 days"] [:due-60 "31-60 days"] [:due-later ">60 days"] ]
|
||||
(for [[id name] [[:due "Due"] [:due-30 "0-30 days"] [:due-60 "31-60 days"] [:due-later ">60 days"]]
|
||||
:let [[[_ outstanding-balance total] ] (id result nil)
|
||||
outstanding-balance (or outstanding-balance 0)
|
||||
total (or total 0)]]
|
||||
@@ -1199,7 +1204,7 @@
|
||||
|
||||
(defn get-cash-flow [context {:keys [client_id]} value]
|
||||
(when client_id
|
||||
(let [{:client/keys [week-a-credits week-a-debits week-b-credits week-b-debits forecasted-transactions ]} (d/pull (d/db (d/connect uri)) '[*] client_id )
|
||||
(let [{:client/keys [week-a-credits week-a-debits week-b-credits week-b-debits forecasted-transactions ]} (d/pull (d/db (d/connect uri)) '[*] client_id)
|
||||
total-cash (reduce
|
||||
(fn [total [credit debit]]
|
||||
(- (+ total credit)
|
||||
@@ -1249,7 +1254,7 @@
|
||||
:let [next (t/plus (t/local-date (t/year (time/local-now))
|
||||
(t/month (time/local-now))
|
||||
(Math/min (Math/max day-of-month 1)
|
||||
30) )
|
||||
30))
|
||||
(t/months month))]
|
||||
:when (not (has-fulfilled? id next recent-fulfillments))]
|
||||
{:identifier identifier
|
||||
@@ -1281,8 +1286,8 @@
|
||||
(or week-b-debits 0)))
|
||||
:date (coerce/to-date-time date)})
|
||||
(take (* 7 4) (time/day-of-week-seq 1)))
|
||||
(filter #(< (:amount %) 0) forecasted-transactions))
|
||||
})))
|
||||
(filter #(< (:amount %) 0) forecasted-transactions))})))
|
||||
|
||||
|
||||
(def schema
|
||||
(-> integreat-schema
|
||||
@@ -1368,7 +1373,7 @@
|
||||
|
||||
(defn query
|
||||
([id q]
|
||||
(query id q nil ))
|
||||
(query id q nil))
|
||||
([id q v]
|
||||
(lc/with-context {:query q}
|
||||
(log/info "Executing query" q)
|
||||
@@ -1383,8 +1388,8 @@
|
||||
|
||||
(catch Exception e
|
||||
(if-let [v (or (:validation-error (ex-data e))
|
||||
(:validation-error (ex-data (.getCause e)))
|
||||
)]
|
||||
(:validation-error (ex-data (.getCause e))))]
|
||||
|
||||
(do
|
||||
(warn-event "validation error" {:validation-error v
|
||||
:data (ex-data e)})
|
||||
|
||||
@@ -4,5 +4,7 @@
|
||||
|
||||
(defn get-sales-orders-page [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
[sales-orders sales-orders-count] (d-sales-orders2/get-graphql (<-graphql args))]
|
||||
(result->page sales-orders sales-orders-count :sales_orders args )))
|
||||
[sales-orders sales-orders-count {:keys [total tax]}] (d-sales-orders2/get-graphql (<-graphql args))]
|
||||
(assoc (result->page sales-orders sales-orders-count :sales_orders args)
|
||||
:sales_order_total total
|
||||
:sales_order_tax tax)))
|
||||
|
||||
Reference in New Issue
Block a user