XV-PL-31

… (…) must be P_15 plus the charges less the deductions (…), DoRozliczenia the overpayment when that is negative (FA(3) information sheet, DoZaplaty).

error: the document is invalid

What the rule checks

As the rule set's publisher wrote it. The rule runs on every element the context matches, and fails where the test is false; the validator reports the line of that element

Context
/fa:Faktura/fa:Fa/fa:Rozliczenie
Test
(not(fa:DoZaplaty) or pl:near(pl:dec(fa:DoZaplaty), $balance, 0.001)) and (not(fa:DoRozliczenia) or pl:near(pl:dec(fa:DoRozliczenia), -$balance, 0.001))

Checked with KSeF FA(3)