changes 1

This commit is contained in:
2026-10-29 15:37:44 +03:30
parent 68752f0403
commit 7b25c565fc
9 changed files with 152 additions and 15 deletions
+19 -1
View File
@@ -19,9 +19,27 @@ import {
tehranCalendarDay,
} from './tehran-time';
/** وضعیتی که فاکتور قیمت‌گذاری‌شده برای مشتری ارسال می‌شود. */
const INVOICE_ISSUED_STATUS = 'awaiting_settlement';
/**
* مبدأ راس چک، تاریخ صدور فاکتور است نه امروز و نه تاریخ ثبت پیش‌سفارش.
* اگر فاکتور دوباره ارسال شده باشد، آخرین صدور ملاک است.
*/
export function invoiceAnchorDate(
createdAt: Date,
history: { toStatus: string; changedAt: Date }[] = [],
): Date {
for (let i = history.length - 1; i >= 0; i -= 1) {
const row = history[i];
if (row?.toStatus === INVOICE_ISSUED_STATUS) return row.changedAt;
}
return createdAt;
}
export function calculateCheckRass(
checks: CheckRassInput[],
baseDate: Date = new Date(),
baseDate: Date,
): CheckRassResult {
if (checks.length === 0) {
return {