Skip to content

Commit e31346d

Browse files
chore(export-order): avoid update fulfillment status if set
1 parent 2e86f28 commit e31346d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

functions/lib/integration/export-order.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module.exports = ({ appSdk, storeId, auth }, tinyToken, queueEntry, appData, can
2727
const tiny = new Tiny(tinyToken)
2828
let { metafields } = order
2929
console.log(`#${storeId} ${orderId} searching order ${order.number}`)
30-
if (getOrderUpdateType(order) === 'fulfillment') {
30+
const orderUpdateType = getOrderUpdateType(order)
31+
if (orderUpdateType === 'fulfillment') {
3132
const fulfillmentStatus = order.fulfillment_status && order.fulfillment_status.current
3233
if (fulfillmentStatus && Array.isArray(order.fulfillments)) {
3334
const fulfillmentFromTiny = order.fulfillments.find(({ status, flags }) => {
@@ -144,6 +145,11 @@ module.exports = ({ appSdk, storeId, auth }, tinyToken, queueEntry, appData, can
144145
console.log(`#${storeId} ${orderId} found with tiny status ${tinyStatus}`)
145146
}
146147

148+
if (appData.update_financial_orders_only && orderUpdateType === 'fulfillment') {
149+
console.log(`#${storeId} ${orderId} skipped ${tinyStatus} to be a fulfillment`)
150+
return null
151+
}
152+
147153
if (tinyStatus) {
148154
return tiny.post('/pedido.alterar.situacao', {
149155
id: originalTinyOrder.id,

0 commit comments

Comments
 (0)