project QadFinancials > class BVATExportListing > method ExportFormatting723

Description

This method is used to format ExpoerVATQuarterSum temp-table. Invoked by ApiExpoerQuarterSum.


Parameters


t_sqExportVATQuarterSuminputtemp-tableTemp table of ExportVATQuarterSum.
icPeriodYearForExportFileinputcharacterPeriod Year For Export File.
tqVatExportListingoutputtemp-tableTemp table of VatExportListing.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BVATExportListing.ApiExportQuarterSum


program code (program1/bvatexportlisting.p)

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

for each  t_sqExportVATQuarterSum 
    break by t_sqExportVATQuarterSum.tcVatNumberIdentityEQS 
          by t_sqExportVATQuarterSum.tcCountryCodeEQS:

    <Q-6 run AddressTypePrim (all) (Read) (NoCache)
          (input ?, (AddressTypeId)
           input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
           output dataset tqAddressTypePrim) in BAddressType >
    find first tqAddressTypePrim no-lock no-error.
    if not available tqAddressTypePrim then next.
    
    assign viCustomerRecords = viCustomerRecords + 1.
    
    <Q-7 run AddressByBusinessRelation (all) (Read) (NoCache)
          (input t_sqExportVATQuarterSum.tiBusinessRelationIDEQS, (BusinessRelationId)
           output dataset tqAddressByBusinessRelation) in BBusinessRelation >
    find first tqAddressByBusinessRelation where 
               tqAddressByBusinessRelation.tiAddressType_ID = tqAddressTypePrim.tiAddressType_ID 
               no-lock no-error.
    
    /* BTS 4975 - JLA */
/*  assign vcVatBaseString = trim(replace(string(round(t_sqExportVATQuarterSum.tdBaseRC,2),">>>>>>>>>>>>>>>>9.99":U) , ".":U, "":U)) no-error. */
    
    assign vcContentLine = STRING(viCustomerRecords,"999999":U) 
                         + STRING(t_sqExportVATQuarterSum.tcBusinessRelationNameEQS,"X(32)":U) 
                         + STRING(if avail tqAddressByBusinessRelation then tqAddressByBusinessRelation.tcAddressStreet1 else "":U, "X(24)":U) 
                         + STRING(if avail tqAddressByBusinessRelation then tqAddressByBusinessRelation.tcAddressZip + " ":U + tqAddressByBusinessRelation.tcAddressCity else "":U,"X(28)":U) 
                         + STRING(t_sqExportVATQuarterSum.tcCountryCodeEQS,"X(2)":U) 
                         + STRING(replace(t_sqExportVATQuarterSum.tcVatNumberIdentityEQS, ".":U, "":U), "X(12)":U)
                         + STRING("":U, "X(1)":U) 
                         + replace(replace(string(t_sqExportVATQuarterSum.tdBaseRC, "-9999999999999999.99":U), ".":U, "":U), " ":U, "0":U) 
                         + STRING(string(t_sqExportVATQuarterSum.tiAccPeriodEQS) + string(t_sqExportVATQuarterSum.tiAccYearEQS) ,"X(5)":U) 
                         + STRING("", "X(5)":U).
    
    /* === 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(t_sqExportVATQuarterSum.tcBusinessRelationNameEQS,"X(32)":U) +
                    STRING(if avail tqAddressByBusinessRelation then tqAddressByBusinessRelation.tcAddressStreet1 else "":U,"X(24)":U) +
                    STRING(if avail tqAddressByBusinessRelation then tqAddressByBusinessRelation.tcAddressZip + " ":U + tqAddressByBusinessRelation.tcAddressCity else "":U,"X(28)":U) +
                    STRING(t_sqExportVATQuarterSum.tcCountryCodeEQS,"X(2)":U) +
                    STRING(replace(t_sqExportVATQuarterSum.tcVatNumberIdentityEQS,".":U,"":U),"X(12)":U) +                
                    STRING("":U,"X(1)":U) +
                    (IF length(vcVatBaseString,"CHARACTER":U) <> 13 
                     THEN  SUBSTRING("0000000000000000":U,1,13 - length(vcVatBaseString,"CHARACTER":U),"CHARACTER":U) 
                     ELSE "" ) 
                     + vcVatBaseString +                
                    STRING(string(t_sqExportVATQuarterSum.tiAccPeriodEQS) + string(t_sqExportVATQuarterSum.tiAccYearEQS) ,"X(5)":U) +
                    STRING("","X(5)":U).
        === OLD CODE ====== */
    /* BTS 4975 - JLA */
    
    assign vdTotalBaseRC = vdTotalBaseRC + round(t_sqExportVATQuarterSum.tdBaseRC,2).
    
    create tqVatExportListing.
    assign tqVatExportListing.tiSequenceVEL = viCustomerRecords + 2.
           tqVatExportListing.tcContentVEL  = vcContentLine.

end.
/* end for each*/

/* Fetch Current Companies Company Data */
<Q-2 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-3 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).
    /* BTS 4975 - JLA */
    
    create tqVatExportListing.
    assign tqVatExportListing.tiSequenceVEL = 1
           tqVatExportListing.tcContentVEL  = vcContentLine.
    
    /* Record 000000*/
    /* BTS 4975 - JLA */
    assign vcContentLine = STRING("000000":U,"X(6)":U) +
                           STRING(tqCompanyByCodeActiveID.tcCompanyCode,"X(32)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressStreet1,"X(24)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressZip + " ":U + tqCompanyPropertyByBusinessRel.tcAddressCity,"X(28)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressCountryCode,"X(2)":U) +
                           STRING(replace(tqCompanyPropertyByBusinessRel.tcVatNumberIdentity,".":U,"":U),"X(9)":U) +
                           STRING("":U ,"X(17)":U) +
                           STRING(icPeriodYearForExportFile /* Period (Quarter/Year) QYYYY */ ,"X(5)":U) +
                           "E":U + 
                           STRING("":U,"X(4)":U). 
    /* BTS 4975 - JLA */
    
    create tqVatExportListing.
    assign tqVatExportListing.tiSequenceVEL = 2
           tqVatExportListing.tcContentVEL  = vcContentLine.
                    
    /* Record 999999*/
    /* BTS 4975 - JLA */
    assign vcContentLine = "999999":U +
                           STRING("":U,"X(84)":U) +
                           STRING(tqCompanyPropertyByBusinessRel.tcAddressCountryCode,"X(2)":U) +
                           STRING(replace(tqCompanyPropertyByBusinessRel.tcVatNumberIdentity,".":U,"":U),"X(9)":U) +
                           STRING("":U,"X(4)":U) +
                           replace(replace(string(vdTotalBaseRC, "-9999999999.99":U), ".":U, "":U), " ":U, "0":U) +
                           string(viCustomerRecords, "999999":U) + 
                           STRING("":U,"X(4)":U).
    /* BTS 4975 - JLA */
    
    create tqVatExportListing.
    assign tqVatExportListing.tiSequenceVEL = viCustomerRecords + 3
           tqVatExportListing.tcContentVEL  = vcContentLine.
end.