project QadFinancials > class BDebtor > method InitialValues

Description

Add code here to initialize the calculated fields of a 'new' record (= a record that must be created in the application database) in a class temp-table.


Parameters


icTableNameinputcharacterName of the database table of which a record is created in the class temp-table.
oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bdebtor.p)

<ANCESTOR-CODE>

if icTableName = "Debtor":U
then do:
    assign tDebtor.DebtorIsActive              = yes
           tDebtor.Currency_ID                 = viCompanyLCId
           tDebtor.tcCurrencyCode              = vcCompanyLC
           tDebtor.VatDeliveryType             = {&VATDELIVERYTYPE-SERVICE}
           tDebtor.VatPercentageLevel          = {&VATPERCENTAGELEVEL-NONE}
           tDebtor.tlBusinessRelationIsInterco = no
           tDebtor.DebtorIsFixedCredLim        = false
           tDebtor.DebtorFixedCredLimTC        = 0
           tDebtor.DebtorIsTurnOverCredLim     = false
           tDebtor.DebtorPercTurnOverCredLim   = 0
           tDebtor.DebtorIsMaxDaysDueCredLim   = false
           tDebtor.DebtorMaxNumDaysCredLim     = 0
           tDebtor.DebtorIsInclOpenItmCredLim = false
           tDebtor.DebtorIsInclSOCredLim       = false
           tDebtor.DebtorIsCheckBefSOCredLim   = false
           tDebtor.DebtorIsCheckAftSOCredLim   = false
           tDebtor.DebtorIsCheckBefDICredLim   = false
           tDebtor.DebtorIsCheckAftDICredLim   = false
           tDebtor.DebtorPercWarningCredLim    = 0
           tDebtor.DebtorIsOverruleDICredLim   = false
           tDebtor.DebtorIsOverruleSOCredLim   = false
           tDebtor.DebtorIsTaxInCity           = true
           tDebtor.DebtorIsOverruleSOCredLim   = true.

    /* ====================================================================== */
    /* Get the Initial or Default Profile Code (in case just one would exist) */
    /* ====================================================================== */
    if vcInitialProfileCode = "-1":U
    then do :
        <Q-2 run ProfileByCodeAndType (all) (Read) (NoCache)
           (input ?, (ProfileCode)
            input {&PROFILETYPECODE-DEBTORACCOUNT}, (ProfileTypeCode)
            output dataset tqProfileByCodeAndType) in BProfile>
    
        find tqProfileByCodeAndType where
             tqProfileByCodeAndType.tlProfileIsActive
             no-error.
        if available tqProfileByCodeAndType           
        then assign vcInitialProfileCode = tqProfileByCodeAndType.tcProfileCode.
        else assign vcInitialProfileCode = ''.

    end. /*     if vcInitialProfileCode = '' */

    assign tDebtor.tcCnControlGLProfileCode  = vcInitialProfileCode
           tDebtor.tcInvControlGLProfileCode = vcInitialProfileCode.

    /* ===================================================================== */
    /* Get the Initial or Default Reason Code (in case just one would exist) */  
    /* ======================================================================*/
    if vcInitialReasonCode = "-1":U
    then do :
        <Q-3 run ReasonForMatching (all) (Read) (NoCache)
           (input ?, (ReasonID)
            input ?, (ReasonCode)
            input ?, (ReasonIsLogisticMatching)
            input yes, (ReasonIsActive)
            input ?, (ReasonIsInitialStatus)
            output dataset tqReasonForMatching) in BReason>

        find tqReasonForMatching where
             tqReasonForMatching.tlReasonIsActive
             no-error.
        if available tqReasonForMatching 
        then assign vcInitialReasonCode = tqReasonForMatching.Tcreasoncode.
        else assign vcInitialReasonCode = ''.

    end. /* if vcInitialReasonCode = '' */

    assign tDebtor.tcReasonCode = vcInitialReasonCode.
    
    /* ===================================================================================================== */
    /* Get the Initial or Default Debtor SharedSet Code that is linked to the current company (viCompanyId)  */
    /* ===================================================================================================== */
    if viInitialCompanyID <> viCompanyId
    then do :
        <Q-1 run LookupSharedSetForCompany (all) (Read) (Cache)
           (input viCompanyId, (CompanyId)
            input {&SHAREDSETTYPECODE-DEBTOR}, (SharedSetType)
            output dataset tqSharedSetForCompany) in BCompany>

        find first tqSharedSetForCompany no-error.
        if available tqSharedSetForCompany
        then assign viInitialDebtorSharedSetID = tqSharedSetForCompany.tiSharedSet_ID
                    viInitialCompanyID         = viCompanyId.

    end. /* viInitialCompanyID <> viCompanyId */

    assign tDebtor.SharedSet_ID = viInitialDebtorSharedSetID.

    /* ============================================================ */
    /* Create tAddressRefDebtor at least one record must be defined */
    /* ============================================================ */
    create tAddressRefDebtor. 
    assign tAddressRefDebtor.tiBusinessRelation_ID = 0
           tAddressRefDebtor.tc_Rowid            = string(rowid(tAddressRefDebtor)).

end. /* icTableName = "Debtor":U */