project QadFinancials > class BMfgCreditTerms > method UpdateMfgData

Description

Controls the processing of any update logic that is required when performing a create/modfiy operation on an MFG/PRO business component.
KEEP THE ANCESTOR TAG IN THE DESCENDANTS TO AVOID SCOPING PROBLEMS ON THE RECORD-AVAILABILITY
This method is the place holder for nay update ligic and complex mapping from the financials table to MFG/PRO.


Parameters


icMfgTableNameinputcharacterName of the MFG/PRO table name that is currently being processed. This is used to determine which logic to execute within the method in the cases where one business component maps to multiple tables in MFG/PRO.
icFinancialTableNameinputcharacterName of the Financial table name that is currently being processed. This is used to determine which logic to execute within the method in the cases where one business component has multiple tables that map to MFG/PRO.
ihFinancialDataBufferinputhandle
ihMfgDataBufferinputhandle
icMfgDomaininputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program/bmfgcreditterms.p)

<ANCESTOR-CODE>
if oiReturnStatus = 0
then oiReturnStatus = -98.                             

/* update the mfg table according the values of Payment Condition fields value */
if available tCopyPaymentCondition
then do:     
    /*  sync some simple fields */
    assign tct_mstr.ct_mod_date = today
           tct_mstr.ct_userid   = vcUserLogin.

    /* sync PaymentConditionPaymentType */
    if tCopyPaymentCondition.PaymentConditionPaymentTyp = {&PAYMENTCONDITIONPAYMENTTYPE-STAGED}
    then assign tct_mstr.ct_dating = yes.
    else assign tct_mstr.ct_dating = no.
    
    /* sync discount days if not both are 0 */
    /* months */
    if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-MONTHS}
    then assign tct_mstr.ct_disc_days = (tCopyPaymentCondition.PaymentConditionDayMthDisc * 30) 
                                        + tCopyPaymentCondition.PaymentConditionSupDayDisc.
    /* days */
    else if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-DAYS}
    then assign tct_mstr.ct_disc_days = tCopyPaymentCondition.PaymentConditionDayMthDisc 
                                        + tCopyPaymentCondition.PaymentConditionSupDayDisc.
    /* FortNight */                                    
    else if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-FORTNIGHT}
    then assign tct_mstr.ct_disc_days = (tCopyPaymentCondition.PaymentConditionDayMthDisc * 15) 
                                        + tCopyPaymentCondition.PaymentConditionSupDayDisc.
    
    /* Week */
    else if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-WEEK}
    then assign tct_mstr.ct_disc_days = (tCopyPaymentCondition.PaymentConditionDayMthDisc * 7) 
                                        + tCopyPaymentCondition.PaymentConditionSupDayDisc.


    else assign tct_mstr.ct_disc_days = 0. 

    /* sync ct_from_inv by period type of discount */
    if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-DAYS}
    then assign tct_mstr.ct_from_inv = 1.
    else if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-MONTHS}
    then tct_mstr.ct_from_inv = 2.      
    else if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-FORTNIGHT}
    then assign tct_mstr.ct_from_inv = 3.
    else if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-WEEK}
    then assign tct_mstr.ct_from_inv = 4.

    /* sync normal due days */   
    /* months */
   if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-MONTHS}
    then assign tct_mstr.ct_due_days = (tCopyPaymentCondition.PaymentConditionDaysMonths * 30) 
                                        + tCopyPaymentCondition.PaymentConditionSupplDays.
    /* days */
    else if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-DAYS}
    then assign tct_mstr.ct_due_days =  tCopyPaymentCondition.PaymentConditionDaysMonths 
                                        + tCopyPaymentCondition.PaymentConditionSupplDays.
    /* FORTNIGHT */                                    
    else if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-FORTNIGHT}
    then assign tct_mstr.ct_due_days =  (tCopyPaymentCondition.PaymentConditionDaysMonths * 15)
                                        + tCopyPaymentCondition.PaymentConditionSupplDays.
    /* WEEKS */
    else if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-WEEK}
    then assign tct_mstr.ct_due_days =  (tCopyPaymentCondition.PaymentConditionDaysMonths * 7 )
                                        + tCopyPaymentCondition.PaymentConditionSupplDays .                              
    else assign tct_mstr.ct_due_days = 0. 

    /* sync period type */
    if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-DAYS}
    then assign tct_mstr.ct_due_inv = 1.
    else if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-MONTHS}
         then assign tct_mstr.ct_due_inv = 2.      
         else if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-FORTNIGHT}
              then assign tct_mstr.ct_due_inv = 3.
              else if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-WEEK}
                   then assign tct_mstr.ct_due_inv = 4.

    /* sync ct_mtd_disc by period type of discount */
    if tCopyPaymentCondition.PaymentConditionPdDiscType = {&PAYMENTCONDITIONPERIODTYPE-MONTHS}
    then assign tct_mstr.ct_mtd_disc = yes.
    else assign tct_mstr.ct_mtd_disc = no.

    /* sync ct_mtd_due by period type of normal */
    if tCopyPaymentCondition.PaymentConditionPeriodType = {&PAYMENTCONDITIONPERIODTYPE-MONTHS}
    then assign tct_mstr.ct_mtd_due = yes.
    else assign tct_mstr.ct_mtd_due = no.

end. /* end of if available tCopyPaymentCondition */

if oiReturnStatus = -98
then assign oiReturnStatus = 0.