| Název | Popis | Třída |
|---|---|---|
| UpdateBankAccountsBalance2 | Procedures |
begin
for select ID from BankAccounts into :mBankAccount_ID do
begin
mPeriod_ID = null;
mLocalAmount = null;
mAmount = null;
mBegLocalAmount = null;
mBegAmount = null;
select
first 1 P.ID
from BankAccounts2 BA2
join Periods P on P.id = BA2.Period_ID
where (BA2.Parent_ID = :mBankAccount_ID)
order by P.SequenceNumber desc
into :mPeriod_ID;
select
coalesce(sum((case when BS2.Credit = 'A' then BS2.LocalTAmount else -BS2.LocalTamount end)), 0),
coalesce(sum((case when BS2.Credit = 'A' then BS2.TAmount else -BS2.TAmount end)), 0)
from BankStatements2 BS2
join BankStatements BS on BS.ID = BS2.Parent_ID
where ((:mPeriod_ID is null) or (BS.Period_ID = :mPeriod_ID))
and (BS.BankAccount_ID = :mBankAccount_ID)
and (BS2.IsMultiPaymentRow = 'N')
into :mLocalAmount, mAmount;
if (mPeriod_ID is null) then
begin
mBegLocalAmount = 0;
mBegAmount = 0;
end
else
begin
select
BeginningLocal, Beginning
from BankAccounts2
where (Parent_ID = :mBankAccount_ID) and (Period_ID = :mPeriod_ID)
into mBegLocalAmount, mBegAmount;
end
update SYS$BankAccountsBalance
set LocalAmount = (:mBegLocalAmount + :mLocalAmount),
Amount = (:mBegAmount + :mAmount)
where Account_ID = :mBankaccount_ID;
end
endGenerated by ABRA Software a.s. 27.10.2021 16:34:18