fix(qa): evaluate credit warnings from declared contractual days
This commit is contained in:
@@ -119,6 +119,7 @@ export type BusinessFinancialPlanInput = {
|
||||
annualGrowthPercent?: string;
|
||||
/** Explicit opt-in; saved forecasts without this choice retain their values. */
|
||||
applyAnnualGrowth?: boolean;
|
||||
creditTermDays?: string;
|
||||
dividendsByPeriod?: string[];
|
||||
operatingExpenseLines?: {
|
||||
label: string;
|
||||
@@ -196,6 +197,7 @@ export function serializeBusinessPlanSnapshot(
|
||||
const snapshot = JSON.stringify({
|
||||
version: [
|
||||
'applyAnnualGrowth',
|
||||
'creditTermDays',
|
||||
'dividendsByPeriod',
|
||||
'operatingExpenseLines',
|
||||
'fundingBreakdown',
|
||||
@@ -298,6 +300,7 @@ export function restoreBusinessPlanSnapshot(
|
||||
decoded.version < 18 &&
|
||||
[
|
||||
'applyAnnualGrowth',
|
||||
'creditTermDays',
|
||||
'dividendsByPeriod',
|
||||
'operatingExpenseLines',
|
||||
'fundingBreakdown',
|
||||
@@ -307,6 +310,11 @@ export function restoreBusinessPlanSnapshot(
|
||||
return null;
|
||||
const shortText = (v: unknown) =>
|
||||
typeof v === 'string' && v.length <= 160;
|
||||
if (
|
||||
plan.creditTermDays !== undefined &&
|
||||
!shortText(plan.creditTermDays)
|
||||
)
|
||||
return null;
|
||||
const amounts = (v: unknown) =>
|
||||
Array.isArray(v) && v.length <= 60 && v.every(shortText);
|
||||
if (
|
||||
@@ -1406,6 +1414,12 @@ export function compareBusinessScenarios(input: BusinessFinancialPlanInput) {
|
||||
|
||||
/** Forecast separates invoiced sales, collections, accounting expenses and cash payments. */
|
||||
export function forecastBusinessPlan(input: BusinessFinancialPlanInput) {
|
||||
if (
|
||||
input.creditTermDays?.trim() &&
|
||||
(!/^\d+$/.test(input.creditTermDays) ||
|
||||
Number(input.creditTermDays) > 365)
|
||||
)
|
||||
throw new Error('Indique um prazo entre 0 e 365 dias.');
|
||||
if (input.fundingBreakdown) {
|
||||
const f = input.fundingBreakdown;
|
||||
const total =
|
||||
|
||||
Reference in New Issue
Block a user