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

Refactor IOU.requestMoney function #52231

Merged
merged 12 commits into from
Nov 22, 2024
Prev Previous commit
rename transactionData
mkzie2 committed Nov 22, 2024

Verified

This commit was signed with the committer’s verified signature.
commit e08c53a2ea6a9a2aa3eba94c0f03453c80471f80
8 changes: 4 additions & 4 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ type GPSPoint = {
long: number;
};

type RequestMoneyTransactionData = {
type RequestMoneyTransactionParams = {
attendees: Attendee[] | undefined;
amount: number;
currency: string;
@@ -202,7 +202,7 @@ type RequestMoneyInformation = {
gpsPoints?: GPSPoint;
action?: IOUAction;
reimbursible?: boolean;
transactionData: RequestMoneyTransactionData;
transactionParams: RequestMoneyTransactionParams;
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
@@ -3565,7 +3565,7 @@ function shareTrackedExpense(
* Submit expense to another user
*/
function requestMoney(requestMoneyInformation: RequestMoneyInformation) {
const {report, participantParams, policyParams = {}, transactionData, gpsPoints, action, reimbursible} = requestMoneyInformation;
const {report, participantParams, policyParams = {}, transactionParams, gpsPoints, action, reimbursible} = requestMoneyInformation;
const {participant, payeeAccountID, payeeEmail} = participantParams;
const {policy, policyCategories, policyTagList} = policyParams;
const {
@@ -3584,7 +3584,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation) {
actionableWhisperReportActionID,
linkedTrackedExpenseReportAction,
linkedTrackedExpenseReportID,
} = transactionData;
} = transactionParams;

// If the report is iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function
const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
@@ -217,7 +217,7 @@ function IOURequestStepAmount({
payeeEmail: currentUserPersonalDetails.login,
payeeAccountID: currentUserPersonalDetails.accountID,
},
transactionData: {
transactionParams: {
amount: backendAmount,
currency,
created: transaction?.created ?? '',
Original file line number Diff line number Diff line change
@@ -252,7 +252,7 @@ function IOURequestStepConfirmation({
},
gpsPoints,
action,
transactionData: {
transactionParams: {
amount: transaction.amount,
attendees: transaction.attendees,
currency: transaction.currency,
Original file line number Diff line number Diff line change
@@ -262,7 +262,7 @@ function IOURequestStepScan({
payeeAccountID: currentUserPersonalDetails.accountID,
participant,
},
transactionData: {
transactionParams: {
amount: 0,
attendees: transaction?.attendees,
currency: transaction?.currency ?? 'USD',
@@ -369,7 +369,7 @@ function IOURequestStepScan({
lat: successData.coords.latitude,
long: successData.coords.longitude,
},
transactionData: {
transactionParams: {
amount: 0,
attendees: transaction?.attendees,
currency: transaction?.currency ?? 'USD',
4 changes: 2 additions & 2 deletions src/pages/iou/request/step/IOURequestStepScan/index.tsx
Original file line number Diff line number Diff line change
@@ -291,7 +291,7 @@ function IOURequestStepScan({
payeeAccountID: currentUserPersonalDetails.accountID,
participant,
},
transactionData: {
transactionParams: {
amount: 0,
attendees: transaction?.attendees,
currency: transaction?.currency ?? 'USD',
@@ -399,7 +399,7 @@ function IOURequestStepScan({
lat: successData.coords.latitude,
long: successData.coords.longitude,
},
transactionData: {
transactionParams: {
amount: 0,
attendees: transaction?.attendees,
currency: transaction?.currency ?? 'USD',
24 changes: 12 additions & 12 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -301,7 +301,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -520,7 +520,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -675,7 +675,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -1491,7 +1491,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -1727,7 +1727,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -1855,7 +1855,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -1956,7 +1956,7 @@ describe('actions/IOU', () => {
payeeAccountID: TEST_USER_ACCOUNT_ID,
participant: {login: RORY_EMAIL, accountID: RORY_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -2705,7 +2705,7 @@ describe('actions/IOU', () => {
payeeAccountID: TEST_USER_ACCOUNT_ID,
participant: {login: RORY_EMAIL, accountID: RORY_ACCOUNT_ID},
},
transactionData: {
transactionParams: {
amount: amount2,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -2923,7 +2923,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID, isPolicyExpenseChat: true, reportID: chatReport.reportID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -3030,7 +3030,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID, isPolicyExpenseChat: true, reportID: chatReport.reportID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,
@@ -3138,7 +3138,7 @@ describe('actions/IOU', () => {
payeeAccountID: RORY_ACCOUNT_ID,
participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID, isPolicyExpenseChat: true, reportID: chatReport.reportID},
},
transactionData: {
transactionParams: {
amount,
attendees: [],
currency: CONST.CURRENCY.USD,