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

fix: Use localized message for split requests in LHN #29263

Merged
merged 7 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
SettleExpensifyCardParams,
RequestAmountParams,
SplitAmountParams,
DidSplitAmountParams,
paultsimura marked this conversation as resolved.
Show resolved Hide resolved
AmountEachParams,
PayerOwesAmountParams,
PayerOwesParams,
Expand Down Expand Up @@ -535,6 +536,7 @@ export default {
requestAmount: ({amount}: RequestAmountParams) => `request ${amount}`,
requestedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `requested ${formattedAmount}${comment ? ` for ${comment}` : ''}`,
splitAmount: ({amount}: SplitAmountParams) => `split ${amount}`,
didSplitAmount: ({amount, comment}: DidSplitAmountParams) => `split ${amount}${comment ? ` for ${comment}` : ''}`,
paultsimura marked this conversation as resolved.
Show resolved Hide resolved
amountEach: ({amount}: AmountEachParams) => `${amount} each`,
payerOwesAmount: ({payer, amount}: PayerOwesAmountParams) => `${payer} owes ${amount}`,
payerOwes: ({payer}: PayerOwesParams) => `${payer} owes: `,
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
SettleExpensifyCardParams,
RequestAmountParams,
SplitAmountParams,
DidSplitAmountParams,
paultsimura marked this conversation as resolved.
Show resolved Hide resolved
AmountEachParams,
PayerOwesAmountParams,
PayerOwesParams,
Expand Down Expand Up @@ -527,6 +528,7 @@ export default {
requestAmount: ({amount}: RequestAmountParams) => `solicitar ${amount}`,
requestedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `solicité ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
splitAmount: ({amount}: SplitAmountParams) => `dividir ${amount}`,
didSplitAmount: ({amount, comment}: DidSplitAmountParams) => `dividió ${amount}${comment ? ` para ${comment}` : ''}`,
paultsimura marked this conversation as resolved.
Show resolved Hide resolved
amountEach: ({amount}: AmountEachParams) => `${amount} cada uno`,
payerOwesAmount: ({payer, amount}: PayerOwesAmountParams) => `${payer} debe ${amount}`,
payerOwes: ({payer}: PayerOwesParams) => `${payer} debe: `,
Expand Down
3 changes: 3 additions & 0 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ type RequestedAmountMessageParams = {formattedAmount: string; comment: string};

type SplitAmountParams = {amount: number};

type DidSplitAmountParams = {amount: number; comment: string};
paultsimura marked this conversation as resolved.
Show resolved Hide resolved

type AmountEachParams = {amount: number};

type PayerOwesAmountParams = {payer: string; amount: number};
Expand Down Expand Up @@ -269,6 +271,7 @@ export type {
RequestAmountParams,
RequestedAmountMessageParams,
SplitAmountParams,
DidSplitAmountParams,
paultsimura marked this conversation as resolved.
Show resolved Hide resolved
AmountEachParams,
PayerOwesAmountParams,
PayerOwesParams,
Expand Down
8 changes: 8 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,14 @@ function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceip
return reportActionMessage;
}

if (!isIOUReport(report) && ReportActionsUtils.isSplitBillAction(reportAction)) {
// This covers group chats where the last action is a split bill action
const linkedTransaction = TransactionUtils.getLinkedTransaction(reportAction);
paultsimura marked this conversation as resolved.
Show resolved Hide resolved
const {amount, currency, comment} = getTransactionDetails(linkedTransaction);
const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency);
return Localize.translateLocal('iou.didSplitAmount', {amount: formattedAmount, comment});
paultsimura marked this conversation as resolved.
Show resolved Hide resolved
}

const totalAmount = getMoneyRequestTotal(report);
const payerName = isExpenseReport(report) ? getPolicyName(report) : getDisplayNameForParticipant(report.managerID, true);
const formattedAmount = CurrencyUtils.convertToDisplayString(totalAmount, report.currency);
Expand Down
Loading