project QadFinancials > class BCInvoice > method DefaultValuesWHTNewRow

Description

This method will be used to retrieve values for fields required on the WHT record for a new row to be created.


Parameters


icCreditorCodeinputcharacter
icCInvoiceTypeinputcharacter
ocDefaultWHTCodeoutputcharacter
ocTx2TaxTypeoutputcharacter
odTx2TaxPctoutputdecimal
odTx2PctRecvoutputdecimal
ocTx2Descoutputcharacter
ocWHTAcctoutputcharacter
ocWHTSubAcctoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program3/bcinvoice.p)

assign oiReturnStatus      = -98
       viLocalReturnStatus = 0. 

/******************************/
/* Normalize input parameters */
/******************************/
if icCInvoiceType = ? then assign icCInvoiceType = "":U.
if icCreditorCode = ? then assign icCreditorCode = "":U.

/*****************************/
/* Default output parameters */
/*****************************/
assign ocDefaultWHTCode = "":U
       ocTx2Desc        = "":U
       ocTx2TaxType     = "":U
       ocWHTAcct        = "":U
       ocWHTSubAcct     = "":U
       odTx2PctRecv     = 0
       odTx2TaxPct      = 0.
       
/*****************************/
/* Validate input parameters */
/*****************************/       
if icCInvoiceType = "":U
then do:
    assign vcMessage      = trim(#T-20'The specified supplier invoice type is not defined in the system or is invalid.':80(996402287)T-20#)
           oiReturnStatus = -1.
    <M-49 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'CInvoice Type':U (icFieldName), 
        input  icCInvoiceType (icFieldValue), 
        input  'S':U (icType), 
        input  2 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-822378':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    return.
end.  
if icCreditorCode = "":U 
then do:
    assign vcMessage = trim(#T-13'The specified Supplier Code is not defined in the system or is invalid.':80(349635954)T-13#)
           oiReturnStatus = -1.    
    <M-65 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'Supplier Code':U (icFieldName), 
        input  icCreditorCode (icFieldValue), 
        input  'S':U (icType), 
        input  2 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-681195':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    return.
end.    

if icCreditorCode <> "":U
then do:
        
    <Q-64 run CreditorVatForVatDetails (all) (Read) (NoCache)
       (input viDomainID, (DomainId)
        input viCompanyId, (CompanyId)
        input icCreditorCode, (CreditorCode)
        input vcDomainCode, (DomainCode)
        output dataset tqCreditorVatForVatDetails) in BCreditor >
           
    find first tqCreditorVatForVatDetails 
         where tqCreditorVatForVatDetails.tcCreditorCode = icCreditorCode and
               tqCreditorVatForVatDetails.tiDomain_ID = viDomainID and
               tqCreditorVatForVatDetails.tctx2_domain = vcDomainCode no-error.
    if available tqCreditorVatForVatDetails 
    then do:
        assign ocDefaultWHTCode = tqCreditorVatForVatDetails.tcVatCode.
    
        if icCInvoiceType = {&INVOICETYPE-INVOICE} or
           icCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
        then assign ocTx2Desc     = tqCreditorVatForVatDetails.tctx2_desc
                    ocTx2TaxType  = tqCreditorVatForVatDetails.tctx2_tax_type
                    odTx2PctRecv  = tqCreditorVatForVatDetails.tdtx2_pct_recv
                    odTx2TaxPct   = tqCreditorVatForVatDetails.tdtx2_tax_pct
                    ocWHTAcct     = tqCreditorVatForVatDetails.tctx2_ap_acct
                    ocWHTSubAcct  = tqCreditorVatForVatDetails.tctx2_ap_sub.
                    
        else if icCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
                icCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
        then assign ocTx2Desc     = tqCreditorVatForVatDetails.tctx2_desc
                    ocTx2TaxType  = tqCreditorVatForVatDetails.tctx2_tax_type
                    odTx2PctRecv  = tqCreditorVatForVatDetails.tdtx2_pct_recv
                    odTx2TaxPct   = tqCreditorVatForVatDetails.tdtx2_tax_pct
                    ocWHTAcct     = tqCreditorVatForVatDetails.tctx2_ap_cn_acct
                    ocWHTSubAcct  = tqCreditorVatForVatDetails.tctx2_ap_cn_sub.

    end. /* if available tqCreditorVatForVatDetails */
end. /* if icCreditorCode <> "":U */

assign oiReturnStatus = viLocalReturnStatus.