select SUM(A.LocalAmount - A.LocalCreditAmount - A.LocalPaidAmount + A.LocalPaidCreditAmount) from IssuedInvoices A where (A.Firm_ID IN (SELECT x.ID FROM Firms x WHERE x.ID = :FirmOID OR x.Firm_ID = :FirmOID)) and A.DueDate$Date < :TestDate and (((A.LocalAmount>=0) and ((A.LocalAmount + A.LocalPaidCreditAmount - A.LocalPaidAmount - A.LocalCreditAmount) > 0)) or ((A.LocalAmount <0) and ((A.LocalAmount + A.LocalPaidCreditAmount - A.LocalPaidAmount - A.LocalCreditAmount) < 0)))
Generated by ABRA Software a.s. 27.10.2021 16:34:09