Skip to content

Commit c2e3773

Browse files
committed
refactor: extract MoneyRequestBuilder.ts from IOU/index.ts
Extracts the money-request data-builder cluster (13 functions plus 9 supporting types) from IOU/index.ts into a new dedicated MoneyRequestBuilder.ts module. Functions moved: - buildMinimalTransactionForFormula - getReportPreviewAction - getReceiptError - buildOnyxDataForTestDriveIOU - getTransactionWithPreservedLocalReceiptSource - buildOnyxDataForMoneyRequest (~687 lines) - recalculateOptimisticReportName - maybeUpdateReportNameForFormulaTitle - getMoneyRequestInformation (~422 lines) - calculateDiffAmount - getUpdatedMoneyRequestReportData - mergePolicyRecentlyUsedCategories - mergePolicyRecentlyUsedCurrencies Function bodies are byte-identical to their pre-move state on main, with the documented translations of direct module-private state reads (allReports, allPersonalDetails, allReportActions, allReportNameValuePairs, deprecatedCurrentUserPersonalDetails, deprecatedUserAccountID) to the corresponding getters on index.ts (the established pattern from PRs B-D). Namespace imports (Localize.translateLocal, NumberUtils.rand64) are converted to named imports (translateLocal, rand64) per lint rules for new files. A new getCurrentUserPersonalDetails getter is added to index.ts to expose deprecatedCurrentUserPersonalDetails for the moved functions. Consumers re-pointed to import from ./MoneyRequestBuilder: - Split.ts, SplitTransactionUpdate.ts, TrackExpense.ts, PerDiem.ts, SendInvoice.ts, Duplicate.ts, BulkEdit.ts, Receipt.ts, PayMoneyRequest.ts, DeleteMoneyRequest.ts, UpdateMoneyRequest.ts - src/pages/inbox/report/ReportActionsView.tsx - tests/actions/IOU/GetMoneyRequestInformationTest.ts - tests/actions/IOUTest.ts, IOUTest/SplitTest.ts, IOUTest/DeleteMoneyRequestTest.ts, IOUTest/DuplicateTest.ts - tests/actions/MergeTransactionTest.ts Final size: index.ts drops from 2,805 to ~1,160 lines. Part of Issue #72804 (break up src/libs/actions/IOU/).
1 parent cab0b7b commit c2e3773

22 files changed

Lines changed: 1687 additions & 1707 deletions

src/libs/ReceiptUploadRetryHandler/handleFileRetry.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import type * as IOU from '@userActions/IOU';
2+
import type {RequestMoneyInformation} from '@userActions/IOU/MoneyRequestBuilder';
23
import {replaceReceipt} from '@userActions/IOU/Receipt';
34
import {startSplitBill} from '@userActions/IOU/Split';
45
import * as TrackExpense from '@userActions/IOU/TrackExpense';
56
import CONST from '@src/CONST';
67
import type {ReceiptError} from '@src/types/onyx/Transaction';
78

89
export default function handleFileRetry(message: ReceiptError, file: File, dismissError: () => void, setShouldShowErrorModal: (value: boolean) => void) {
9-
const retryParams: IOU.ReplaceReceipt | IOU.StartSplitBilActionParams | TrackExpense.CreateTrackExpenseParams | IOU.RequestMoneyInformation =
10+
const retryParams: IOU.ReplaceReceipt | IOU.StartSplitBilActionParams | TrackExpense.CreateTrackExpenseParams | RequestMoneyInformation =
1011
typeof message.retryParams === 'string'
11-
? (JSON.parse(message.retryParams) as IOU.ReplaceReceipt | IOU.StartSplitBilActionParams | TrackExpense.CreateTrackExpenseParams | IOU.RequestMoneyInformation)
12+
? (JSON.parse(message.retryParams) as IOU.ReplaceReceipt | IOU.StartSplitBilActionParams | TrackExpense.CreateTrackExpenseParams | RequestMoneyInformation)
1213
: message.retryParams;
1314

1415
switch (message.action) {
@@ -38,7 +39,7 @@ export default function handleFileRetry(message: ReceiptError, file: File, dismi
3839
}
3940
case CONST.IOU.ACTION_PARAMS.MONEY_REQUEST: {
4041
dismissError();
41-
const requestMoneyParams = {...retryParams} as IOU.RequestMoneyInformation;
42+
const requestMoneyParams = {...retryParams} as RequestMoneyInformation;
4243
requestMoneyParams.transactionParams.receipt = file;
4344
requestMoneyParams.isRetry = true;
4445
requestMoneyParams.shouldPlaySound = false;

src/libs/actions/IOU/BulkEdit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import ONYXKEYS from '@src/ONYXKEYS';
3030
import type * as OnyxTypes from '@src/types/onyx';
3131
import type {SearchResultDataType} from '@src/types/onyx/SearchResults';
3232
import type {TransactionChanges} from '@src/types/onyx/Transaction';
33-
import {getAllTransactionViolations, getUpdatedMoneyRequestReportData} from '.';
33+
import {getAllTransactionViolations} from '.';
34+
import {getUpdatedMoneyRequestReportData} from './MoneyRequestBuilder';
3435

3536
function removeUnchangedBulkEditFields(
3637
transactionChanges: TransactionChanges,

src/libs/actions/IOU/DeleteMoneyRequest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import type {Route} from '@src/ROUTES';
3434
import ROUTES from '@src/ROUTES';
3535
import type * as OnyxTypes from '@src/types/onyx';
3636
import type ReportAction from '@src/types/onyx/ReportAction';
37-
import {getAllReportActionsFromIOU, getAllReportNameValuePairs, getAllReports, getAllTransactions, getAllTransactionViolations, getReportPreviewAction} from '.';
37+
import {getAllReportActionsFromIOU, getAllReportNameValuePairs, getAllReports, getAllTransactions, getAllTransactionViolations} from '.';
38+
import {getReportPreviewAction} from './MoneyRequestBuilder';
3839

3940
type DeleteMoneyRequestFunctionParams = {
4041
transactionID: string | undefined;

src/libs/actions/IOU/Duplicate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ import type * as OnyxTypes from '@src/types/onyx';
4545
import type {Attendee, Participant} from '@src/types/onyx/IOU';
4646
import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails';
4747
import type {WaypointCollection} from '@src/types/onyx/Transaction';
48-
import type {RequestMoneyInformation} from '.';
4948
import {getAllReportActionsFromIOU, getAllReports, getAllTransactions, getAllTransactionViolations, getMoneyRequestParticipantsFromReport} from '.';
5049
import {getCleanUpTransactionThreadReportOnyxData} from './DeleteMoneyRequest';
50+
import type {RequestMoneyInformation} from './MoneyRequestBuilder';
5151
import type {PerDiemExpenseInformation} from './PerDiem';
5252
import {submitPerDiemExpense} from './PerDiem';
5353
import type {CreateDistanceRequestInformation} from './Split';

0 commit comments

Comments
 (0)