Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update empty field check logic #26643

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ const CONST = {
TRANSACTION: {
DEFAULT_MERCHANT: 'Request',
UNKNOWN_MERCHANT: 'Unknown Merchant',
PARTIAL_TRANSACTION_MERCHANT: '(none)',
TYPE: {
CUSTOM_UNIT: 'customUnit',
},
Expand Down
12 changes: 9 additions & 3 deletions src/libs/TransactionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will have conflicts with this one #26603 lets merge that first and sync iup this branch with it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one doesn't touch TransactionUtils 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mountiny @MariaHCD no conflicts 😁

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it adds the PARTIAL_TRANSACTION_MERCHANT thats what I meant, maybe there will be no conflict, but I just wanted to go in order 😅 been waiting hours for someone to merge it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I added at the exact same spot and with the same name on purpose, to avoid conflicts 😁

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 === '')
);
}

/**
Expand Down Expand Up @@ -262,7 +268,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);
}

/**
Expand Down
Loading