From e12ea32bda7c79cafc007ef75f99156031ed50fb Mon Sep 17 00:00:00 2001 From: Alberto Date: Thu, 21 Sep 2023 17:10:19 +0800 Subject: [PATCH 1/7] Display distance message --- src/languages/en.ts | 3 +++ src/languages/types.ts | 6 ++++++ src/libs/ReportUtils.js | 26 +++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1882b7e97afb..ceaf1c47b52c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -534,9 +534,12 @@ export default { pendingConversionMessage: "Total will update when you're back online", changedTheRequest: 'changed the request', setTheRequest: ({valueName, newValueToDisplay}: SetTheRequestParams) => `set the ${valueName} to ${newValueToDisplay}`, + setTheDistance: ({newDistanceToDisplay, newAmountToDisplay}: SetTheDistanceParams) => `set the distance to ${newDistanceToDisplay}, setting the amount to ${newAmountToDisplay}`, removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) => `removed the ${valueName} (previously ${oldValueToDisplay})`, updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) => `changed the ${valueName} to ${newValueToDisplay} (previously ${oldValueToDisplay})`, + updatedTheDistance: ({newDistanceToDisplay, oldDistanceToDisplay, newAmountToDisplay, oldAmountToDisplay}: UpdatedTheDistanceParams) => + `changed the distance to ${newDistanceToDisplay} (previously ${oldDistanceToDisplay}), updating the amount to ${newAmountToDisplay} (previously ${oldAmountToDisplay})`, threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${formattedAmount} request${comment ? ` for ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`, tagSelection: ({tagName}: TagSelectionParams) => `Select a ${tagName} to add additional organization to your money`, diff --git a/src/languages/types.ts b/src/languages/types.ts index 9af00ceef8de..4dc6166d3f18 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -186,10 +186,14 @@ type ParentNavigationSummaryParams = {rootReportName: string; workspaceName: str type SetTheRequestParams = {valueName: string; newValueToDisplay: string}; +type SetTheDistanceParams = {newDistanceToDisplay: string, newAmountToDisplay: string}; + type RemovedTheRequestParams = {valueName: string; oldValueToDisplay: string}; type UpdatedTheRequestParams = {valueName: string; newValueToDisplay: string; oldValueToDisplay: string}; +type UpdatedTheDistanceParams = {newDistanceToDisplay: string, oldDistanceToDisplay: string, newAmountToDisplay: string, oldAmountToDisplay: string}; + type TagSelectionParams = {tagName: string}; /* Translation Object types */ @@ -304,4 +308,6 @@ export type { UpdatedTheRequestParams, RemovedTheRequestParams, TagSelectionParams, + SetTheDistanceParams + UpdatedTheDistanceParams }; diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 3c14f45b53ed..442a9f212625 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1533,6 +1533,23 @@ function getProperSchemaForModifiedExpenseMessage(newValue, oldValue, valueName, return Localize.translateLocal('iou.updatedTheRequest', {valueName: displayValueName, newValueToDisplay, oldValueToDisplay}); } +/** + * Get the proper message schema for modified expense message. + * + * @param {String} newValue + * @param {String} oldValue + * @param {String} valueName + * @param {Boolean} valueInQuotes + * @returns {String} + */ + +function getProperSchemaForModifiedDistanceMessage(newDistance, oldDistance, newAmount, oldAmount) { + if (!oldDistance) { + return Localize.translateLocal('iou.setTheRequest', {valueName: displayValueName, newValueToDisplay}); + } + return Localize.translateLocal('iou.updatedTheRequest', {valueName: displayValueName, newValueToDisplay, oldValueToDisplay}); +} + /** * Get the report action message when expense has been modified. * @@ -1550,6 +1567,14 @@ function getModifiedExpenseMessage(reportAction) { _.has(reportActionOriginalMessage, 'oldCurrency') && _.has(reportActionOriginalMessage, 'amount') && _.has(reportActionOriginalMessage, 'currency'); + const hasModifiedMerchant = _.has(reportActionOriginalMessage, 'oldMerchant') && _.has(reportActionOriginalMessage, 'merchant'); + + // Only Distance edits should modify amount and merchant (which stores distance) in a single transaction. + // We check the merchant is in distance format (includes @) as a sanity check + if (hasModifiedAmount && hasModifiedMerchant && reportActionOriginalMessage.merchant.includes('@')) { + + } + if (hasModifiedAmount) { const oldCurrency = reportActionOriginalMessage.oldCurrency; const oldAmount = CurrencyUtils.convertToDisplayString(reportActionOriginalMessage.oldAmount, oldCurrency); @@ -1573,7 +1598,6 @@ function getModifiedExpenseMessage(reportAction) { return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage.created, formattedOldCreated, Localize.translateLocal('common.date'), false); } - const hasModifiedMerchant = _.has(reportActionOriginalMessage, 'oldMerchant') && _.has(reportActionOriginalMessage, 'merchant'); if (hasModifiedMerchant) { return getProperSchemaForModifiedExpenseMessage(reportActionOriginalMessage.merchant, reportActionOriginalMessage.oldMerchant, Localize.translateLocal('common.merchant'), true); } From 800630dca71e70b3708f86575100ed609025a18c Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 22 Sep 2023 11:23:31 +0800 Subject: [PATCH 2/7] display right message --- src/languages/en.ts | 2 ++ src/libs/ReportUtils.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index ceaf1c47b52c..18f0f00048b3 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -68,6 +68,8 @@ import type { ManagerApprovedParams, SetTheRequestParams, UpdatedTheRequestParams, + SetTheDistanceParams, + UpdatedTheDistanceParams, RemovedTheRequestParams, RequestedAmountMessageParams, TagSelectionParams, diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 442a9f212625..984891b39081 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1545,9 +1545,9 @@ function getProperSchemaForModifiedExpenseMessage(newValue, oldValue, valueName, function getProperSchemaForModifiedDistanceMessage(newDistance, oldDistance, newAmount, oldAmount) { if (!oldDistance) { - return Localize.translateLocal('iou.setTheRequest', {valueName: displayValueName, newValueToDisplay}); + return Localize.translateLocal('iou.setTheDistance', {newDistanceToDisplay: newDistance, newAmountToDisplay: newAmount}); } - return Localize.translateLocal('iou.updatedTheRequest', {valueName: displayValueName, newValueToDisplay, oldValueToDisplay}); + return Localize.translateLocal('iou.updatedTheDistance', {newDistanceToDisplay: newDistance, oldDistanceToDisplay: oldDistance, newAmountToDisplay: newAmount, oldAmountToDisplay: oldAmount}); } /** @@ -1567,14 +1567,8 @@ function getModifiedExpenseMessage(reportAction) { _.has(reportActionOriginalMessage, 'oldCurrency') && _.has(reportActionOriginalMessage, 'amount') && _.has(reportActionOriginalMessage, 'currency'); - const hasModifiedMerchant = _.has(reportActionOriginalMessage, 'oldMerchant') && _.has(reportActionOriginalMessage, 'merchant'); - - // Only Distance edits should modify amount and merchant (which stores distance) in a single transaction. - // We check the merchant is in distance format (includes @) as a sanity check - if (hasModifiedAmount && hasModifiedMerchant && reportActionOriginalMessage.merchant.includes('@')) { - - } + const hasModifiedMerchant = _.has(reportActionOriginalMessage, 'oldMerchant') && _.has(reportActionOriginalMessage, 'merchant'); if (hasModifiedAmount) { const oldCurrency = reportActionOriginalMessage.oldCurrency; const oldAmount = CurrencyUtils.convertToDisplayString(reportActionOriginalMessage.oldAmount, oldCurrency); @@ -1582,6 +1576,12 @@ function getModifiedExpenseMessage(reportAction) { const currency = reportActionOriginalMessage.currency; const amount = CurrencyUtils.convertToDisplayString(reportActionOriginalMessage.amount, currency); + // Only Distance edits should modify amount and merchant (which stores distance) in a single transaction. + // We check the merchant is in distance format (includes @) as a sanity check + if (hasModifiedMerchant && reportActionOriginalMessage.merchant.includes('@')) { + return getProperSchemaForModifiedDistanceMessage(reportActionOriginalMessage.merchant, reportActionOriginalMessage.oldMerchant, amount, oldAmount); + } + return getProperSchemaForModifiedExpenseMessage(amount, oldAmount, Localize.translateLocal('iou.amount'), false); } From aa7130d974aeb4f043949e27bc545f264e460251 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 22 Sep 2023 11:25:48 +0800 Subject: [PATCH 3/7] spanish --- src/languages/es.ts | 5 +++++ src/languages/types.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 87c7a19fed8a..904dcd1e0471 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -67,7 +67,9 @@ import type { ParentNavigationSummaryParams, ManagerApprovedParams, SetTheRequestParams, + SetTheDistanceParams, UpdatedTheRequestParams, + UpdatedTheDistanceParams, RemovedTheRequestParams, RequestedAmountMessageParams, TagSelectionParams, @@ -526,10 +528,13 @@ export default { pendingConversionMessage: 'El total se actualizará cuando estés online', changedTheRequest: 'cambió la solicitud', setTheRequest: ({valueName, newValueToDisplay}: SetTheRequestParams) => `estableció ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay}`, + setTheDistance: ({newDistanceToDisplay, newAmountToDisplay}: SetTheDistanceParams) => `set the distance to ${newDistanceToDisplay}, setting the amount to ${newAmountToDisplay}`, removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) => `eliminó ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} (previamente ${oldValueToDisplay})`, updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) => `cambío ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`, + updatedTheDistance: ({newDistanceToDisplay, oldDistanceToDisplay, newAmountToDisplay, oldAmountToDisplay}: UpdatedTheDistanceParams) => + `changed the distance to ${newDistanceToDisplay} (previously ${oldDistanceToDisplay}), updating the amount to ${newAmountToDisplay} (previously ${oldAmountToDisplay})`, threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, tagSelection: ({tagName}: TagSelectionParams) => `Seleccione una ${tagName} para organizar mejor tu dinero`, diff --git a/src/languages/types.ts b/src/languages/types.ts index 4dc6166d3f18..fed752e09819 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -308,6 +308,6 @@ export type { UpdatedTheRequestParams, RemovedTheRequestParams, TagSelectionParams, - SetTheDistanceParams - UpdatedTheDistanceParams + SetTheDistanceParams, + UpdatedTheDistanceParams, }; From 4fdd5bd6420ed68b9afc791d9ea1833dfd895c0b Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 25 Sep 2023 11:36:32 +0800 Subject: [PATCH 4/7] update messages --- src/languages/en.ts | 4 ++-- src/languages/es.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 18f0f00048b3..18a334ebb735 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -536,12 +536,12 @@ export default { pendingConversionMessage: "Total will update when you're back online", changedTheRequest: 'changed the request', setTheRequest: ({valueName, newValueToDisplay}: SetTheRequestParams) => `set the ${valueName} to ${newValueToDisplay}`, - setTheDistance: ({newDistanceToDisplay, newAmountToDisplay}: SetTheDistanceParams) => `set the distance to ${newDistanceToDisplay}, setting the amount to ${newAmountToDisplay}`, + setTheDistance: ({newDistanceToDisplay, newAmountToDisplay}: SetTheDistanceParams) => `set the distance to ${newDistanceToDisplay}, which set the amount to ${newAmountToDisplay}`, removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) => `removed the ${valueName} (previously ${oldValueToDisplay})`, updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) => `changed the ${valueName} to ${newValueToDisplay} (previously ${oldValueToDisplay})`, updatedTheDistance: ({newDistanceToDisplay, oldDistanceToDisplay, newAmountToDisplay, oldAmountToDisplay}: UpdatedTheDistanceParams) => - `changed the distance to ${newDistanceToDisplay} (previously ${oldDistanceToDisplay}), updating the amount to ${newAmountToDisplay} (previously ${oldAmountToDisplay})`, + `changed the distance to ${newDistanceToDisplay} (previously ${oldDistanceToDisplay}), which updated the amount to ${newAmountToDisplay} (previously ${oldAmountToDisplay})`, threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${formattedAmount} request${comment ? ` for ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`, tagSelection: ({tagName}: TagSelectionParams) => `Select a ${tagName} to add additional organization to your money`, diff --git a/src/languages/es.ts b/src/languages/es.ts index 904dcd1e0471..e966676acc8c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -528,13 +528,13 @@ export default { pendingConversionMessage: 'El total se actualizará cuando estés online', changedTheRequest: 'cambió la solicitud', setTheRequest: ({valueName, newValueToDisplay}: SetTheRequestParams) => `estableció ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay}`, - setTheDistance: ({newDistanceToDisplay, newAmountToDisplay}: SetTheDistanceParams) => `set the distance to ${newDistanceToDisplay}, setting the amount to ${newAmountToDisplay}`, + setTheDistance: ({newDistanceToDisplay, newAmountToDisplay}: SetTheDistanceParams) => `estableció la distancia a ${newDistanceToDisplay}, lo que estableció el importe a ${newAmountToDisplay}`, removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) => `eliminó ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} (previamente ${oldValueToDisplay})`, updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) => `cambío ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`, updatedTheDistance: ({newDistanceToDisplay, oldDistanceToDisplay, newAmountToDisplay, oldAmountToDisplay}: UpdatedTheDistanceParams) => - `changed the distance to ${newDistanceToDisplay} (previously ${oldDistanceToDisplay}), updating the amount to ${newAmountToDisplay} (previously ${oldAmountToDisplay})`, + `cambió la distancia a ${newDistanceToDisplay} (previamente ${oldDistanceToDisplay}), lo que cambió el importe a ${newAmountToDisplay} (previamente ${oldAmountToDisplay})`, threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, tagSelection: ({tagName}: TagSelectionParams) => `Seleccione una ${tagName} para organizar mejor tu dinero`, From 80445b53a7c68a063b71437f563f0113a34b3cda Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 25 Sep 2023 11:36:53 +0800 Subject: [PATCH 5/7] typo --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index e966676acc8c..982b68901eb1 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -532,7 +532,7 @@ export default { removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) => `eliminó ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} (previamente ${oldValueToDisplay})`, updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) => - `cambío ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`, + `cambió ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`, updatedTheDistance: ({newDistanceToDisplay, oldDistanceToDisplay, newAmountToDisplay, oldAmountToDisplay}: UpdatedTheDistanceParams) => `cambió la distancia a ${newDistanceToDisplay} (previamente ${oldDistanceToDisplay}), lo que cambió el importe a ${newAmountToDisplay} (previamente ${oldAmountToDisplay})`, threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, From e2b09c887e6786ec9102841aef0c2ab4effee34e Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 29 Sep 2023 12:59:56 +0800 Subject: [PATCH 6/7] prettier --- src/languages/es.ts | 3 ++- src/languages/types.ts | 4 ++-- src/libs/ReportUtils.js | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 0bfbf5ba453e..acfb1f6494dd 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -533,7 +533,8 @@ export default { pendingConversionMessage: 'El total se actualizará cuando estés online', changedTheRequest: 'cambió la solicitud', setTheRequest: ({valueName, newValueToDisplay}: SetTheRequestParams) => `estableció ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay}`, - setTheDistance: ({newDistanceToDisplay, newAmountToDisplay}: SetTheDistanceParams) => `estableció la distancia a ${newDistanceToDisplay}, lo que estableció el importe a ${newAmountToDisplay}`, + setTheDistance: ({newDistanceToDisplay, newAmountToDisplay}: SetTheDistanceParams) => + `estableció la distancia a ${newDistanceToDisplay}, lo que estableció el importe a ${newAmountToDisplay}`, removedTheRequest: ({valueName, oldValueToDisplay}: RemovedTheRequestParams) => `eliminó ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} (previamente ${oldValueToDisplay})`, updatedTheRequest: ({valueName, newValueToDisplay, oldValueToDisplay}: UpdatedTheRequestParams) => diff --git a/src/languages/types.ts b/src/languages/types.ts index 12c9da2f1bca..bd178ed0e712 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -186,13 +186,13 @@ type ParentNavigationSummaryParams = {rootReportName: string; workspaceName: str type SetTheRequestParams = {valueName: string; newValueToDisplay: string}; -type SetTheDistanceParams = {newDistanceToDisplay: string, newAmountToDisplay: string}; +type SetTheDistanceParams = {newDistanceToDisplay: string; newAmountToDisplay: string}; type RemovedTheRequestParams = {valueName: string; oldValueToDisplay: string}; type UpdatedTheRequestParams = {valueName: string; newValueToDisplay: string; oldValueToDisplay: string}; -type UpdatedTheDistanceParams = {newDistanceToDisplay: string, oldDistanceToDisplay: string, newAmountToDisplay: string, oldAmountToDisplay: string}; +type UpdatedTheDistanceParams = {newDistanceToDisplay: string; oldDistanceToDisplay: string; newAmountToDisplay: string; oldAmountToDisplay: string}; type FormattedMaxLengthParams = {formattedMaxLength: string}; diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index dc9221d41761..72fb45afe19c 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1579,7 +1579,12 @@ function getProperSchemaForModifiedDistanceMessage(newDistance, oldDistance, new if (!oldDistance) { return Localize.translateLocal('iou.setTheDistance', {newDistanceToDisplay: newDistance, newAmountToDisplay: newAmount}); } - return Localize.translateLocal('iou.updatedTheDistance', {newDistanceToDisplay: newDistance, oldDistanceToDisplay: oldDistance, newAmountToDisplay: newAmount, oldAmountToDisplay: oldAmount}); + return Localize.translateLocal('iou.updatedTheDistance', { + newDistanceToDisplay: newDistance, + oldDistanceToDisplay: oldDistance, + newAmountToDisplay: newAmount, + oldAmountToDisplay: oldAmount, + }); } /** From 50bef134521177a9b3f01861d69aa90f8fc38ae1 Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 2 Oct 2023 15:47:19 +0800 Subject: [PATCH 7/7] update header --- src/libs/ReportUtils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 72fb45afe19c..0ab3255eb0ad 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1566,12 +1566,12 @@ function getProperSchemaForModifiedExpenseMessage(newValue, oldValue, valueName, } /** - * Get the proper message schema for modified expense message. + * Get the proper message schema for modified distance message. * - * @param {String} newValue - * @param {String} oldValue - * @param {String} valueName - * @param {Boolean} valueInQuotes + * @param {String} newDistance + * @param {String} oldDistance + * @param {String} newAmount + * @param {String} oldAmount * @returns {String} */