project QadFinancials > class BVATExportListing > method ExportFormatting725

Description

This method is used to format temp table ExportVATListingYearly, and invoked by APIExportYearlyBE.


Parameters


t_sqExportVATListingYearlyinputtemp-tableTemp table of ExportVATListingYearly.
tqVatExportListingoutputtemp-tableTemp table of VatExportListing.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BVATExportListing.ApiExportYearlyVatBE


program code (program6/bvatexportlisting.p)

/* Record 000000 CUSTOMER RECORDS */
assign viCustomerRecords = 0
       vdTotalBaseRC     = 0
       vdTotalVatRC      = 0. 

empty temp-table tqVatExportListing.

for each  t_sqExportVATListingYearly:

    /* BTS 4975 - JLA */
    /* Skip the customer where base and vat are zero */
    if t_sqExportVATListingYearly.tdBaseRC + t_sqExportVATListingYearly.tdVatRC = 0
    then next.
    /* BTS 4975 - JLA */

    <Q-6 run DebtorByDebtor (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
        input ?, (DebtorId)
        input t_sqExportVATListingYearly.tcDebtorCode, (DebtorCode)
        output dataset tqDebtorByDebtor) in BDebtor >
    find first tqDebtorByDebtor no-lock no-error.
    
    assign viCustomerRecords = viCustomerRecords + 1
           vdTotalBaseRC     = vdTotalBaseRC     + t_sqExportVATListingYearly.tdBaseRC
           vdTotalVatRC      = vdTotalVatRC      + t_sqExportVATListingYearly.tdVatRC.    
    
/* BTS 4975 - JLA */
/* - make it more readable                         */
/* - Change the way CustomerRecords are formatted  */
/* - Change the way baseRC and VatRc are formatted */    
/* - baseRC and vatRC always with 2 decimals       */
    assign vcContentLine = STRING(viCustomerRecords,"999999":U) 
                         + STRING(if available tqDebtorByDebtor 
                                  then tqDebtorByDebtor.tcBusinessRelationName1 
                                  else "":U,"X(32)":U) 
                         + STRING(if available tqDebtorByDebtor 
                                  then tqDebtorByDebtor.tcAddressStreet1        
                                  else "":U,"X(24)":U) 
                         + STRING(if available tqDebtorByDebtor 
                                  then (tqDebtorByDebtor.tcAddressZip + " ":U + tqDebtorByDebtor.tcAddressCity) 
                                  else "":U ,"X(27)":U) 
                         + STRING("BE":U, "X(2)":U) 
                         + STRING(replace(t_sqExportVATListingYearly.tcVatNumberIdentity, ".":U, "":U), "X(9)":U)  
                         + replace(replace(string(t_sqExportVATListingYearly.tdBaseRC, "-9999999.99":U), ".":U, "":U), " ":U, "0":U) 
                         + replace(replace(string(t_sqExportVATListingYearly.tdVatRC , "-9999999.99":U), ".":U, "":U), " ":U, "0":U) 
                         + STRING("":U, "X(8)":U)
                         no-error.
/* === OLD CODE ==========
    vcContentLine = (IF length(STRING(viCustomerRecords),"CHARACTER":U) <> 6 THEN  SUBSTRING("000000":U,1, 6 - length(STRING(viCustomerRecords),"CHARACTER":U),"CHARACTER":U) ELSE "":U) + STRING(viCustomerRecords) +
                    STRING(if available tqDebtorByDebtor then tqDebtorByDebtor.tcBusinessRelationName1 else "":U,"X(32)":U) +
                    STRING(if available tqDebtorByDebtor then tqDebtorByDebtor.tcAddressStreet1 else "":U,"X(24)":U) +
                    STRING(if available tqDebtorByDebtor then (tqDebtorByDebtor.tcAddressZip + " ":U + tqDebtorByDebtor.tcAddressCity) else "":U ,"X(27)":U) +
                    STRING("BE":U,"X(2)":U) +
                    STRING(replace(t_sqExportVATListingYearly.tcVatNumberIdentity,".":U,"":U),"X(9)":U) +
                    (IF length(replace(string(round(t_sqExportVATListingYearly.tdBaseRC,2)) , ".":U, "":U),"CHARACTER":U) <> 10 THEN  subSTRING("0000000000000000":U,1, 10 - length(replace(string(round(t_sqExportVATListingYearly.tdBaseRC,2))  , ".":U, "":U),"CHARACTER":U),"CHARACTER":U) ELSE "":U) + replace(string(round(t_sqExportVATListingYearly.tdBaseRC,2))  , ".":U, "":U) +
                    (IF length(replace(string(round(t_sqExportVATListingYearly.tdVatRC,2))  , ".":U, "":U),"CHARACTER":U) <> 10 THEN  subSTRING("0000000000000000":U,1, 10 - length(replace(string(round(t_sqExportVATListingYearly.tdVatRC ,2))  , ".":U, "":U),"CHARACTER":U),"CHARACTER":U) ELSE "":U) + replace(string(round(t_sqExportVATListingYearly.tdVatRC ,2))  , ".":U, "":U)  +
                    STRING("":U,"X(8)":U).   
   === OLD CODE ========== */                                     
