Correct duplicate Xero orders
This commit is contained in:
parent
acf2103f0c
commit
7240dd1b87
2 changed files with 9 additions and 5 deletions
12
src/Order.hs
12
src/Order.hs
|
@ -185,10 +185,14 @@ upsertOrder :: ZGoOrder -> Action IO ()
|
||||||
upsertOrder o = do
|
upsertOrder o = do
|
||||||
let order = val $ updateOrderTotals o
|
let order = val $ updateOrderTotals o
|
||||||
case order of
|
case order of
|
||||||
Doc d ->
|
Doc d -> upsert (select ["_id" =: q_id o] "orders") d
|
||||||
if isJust (q_id o)
|
_ -> return ()
|
||||||
then upsert (select ["_id" =: q_id o] "orders") d
|
|
||||||
else insert_ "orders" d
|
upsertXeroOrder :: ZGoOrder -> Action IO ()
|
||||||
|
upsertXeroOrder o = do
|
||||||
|
let order = val $ updateOrderTotals o
|
||||||
|
case order of
|
||||||
|
Doc d -> upsert (select ["externalInvoice" =: qexternalInvoice o, "shortCode" =: qshortCode o] "orders") d
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
-- | Function to update order totals from items
|
-- | Function to update order totals from items
|
||||||
|
|
|
@ -752,7 +752,7 @@ routes pipe config = do
|
||||||
post "/api/orderx" $ do
|
post "/api/orderx" $ do
|
||||||
newOrder <- jsonData
|
newOrder <- jsonData
|
||||||
let q = payload (newOrder :: Payload ZGoOrder)
|
let q = payload (newOrder :: Payload ZGoOrder)
|
||||||
_ <- liftIO $ run (upsertOrder q)
|
_ <- liftIO $ run (upsertXeroOrder q)
|
||||||
myOrder <-
|
myOrder <-
|
||||||
liftIO $
|
liftIO $
|
||||||
run (findXeroOrder (qaddress q) (qexternalInvoice q) (qshortCode q))
|
run (findXeroOrder (qaddress q) (qexternalInvoice q) (qshortCode q))
|
||||||
|
|
Loading…
Reference in a new issue