project QadFinancials > class BExpenseNote > method CreateAdjustments

Description

Method to create adjustments of employee invoices and advances. It's to be called from APIExpNoteRegister.


Parameters


iiAccYearinputinteger
iiAccPeriodinputinteger
icAdjustmentJournalCodeinputcharacter
itRegistrationDateinputdate
icDescriptioninputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BExpenseNote.APIExpNoteRegister


program code (program3/bexpensenote.p)

/* -------------------------------------------------------------------- */
/* Adjustment Posting:                                                  */
/* Debit: Creditor Control Account - Adjustment of new employee invoice */
/* Credit: Creditor Control Account - Adjustment of advance             */
/* Create only posting headers and fill-in tMovementEN.                 */
/* BCInvoice.CreateCInvoiceMovements will generate PostingLines         */
/* -------------------------------------------------------------------- */
for each tAdjustments:
   
    empty temp-table tDefaultSafsEN.

    <M-1 run AddPostingHeader
       (input  ? (iiCompanyId), 
        input  iiAccYear (iiPeriodYear), 
        input  iiAccPeriod (iiPeriodPeriod), 
        input  icAdjustmentJournalCode (icJournalCode), 
        input  '' (icReportingJournalCode), 
        input  0 (iiVoucher), 
        input  itRegistrationDate (itPostingDate), 
        input  ? (itValueDate), 
        input  icDescription (icPostingText), 
        input  ? (icPostingBusinessRelationText), 
        input  ? (icPostingInvoiceReferenceText), 
        input  ? (icPostingParentText), 
        input  ? (iiBPeriodId), 
        input  ? (icPostingOriginAddressCode), 
        input  ? (icPostingOriginDocument), 
        input  ? (icPostingOriginDocumentType), 
        input  '':U (icBatchNumber), 
        input  ? (icBankImpLineRef), 
        output viPosting_ID (oiPostingId), 
        output vcPostingRowid (ocRowid), 
        output viPostingVoucher (oiPostingVoucher), 
        output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
    if viFcReturnSuper <> 0
    then do:
        assign oiReturnStatus = min(-1, viFcReturnSuper).        
        return.
    end.        
    
    /* Invoice Adjustment */
    create tMovementEN.
    assign tMovementEN.tiCInvoiceId              = tAdjustments.tiNewCInvoice_ID
           tMovementEN.tcPostingRowId            = vcPostingRowid
           tMovementEN.tdAmountDebitTC           = tAdjustments.tdInvAmountTC
           tMovementEN.tdAmountDebitLC           = tAdjustments.tdAdjAmountLC
           tMovementEN.tdMovementDiscountTC      = 0
           tMovementEN.tdCInvoiceHoldAmountTC    = ? /* Set to unknown-value to make sure this field in the invoice is not updated */
           tMovementEN.tlMovementisForDraft      = false
           tMovementEN.tlIsUndoPayment           = false.

    /* Advance Adjustment */
    create tMovementEN.
    assign tMovementEN.tiCInvoiceId              = tAdjustments.tiAdvCInvoice_ID
           tMovementEN.tcPostingRowId            = vcPostingRowid
           tMovementEN.tcPostingText             = tAdjustments.tcPostingText
           tMovementEN.tdAmountCreditTC          = tAdjustments.tdAdvAmountTC
           tMovementEN.tdMovementDiscountTC      = 0
           tMovementEN.tdCInvoiceHoldAmountTC    = ? /* Set to unknown-value to make sure this field in the invoice is not updated */
           tMovementEN.tlMovementisForDraft      = false
           tMovementEN.tlIsUndoPayment           = false.
end.