Adds gift cards to sales summaries

This commit is contained in:
2024-04-01 16:06:34 -07:00
parent 4c52dbc4d6
commit 3957286624
3 changed files with 55 additions and 23 deletions

View File

@@ -82,12 +82,12 @@
:in $ [?clients ?start-date ?end-date]
:where [(iol-ion.query/scan-sales-orders $ ?clients ?start-date ?end-date) [[?e _ ?sort-default] ...]]
[?e :sales-order/returns ?r]
#_[?e :sales-order/charges ?c]
#_[?c :charge/tax ?tax]]
(dc/db conn)
[[c] date date]))
0.0)
(dc/db conn)
[[c] date date]))
0.0)
:sales-summary/sales-items
@@ -168,6 +168,20 @@
[[c] date date]))
0.0)
:sales-summary/total-gift-card-payments
(or (ffirst (dc/q '[:find (sum ?total)
:with ?c
:in $ [?clients ?start-date ?end-date]
:where [(iol-ion.query/scan-sales-orders $ ?clients ?start-date ?end-date) [[?e _ ?sort-default] ...]]
[?e :sales-order/charges ?c]
[?c :charge/total ?total]
(or [?c :charge/type-name "SQUARE_GIFT_CARD"]
[?c :charge/type-name "WALLET"]
[?c :charge/type-name "GIFT_CARD"])]
(dc/db conn)
[[c] date date]))
0.0)
:sales-summary/total-cash-refunds
(or (ffirst (dc/q '[:find (sum ?t)
:in $ [?clients ?start-date ?end-date]
@@ -200,10 +214,8 @@
:sales-summary/total-food-app-refunds
(or (ffirst (dc/q '[:find (sum ?t)
:in $ [?clients ?start-date ?end-date]
:where
:where [(iol-ion.query/scan-sales-refunds $ ?clients ?start-date ?end-date) [[?e _ ?sort-default] ...]]
(not [?e :sales-refund/type "CASH"])
(not [?e :sales-refund/type "CARD"])
[?e :sales-refund/type "EXTERNAL"]
[?e :sales-refund/total ?t]]
(dc/db conn)
[[c] date date]))