Completar combinação CBF15 com saldos anteriores e conferir PEC residual
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { economicCase } from "./irpc-economic-case.mjs";
|
||||
import { investmentCarryCase } from "./irpc-investment-carry-case.mjs";
|
||||
import {
|
||||
prepareInvestmentCarry,
|
||||
} from "../../../resources/js/lib/irpc-annual-settlement.ts";
|
||||
export function combinedCase() {
|
||||
const c = economicCase(true);
|
||||
c.b = prepareInvestmentCarry(c.d, c.b);
|
||||
c.b.investmentCredit = structuredClone(
|
||||
investmentCarryCase().b.investmentCredit,
|
||||
);
|
||||
c.b.investmentCredit.assessmentKey = c.b.assessmentKey;
|
||||
return c;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { investmentCase } from "./helpers/irpc-investment-case.mjs";
|
||||
import { combinedCase } from "./helpers/irpc-investment-combination-case.mjs";
|
||||
import {
|
||||
calculateAnnual,
|
||||
recordAnnual,
|
||||
annualCurrent,
|
||||
annualBook,
|
||||
saveAnnualBook,
|
||||
annualHtml,
|
||||
} from "../../resources/js/lib/irpc-annual-settlement.ts";
|
||||
const f = (n) => ({ numerator: String(n), denominator: "1" });
|
||||
test("CBF15 carry combines with economic/current and prior international/PEC once in statutory order", () => {
|
||||
const c = combinedCase(),
|
||||
m = calculateAnnual(c.d, c.b);
|
||||
assert.deepEqual(m.pending, []);
|
||||
assert.deepEqual(m.investmentCredit.deducted, f(400));
|
||||
assert.deepEqual(m.arithmeticBalance, f(138));
|
||||
});
|
||||
test("explicit current and prior PEC allocation cannot exceed collecta left after CBF15", () => {
|
||||
const c = combinedCase();
|
||||
Object.assign(c.b.investmentCredit.assets[0], {
|
||||
amount: "40000",
|
||||
proofAmount: "40000",
|
||||
});
|
||||
const m = calculateAnnual(c.d, c.b);
|
||||
assert.equal(
|
||||
m.arithmeticBalance,
|
||||
null,
|
||||
"An excessive PEC allocation must not manufacture a recoverable balance",
|
||||
);
|
||||
assert.match(m.pending.join(" "), /PEC.*CBF15/);
|
||||
});
|
||||
|
||||
test("documented residual quota and expired original window retain distinct unused credits", () => {
|
||||
const c = combinedCase();
|
||||
c.b.investmentCredit.soleProject = "no";
|
||||
c.b.investmentCredit.projectQuota = {
|
||||
amount: "100",
|
||||
reference:
|
||||
"SYNTHETIC residual collecta allocated to this project after prior credits",
|
||||
};
|
||||
let m = calculateAnnual(c.d, c.b);
|
||||
assert.deepEqual(m.pending, []);
|
||||
assert.deepEqual(m.arithmeticBalance, f(438));
|
||||
assert.deepEqual(m.investmentCredit.unused, f(300));
|
||||
c.b.investmentCredit.projectQuota.amount = "1339";
|
||||
assert.match(
|
||||
calculateAnnual(c.d, c.b).pending.join(" "),
|
||||
/Quota residualCBF15/,
|
||||
);
|
||||
c.b.investmentCredit.soleProject = "yes";
|
||||
c.b.investmentCredit.startDate = "2021-01-01";
|
||||
m = calculateAnnual(c.d, c.b);
|
||||
assert.deepEqual(m.pending, []);
|
||||
assert.deepEqual(m.investmentCredit.expired, f(400));
|
||||
assert.deepEqual(m.arithmeticBalance, f(538));
|
||||
});
|
||||
test("explicit zero PEC allocation after exhausted collecta preserves prior PEC and recovers only PPC", () => {
|
||||
const c = combinedCase();
|
||||
Object.assign(c.b.investmentCredit.assets[0], {
|
||||
amount: "40000",
|
||||
proofAmount: "40000",
|
||||
});
|
||||
c.b.creditCarry.currentPec = "0";
|
||||
c.b.creditCarry.lots[1].selected = "0";
|
||||
const m = calculateAnnual(c.d, c.b);
|
||||
assert.deepEqual(m.pending, []);
|
||||
assert.deepEqual(m.investmentCredit.deducted, f(1338));
|
||||
assert.deepEqual(m.pecDeduction.deducted, f(0));
|
||||
assert.deepEqual(m.creditCarry.priorPec, f(0));
|
||||
assert.deepEqual(m.arithmeticBalance, f(-500));
|
||||
assert.equal(m.creditCarry.officialBalancesConsumed, false);
|
||||
const b = recordAnnual(c.d, c.b, "2026-11-11T09:00:00+02:00"),
|
||||
d = { ...c.d, modelo_a_snapshot: saveAnnualBook(c.d, b) },
|
||||
back = annualBook(d);
|
||||
assert.equal(annualCurrent(d, back), true);
|
||||
assert.deepEqual(
|
||||
calculateAnnual(d, back).investmentCredit,
|
||||
m.investmentCredit,
|
||||
);
|
||||
assert.match(annualHtml(d), /CBF15/);
|
||||
});
|
||||
|
||||
test("current CBF15 and prior international/PEC obey the same residual collecta guard", () => {
|
||||
const c = combinedCase();
|
||||
c.b.version = 2;
|
||||
c.b.investmentCredit = structuredClone(investmentCase().b.investmentCredit);
|
||||
c.b.investmentCredit.assessmentKey = c.b.assessmentKey;
|
||||
let m = calculateAnnual(c.d, c.b);
|
||||
assert.deepEqual(m.pending, []);
|
||||
assert.deepEqual(m.arithmeticBalance, f(38));
|
||||
Object.assign(c.b.investmentCredit.assets[0], {
|
||||
amount: "40000",
|
||||
proofAmount: "40000",
|
||||
});
|
||||
m = calculateAnnual(c.d, c.b);
|
||||
assert.equal(m.arithmeticBalance, null);
|
||||
assert.match(m.pending.join(" "), /PEC.*CBF15/);
|
||||
});
|
||||
Reference in New Issue
Block a user