@@ -112,7 +112,41 @@ type TrackExpenseInformation = {
112
112
actionableWhisperReportActionIDParam ?: string ;
113
113
onyxData : OnyxData ;
114
114
} ;
115
-
115
+ type CategorizeTrackedExpenseTransactionParams = {
116
+ transactionID : string ;
117
+ amount : number ;
118
+ currency : string ;
119
+ comment : string ;
120
+ merchant : string ;
121
+ created : string ;
122
+ taxCode : string ;
123
+ taxAmount : number ;
124
+ category ?: string ;
125
+ tag ?: string ;
126
+ billable ?: boolean ;
127
+ receipt ?: Receipt ;
128
+ } ;
129
+ type CategorizeTrackedExpensePolicyParams = {
130
+ policyID : string ;
131
+ isDraftPolicy : boolean ;
132
+ } ;
133
+ type CategorizeTrackedExpenseReportInformation = {
134
+ moneyRequestPreviewReportActionID : string ;
135
+ moneyRequestReportID : string ;
136
+ moneyRequestCreatedReportActionID : string ;
137
+ actionableWhisperReportActionID : string ;
138
+ linkedTrackedExpenseReportAction : OnyxTypes . ReportAction ;
139
+ linkedTrackedExpenseReportID : string ;
140
+ transactionThreadReportID : string ;
141
+ reportPreviewReportActionID : string ;
142
+ } ;
143
+ type CategorizeTrackedExpenseParams = {
144
+ onyxData : OnyxData | undefined ;
145
+ reportInformation : CategorizeTrackedExpenseReportInformation ;
146
+ transactionParams : CategorizeTrackedExpenseTransactionParams ;
147
+ policyParams : CategorizeTrackedExpensePolicyParams ;
148
+ createdWorkspaceParams ?: CreateWorkspaceParams ;
149
+ } ;
116
150
type SendInvoiceInformation = {
117
151
senderWorkspaceID : string ;
118
152
receiver : Partial < OnyxTypes . PersonalDetails > ;
@@ -3528,34 +3562,12 @@ function convertTrackedExpenseToRequest(
3528
3562
API . write ( WRITE_COMMANDS . CONVERT_TRACKED_EXPENSE_TO_REQUEST , parameters , { optimisticData, successData, failureData} ) ;
3529
3563
}
3530
3564
3531
- function categorizeTrackedExpense (
3532
- policyID : string ,
3533
- transactionID : string ,
3534
- moneyRequestPreviewReportActionID : string ,
3535
- moneyRequestReportID : string ,
3536
- moneyRequestCreatedReportActionID : string ,
3537
- actionableWhisperReportActionID : string ,
3538
- linkedTrackedExpenseReportAction : OnyxTypes . ReportAction ,
3539
- linkedTrackedExpenseReportID : string ,
3540
- transactionThreadReportID : string ,
3541
- reportPreviewReportActionID : string ,
3542
- onyxData : OnyxData | undefined ,
3543
- amount : number ,
3544
- currency : string ,
3545
- comment : string ,
3546
- merchant : string ,
3547
- created : string ,
3548
- isDraftPolicy : boolean ,
3549
- category ?: string ,
3550
- tag ?: string ,
3551
- taxCode = '' ,
3552
- taxAmount = 0 ,
3553
- billable ?: boolean ,
3554
- receipt ?: Receipt ,
3555
- createdWorkspaceParams ?: CreateWorkspaceParams ,
3556
- ) {
3565
+ function categorizeTrackedExpense ( trackedExpenseParams : CategorizeTrackedExpenseParams ) {
3566
+ const { onyxData, reportInformation, transactionParams, policyParams, createdWorkspaceParams} = trackedExpenseParams ;
3557
3567
const { optimisticData, successData, failureData} = onyxData ?? { } ;
3558
-
3568
+ const { transactionID} = transactionParams ;
3569
+ const { isDraftPolicy} = policyParams ;
3570
+ const { actionableWhisperReportActionID, moneyRequestReportID, linkedTrackedExpenseReportAction, linkedTrackedExpenseReportID, transactionThreadReportID} = reportInformation ;
3559
3571
const {
3560
3572
optimisticData : moveTransactionOptimisticData ,
3561
3573
successData : moveTransactionSuccessData ,
@@ -3574,27 +3586,12 @@ function categorizeTrackedExpense(
3574
3586
optimisticData ?. push ( ...moveTransactionOptimisticData ) ;
3575
3587
successData ?. push ( ...moveTransactionSuccessData ) ;
3576
3588
failureData ?. push ( ...moveTransactionFailureData ) ;
3577
-
3578
3589
const parameters = {
3579
- policyID,
3580
- transactionID,
3581
- moneyRequestPreviewReportActionID,
3582
- moneyRequestReportID,
3583
- moneyRequestCreatedReportActionID,
3584
- actionableWhisperReportActionID,
3590
+ onyxData,
3591
+ ...reportInformation ,
3592
+ ...policyParams ,
3593
+ ...transactionParams ,
3585
3594
modifiedExpenseReportActionID,
3586
- reportPreviewReportActionID,
3587
- amount,
3588
- currency,
3589
- comment,
3590
- merchant,
3591
- category,
3592
- tag,
3593
- taxCode,
3594
- taxAmount,
3595
- billable,
3596
- created,
3597
- receipt,
3598
3595
policyExpenseChatReportID : createdWorkspaceParams ?. expenseChatReportID ,
3599
3596
policyExpenseCreatedReportActionID : createdWorkspaceParams ?. expenseCreatedReportActionID ,
3600
3597
adminsChatReportID : createdWorkspaceParams ?. adminsChatReportID ,
@@ -3967,32 +3964,43 @@ function trackExpense(
3967
3964
if ( ! linkedTrackedExpenseReportAction || ! actionableWhisperReportActionID || ! linkedTrackedExpenseReportID ) {
3968
3965
return ;
3969
3966
}
3970
- categorizeTrackedExpense (
3971
- chatReport ?. policyID ?? '-1' ,
3972
- transaction ?. transactionID ?? '-1' ,
3973
- iouAction ?. reportActionID ?? '-1' ,
3974
- iouReport ?. reportID ?? '-1' ,
3975
- createdIOUReportActionID ?? '-1' ,
3976
- actionableWhisperReportActionID ,
3977
- linkedTrackedExpenseReportAction ,
3978
- linkedTrackedExpenseReportID ,
3979
- transactionThreadReportID ?? '-1' ,
3980
- reportPreviewAction ?. reportActionID ?? '-1' ,
3981
- onyxData ,
3967
+ const transactionParams = {
3968
+ transactionID : transaction ?. transactionID ?? '-1' ,
3982
3969
amount,
3983
3970
currency,
3984
3971
comment,
3985
3972
merchant,
3986
3973
created,
3987
- isDraftPolicy ,
3988
- category ,
3989
- tag ,
3990
3974
taxCode,
3991
3975
taxAmount,
3976
+ category,
3977
+ tag,
3992
3978
billable,
3993
- trackedReceipt ,
3979
+ receipt : trackedReceipt ,
3980
+ } ;
3981
+ const policyParams = {
3982
+ policyID : chatReport ?. policyID ?? '-1' ,
3983
+ isDraftPolicy,
3984
+ } ;
3985
+ const reportInformation = {
3986
+ moneyRequestPreviewReportActionID : iouAction ?. reportActionID ?? '-1' ,
3987
+ moneyRequestReportID : iouReport ?. reportID ?? '-1' ,
3988
+ moneyRequestCreatedReportActionID : createdIOUReportActionID ?? '-1' ,
3989
+ actionableWhisperReportActionID,
3990
+ linkedTrackedExpenseReportAction,
3991
+ linkedTrackedExpenseReportID,
3992
+ transactionThreadReportID : transactionThreadReportID ?? '-1' ,
3993
+ reportPreviewReportActionID : reportPreviewAction ?. reportActionID ?? '-1' ,
3994
+ } ;
3995
+ const trackedExpenseParams = {
3996
+ onyxData,
3997
+ reportInformation,
3998
+ transactionParams,
3999
+ policyParams,
3994
4000
createdWorkspaceParams,
3995
- ) ;
4001
+ } ;
4002
+
4003
+ categorizeTrackedExpense ( trackedExpenseParams ) ;
3996
4004
break ;
3997
4005
}
3998
4006
case CONST . IOU . ACTION . SHARE : {
0 commit comments