project QadFinancials > class BPosting > method AddTaxPostingAddress

Description

get the tax id's for the ship from and ship to address


Parameters


iiShipFromAddressIdinputintegerShip From Address ID
iiShipToAddressIdinputintegerShip To Address ID
ilCustomerInvoiceinputlogicalCustomer invoice or not ?
iiCreditorIdinputintegerCreditor ID : used to search the right creditor and to fill the tax id fields of posting vat
icSoldToDebtorCodeinputcharacterSold To Debtor Code : if that is filled, then fill the tax id fields of postingvat with those of the sold to debtor
ocOwnTaxIdFederaloutputcharacterOwn Tax ID federal
ocOwnTaxIdStateoutputcharacterOwn Tax ID State
ocOwnTaxIdMisc1outputcharacterOwn Tax ID Misc 1
ocOwnTaxIdMisc2outputcharacterOwn Tax ID Misc 2
ocOwnTaxIdMisc3outputcharacterOwn Tax ID Misc 3
oiOwnTaxDeclarationoutputintegerOwn Tax Declaration
ocTaxIdFederaloutputcharacterTax Id Federal
ocTaxIdStateoutputcharacterTax ID State
ocTaxIdMisc1outputcharacterTax Id Misc 1
ocTaxIdMisc2outputcharacterTax ID Misc 2
ocTaxIdMisc3outputcharacterTax ID Misc 3
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.AddTaxPosting


program code (program6/bposting.p)

if ilCustomerInvoice
then do :
    if iiShipFromAddressId <> 0
    then do:
        <Q-1 run AddressById (all) (Read) (NoCache)
           (input iiShipFromAddressId, (AddressID)
            output dataset tqAddressById) in BBusinessRelation >
        find first tqAddressById where
                   tqAddressById.tiAddress_ID = iiShipFromAddressId 
                   no-error.
        if available tqAddressById
        then assign ocOwnTaxIdFederal = tqAddressById.tcAddressTaxIDFederal
                    ocOwnTaxIdState   = tqAddressById.tcAddressTaxIDState
                    ocOwnTaxIdMisc1   = tqAddressById.tcAddressTaxIDMisc1
                    ocOwnTaxIdMisc2   = tqAddressById.tcAddressTaxIDMisc2
                    ocOwnTaxIdMisc3   = tqAddressById.tcAddressTaxIDMisc3.
    end.
    if icSoldToDebtorCode <> "":U
    then do:
        <Q-3 run DebtorByBusinessRelation (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input icSoldToDebtorCode, (DebtorCode)
            input ?, (DebtorId)
            input ?, (BusinessRelationID)
            output dataset tqDebtorByBusinessRelation) in BDebtor >
        find first tqDebtorByBusinessRelation where
                   tqDebtorByBusinessRelation.tcDebtorCode = icSoldToDebtorCode
                   no-error.
        if available tqDebtorByBusinessRelation
        then assign ocTaxIdFederal = tqDebtorByBusinessRelation.tcDebtorTaxIDFederal
                    ocTaxIdState   = tqDebtorByBusinessRelation.tcDebtorTaxIDState
                    ocTaxIdMisc1   = tqDebtorByBusinessRelation.tcDebtorTaxIDMisc1
                    ocTaxIdMisc2   = tqDebtorByBusinessRelation.tcDebtorTaxIDMisc2
                    ocTaxIdMisc3   = tqDebtorByBusinessRelation.tcDebtorTaxIDMisc3.
    end.
    else do:
        if iiShipToAddressId <> 0
        then do:
            <Q-4 run AddressById (all) (Read) (NoCache)
               (input iiShipToAddressId, (AddressID)
                output dataset tqAddressById) in BBusinessRelation >
            find first tqAddressById where
                       tqAddressById.tiAddress_ID = iiShipToAddressId 
                       no-error.
            if available tqAddressById
            then assign ocTaxIdFederal = tqAddressById.tcAddressTaxIDFederal
                        ocTaxIdState   = tqAddressById.tcAddressTaxIDState
                        ocTaxIdMisc1   = tqAddressById.tcAddressTaxIDMisc1
                        ocTaxIdMisc2   = tqAddressById.tcAddressTaxIDMisc2
                        ocTaxIdMisc3   = tqAddressById.tcAddressTaxIDMisc3.
        end.
    end.
end.
else do :
    if iiCreditorId <> 0
    then do:
        <Q-5 run CreditorAllInfo (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input iiCreditorId, (Creditor_ID)
            output dataset tqCreditorAllInfo) in BCreditor >
        find first tqCreditorAllInfo where
                   tqCreditorAllInfo.tiCreditor_ID = iiCreditorId
                   no-error.
        if available tqCreditorAllInfo
        then assign ocTaxIdFederal = tqCreditorAllInfo.tcCreditorTaxIDFederal
                    ocTaxIdState   = tqCreditorAllInfo.tcCreditorTaxIDState
                    ocTaxIdMisc1   = tqCreditorAllInfo.tcCreditorTaxIDMisc1
                    ocTaxIdMisc2   = tqCreditorAllInfo.tcCreditorTaxIDMisc2
                    ocTaxIdMisc3   = tqCreditorAllInfo.tcCreditorTaxIDMisc3.
    end.

    if iiShipToAddressId <> 0
    then do:
        <Q-2 run AddressById (all) (Read) (NoCache)
           (input iiShipToAddressId, (AddressID)
            output dataset tqAddressById) in BBusinessRelation >
        find first tqAddressById where
                   tqAddressById.tiAddress_ID = iiShipToAddressId 
                   no-error.
        if available tqAddressById
        then assign ocOwnTaxIdFederal = tqAddressById.tcAddressTaxIDFederal
                    ocOwnTaxIdState   = tqAddressById.tcAddressTaxIDState
                    ocOwnTaxIdMisc1   = tqAddressById.tcAddressTaxIDMisc1
                    ocOwnTaxIdMisc2   = tqAddressById.tcAddressTaxIDMisc2
                    ocOwnTaxIdMisc3   = tqAddressById.tcAddressTaxIDMisc3.
    end.
end.