@@ -3786,6 +3786,8 @@ function createSplitsAndOnyxData(
3786
3786
existingSplitChatReportID = '' ,
3787
3787
billable = false ,
3788
3788
iouRequestType : IOURequestType = CONST . IOU . REQUEST_TYPE . MANUAL ,
3789
+ taxCode = '' ,
3790
+ taxAmount = 0 ,
3789
3791
) : SplitsAndOnyxData {
3790
3792
const currentUserEmailForIOUSplit = PhoneNumber . addSMSDomainIfPhoneNumber ( currentUserLogin ) ;
3791
3793
const participantAccountIDs = participants . map ( ( participant ) => Number ( participant . accountID ) ) ;
@@ -3807,8 +3809,8 @@ function createSplitsAndOnyxData(
3807
3809
undefined ,
3808
3810
category ,
3809
3811
tag ,
3810
- undefined ,
3811
- undefined ,
3812
+ taxCode ,
3813
+ taxAmount ,
3812
3814
billable ,
3813
3815
) ;
3814
3816
@@ -3963,14 +3965,16 @@ function createSplitsAndOnyxData(
3963
3965
3964
3966
// Loop through participants creating individual chats, iouReports and reportActionIDs as needed
3965
3967
const currentUserAmount = splitShares ?. [ currentUserAccountID ] ?. amount ?? IOUUtils . calculateAmount ( participants . length , amount , currency , true ) ;
3968
+ const currentUserTaxAmount = IOUUtils . calculateAmount ( participants . length , taxAmount , currency , true ) ;
3966
3969
3967
- const splits : Split [ ] = [ { email : currentUserEmailForIOUSplit , accountID : currentUserAccountID , amount : currentUserAmount } ] ;
3970
+ const splits : Split [ ] = [ { email : currentUserEmailForIOUSplit , accountID : currentUserAccountID , amount : currentUserAmount , taxAmount : currentUserTaxAmount } ] ;
3968
3971
3969
3972
const hasMultipleParticipants = participants . length > 1 ;
3970
3973
participants . forEach ( ( participant ) => {
3971
3974
// In a case when a participant is a workspace, even when a current user is not an owner of the workspace
3972
3975
const isPolicyExpenseChat = ReportUtils . isPolicyExpenseChat ( participant ) ;
3973
3976
const splitAmount = splitShares ?. [ participant . accountID ?? - 1 ] ?. amount ?? IOUUtils . calculateAmount ( participants . length , amount , currency , false ) ;
3977
+ const splitTaxAmount = IOUUtils . calculateAmount ( participants . length , taxAmount , currency , false ) ;
3974
3978
3975
3979
// To exclude someone from a split, the amount can be 0. The scenario for this is when creating a split from a group chat, we have remove the option to deselect users to exclude them.
3976
3980
// We can input '0' next to someone we want to exclude.
@@ -4040,8 +4044,8 @@ function createSplitsAndOnyxData(
4040
4044
undefined ,
4041
4045
category ,
4042
4046
tag ,
4043
- undefined ,
4044
- undefined ,
4047
+ taxCode ,
4048
+ ReportUtils . isExpenseReport ( oneOnOneIOUReport ) ? - splitTaxAmount : splitTaxAmount ,
4045
4049
billable ,
4046
4050
) ;
4047
4051
@@ -4132,6 +4136,7 @@ function createSplitsAndOnyxData(
4132
4136
reportPreviewReportActionID : oneOnOneReportPreviewAction . reportActionID ,
4133
4137
transactionThreadReportID : optimisticTransactionThread . reportID ,
4134
4138
createdReportActionIDForThread : optimisticCreatedActionForTransactionThread . reportActionID ,
4139
+ taxAmount : splitTaxAmount ,
4135
4140
} ;
4136
4141
4137
4142
splits . push ( individualSplit ) ;
@@ -4185,6 +4190,8 @@ type SplitBillActionsParams = {
4185
4190
existingSplitChatReportID ?: string ;
4186
4191
splitShares ?: SplitShares ;
4187
4192
splitPayerAccountIDs ?: number [ ] ;
4193
+ taxCode ?: string ;
4194
+ taxAmount ?: number ;
4188
4195
} ;
4189
4196
4190
4197
/**
@@ -4207,6 +4214,8 @@ function splitBill({
4207
4214
existingSplitChatReportID = '' ,
4208
4215
splitShares = { } ,
4209
4216
splitPayerAccountIDs = [ ] ,
4217
+ taxCode = '' ,
4218
+ taxAmount = 0 ,
4210
4219
} : SplitBillActionsParams ) {
4211
4220
const currentCreated = DateUtils . enrichMoneyRequestTimestamp ( created ) ;
4212
4221
const { splitData, splits, onyxData} = createSplitsAndOnyxData (
@@ -4224,6 +4233,8 @@ function splitBill({
4224
4233
existingSplitChatReportID ,
4225
4234
billable ,
4226
4235
iouRequestType ,
4236
+ taxCode ,
4237
+ taxAmount ,
4227
4238
) ;
4228
4239
4229
4240
const parameters : SplitBillParams = {
@@ -4243,6 +4254,8 @@ function splitBill({
4243
4254
policyID : splitData . policyID ,
4244
4255
chatType : splitData . chatType ,
4245
4256
splitPayerAccountIDs,
4257
+ taxCode,
4258
+ taxAmount,
4246
4259
} ;
4247
4260
4248
4261
API . write ( WRITE_COMMANDS . SPLIT_BILL , parameters , onyxData ) ;
@@ -4269,6 +4282,8 @@ function splitBillAndOpenReport({
4269
4282
iouRequestType = CONST . IOU . REQUEST_TYPE . MANUAL ,
4270
4283
splitShares = { } ,
4271
4284
splitPayerAccountIDs = [ ] ,
4285
+ taxCode = '' ,
4286
+ taxAmount = 0 ,
4272
4287
} : SplitBillActionsParams ) {
4273
4288
const currentCreated = DateUtils . enrichMoneyRequestTimestamp ( created ) ;
4274
4289
const { splitData, splits, onyxData} = createSplitsAndOnyxData (
@@ -4286,6 +4301,8 @@ function splitBillAndOpenReport({
4286
4301
'' ,
4287
4302
billable ,
4288
4303
iouRequestType ,
4304
+ taxCode ,
4305
+ taxAmount ,
4289
4306
) ;
4290
4307
4291
4308
const parameters : SplitBillParams = {
@@ -4305,6 +4322,8 @@ function splitBillAndOpenReport({
4305
4322
policyID : splitData . policyID ,
4306
4323
chatType : splitData . chatType ,
4307
4324
splitPayerAccountIDs,
4325
+ taxCode,
4326
+ taxAmount,
4308
4327
} ;
4309
4328
4310
4329
API . write ( WRITE_COMMANDS . SPLIT_BILL_AND_OPEN_REPORT , parameters , onyxData ) ;
@@ -4324,6 +4343,8 @@ type StartSplitBilActionParams = {
4324
4343
category : string | undefined ;
4325
4344
tag : string | undefined ;
4326
4345
currency : string ;
4346
+ taxCode : string ;
4347
+ taxAmount : number ;
4327
4348
} ;
4328
4349
4329
4350
/** Used exclusively for starting a split expense request that contains a receipt, the split request will be completed once the receipt is scanned
@@ -4342,6 +4363,8 @@ function startSplitBill({
4342
4363
category = '' ,
4343
4364
tag = '' ,
4344
4365
currency,
4366
+ taxCode = '' ,
4367
+ taxAmount = 0 ,
4345
4368
} : StartSplitBilActionParams ) {
4346
4369
const currentUserEmailForIOUSplit = PhoneNumber . addSMSDomainIfPhoneNumber ( currentUserLogin ) ;
4347
4370
const participantAccountIDs = participants . map ( ( participant ) => Number ( participant . accountID ) ) ;
@@ -4366,8 +4389,8 @@ function startSplitBill({
4366
4389
undefined ,
4367
4390
category ,
4368
4391
tag ,
4369
- undefined ,
4370
- undefined ,
4392
+ taxCode ,
4393
+ taxAmount ,
4371
4394
billable ,
4372
4395
) ;
4373
4396
@@ -4609,6 +4632,8 @@ function startSplitBill({
4609
4632
billable,
4610
4633
...( existingSplitChatReport ? { } : { createdReportActionID : splitChatCreatedReportAction . reportActionID } ) ,
4611
4634
chatType : splitChatReport ?. chatType ,
4635
+ taxCode,
4636
+ taxAmount,
4612
4637
} ;
4613
4638
4614
4639
API . write ( WRITE_COMMANDS . START_SPLIT_BILL , parameters , { optimisticData, successData, failureData} ) ;
@@ -4693,9 +4718,11 @@ function completeSplitBill(chatReportID: string, reportAction: OnyxTypes.ReportA
4693
4718
const splitParticipants : Split [ ] = updatedTransaction ?. comment . splits ?? [ ] ;
4694
4719
const amount = updatedTransaction ?. modifiedAmount ;
4695
4720
const currency = updatedTransaction ?. modifiedCurrency ;
4721
+ console . debug ( updatedTransaction ) ;
4696
4722
4697
4723
// Exclude the current user when calculating the split amount, `calculateAmount` takes it into account
4698
4724
const splitAmount = IOUUtils . calculateAmount ( splitParticipants . length - 1 , amount ?? 0 , currency ?? '' , false ) ;
4725
+ const splitTaxAmount = IOUUtils . calculateAmount ( splitParticipants . length - 1 , updatedTransaction ?. taxAmount ?? 0 , currency ?? '' , false ) ;
4699
4726
4700
4727
const splits : Split [ ] = [ { email : currentUserEmailForIOUSplit } ] ;
4701
4728
splitParticipants . forEach ( ( participant ) => {
@@ -4759,8 +4786,8 @@ function completeSplitBill(chatReportID: string, reportAction: OnyxTypes.ReportA
4759
4786
undefined ,
4760
4787
updatedTransaction ?. category ,
4761
4788
updatedTransaction ?. tag ,
4762
- undefined ,
4763
- undefined ,
4789
+ updatedTransaction ?. taxCode ,
4790
+ isPolicyExpenseChat ? - splitTaxAmount : splitAmount ,
4764
4791
updatedTransaction ?. billable ,
4765
4792
) ;
4766
4793
@@ -4834,6 +4861,8 @@ function completeSplitBill(chatReportID: string, reportAction: OnyxTypes.ReportA
4834
4861
comment : transactionComment ,
4835
4862
category : transactionCategory ,
4836
4863
tag : transactionTag ,
4864
+ taxCode : transactionTaxCode ,
4865
+ taxAmount : transactionTaxAmount ,
4837
4866
} = ReportUtils . getTransactionDetails ( updatedTransaction ) ?? { } ;
4838
4867
4839
4868
const parameters : CompleteSplitBillParams = {
@@ -4846,6 +4875,8 @@ function completeSplitBill(chatReportID: string, reportAction: OnyxTypes.ReportA
4846
4875
category : transactionCategory ,
4847
4876
tag : transactionTag ,
4848
4877
splits : JSON . stringify ( splits ) ,
4878
+ taxCode : transactionTaxCode ,
4879
+ taxAmount : transactionTaxAmount ,
4849
4880
} ;
4850
4881
4851
4882
API . write ( WRITE_COMMANDS . COMPLETE_SPLIT_BILL , parameters , { optimisticData, successData, failureData} ) ;
@@ -6607,8 +6638,8 @@ function setMoneyRequestTaxRate(transactionID: string, taxCode: string) {
6607
6638
Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION_DRAFT } ${ transactionID } ` , { taxCode} ) ;
6608
6639
}
6609
6640
6610
- function setMoneyRequestTaxAmount ( transactionID : string , taxAmount : number , isDraft : boolean ) {
6611
- Onyx . merge ( `${ isDraft ? ONYXKEYS . COLLECTION . TRANSACTION_DRAFT : ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` , { taxAmount} ) ;
6641
+ function setMoneyRequestTaxAmount ( transactionID : string , taxAmount : number | null ) {
6642
+ Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION_DRAFT } ${ transactionID } ` , { taxAmount} ) ;
6612
6643
}
6613
6644
6614
6645
function setShownHoldUseExplanation ( ) {
0 commit comments