working on ezcater

ezcater other.

dajusments.

migration for square2
This commit is contained in:
2022-08-19 06:42:40 -07:00
parent dae1cb4a9b
commit bd0f8da16b
21 changed files with 1158 additions and 155 deletions

View File

@@ -86,48 +86,23 @@
"2022-06-01T07:00:00Z")
(sut/order->sales-order)
(:sales-order/date )))))
(t/testing "It should categorize every item as 'External Catering'"
(t/is (= 2
(t/testing "It should simulate a single line item for everything"
(t/is (= 1
(-> known-order
sut/order->sales-order
:sales-order/line-items
count)))
(t/is (= #{"External Catering"}
(t/is (= #{"EZCater Catering"}
(->> known-order
sut/order->sales-order
:sales-order/line-items
(map :order-line-item/category)
set))))
(t/testing "It should generate an id for every line item"
(t/is (= ["ezcater/order/ABC-DT-9ab05fee-a9c5-483b-a7f2-14debde4b7a8-0"
"ezcater/order/ABC-DT-9ab05fee-a9c5-483b-a7f2-14debde4b7a8-1"]
(->> known-order
sut/order->sales-order
:sales-order/line-items
(map :order-line-item/external-id)))))
(t/testing "It should generate an external-id"
(t/is (= "ezcater/order/ABC-DT-9ab05fee-a9c5-483b-a7f2-14debde4b7a8"
(:sales-order/external-id (sut/order->sales-order known-order)))))
(t/testing "Should include package name"
(t/is (= #{"Spartan Package"}
(->> known-order
sut/order->sales-order
:sales-order/line-items
(map :order-line-item/item-name)
set))))
(t/testing "Should use the total amount"
(t/is (= [34.29 206.75]
(->> (-> known-order
(assoc-in [:catererCart :orderItems 0 :totalInSubunits :subunits] 3429)
(assoc-in [:catererCart :orderItems 1 :totalInSubunits :subunits] 20675))
sut/order->sales-order
:sales-order/line-items
(map :order-line-item/total)))))
(t/testing "Should capture amounts"
(t/is (= 35.09 (-> known-order
@@ -147,7 +122,7 @@
(-> known-order
(assoc :orderSourceType "EZCATER")
(assoc-in [:totals :subTotal :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :cost :subunits] 10000)
sut/commision)))))
(t/testing "Should calculate 15% commision on marketplace orders"
(t/is (dollars= 15.0
@@ -160,7 +135,7 @@
(-> known-order
(assoc :orderSourceType "MARKETPLACE")
(assoc-in [:totals :subTotal :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :cost :subunits] 10000)
sut/commision)))))
(t/testing "Should calculate 2.75% ccp fee"
(t/is (dollars= 8.25
@@ -168,10 +143,10 @@
(assoc :orderSourceType "MARKETPLACE")
(assoc-in [:totals :subTotal :subunits] 10000)
(assoc-in [:totals :salesTax :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :subunits] 10000)
(assoc-in [:catererCart :feesAndDiscounts 0 :cost :subunits] 10000)
sut/ccp-fee))))
(t/testing "Should use ezcater total paid to the customer"
(t/is (dollars= 420.65
(t/is (dollars= 454.09
(-> known-order
sut/order->sales-order
:sales-order/total))))
@@ -179,6 +154,14 @@
(t/is (dollars= -41.8975
(-> known-order
sut/order->sales-order
:sales-order/discount)))))
:sales-order/discount))))
(t/testing "Should create a charge for the order"
(t/is (dollars= 454.09
(-> known-order
sut/order->sales-order
:sales-order/charges
first
:charge/total)))))