From 1fb0c2b0665a8984e2ced90b3aac823a99fc95f7 Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 4 Sep 2023 12:07:21 +0200 Subject: [PATCH 1/2] Update empty field check logic --- src/CONST.ts | 1 + src/libs/TransactionUtils.js | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 666d7db19a15..6be817b6296b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -666,6 +666,7 @@ const CONST = { TRANSACTION: { DEFAULT_MERCHANT: 'Request', UNKNOWN_MERCHANT: 'Unknown Merchant', + PARTIAL_TRANSACTION_MERCHANT: '(none)', TYPE: { CUSTOM_UNIT: 'customUnit', }, diff --git a/src/libs/TransactionUtils.js b/src/libs/TransactionUtils.js index b31ebb0757c9..d62a80341a9a 100644 --- a/src/libs/TransactionUtils.js +++ b/src/libs/TransactionUtils.js @@ -89,8 +89,11 @@ function hasReceipt(transaction) { * @param {Object} transaction * @returns {Boolean} */ -function areModifiedFieldsPopulated(transaction) { - return transaction.modifiedMerchant !== CONST.TRANSACTION.UNKNOWN_MERCHANT && transaction.modifiedAmount !== 0 && transaction.modifiedCreated !== ''; +function areRequiredFieldsEmpty(transaction) { + return (transaction.modifiedMerchant === CONST.TRANSACTION.UNKNOWN_MERCHANT + || (transaction.modifiedMerchant === '' && (transaction.merchant === CONST.TRANSACTION.UNKNOWN_MERCHANT || transaction.merchant === '' || transaction.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)) + || (transaction.modifiedAmount === 0 && transaction.amount === 0) + || (transaction.modifiedCreated === '' && transaction.created === '')); } /** @@ -262,7 +265,7 @@ function isReceiptBeingScanned(transaction) { * @returns {Boolean} */ function hasMissingSmartscanFields(transaction) { - return hasReceipt(transaction) && !isDistanceRequest(transaction) && !isReceiptBeingScanned(transaction) && !areModifiedFieldsPopulated(transaction); + return hasReceipt(transaction) && !isDistanceRequest(transaction) && !isReceiptBeingScanned(transaction) && areRequiredFieldsEmpty(transaction); } /** From 43eaa872c6755b55bc722d886fdb918fe4e9f07a Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 4 Sep 2023 12:25:37 +0200 Subject: [PATCH 2/2] prettier --- src/libs/TransactionUtils.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libs/TransactionUtils.js b/src/libs/TransactionUtils.js index d62a80341a9a..b99c44abad90 100644 --- a/src/libs/TransactionUtils.js +++ b/src/libs/TransactionUtils.js @@ -90,10 +90,13 @@ function hasReceipt(transaction) { * @returns {Boolean} */ function areRequiredFieldsEmpty(transaction) { - return (transaction.modifiedMerchant === CONST.TRANSACTION.UNKNOWN_MERCHANT - || (transaction.modifiedMerchant === '' && (transaction.merchant === CONST.TRANSACTION.UNKNOWN_MERCHANT || transaction.merchant === '' || transaction.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)) - || (transaction.modifiedAmount === 0 && transaction.amount === 0) - || (transaction.modifiedCreated === '' && transaction.created === '')); + return ( + transaction.modifiedMerchant === CONST.TRANSACTION.UNKNOWN_MERCHANT || + (transaction.modifiedMerchant === '' && + (transaction.merchant === CONST.TRANSACTION.UNKNOWN_MERCHANT || transaction.merchant === '' || transaction.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)) || + (transaction.modifiedAmount === 0 && transaction.amount === 0) || + (transaction.modifiedCreated === '' && transaction.created === '') + ); } /**