mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 13:28:11 +00:00
change price logic on the ,rule engine ui, auto generate the contrat
This commit is contained in:
@@ -315,15 +315,27 @@ export class RuleEngineService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshot all LIVE rates into booking_rate_snapshot for a booking.
|
||||
* Snapshot only the rates used in a booking's final price.
|
||||
*/
|
||||
async snapshotLiveRates(bookingId: string): Promise<BookingRateSnapshot[]> {
|
||||
const liveRates = await this.ratesRepo.findLiveRates();
|
||||
async snapshotRates(
|
||||
bookingId: string,
|
||||
rates: Array<{
|
||||
id: string;
|
||||
rateType: string;
|
||||
rateValue: number;
|
||||
rateUnit: string;
|
||||
currency: string;
|
||||
}>,
|
||||
): Promise<BookingRateSnapshot[]> {
|
||||
const snapshotRepo = this.dataSource.getRepository(BookingRateSnapshot);
|
||||
const now = new Date();
|
||||
const seen = new Set<string>();
|
||||
const snapshots: BookingRateSnapshot[] = [];
|
||||
|
||||
for (const rate of liveRates) {
|
||||
for (const rate of rates) {
|
||||
if (seen.has(rate.id)) continue;
|
||||
seen.add(rate.id);
|
||||
|
||||
const snapshot = snapshotRepo.create({
|
||||
bookingId,
|
||||
rateId: rate.id,
|
||||
|
||||
Reference in New Issue
Block a user