Нормализовать НДС follow-up за месяц в налоговый квартал

This commit is contained in:
2026-05-25 23:15:54 +03:00
parent d1536ed84b
commit af4b01d954
3 changed files with 71 additions and 2 deletions
+21 -1
View File
@@ -211,6 +211,22 @@ function deriveTaxQuarterWindowForDate(value) {
period_to: `${year}-${String(quarterEndMonth).padStart(2, "0")}-${String(quarterEndDay).padStart(2, "0")}`
};
}
function isFullCalendarMonthWindow(periodFrom, periodTo) {
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) {
const isoDate = normalizeIsoDateForQuery(value);
if (!isoDate) {
@@ -3003,8 +3019,12 @@ 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) {
filters.extracted_filters = {