project QadFinancials > class BDInvoice > method DefaultValuesShipFromShipTo

Description

default the ship to address from customer if only one is defined, default the ship from address from the cm_mstr, if filled


Parameters


iiDebtorIdinputinteger
icDebtorCodeinputcharacterDebtor Code
ocShipToBusinessRelationCodeoutputcharacterbusiness relation code of the ship to
ocShipToAddressTypeCodeoutputcharacterAddress type code of the ship to
ocShipToAddressStreet1outputcharacterStreet 1 of ship to
ocShipToAddressStreet2outputcharacterStreet 2 of Ship to
ocShipToAddressStreet3outputcharacterStreet 3 of Ship To
ocShipToAddressZipoutputcharacterzip of ship to
ocShipToAddressCityoutputcharactercity of Ship To
ocShipToAddressStateoutputcharacterstate of ship to
ocShipToCountryCodeoutputcharactercountry code of ship to
olShipToAddressIsTaxInCityoutputlogicalTax in city flag of ship to address
olShipToCountryIsEUCountryoutputlogicalIs the ship to country an EU Country
ocShipToTxzTaxZoneoutputcharacterTax zone of the ship to address
oiShipToAddressIdoutputintegerShip To Address ID
ocDebtorShipToCodeoutputcharacterDebtor Ship To Code
ocShipFromBusinessRelationCodeoutputcharactership from business relation code
ocShipFromAddressTypeCodeoutputcharactership From Address Type Code
ocShipFromAddressStreet1outputcharacterShip From Address Street 1
ocShipFromAddressStreet2outputcharacterShip From Address Street 2
ocShipFromAddressStreet3outputcharacterShip From Address Street 3
ocShipFromAddressZipoutputcharacterShip From Address Zip
ocShipFromAddressCityoutputcharacterShip From Address City
ocShipFromAddressStateoutputcharacterShip From Address State
ocShipFromCountryCodeoutputcharacterShip From Country Code
ocShipFromTaxIdStateoutputcharacterShip From Tax ID State
olShipFromCountryIsEUCountryoutputlogicalShip From Country Is EU Country
ocShipFromTaxZoneoutputcharacterShip From Tax Zone
oiShipFromAddressIdoutputintegerShip From Address ID
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.CreateDInvoices
method BDInvoice.DefaultValuesDebtor


program code (program6/bdinvoice.p)

if icDebtorCode = ? then assign icDebtorCode = "":U.

if icDebtorCode = "":U
then return.

<Q-26 run DebtorShipToByDebtorByAddress1 (first2) (Read) (NoCache)
   (input viCompanyId, (CompanyId)
    input icDebtorCode, (DebtorCode)
    input iiDebtorId, (DebtorID)
    output dataset tqDebtorShipToByDebtorByAddress1) in BDebtorShipToQuery> 
               
/* In case just one DebtorShiptTo is found, this is used */
find tqDebtorShipToByDebtorByAddress1 where
     tqDebtorShipToByDebtorByAddress1.tcDebtorCode = icDebtorCode
     no-error.
if available tqDebtorShipToByDebtorByAddress1
then do:
     assign ocDebtorShipToCode           = tqDebtorShipToByDebtorByAddress1.tcDebtorShipToCode
            ocShipToBusinessRelationCode = tqDebtorShipToByDebtorByAddress1.tcBusinessRelationCode
            ocShipToAddressTypeCode      = tqDebtorShipToByDebtorByAddress1.tcAddressTypeCode
            ocShipToAddressStreet1       = tqDebtorShipToByDebtorByAddress1.tcAddressStreet1
            ocShipToAddressStreet2       = tqDebtorShipToByDebtorByAddress1.tcAddressStreet2
            ocShipToAddressStreet3       = tqDebtorShipToByDebtorByAddress1.tcAddressStreet3
            ocShipToAddressZip           = tqDebtorShipToByDebtorByAddress1.tcAddressZip
            ocShipToAddressCity          = tqDebtorShipToByDebtorByAddress1.tcAddressCity
            ocShipToAddressState         = tqDebtorShipToByDebtorByAddress1.tcStateCode
            ocShipToCountryCode          = tqDebtorShipToByDebtorByAddress1.tcCountryCode
            olShipToAddressIsTaxInCity   = tqDebtorShipToByDebtorByAddress1.tlAddressIsTaxInCity
            olShipToCountryIsEUCountry   = tqDebtorShipToByDebtorByAddress1.tlCountryIsEUCountry
            ocShipToTxzTaxZone           = tqDebtorShipToByDebtorByAddress1.tcTxzTaxZone
            oiShipToAddressId            = tqDebtorShipToByDebtorByAddress1.tiAddress_ID.
                
end. /* available tqDebtorShipToByDebtorByAddress11 */

