project QadFinancials > class BCInvoice > method CalcAllCInvoiceMovementForBounced
query calculated fields procedure
Description
Assign a value to query calculated fields
Parameters
iiCompanyId | input | integer | Company id |
icCompanyList | input | character | |
iiCreditorId | input | integer | |
itFromPostingDate | input | date | |
itToPostingDate | input | date | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bcinvoice.p)
create query vhQuery in widget-pool "non-persistent".
vhQuery:forward-only = yes.
vhQuery:set-buffers(ih_Buffer).
vhQuery:query-prepare("for each ":U + ih_Buffer:table).
vhQuery:query-open().
vhQuery:get-first().
do while not vhQuery:query-off-end:
assign {&tcCInvoiceNumber} = string({&tiCInvoicePostingYear}) + "/":U + {&tcJournaInvoiceCode} + "/":U + string({&tiCInvoiceVoucher},"999999999":U)
{&tcCDocumentNumber} = string({&tiPostingYear}) + "/":U + {&tcJournalCode} + "/":U + string({&tiPostingVoucher},"999999999":U)
{&tdOpenAmountLC} = {&tdCInvoiceBalanceDebitLC} - {&tdCInvoiceBalanceCreditLC}
{&tdOpenAmountTC} = {&tdCInvoiceBalanceDebitTC} - {&tdCInvoiceBalanceCreditTC}
{&tdOpenAmountCC} = {&tdCInvoiceBalanceDebitCC} - {&tdCInvoiceBalanceCreditCC}
{&tdOriginalAmountLC} = {&tdCInvoiceOriginalDebitLC} - {&tdCInvoiceOriginalCreditLC}
{&tdOriginalAmountTC} = {&tdCInvoiceOriginalDebitTC} - {&tdCInvoiceOriginalCreditTC}
{&tdOriginalAmountCC} = {&tdCInvoiceOriginalDebitCC} - {&tdCInvoiceOriginalCreditCC}.
if {&ttCInvoiceDueDate} <> ?
then do:
/* Invoice is open and overdue */
if {&tlCInvoiceIsOpen} = true and
{&ttCInvoiceDueDate} <= today
then assign {&tiOverdueDays} = today - {&ttCInvoiceDueDate}.
/* Invoice is closed but payed after due date */
else if {&tlCInvoiceIsOpen} = false and
{&ttCInvoiceDueDate} < {&ttCInvoiceClosingDate}
then assign {&tiOverdueDays} = {&ttCInvoiceClosingDate} - {&ttCInvoiceDueDate}.
/* Invoice is payed within time or is still opened but not overdue */
else assign {&tiOverdueDays} = 0.
end.
assign vttempdate = date(1,1,year({&ttPostingDate})) + (2 - weekday(date(1,1,year({&ttPostingDate})))).
if weekday(date(1,1,year({&ttPostingDate}))) >= 6 then
vttempdate = vttempdate + 7.
assign {&tiWeekNumbers} = truncate(((date({&ttPostingDate}) - vttempdate) + 7) / 7 , 0).
if {&tiWeekNumbers} > 52
then do:
assign vttempdate = date(1,1,year({&ttPostingDate}) + 1) + (2 - weekday(date(1,1,year({&ttPostingDate}) + 1))).
if weekday(date(1,1,year({&ttPostingDate}) + 1)) >= 6 then
vttempdate = vttempdate + 7.
if {&ttPostingDate} < vttempdate then
{&tiWeekNumbers} = 52.
end.
assign {&tdPaymentAmountTC} = {&tdPostingLineDebitTC} - {&tdPostingLineCreditTC}.
vhQuery:get-next().
end.
vhQuery:query-close().
delete object vhQuery.