project QadFinancials > class BCInvoice > method AdditionalUpdatesAllCreateSCRounding

Description

As the user now has access to update the SC postings they can become out of balance. This methods calls the BPosting to create a posting line if this is the case and return a warning.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.AdditionalUpdatesAll


program code (program8/bcinvoice.p)

/* ======================================================================================= */
/* Go through all un-deleted Invoices,                                                    */
/* The rounding is only applicable if the SC amount uses a different exchange SC rate     */
/* for the tax postings, so the invoice has to be taxable and if it is initial then there */
/* are no postings                                                                        */
/* ====================================================================================== */
assign vcIsTaxSCExchangeRateChanged = 'false'.
for each tCInvoice where                
        tCInvoice.tc_Status <> "D":U and
        tCInvoice.CInvoiceIsInitialStatus = false on error undo, throw:     
  /* the journal entry instance has already been started by the calling method 
       Only want to check the CI postings.
       Only want to do the rounding for new postings */     
    find first tCInvoicePosting where
               tCInvoicePosting.CInvoice_ID         = tCInvoice.CInvoice_ID and               
               tCInvoicePosting.CInvoicePostingType = {&INVOICEPOSTINGTYPE-INITIAL}
               no-error.
    if available tCInvoicePosting and tCInvoicePosting.tc_Status = "N":U
    then do:        
        /* Only if it taxable should we create a SC rounding posting line */            
        if tCInvoice.CInvoiceIsTaxable
        then do:             
            /* Check that the one of the tax lines SC currency has been changed */           
            for each tCInvoiceVat where 
                     tCInvoiceVat.CInvoice_ID                  = tCInvoice.CInvoice_ID and
                     tCInvoiceVat.tdCInvoiceVatExchangeRateCC <> 0                     and
                     tCInvoiceVat.tdCInvoiceVatExchangeRateCC <> ?:
                     
                if tCInvoiceVat.tdCInvoiceVatExchangeRateCC <> tCInvoice.CInvoiceCCRate
                then do:           
                    assign vcIsTaxSCExchangeRateChanged = "true".
                    leave.
                end. /* if tCInvoiceVat.tdCInvoiceVatExchangeRateCC */                                   
                
            end. /* for each tCInvoiceVat */   
        end. /* if tCInvoice.CInvoiceIsTaxable */
     end.  /* if available tCInvoicePosting */  
    
    /* check that the JournalEntry instance has been created 
        e.g. if the invoice is being modified and only description
        is updated - there will be no BJE               */
    if (viBJournalEntryCIID <> 0 and
        viBJournalEntryCIID <> ? and
        valid-handle(vhBJournalEntryCIInst) = true)
    then do:              
        <M-48 run SetPublicData
           (input  'vlTaxPostingSCExRateModified':U (icDataList), 
            input  vcIsTaxSCExchangeRateChanged (icValueList), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
        
        if viFcReturnSuper < 0
        then do:
            <M-97 run SetMessage
               (input  trim(subst(#T-46'Internal error. The system was unable to set property &1 in the journal entry component.':150(906575812)T-46#, 'vlPostingMustBeBalanced':U)) (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'qadfin-418006':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        end. /* if viFcReturnSuper < 0 */  
        assign oiReturnStatus = viFcReturnSuper. 
    end. /* if (viBJournalEntryCIID <> 0 */        
end.  /* for each tCInvoice where */