project QadFinancials > class BCInvoice > method DefaultValuesInvoiceType
Parameters
icCInvoiceRowId | input | character | Row ID of the supplier invoice |
icCInvoiceType | input | character | |
iiCreditorInvControlGLProfileId | input | integer | |
iiCreditorCnControlGLProfileId | input | integer | |
iiDivisionProfileId | input | integer | |
iiOldCInvoiceVoucher | input | integer | |
icOldJournalCode | input | character | |
iiJournalYear | input | integer | |
ilCInvoiceIsInitialStatus | input | logical | |
olControlGLIsDivisionAccount | output | logical | |
ocDivisionCode | output | character | |
ocCostCentreCode | output | character | |
ocProjectCode | output | character | |
ocJournalCode | output | character | |
oiCInvoiceVoucher | output | integer | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program3/bcinvoice.p)
if icCInvoiceType = ?
then assign icCInvoiceType = "":U.
if icCInvoiceType = "":U
then return.
assign vlUpdateDaybook = false
viControlGLProfileId = if icCInvoiceType = {&INVOICETYPE-INVOICE} or
icCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then iiCreditorInvControlGLProfileId
else iiCreditorCnControlGLProfileId.
if viControlGLProfileId = 0 or
viControlGLProfileId = ?
then return.
find first tCInvoice where
tCInvoice.tc_Rowid = icCInvoiceRowId
no-error.
if not available tCInvoice
then do:
<M-9 run SetMessage
(input #T-10'The specified supplier invoice is not defined in the system or is invalid.':255(69257)t-10# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7998':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -3.
return.
end.
if iiDivisionProfileId <> 0 or
iiDivisionProfileId <> ?
then do:
assign viDivisionProfileId = iiDivisionProfileId.
if viDivisionProfileId <> 0 and
viDivisionProfileId <> ?
then do:
<Q-14 run GetDivisionFromProfile (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input viDivisionProfileId, (DivisionProfileId)
output dataset tqDivisionFromProfile) in BProfile>
find first tqDivisionFromProfile where
tqDivisionFromProfile.tiProfile_ID = viDivisionProfileId
no-error.
assign ocDivisionCode = if available tqDivisionFromProfile
then tqDivisionFromProfile.tcDivisionCode
else "":U.
end.
end.
<Q-1 run ProfileLinkByGL (all) (Read) (NoCache)
(input viControlGLProfileId, (GlProfileId)
input viCompanyId, (CompanyId)
output dataset tqProfileLinkByGL) in BProfile>
find first tqProfileLinkByGL where
tqProfileLinkByGL.tiProfile_ID = viControlGLProfileId
no-error.
if available tqProfileLinkByGL
then do:
if ocDivisionCode = "":U
then do:
assign olControlGLIsDivisionAccount = tqProfileLinkByGL.tlGLIsDivisionAccount.
if olControlGLIsDivisionAccount
then do:
assign viDivisionProfileId = if iiDivisionProfileId = 0 or
iiDivisionProfileId = ?
then tqProfileLinkByGL.tiDivisionProfile_ID
else iiDivisionProfileId.
if viDivisionProfileId <> 0 and
viDivisionProfileId <> ?
then do:
<Q-2 run GetDivisionFromProfile (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input viDivisionProfileId, (DivisionProfileId)
output dataset tqDivisionFromProfile) in BProfile>
find first tqDivisionFromProfile where
tqDivisionFromProfile.tiProfile_ID = viDivisionProfileId
no-error.
assign ocDivisionCode = if available tqDivisionFromProfile
then tqDivisionFromProfile.tcDivisionCode
else "":U.
end.
else assign ocDivisionCode = "":U.
end.
end. /*if ocDivisionCode = "":U*/
if tqProfileLinkByGL.tiCostCentreProfile_ID <> 0 and
tqProfileLinkByGL.tiCostCentreProfile_ID <> ?
then do:
<Q-3 run GetCostCentreFromProfile (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tqProfileLinkByGL.tiCostCentreProfile_ID, (CostCentreProfileId)
output dataset tqCostCentreFromProfile) in BProfile>
find first tqCostCentreFromProfile where
tqCostCentreFromProfile.tiProfile_ID = tqProfileLinkByGL.tiCostCentreProfile_ID
no-error.
assign ocCostCentreCode = if available tqCostCentreFromProfile
then tqCostCentreFromProfile.tcCostCentreCode
else "":U.
end.
else assign ocCostCentreCode = "":U.
if tqProfileLinkByGL.tiProjectProfile_ID <> 0 and
tqProfileLinkByGL.tiProjectProfile_ID <> ?
then do:
<Q-4 run GetProjectFromProfile (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input tqProfileLinkByGL.tiProjectProfile_ID, (ProjectProfileID)
output dataset tqProjectFromProfile) in BProfile>
find first tqProjectFromProfile where
tqProjectFromProfile.tiProfile_ID = tqProfileLinkByGL.tiProjectProfile_ID
no-error.
assign ocProjectCode = if available tqProjectFromProfile
then tqProjectFromProfile.tcProjectCode
else "":U.
end.
else assign ocProjectCode = "":U.
end.
else assign olControlGLIsDivisionAccount = false
ocDivisionCode = "":U
ocCostCentreCode = "":U
ocProjectCode = "":U.
if (icOldJournalCode <> ? and
icOldJournalCode <> "":U) and
(iiJournalYear <> ? and
iiJournalYear <> 0) and
ilCInvoiceIsInitialStatus <> true and
vlCIDomainIsConsecutNr <> true
then do:
assign vhFcComponent = ?.
<M-11 run ReleaseNumber
(input viCompanyId (iiCompanyId),
input iiJournalYear (iiNumbrYear),
input icOldJournalCode (icNumbrType),
input iiOldCInvoiceVoucher (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
/* Assign Daybook Code if only one Daybook exists for this particular invoice type with a Daybook Control of Financial */
if icCInvoiceType <> "":U and
vlPOCAllowUpdateDaybookOnInv
then do:
assign vcJournalTypeCode = if icCInvoiceType = {&INVOICETYPE-INVOICE} or icCInvoiceType = {&INVOICETYPE-FINANCECHARGE}
then {&JOURNALTYPE-CREDITORINVOICE}
else if icCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then {&JOURNALTYPE-CREDITORCREDITNOTE}
else if icCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then {&JOURNALTYPE-CREDITORINVOICECORRECT}
else if icCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
then {&JOURNALTYPE-CREDITORCREDITNOTECORRECT}
else "":U
vlCorrection = if (icCInvoiceType = {&INVOICETYPE-INVOICECORRECTION} or
icCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION})
then true
else false.
<Q-6 run LookupSharedSetForCompany (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input {&SHAREDSETTYPECODE-JOURNAL}, (SharedSetType)
output dataset tqSharedSetForCompany) in BCompany >
find first tqSharedSetForCompany no-error.
if available tqSharedSetForCompany then do:
<Q-5 run JournalForProfileLinkDef (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input if available tqsharedSetForCompany then tqsharedSetForCompany.tiSharedSet_ID else 0, (SharedSetId)
input vcJournalTypeCode, (JournalTypeCode)
input True, (JournalIsActive)
input vlCorrection, (JournalTypeIsCorrection)
input {&JOURNALCONTROL-FINANCIAL}, (JournalControl)
output dataset tqJournalForProfileLinkDef) in BJournal >
find first tqJournalForProfileLinkDef where
tqJournalForProfileLinkDef.tcJournalTypeCode = vcJournalTypeCode and
tqJournalForProfileLinkDef.tlJournalIsActive = true and
tqJournalForProfileLinkDef.tlJournalTypeIsCorrection = vlCorrection and
tqJournalForProfileLinkDef.tcJournalControl = {&JOURNALCONTROL-FINANCIAL}
no-error.
if available tqJournalForProfileLinkDef
then do:
assign vcJournalCode = tqJournalForProfileLinkDef.tcJournalCode.
find next tqJournalForProfileLinkDef no-error.
if not available tqJournalForProfileLinkDef
then do:
assign ocJournalCode = vcJournalCode.
/*get the new voucher number - first release */
if ilCInvoiceIsInitialStatus <> true
then do:
/* ============================================== */
/* Check if consecutive numbering is enabled. */
/* If so, use a temporary number. */
/* Otherwise use standard numbering functionality */
/* ============================================== */
if vlCIDomainIsConsecutNr = true and
(icCInvoiceType <> {&INVOICETYPE-PREPAYMENT} and
icCInvoiceType <> {&INVOICETYPE-ADJUSTMENT})
then assign viTempCInvoiceVoucher = viTempCInvoiceVoucher + 1
oiCInvoiceVoucher = viTempCInvoiceVoucher.
else do:
assign vhFcComponent = ?.
<M-8 run GetNumber
(input viCompanyId (iiCompanyId),
input iiJournalYear (iiNumbrYear),
input ocJournalCode (icNumbrType),
output oiCInvoiceVoucher (oiNumber),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end. /* else do: */
assign tCInvoice.CInvoicePostingYear = iiJournalYear
tCInvoice.tcJournalCode = ocJournalCode
tCInvoice.CInvoiceVoucher = oiCInvoiceVoucher.
end.
end.
end.
end.
end.
else assign ocJournalCode = "":U.