/* BTS 4975 - JLA */    
    
    create tqVatExportListing.
    assign tqVatExportListing.tiSequenceVEL = viCustomerRecords + 2.
           tqVatExportListing.tcContentVEL  = vcContentLine.

end.
/* end for each*/

/* Fetch Current Companies Company Data */
<Q-3 run CompanyPropertyByBusinessRel (first) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
           output dataset tqCompanyPropertyByBusinessRel) in BCompanyProperty >

find first tqCompanyPropertyByBusinessRel no-lock no-error.

if available tqCompanyPropertyByBusinessRel then do:

    <Q-5 run CompanyByCodeActiveID (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input ?, (CompanyCode)
           input ?, (CompanyIsActive)
           output dataset tqCompanyByCodeActiveID) in BCompany >
    
    FIND FIRST  tqCompanyByCodeActiveID no-lock no-error.

    /* Record 555555*/
    /* BTS 4975 - JLA */
    assign vcContentLine = "555555":U +
                           STRING(tqCompanyByCodeActiveID.tcCompanyCode,"X(32)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressStreet1,"X(24)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressZip + " ":U + tqCompanyPropertyByBusinessRel.tcAddressCity,"X(27)":U) +
                           STRING("":U,"X(11)":U) +
                           string(viCustomerRecords ,"9999999999":U) + 
                           STRING("":U,"X(18)":U)
                           no-error.
    /* BTS 4975 - JLA */
    
    create tqVatExportListing.
    assign tqVatExportListing.tiSequenceVEL = 1
           tqVatExportListing.tcContentVEL  = vcContentLine.
    
    /* Record 000000*/
    /* BTS 4975 - JLA */
    assign vcContentLine = "000000":U +
                           STRING(tqCompanyByCodeActiveID.tcCompanyCode,"X(32)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressStreet1,"X(24)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressZip + " ":U + tqCompanyPropertyByBusinessRel.tcAddressCity,"X(27)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressCountryCode,"X(2)":U) +
                           STRING(replace(tqCompanyPropertyByBusinessRel.tcVatNumberIdentity,".":U,"":U),"X(9)":U) +
                           STRING(/* VR jaarOmzet */ "":U ,"X(10)":U) +
                           STRING(/* LandbouwOndernemer */ "":U ,"X(10)":U) +
                           "E":U + 
                           STRING(viListingYear ,"9999":U) +
                           STRING("":U, "X(3)":U)
                           no-error. 
    /* BTS 4975 - JLA */
    
    create tqVatExportListing.
    assign tqVatExportListing.tiSequenceVEL = 2
           tqVatExportListing.tcContentVEL  = vcContentLine.
    
    /* Record 999999*/
    /* BTS 4975 - JLA */
    assign vcContentLine = "999999":U +
                           replace(replace(string(vdTotalBaseRC, "-9999999999999.99":U), ".":U, "":U), " ":U, "0":U) +
                           replace(replace(string(vdTotalVatRC,  "-9999999999999.99":U), ".":U, "":U), " ":U, "0":U) +
                           STRING("":U,"X(51)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressCountryCode,"X(2)":U) +
                           STRING(replace(tqCompanyPropertyByBusinessRel.tcVatNumberIdentity,".":U,"":U),"X(9)":U) +
                           STRING("":U,"X(28)":U)
                           no-error.
    /* BTS 4975 - JLA */
    
    create tqVatExportListing.
    assign tqVatExportListing.tiSequenceVEL = viCustomerRecords + 3
           tqVatExportListing.tcContentVEL  = vcContentLine.

end.