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
|
||||
let order = val $ updateOrderTotals o
|
||||
case order of
|
||||
Doc d ->
|
||||
if isJust (q_id o)
|
||||
then upsert (select ["_id" =: q_id o] "orders") d
|
||||
else insert_ "orders" d
|
||||
Doc d -> upsert (select ["_id" =: q_id o] "orders") d
|
||||
_ -> return ()
|
||||
|
||||
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 ()
|
||||
|
||||
-- | Function to update order totals from items
|
||||
|
|
|
@ -752,7 +752,7 @@ routes pipe config = do
|
|||
post "/api/orderx" $ do
|
||||
newOrder <- jsonData
|
||||
let q = payload (newOrder :: Payload ZGoOrder)
|
||||
_ <- liftIO $ run (upsertOrder q)
|
||||
_ <- liftIO $ run (upsertXeroOrder q)
|
||||
myOrder <-
|
||||
liftIO $
|
||||
run (findXeroOrder (qaddress q) (qexternalInvoice q) (qshortCode q))
|
||||
|
|
Loading…
Reference in a new issue