project QadFinancials > class BBill > method ChangeBillStatus
Description
When all invoices are closed, change bill status to Closed; if one of the invoices reopens, change bill status to Initial.
Parameters
Internal usage
QadFinancials
program code (program1/bbill.p)
if icChangedBillStatus <> {&BILLSTATUS-CONFIRM} and
icChangedBillStatus <> {&BILLSTATUS-CLOSED}
then return.
vcBillIDList = "".
if icChangedBillStatus = {&BILLSTATUS-CLOSED} then
do:
for each tBillListForChangeStatus:
/*Get Open DInvoice*/
<Q-93 run GetDInvoiceByBillID (all) (Read) (NoCache)
(input ?, (CompanyId)
input tBillListForChangeStatus.tiBill_ID, (Bill_Id)
input true, (IsOpen)
output dataset tqGetDInvoiceByBillID) in BBill>
/*Go through Open Invoice for the Bill_ID*/
for each tqGetDInvoiceByBillID:
if not can-find(first tFullAdjDInvoiceForStatus where tFullAdjDInvoiceForStatus.tiDInvoice_ID = tqGetDInvoiceByBillID.tiDInvoice_ID) then
do:
delete tBillListForChangeStatus.
leave.
end.
end.
end. /*Loop BIll_ID*/
end.
for each tBillListForChangeStatus:
if vcBillIDList = '':U then
assign vcBillIDList = string(tBillListForChangeStatus.tiBill_ID).
else
assign vcBillIDList = vcBillIDList + chr(4) + string(tBillListForChangeStatus.tiBill_ID).
end.
if vcBillIDList = "" then
return.
<M-87 run DataLoad
(input '':U (icRowids),
input vcBillIDList (icPkeys),
input '':U (icObjectIds),
input '' (icFreeform),
input no (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BBill>
for each tBill:
tBill.BillStatus = icChangedBillStatus.
tBill.tc_status = 'C'.
end.
<M-55 run ValidateBC (output oiReturnStatus (oiReturnStatus)) in BBill>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then
assign
oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then
return.
<M-92 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BBill>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then
assign
oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then
return.
<M-91 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BBill>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then
assign oiReturnStatus = viFcReturnSuper.