Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/libs/MergeTransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
isFetchingWaypointsFromServer,
isFromCreditCardImport,
isMerchantMissing,
isOdometerDistanceRequest,
isPerDiemRequest,
isScanning,
isTimeRequest,
Expand All @@ -54,7 +55,7 @@
};

/** Type for merge transaction values that can be null to clear existing values in Onyx */
type MergeTransactionUpdateValues = Partial<Record<keyof MergeTransaction, MergeTransaction[keyof MergeTransaction] | null>>;

Check failure on line 58 in src/libs/MergeTransactionUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'any' overrides all other types in this union type

const MERGE_FIELD_TRANSLATION_KEYS = {
amount: 'iou.amount',
Expand Down Expand Up @@ -374,6 +375,10 @@
customUnit: mergeTransaction.customUnit,
waypoints: mergeTransaction.waypoints,
attendees: mergeTransaction.attendees,
...(mergeTransaction.odometerStart !== undefined && {odometerStart: mergeTransaction.odometerStart}),
...(mergeTransaction.odometerEnd !== undefined && {odometerEnd: mergeTransaction.odometerEnd}),
...(mergeTransaction.odometerStartImage !== undefined && {odometerStartImage: mergeTransaction.odometerStartImage}),

Check failure on line 380 in src/libs/MergeTransactionUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
...(mergeTransaction.odometerEndImage !== undefined && {odometerEndImage: mergeTransaction.odometerEndImage}),

Check failure on line 381 in src/libs/MergeTransactionUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
},
reimbursable: mergeTransaction.reimbursable,
billable: mergeTransaction.billable,
Expand Down Expand Up @@ -631,6 +636,14 @@
updatedValues.taxName = getTaxName(policy, transaction) ?? transaction?.taxValue ?? '';
updatedValues.taxAmount = transaction?.taxAmount;
updatedValues.taxPolicyID = policy?.id;

// Copy odometer readings from the selected transaction for odometer distance requests
if (isOdometerDistanceRequest(transaction)) {
updatedValues.odometerStart = transaction?.comment?.odometerStart;
updatedValues.odometerEnd = transaction?.comment?.odometerEnd;
updatedValues.odometerStartImage = transaction?.comment?.odometerStartImage;
updatedValues.odometerEndImage = transaction?.comment?.odometerEndImage;
}
}

if (field === 'taxValue') {
Expand Down
8 changes: 8 additions & 0 deletions src/libs/actions/MergeTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
return !deepEqual(mergeValue, targetValue);
}),
);
filteredTransactionChanges.comment = filteredTransactionChanges.description;

Check failure on line 240 in src/libs/actions/MergeTransaction.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
const shouldBuildOptimisticModifiedExpenseReportAction = false;

if (isUnreportedExpense) {
Expand Down Expand Up @@ -286,6 +286,10 @@
comment: {
waypoints: mergeTransaction.waypoints ?? null,
customUnit: mergeTransaction.customUnit ?? null,
...(mergeTransaction.odometerStart !== undefined && {odometerStart: mergeTransaction.odometerStart}),
...(mergeTransaction.odometerEnd !== undefined && {odometerEnd: mergeTransaction.odometerEnd}),
...(mergeTransaction.odometerStartImage !== undefined && {odometerStartImage: mergeTransaction.odometerStartImage}),

Check failure on line 291 in src/libs/actions/MergeTransaction.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
...(mergeTransaction.odometerEndImage !== undefined && {odometerEndImage: mergeTransaction.odometerEndImage}),

Check failure on line 292 in src/libs/actions/MergeTransaction.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
},
routes: mergeTransaction.routes ?? null,
iouRequestType: mergeTransaction.iouRequestType ?? null,
Expand Down Expand Up @@ -353,6 +357,10 @@
waypoints: mergeTransaction.waypoints ?? null,
attendees: mergeTransaction.attendees,
originalTransactionID: mergeTransaction.originalTransactionID,
...(mergeTransaction.odometerStart !== undefined && {odometerStart: mergeTransaction.odometerStart}),
...(mergeTransaction.odometerEnd !== undefined && {odometerEnd: mergeTransaction.odometerEnd}),
...(mergeTransaction.odometerStartImage !== undefined && {odometerStartImage: mergeTransaction.odometerStartImage}),

Check failure on line 362 in src/libs/actions/MergeTransaction.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
...(mergeTransaction.odometerEndImage !== undefined && {odometerEndImage: mergeTransaction.odometerEndImage}),

Check failure on line 363 in src/libs/actions/MergeTransaction.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe assignment of an error typed value
}),
billable: mergeTransaction.billable,
reimbursable: mergeTransaction.reimbursable,
Expand Down
13 changes: 13 additions & 0 deletions src/types/onyx/MergeTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {IOURequestType} from '@libs/actions/IOU';
import type {FileObject} from '@src/types/utils/Attachment';
import type {Attendee} from './IOU';
import type Transaction from './Transaction';
import type {Comment, Receipt, Routes, TransactionCustomUnit, WaypointCollection} from './Transaction';
Expand Down Expand Up @@ -68,6 +69,18 @@ type MergeTransaction = {
/** The iou request type of the transaction */
iouRequestType?: IOURequestType;

/** Odometer start reading for distance expenses */
odometerStart?: number;

/** Odometer end reading for distance expenses */
odometerEnd?: number;

/** Odometer start image */
odometerStartImage?: FileObject | string;

/** Odometer end image */
odometerEndImage?: FileObject | string;

/** The attendees of the transaction */
attendees?: Attendee[];

Expand Down
Loading