project QadFinancials > class BDInvoice > method ValBalanceNotNegative

validation procedure

Description

Validates the balance fields.
Balance fields cannot be negative.


Parameters


idTargetFieldinputdecimalValue of the business field to validate.
icTargetFieldNameinputcharacterName of the business field to validate.
icRowidinputcharacterContents of field tc_Rowid, if the target field is a field of a component temp-table.
icDInvoiceTypeinputcharacterDInvoice Type
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/bdinvoice.p)

assign vcMessage = "":U.

    if idTargetField < 0
    then do:
        case icTargetFieldName:
            when "DInvoice.DInvoiceBalanceDebitTC":U
            then assign vcMessage = if icDinvoiceType = {&INVOICETYPE-INVOICE} or icDinvoiceType = {&INVOICETYPE-FINANCECHARGE}
                                    then trim(#T-2'The TC balance amount cannot be negative.':150(1125)T-2#)
                                    else "":U.
            when "DInvoice.DInvoiceBalanceCreditTC":U 
            then assign vcMessage = if icDinvoiceType = {&INVOICETYPE-CREDITNOTE}
                                    then trim(#T-4'The TC balance amount cannot be negative.':150(1125)T-4#)
                                    else "":U.
            when "DInvoice.DInvoiceBalanceDebitlC":U
            then assign vcMessage = if icDinvoiceType = {&INVOICETYPE-INVOICE} or icDinvoiceType = {&INVOICETYPE-FINANCECHARGE}
                                    then trim(#T-3'The balance amount in the base currency cannot be negative.':150(1126)t-3#)
                                    else "":U.
            when "DInvoice.DInvoiceBalanceCreditlC":U
            then assign vcMessage = if icDinvoiceType = {&INVOICETYPE-CREDITNOTE}
                                    then trim(#T-5'The balance amount in the base currency cannot be negative.':150(1126)t-5#)
                                    else "":U.
        end case.
    end. 
    
    if idTargetField > 0
    then do:
        case icTargetFieldName:
            when "DInvoice.DInvoiceBalanceDebitTC":U
            then assign vcMessage = if icDinvoiceType = {&INVOICETYPE-INVOICE} or icDinvoiceType = {&INVOICETYPE-FINANCECHARGE} 
                                    then trim(#T-6'The balance amount in the transaction currency must be less than or equal to zero.':150(14068)t-6#)
                                    else "":U.
            when "DInvoice.DInvoiceBalanceCreditTC":U 
            then assign vcMessage = if icDinvoiceType = {&INVOICETYPE-CREDITNOTE}
                                    then trim(#T-7'The balance amount in the transaction currency must be less than or equal to zero.':150(14068)t-7#)
                                    else "":U.
            when "DInvoice.DInvoiceBalanceDebitlC":U
            then assign vcMessage = if icDinvoiceType = {&INVOICETYPE-INVOICE} or icDinvoiceType = {&INVOICETYPE-FINANCECHARGE}
                                    then trim(#T-8'The balance amount in the base currency must be less than or equal to zero.':150(14069)t-8#)
                                    else "":U.
            when "DInvoice.DInvoiceBalanceCreditlC":U
            then assign vcMessage = if icDinvoiceType = {&INVOICETYPE-CREDITNOTE}
                                    then trim(#T-9'The balance amount in the base currency must be less than or equal to zero.':150(14069)t-9#)
                                    else "":U.
        end case.
    end. 

    if vcMessage <> "":U
    then do:
        assign oiReturnStatus = -1.
        <M-1 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  icTargetFieldName (icFieldName),
                     input  string(idTargetField) (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  icRowid (icRowid),
                     input  'QADFIN-2074':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
    end.