Procedura-DocumentsForClosing
Parametry:
Návratové hodnoty:
| Název | Popis | Datový typ |
|---|
| ID | | Char(10) |
Tělo:
BEGIN
/* JCD */
if (:DocumentType = '12') then begin
for
select
A.ID
from
CustomsDeclarations A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Ostatní příjmy */
if (:DocumentType = '01') then begin
for
select
A.ID
from
OtherIncomes A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Ostatní výdaje */
if (:DocumentType = '02') then begin
for
select
A.ID
from
OtherExpenses A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Zálohové listy k faktuře přijaté */
if (:DocumentType = '11') then begin
for
select
A.ID
from
ReceivedDInvoices A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Zálohové listy k faktuře vydané */
if (:DocumentType = '10') then begin
for
select
A.ID
from
IssuedDInvoices A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Faktury vydané */
if (:DocumentType = '03') then begin
for
select
A.ID
from
IssuedInvoices A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Faktury přijaté */
if (:DocumentType = '04') then begin
for
select
A.ID
from
ReceivedInvoices A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Penalizační faktury */
if (:DocumentType = '17') then begin
for
select
A.ID
from
PenaltyInvoices A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Dobropisy faktur vydaných */
if (:DocumentType = '60') then begin
for
select
A.ID
from
IssuedCreditNotes A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Dobropisy faktur přijatých */
if (:DocumentType = '61') then begin
for
select
A.ID
from
ReceivedCreditNotes A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Danove zalohove listy vydane */
if (:DocumentType = '62') then begin
for
select
A.ID
from
VATIssuedDInvoices A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Dobropisy danovych zalohovych listu vydanych */
if (:DocumentType = '63') then begin
for
select
A.ID
from
VATIssuedDCreditNotes A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Danove zalohove listy prijate */
if (:DocumentType = '64') then begin
for
select
A.ID
from
VATReceivedDInvoices A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
/* Dobropisy danovych zalohovych listu prijatych */
if (:DocumentType = '65') then begin
for
select
A.ID
from
VATReceivedDCreditNotes A
join Periods P on P.ID = A.Period_ID
where
P.DateTo$DATE-1 < :DateTo$DATE+1 and
A.DocQueue_ID = :DocQueue_ID and
A.Currency_ID <> :LocalCurrency_ID and
((A.ClosingPeriod_ID is Null) or
(A.LastPaymentPeriod_ID is Null) or
(A.ClosingPeriod_ID <> A.LastPaymentPeriod_ID))
into
ID
do begin
suspend;
end
end
END;
Generated by ABRA Software a.s. 27.10.2021 16:34:13