Skip to content

Commit c867b96

Browse files
committed
fix: setting order status to LFT on orders from custom CD (by domain and customer group)
1 parent f236ecc commit c867b96

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

functions/lib/integration/exports/orders-to-horus.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = async ({ appSdk, storeId, auth }, orderId, opts = {}) => {
2828
const horus = new Horus(username, password, baseURL)
2929
const companyCode = appData.company_code || 1
3030
const subsidiaryCode = appData.subsidiary_code || 1
31+
let customCd = null
3132
let subtotal = 0
3233

3334
console.log('> Order =>', orderId)
@@ -55,6 +56,7 @@ module.exports = async ({ appSdk, storeId, auth }, orderId, opts = {}) => {
5556
return null
5657
}
5758
const { amount, number } = order
59+
customCd = order.domain === 'lojaclassica.com.br' && customer.group
5860

5961
if (amount && !amount.total) {
6062
console.log(`${logHead} skipped, order without total`)
@@ -376,7 +378,9 @@ module.exports = async ({ appSdk, storeId, auth }, orderId, opts = {}) => {
376378

377379
body.STA_PEDIDO = order.status === 'cancelled'
378380
? 'CAN'
379-
: parseFinancialStatus(order.financial_status?.current)
381+
: customCd && order.financial_status?.current === 'paid'
382+
? 'LFT'
383+
: parseFinancialStatus(order.financial_status?.current)
380384

381385
const params = new url.URLSearchParams(body)
382386
const endpoint = `/AltStatus_Pedido?${params.toString()}`

0 commit comments

Comments
 (0)