Нормализовать НДС follow-up за месяц в налоговый квартал
This commit is contained in:
@@ -355,6 +355,23 @@ function deriveTaxQuarterWindowForDate(value: unknown): { period_from: string; p
|
||||
};
|
||||
}
|
||||
|
||||
function isFullCalendarMonthWindow(periodFrom: unknown, periodTo: unknown): boolean {
|
||||
const fromIso = normalizeIsoDateForQuery(periodFrom);
|
||||
const toIso = normalizeIsoDateForQuery(periodTo);
|
||||
if (!fromIso || !toIso) {
|
||||
return false;
|
||||
}
|
||||
const fromMatch = fromIso.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
||||
const toMatch = toIso.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
||||
if (!fromMatch || !toMatch || fromMatch[1] !== toMatch[1] || fromMatch[2] !== toMatch[2] || fromMatch[3] !== "01") {
|
||||
return false;
|
||||
}
|
||||
const year = Number(fromMatch[1]);
|
||||
const month = Number(fromMatch[2]);
|
||||
const lastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
||||
return toMatch[3] === String(lastDay).padStart(2, "0");
|
||||
}
|
||||
|
||||
function deriveMonthWindowForDate(value: unknown): { period_from: string; period_to: string } | null {
|
||||
const isoDate = normalizeIsoDateForQuery(value);
|
||||
if (!isoDate) {
|
||||
@@ -3716,9 +3733,14 @@ export class AddressQueryService {
|
||||
})
|
||||
});
|
||||
}
|
||||
const vatTaxPeriodFromCarriedMonth =
|
||||
intent.intent === "vat_liability_confirmed_for_tax_period" &&
|
||||
(filters.warnings.includes("period_from_from_followup_context") ||
|
||||
filters.warnings.includes("period_to_from_followup_context")) &&
|
||||
isFullCalendarMonthWindow(filters.extracted_filters.period_from, filters.extracted_filters.period_to);
|
||||
if (
|
||||
intent.intent === "vat_liability_confirmed_for_tax_period" &&
|
||||
filters.warnings.includes("period_derived_from_month_phrase")
|
||||
(filters.warnings.includes("period_derived_from_month_phrase") || vatTaxPeriodFromCarriedMonth)
|
||||
) {
|
||||
const taxQuarterWindow = deriveTaxQuarterWindowForDate(filters.extracted_filters.period_to);
|
||||
if (taxQuarterWindow) {
|
||||
|
||||
Reference in New Issue
Block a user