Skip to content

Commit

Permalink
Merge pull request #27055 from Expensify/yuwen-copyCategory
Browse files Browse the repository at this point in the history
[NoQA] Copy category over from expense when Editing a Money Request
  • Loading branch information
mountiny authored Sep 13, 2023
2 parents 28b9cee + b71fafa commit 2d5bea5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,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 @@ -231,6 +231,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 @@ -365,6 +375,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 @@ -1096,7 +1096,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 @@ -1107,6 +1107,7 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC
currency,
comment,
merchant,
category,
},
{optimisticData, successData, failureData},
);
Expand Down

0 comments on commit 2d5bea5

Please sign in to comment.