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

Track expense with custom distance rate #47864

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/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
Loading