From 5e10872d8170a8340fcad04de46d2095dc934910 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 13 Nov 2024 16:38:03 +0200 Subject: [PATCH 1/2] Fix distance amount changes after submitting track distance expense with description --- .../parameters/CategorizeTrackedExpenseParams.ts | 2 ++ .../API/parameters/ShareTrackedExpenseParams.ts | 2 ++ src/libs/actions/IOU.ts | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libs/API/parameters/CategorizeTrackedExpenseParams.ts b/src/libs/API/parameters/CategorizeTrackedExpenseParams.ts index 78eb0adecc5e..5d7e5a131262 100644 --- a/src/libs/API/parameters/CategorizeTrackedExpenseParams.ts +++ b/src/libs/API/parameters/CategorizeTrackedExpenseParams.ts @@ -11,6 +11,7 @@ type CategorizeTrackedExpenseParams = { moneyRequestPreviewReportActionID: string; moneyRequestReportID: string; moneyRequestCreatedReportActionID: string; + customUnitRateID: string; actionableWhisperReportActionID: string; modifiedExpenseReportActionID: string; reportPreviewReportActionID: string; @@ -20,6 +21,7 @@ type CategorizeTrackedExpenseParams = { taxCode: string; taxAmount: number; billable?: boolean; + waypoints?: string; }; export default CategorizeTrackedExpenseParams; diff --git a/src/libs/API/parameters/ShareTrackedExpenseParams.ts b/src/libs/API/parameters/ShareTrackedExpenseParams.ts index cee4bc40d9ac..c5cd380a7ad9 100644 --- a/src/libs/API/parameters/ShareTrackedExpenseParams.ts +++ b/src/libs/API/parameters/ShareTrackedExpenseParams.ts @@ -20,6 +20,8 @@ type ShareTrackedExpenseParams = { taxCode: string; taxAmount: number; billable?: boolean; + customUnitRateID: string; + waypoints?: string; }; export default ShareTrackedExpenseParams; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 5ec2e81b8c01..70ad2400d74f 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3405,6 +3405,8 @@ function categorizeTrackedExpense( billable?: boolean, receipt?: Receipt, createdWorkspaceParams?: CreateWorkspaceParams, + waypoints?: string, + customUnitRateID?: string, ) { const {optimisticData, successData, failureData} = onyxData ?? {}; @@ -3451,6 +3453,8 @@ function categorizeTrackedExpense( policyExpenseCreatedReportActionID: createdWorkspaceParams?.expenseCreatedReportActionID, adminsChatReportID: createdWorkspaceParams?.adminsChatReportID, adminsCreatedReportActionID: createdWorkspaceParams?.adminsCreatedReportActionID, + waypoints, + customUnitRateID, }; API.write(WRITE_COMMANDS.CATEGORIZE_TRACKED_EXPENSE, parameters, {optimisticData, successData, failureData}); @@ -3486,6 +3490,8 @@ function shareTrackedExpense( billable?: boolean, receipt?: Receipt, createdWorkspaceParams?: CreateWorkspaceParams, + waypoints?: string, + customUnitRateID?: string, ) { const {optimisticData, successData, failureData} = onyxData ?? {}; @@ -3532,6 +3538,8 @@ function shareTrackedExpense( policyExpenseCreatedReportActionID: createdWorkspaceParams?.expenseCreatedReportActionID, adminsChatReportID: createdWorkspaceParams?.adminsChatReportID, adminsCreatedReportActionID: createdWorkspaceParams?.adminsCreatedReportActionID, + waypoints, + customUnitRateID, }; API.write(WRITE_COMMANDS.SHARE_TRACKED_EXPENSE, parameters, {optimisticData, successData, failureData}); @@ -3833,6 +3841,8 @@ function trackExpense( value: recentServerValidatedWaypoints, }); + const waypoints = validWaypoints ? JSON.stringify(sanitizeRecentWaypoints(validWaypoints)) : undefined; + switch (action) { case CONST.IOU.ACTION.CATEGORIZE: { if (!linkedTrackedExpenseReportAction || !actionableWhisperReportActionID || !linkedTrackedExpenseReportID) { @@ -3863,6 +3873,8 @@ function trackExpense( billable, trackedReceipt, createdWorkspaceParams, + waypoints, + customUnitRateID, ); break; } @@ -3894,6 +3906,8 @@ function trackExpense( billable, trackedReceipt, createdWorkspaceParams, + waypoints, + customUnitRateID, ); break; } @@ -3922,7 +3936,7 @@ function trackExpense( receiptGpsPoints: gpsPoints ? JSON.stringify(gpsPoints) : undefined, transactionThreadReportID: transactionThreadReportID ?? '-1', createdReportActionIDForThread: createdReportActionIDForThread ?? '-1', - waypoints: validWaypoints ? JSON.stringify(sanitizeRecentWaypoints(validWaypoints)) : undefined, + waypoints, customUnitRateID, }; if (actionableWhisperReportActionIDParam) { From 76de333cba6f60b9f90014b58e77374d4a45f186 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 13 Nov 2024 16:49:51 +0200 Subject: [PATCH 2/2] reorder --- src/libs/API/parameters/CategorizeTrackedExpenseParams.ts | 2 +- src/libs/API/parameters/ShareTrackedExpenseParams.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/API/parameters/CategorizeTrackedExpenseParams.ts b/src/libs/API/parameters/CategorizeTrackedExpenseParams.ts index 5d7e5a131262..d999f96fb505 100644 --- a/src/libs/API/parameters/CategorizeTrackedExpenseParams.ts +++ b/src/libs/API/parameters/CategorizeTrackedExpenseParams.ts @@ -11,7 +11,6 @@ type CategorizeTrackedExpenseParams = { moneyRequestPreviewReportActionID: string; moneyRequestReportID: string; moneyRequestCreatedReportActionID: string; - customUnitRateID: string; actionableWhisperReportActionID: string; modifiedExpenseReportActionID: string; reportPreviewReportActionID: string; @@ -22,6 +21,7 @@ type CategorizeTrackedExpenseParams = { taxAmount: number; billable?: boolean; waypoints?: string; + customUnitRateID?: string; }; export default CategorizeTrackedExpenseParams; diff --git a/src/libs/API/parameters/ShareTrackedExpenseParams.ts b/src/libs/API/parameters/ShareTrackedExpenseParams.ts index c5cd380a7ad9..c89c0d400e72 100644 --- a/src/libs/API/parameters/ShareTrackedExpenseParams.ts +++ b/src/libs/API/parameters/ShareTrackedExpenseParams.ts @@ -20,7 +20,7 @@ type ShareTrackedExpenseParams = { taxCode: string; taxAmount: number; billable?: boolean; - customUnitRateID: string; + customUnitRateID?: string; waypoints?: string; };