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

[NoQA] Copy category over from expense when Editing a Money Request #27055

Merged
merged 8 commits into from
Sep 13, 2023
1 change: 1 addition & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,7 @@ function getTransactionDetails(transaction) {
currency: TransactionUtils.getCurrency(transaction),
comment: TransactionUtils.getDescription(transaction),
merchant: TransactionUtils.getMerchant(transaction),
category: TransactionUtils.getCategory(transaction),
};
}

Expand Down
11 changes: 11 additions & 0 deletions src/libs/TransactionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ function getMerchant(transaction) {
return lodashGet(transaction, 'modifiedMerchant', null) || lodashGet(transaction, 'merchant', '');
}

/**
* Return the category from the transaction. This "category" field has no "modified" complement.
*
* @param {Object} transaction
* @return {String}
*/
function getCategory(transaction) {
return lodashGet(transaction, 'category', '');
}

/**
* Return the created field from the transaction, return the modifiedCreated if present.
*
Expand Down Expand Up @@ -362,6 +372,7 @@ export {
getCurrency,
getMerchant,
getCreated,
getCategory,
getLinkedTransaction,
getAllReportTransactions,
hasReceipt,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC
];

// STEP 6: Call the API endpoint
const {created, amount, currency, comment, merchant} = ReportUtils.getTransactionDetails(updatedTransaction);
const {created, amount, currency, comment, merchant, category} = ReportUtils.getTransactionDetails(updatedTransaction);
API.write(
'EditMoneyRequest',
{
Expand All @@ -1066,6 +1066,7 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC
currency,
comment,
merchant,
category,
},
{optimisticData, successData, failureData},
);
Expand Down
Loading