project QadFinancials > class BDInvoice > method CreateDInvoiceMovement

Description

Initialize a new record in class table tDInvoiceMovement.


Parameters


ic_ParentRowidinputcharacter= tDInvoiceMovement.tc_ParentRowid
BDInvoiceoutputdatasetclass dataset, containing only the newly initialized record
oiReturnStatusoutputintegererror status


program code (program/bdinvoice.p)

    assign oiReturnStatus = -98.

    empty temp-table t_sDInvoice.
    empty temp-table t_sDInvoiceBank.
    empty temp-table t_sDInvoiceBankPayCode.
    empty temp-table t_sDInvoiceDeduction.
    empty temp-table t_sDInvoiceMovement.
    empty temp-table t_sDInvoiceOpInfo.
    empty temp-table t_sDInvoicePosting.
    empty temp-table t_sDInvoiceStage.
    empty temp-table t_sDInvoiceVat.
    empty temp-table t_sCustomTable0.
    empty temp-table t_sCustomTable1.
    empty temp-table t_sCustomTable2.
    find first tFcRowidConvert where
               tFcRowidConvert.tcFcOldRowid = ic_ParentRowid and
               tFcRowidConvert.tlFcOk       no-error.
    if available tFcRowidConvert
    then assign ic_ParentRowid = tFcRowidConvert.tcFcNewRowid.

    find tDInvoice where
         tDInvoice.tc_Rowid = ic_ParentRowid no-error.
    if not available tDInvoice
    then do:
        { includes/bfcrun.i
          &PROCEDURE  = "SetMessage"
          &PARAMETERS = "input 'Invalid parent ID':U,
                         input '',
                         input 'tDInvoice.tc_Rowid':U,
                         input ic_ParentRowid,
                         input 'S':U,
                         input 3,
                         input ic_ParentRowid,
                         input '',
                         input '',
                         input '',
                         input '',
                         output oiReturnStatus" }
        assign oiReturnStatus = -3.
        return.
    end.

    create tDInvoiceMovement.
    assign tDInvoiceMovement.tc_Rowid  = dynamic-function("GetNumberForNew":U in {&TARGETPROCEDURE})
           tDInvoiceMovement.tc_Status = "N":U.
    { includes/bfcrun.i
      &procedure  = "StartPersistence"
      &parameters = "output vh_persistence,
                     output viFcReturnSuper" }
    if viFcReturnSuper <> 0
    then do:
        assign oiReturnStatus = viFcReturnSuper.
        return.
    end.
    assign tDInvoiceMovement.DInvoiceMovement_ID = dynamic-function ("GetNextValue":U in vh_persistence,"ObjectNumber":U).
    assign tDInvoiceMovement.tc_ParentRowid = tDInvoice.tc_Rowid
           tDInvoiceMovement.DInvoice_ID = tDInvoice.DInvoice_ID.
    { includes/bfcrun.i
      &procedure  = "InitialValues"
      &parameters = "input 'DInvoiceMovement':U,
                     output oiReturnStatus" }

    create t_sDInvoiceMovement.
    raw-transfer tDInvoiceMovement to t_sDInvoiceMovement.
    assign t_sDInvoiceMovement.tc_ParentRowid = ic_ParentRowid.