else do:
    <Q-5 run DebtorByDebtor (first) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressType)
        input ?, (DebtorId)
        input icDebtorCode, (DebtorCode)
        output dataset tqDebtorByDebtor) in BDebtor >
    find first tqDebtorByDebtor where
               tqDebtorByDebtor.tcDebtorCode = icDebtorCode and
               tqDebtorByDebtor.tcAddressTypeCode = {&ADDRESSTYPECODESYSTEM-HEADOFFICE}
               no-error.
    if not available tqDebtorByDebtor
    then return.
    assign ocDebtorShipToCode           = icDebtorCode
           ocShipToBusinessRelationCode = tqDebtorByDebtor.tcBusinessRelationCode
           ocShipToAddressTypeCode      = tqDebtorByDebtor.tcAddressTypeCode
           ocShipToAddressStreet1       = tqDebtorByDebtor.tcAddressStreet1
           ocShipToAddressStreet2       = tqDebtorByDebtor.tcAddressStreet2
           ocShipToAddressStreet3       = tqDebtorByDebtor.tcAddressStreet3
           ocShipToAddressZip           = tqDebtorByDebtor.tcAddressZip
           ocShipToAddressCity          = tqDebtorByDebtor.tcAddressCity
           ocShipToAddressState         = tqDebtorByDebtor.tcStateCode
           ocShipToCountryCode          = tqDebtorByDebtor.tcCountryCode
           olShipToAddressIsTaxInCity   = tqDebtorByDebtor.tlAddressIsTaxInCity
           olShipToCountryIsEUCountry   = tqDebtorByDebtor.tlCountryIsEUCountry
           ocShipToTxzTaxZone           = tqDebtorByDebtor.tcTxzTaxZone
           oiShipToAddressId            = tqDebtorByDebtor.tiAddress_ID.
end. /* end else vlFcQueryRecordsAvailable */

<Q-8 run CustomerByDomainAddress (all) (Read) (NoCache)
   (input vcDomainCode, (DomainCode)
    input icDebtorCode, (Address)
    output dataset tqCustomerByDomainAddress) in BMfgCustomer >
find first tqCustomerByDomainAddress where
           tqCustomerByDomainAddress.tccm_domain = vcDomainCode and
           tqCustomerByDomainAddress.tccm_addr   = icDebtorCode
           no-error.
if available tqCustomerByDomainAddress
then do:
    if tqCustomerByDomainAddress.tccm_site <> "":U
    then do:
        /* don't pass the companyid, because the si_entity is not the current company */
        <Q-9 run CompanyPropertyForSiteAddress (all) (Read) (NoCache)
           (input ?, (CompanyId)
            input vcDomainCode, (DomainCode)
            input tqCustomerByDomainAddress.tccm_site, (Site)
            output dataset tqCompanyPropertyForSiteAddress) in BCompanyProperty >
        find first tqCompanyPropertyForSiteAddress where
                   tqCompanyPropertyForSiteAddress.tcsi_domain = vcDomainCode and
                   tqCompanyPropertyForSiteAddress.tcsi_site   = tqCustomerByDomainAddress.tccm_site
                   no-error.
        if available tqCompanyPropertyForSiteAddress
        then assign ocShipFromBusinessRelationCode = tqCompanyPropertyForSiteAddress.tcBusinessRelationCode
                    ocShipFromAddressTypeCode      = tqCompanyPropertyForSiteAddress.tcAddressTypeCode
                    ocShipFromAddressStreet1       = tqCompanyPropertyForSiteAddress.tcAddressStreet1
                    ocShipFromAddressStreet2       = tqCompanyPropertyForSiteAddress.tcAddressStreet2
                    ocShipFromAddressStreet3       = tqCompanyPropertyForSiteAddress.tcAddressStreet3
                    ocShipFromAddressZip           = tqCompanyPropertyForSiteAddress.tcAddressZip
                    ocShipFromAddressCity          = tqCompanyPropertyForSiteAddress.tcAddressCity
                    ocShipFromAddressState         = tqCompanyPropertyForSiteAddress.tcAddressState
                    ocShipFromCountryCode          = tqCompanyPropertyForSiteAddress.tcCountryCode
                    ocShipFromTaxIdState           = tqCompanyPropertyForSiteAddress.tcAddressTaxIDState
                    olShipFromCountryIsEUCountry   = tqCompanyPropertyForSiteAddress.tlCountryIsEUCountry
                    ocShipFromTaxZone              = tqCompanyPropertyForSiteAddress.tcTxzTaxZone
                    oiShipFromAddressId            = tqCompanyPropertyForSiteAddress.tiAddress_ID.

    end. /* end if tqCustomerByDomainAddress.tccm_site <> "":U */
    else do:
        assign vcMessage      = (#T-11'Customer data is not complete. Re-enter.':255(69626)t-11#)
               vcMessage = vcMessage + #T-20'Customer Code:':15(65571)T-20# + " " +  icDebtorCode .
               oiReturnStatus = -1.
        <M-10 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-8202':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        return.
    end. /* end else if tqCustomerByDomainAddress.tccm_site <> "":U */
end. /* end avaialable tqCustomerByDomainAddress */