Skip to content

Commit a314f7b

Browse files
committed
fix: better seting payment amount with calculated subtotal or order amoutn
1 parent f441461 commit a314f7b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,17 @@ module.exports = async ({ appSdk, storeId, auth }, orderId, opts = {}) => {
333333
const { amount } = order
334334
const transaction = order.transactions && order.transactions.length && order.transactions[0]
335335
const paymentMethodCode = transaction && transaction.payment_method.code
336-
subtotal += subtotal ? (amount.freight || 0) : 0
336+
const paymentAmount = subtotal > 0
337+
? subtotal + (amount.freight || 0)
338+
: amount.total
337339

338340
const body = {
339341
COD_EMPRESA: companyCode,
340342
COD_FILIAL: subsidiaryCode,
341343
COD_CLI: customerCodeHorus,
342344
COD_PED_VENDA: saleCodeHorus,
343345
COD_FORMA: getCodePayment(paymentMethodCode, appData.payments, transaction),
344-
VLR_PARCELA: parsePrice(subtotal || amount.total),
346+
VLR_PARCELA: parsePrice(paymentAmount),
345347
QTD_PARCELAS: 0,
346348
DATA_VENCIMENTO: parseDate(new Date(order.created_at))
347349
}

0 commit comments

Comments
 (0)