Skip to content

Commit

Permalink
Merge pull request #47864 from Expensify/neil-track-custom-rate
Browse files Browse the repository at this point in the history
Track expense with custom distance rate
  • Loading branch information
neil-marcellini authored Sep 5, 2024
2 parents 82b6db1 + 0a2c8ed commit 9d9acde
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/libs/API/parameters/TrackExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type TrackExpenseParams = {
createdReportActionIDForThread: string;
waypoints?: string;
actionableWhisperReportActionID?: string;
customUnitRateID?: string;
};

export default TrackExpenseParams;
2 changes: 2 additions & 0 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3666,6 +3666,7 @@ function trackExpense(
actionableWhisperReportActionID?: string,
linkedTrackedExpenseReportAction?: OnyxTypes.ReportAction,
linkedTrackedExpenseReportID?: string,
customUnitRateID?: string,
) {
const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);
const currentChatReport = isMoneyRequestReport ? ReportUtils.getReportOrDraftReport(report.chatReportID) : report;
Expand Down Expand Up @@ -3805,6 +3806,7 @@ function trackExpense(
transactionThreadReportID: transactionThreadReportID ?? '-1',
createdReportActionIDForThread: createdReportActionIDForThread ?? '-1',
waypoints: validWaypoints ? JSON.stringify(validWaypoints) : undefined,
customUnitRateID,
};
if (actionableWhisperReportActionIDParam) {
parameters.actionableWhisperReportActionID = actionableWhisperReportActionIDParam;
Expand Down
15 changes: 14 additions & 1 deletion src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,22 @@ function IOURequestStepConfirmation({
transaction.actionableWhisperReportActionID,
transaction.linkedTrackedExpenseReportAction,
transaction.linkedTrackedExpenseReportID,
customUnitRateID,
);
},
[report, transaction, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, transactionTaxCode, transactionTaxAmount, policy, policyTags, policyCategories, action],
[
report,
transaction,
currentUserPersonalDetails.login,
currentUserPersonalDetails.accountID,
transactionTaxCode,
transactionTaxAmount,
policy,
policyTags,
policyCategories,
action,
customUnitRateID,
],
);

const createDistanceRequest = useCallback(
Expand Down
7 changes: 7 additions & 0 deletions src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function IOURequestStepDistance({
const isCreatingNewRequest = !(backTo || isEditing);
const [recentWaypoints, {status: recentWaypointsStatus}] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS);
const iouRequestType = TransactionUtils.getRequestType(transaction);
const customUnitRateID = TransactionUtils.getRateID(transaction);

// For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace
// request and the workspace requires a category or a tag
Expand Down Expand Up @@ -293,6 +294,11 @@ function IOURequestStepDistance({
undefined,
undefined,
TransactionUtils.getValidWaypoints(waypoints, true),
undefined,
undefined,
undefined,
undefined,
customUnitRateID,
);
return;
}
Expand Down Expand Up @@ -346,6 +352,7 @@ function IOURequestStepDistance({
policy,
iouRequestType,
reportNameValuePairs,
customUnitRateID,
]);

const getError = () => {
Expand Down

0 comments on commit 9d9acde

Please sign in to comment.