@shushed/helpers 0.0.202-bug-erp-770-20251202173534 → 0.0.202-bug-erp-770-20251203140812
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +29 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -111278,11 +111278,26 @@ function transformMasterOrder(payload) {
|
|
|
111278
111278
|
const shipping_from = invoice0 || sale0 || null;
|
|
111279
111279
|
const mapPaymentMethod = (code, card) => {
|
|
111280
111280
|
const c = String(code || "").toUpperCase();
|
|
111281
|
-
|
|
111282
|
-
|
|
111283
|
-
|
|
111281
|
+
const processorId = String(card?.processor_id || "").toUpperCase();
|
|
111282
|
+
const giftCertId = String(card?.gift_certificate_id || "").trim();
|
|
111283
|
+
const cardType = String(card?.type || "").trim().toLowerCase();
|
|
111284
|
+
if (giftCertId.length > 0) return "GIFT-CARD";
|
|
111285
|
+
if (cardType === "gift certificate") return "GIFT-CARD";
|
|
111286
|
+
if (processorId.includes("GIFT_CERTIFICATE") || processorId.includes("GIFT-CERTIFICATE")) return "GIFT-CARD";
|
|
111287
|
+
if (/(GVOUCHER|VOUCHER|GIFT|EGIFT)/.test(c)) return "GIFT-CARD";
|
|
111288
|
+
if (c.includes("APPLE")) return "APPLE-PAY";
|
|
111289
|
+
if ((c.includes("PAYPAL") || processorId === "PAYPAL") && giftCertId.length === 0) {
|
|
111290
|
+
return "PAYPAL";
|
|
111291
|
+
}
|
|
111284
111292
|
if (c.includes("MOTO")) return "MOTO";
|
|
111285
|
-
if (
|
|
111293
|
+
if (c.includes("ADYEN") && cardType === "credit card" && giftCertId.length === 0) {
|
|
111294
|
+
return "CREDIT-CARD";
|
|
111295
|
+
}
|
|
111296
|
+
const serviceType = String(card?.service_type || "").toUpperCase();
|
|
111297
|
+
if (serviceType.includes("VOUCHER") && giftCertId.length === 0 && processorId !== "PAYPAL") {
|
|
111298
|
+
return "GIFT-CARD";
|
|
111299
|
+
}
|
|
111300
|
+
if (card?.card_number) return "CREDIT-CARD";
|
|
111286
111301
|
return "OTHER";
|
|
111287
111302
|
};
|
|
111288
111303
|
const cardPays = (payload.card_payments || []).map((c) => ({
|
|
@@ -111300,6 +111315,8 @@ function transformMasterOrder(payload) {
|
|
|
111300
111315
|
// For gift voucher grouping
|
|
111301
111316
|
service_type: c.service_type,
|
|
111302
111317
|
// Store for card_brand mapping
|
|
111318
|
+
processor_id: c.processor_id,
|
|
111319
|
+
// Store processor_id for payment method detection
|
|
111303
111320
|
created_by: invoice0?.created_by || sale0?.created_by,
|
|
111304
111321
|
source: "card_payment",
|
|
111305
111322
|
order_no: c.order_no,
|
|
@@ -111425,7 +111442,10 @@ function transformMasterOrder(payload) {
|
|
|
111425
111442
|
const groupCardData = {
|
|
111426
111443
|
card_number: cardPaymentEntryForMethod?.card_number || sortedEntries.find((e) => e.card_number)?.card_number,
|
|
111427
111444
|
transaction_id: cardPaymentEntryForMethod?.transaction_id || sortedEntries.find((e) => e.transaction_id)?.transaction_id,
|
|
111428
|
-
service_type: cardPaymentEntryForMethod?.service_type || sortedEntries.find((e) => e.service_type)?.service_type
|
|
111445
|
+
service_type: cardPaymentEntryForMethod?.service_type || sortedEntries.find((e) => e.service_type)?.service_type,
|
|
111446
|
+
processor_id: cardPaymentEntryForMethod?.processor_id || sortedEntries.find((e) => e.processor_id)?.processor_id,
|
|
111447
|
+
gift_certificate_id: cardPaymentEntryForMethod?.gift_certificate_id || sortedEntries.find((e) => e.gift_certificate_id)?.gift_certificate_id,
|
|
111448
|
+
type: cardPaymentEntryForMethod?.type || sortedEntries.find((e) => e.type && e.source === "card_payment")?.type
|
|
111429
111449
|
};
|
|
111430
111450
|
let pm;
|
|
111431
111451
|
if (cardPaymentEntryForMethod?.type && String(cardPaymentEntryForMethod.type).trim().toLowerCase() === "apple pay") {
|
|
@@ -111467,7 +111487,10 @@ function transformMasterOrder(payload) {
|
|
|
111467
111487
|
const refundCardData = {
|
|
111468
111488
|
card_number: cardPaymentEntryForMethod?.card_number,
|
|
111469
111489
|
transaction_id: cardPaymentEntryForMethod?.transaction_id,
|
|
111470
|
-
service_type: cardPaymentEntryForMethod?.service_type
|
|
111490
|
+
service_type: cardPaymentEntryForMethod?.service_type,
|
|
111491
|
+
processor_id: cardPaymentEntryForMethod?.processor_id,
|
|
111492
|
+
gift_certificate_id: cardPaymentEntryForMethod?.gift_certificate_id,
|
|
111493
|
+
type: cardPaymentEntryForMethod?.type
|
|
111471
111494
|
};
|
|
111472
111495
|
pm = mapPaymentMethod(paymentMethodCode, refundCardData);
|
|
111473
111496
|
}
|