@@ -1093,6 +1093,76 @@ describe('actions/IOU/BulkEdit', () => {
10931093 canEditFieldSpy . mockRestore ( ) ;
10941094 } ) ;
10951095
1096+ it ( 'applies category to split children but skips amount, currency, and tax' , ( ) => {
1097+ const transactionID = 'transaction-split-1' ;
1098+ const transactionThreadReportID = 'thread-split-1' ;
1099+ const iouReportID = 'iou-split-1' ;
1100+ const policy = createRandomPolicy ( 50 , CONST . POLICY . TYPE . TEAM ) ;
1101+
1102+ const transactionThread : Report = {
1103+ ...createRandomReport ( 50 , undefined ) ,
1104+ reportID : transactionThreadReportID ,
1105+ parentReportID : iouReportID ,
1106+ policyID : policy . id ,
1107+ } ;
1108+ const iouReport : Report = {
1109+ ...createRandomReport ( 51 , undefined ) ,
1110+ reportID : iouReportID ,
1111+ policyID : policy . id ,
1112+ type : CONST . REPORT . TYPE . EXPENSE ,
1113+ } ;
1114+
1115+ const reports = {
1116+ [ `${ ONYXKEYS . COLLECTION . REPORT } ${ transactionThreadReportID } ` ] : transactionThread ,
1117+ [ `${ ONYXKEYS . COLLECTION . REPORT } ${ iouReportID } ` ] : iouReport ,
1118+ } ;
1119+
1120+ const splitTransaction : Transaction = {
1121+ ...createRandomTransaction ( 50 ) ,
1122+ transactionID,
1123+ reportID : iouReportID ,
1124+ transactionThreadReportID,
1125+ amount : - 1000 ,
1126+ currency : CONST . CURRENCY . USD ,
1127+ category : 'OldCategory' ,
1128+ comment : { source : CONST . IOU . TYPE . SPLIT } ,
1129+ } ;
1130+ const transactions = {
1131+ [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ] : splitTransaction ,
1132+ } ;
1133+
1134+ const canEditFieldSpy = jest . spyOn ( require ( '@libs/ReportUtils' ) , 'canEditFieldOfMoneyRequest' ) . mockReturnValue ( true ) ;
1135+ // eslint-disable-next-line rulesdir/no-multiple-api-calls
1136+ const writeSpy = jest . spyOn ( API , 'write' ) . mockImplementation ( jest . fn ( ) ) ;
1137+
1138+ updateMultipleMoneyRequests ( {
1139+ transactionIDs : [ transactionID ] ,
1140+ changes : { category : 'Food' , amount : 5000 , currency : CONST . CURRENCY . EUR , taxCode : 'id_TAX_RATE_1' } ,
1141+ policy,
1142+ reports,
1143+ transactions,
1144+ reportActions : { } ,
1145+ policyCategories : undefined ,
1146+ policyTags : { } ,
1147+ hash : undefined ,
1148+ introSelected : undefined ,
1149+ betas : undefined ,
1150+ } ) ;
1151+
1152+ expect ( writeSpy ) . toHaveBeenCalled ( ) ;
1153+ const params = writeSpy . mock . calls . at ( 0 ) ?. [ 1 ] as { updates : string } ;
1154+ const updates = JSON . parse ( params . updates ) as Record < string , unknown > ;
1155+ expect ( updates . category ) . toBe ( 'Food' ) ;
1156+ expect ( updates . amount ) . toBeUndefined ( ) ;
1157+ expect ( updates . currency ) . toBeUndefined ( ) ;
1158+ expect ( updates . taxCode ) . toBeUndefined ( ) ;
1159+ expect ( updates . taxValue ) . toBeUndefined ( ) ;
1160+ expect ( updates . taxAmount ) . toBeUndefined ( ) ;
1161+
1162+ writeSpy . mockRestore ( ) ;
1163+ canEditFieldSpy . mockRestore ( ) ;
1164+ } ) ;
1165+
10961166 it ( 'uses per-transaction policy for category tax mapping in cross-policy bulk edit' , ( ) => {
10971167 // Given: two different policies – transactionPolicy has expense rules mapping "Advertising" → "id_TAX_RATE_1",
10981168 // while the shared bulk-edit policy has no expense rules at all.
0 commit comments