getting standard Shipping and Tax for SO

HI, Below sample code used to get shipping charges for sales order.

static real shippingCharges(SalesId _salesId)
{
QueryRun queryRun;
OSSDeliveryChargeTable deliveryChargeTable, table;
DlvMode mode;
SalesTable _salesTable = SalesTable::find(_salesId);
real shipping;
;

queryRun = new QueryRun(OSSDlvMode::query(_salesTable.CustAccount, _salesTable, _salesTable.DlvMode,
OCSCatalogueTable::find(OCSBrandTable::find(_salesTable.OSSBrandId).CatalogueId, false).ShippingChargegroupId));

while(queryRun.next())
{
deliveryChargeTable = queryRun.get(tablenum(OSSDeliveryChargeTable));
table = deliveryChargeTable;
if(deliveryChargeTable)
{
_salesTable.ossCreateMarkupTransFromChargeRecord(true, deliveryChargeTable, deliveryChargeTable.DlvModeId);
}
}
shipping = MarkupTrans::ossCalculateDeliveryCharges(_salesTable);

return shipping;
}

Getting tax(multiple ways):

displayFields = SalesTotals::displayFieldsServer(SalesTable::find(oldSalesId), SalesUpdate::All, ‘USD’);

tax = conPeek(displayFields, 16);
ossOrderValue.Tax = Tax;
if(!ossOrderValue.Tax)
ossOrderValue.Tax = SalesTable::find(oldSalesId).ossTaxCalc();
if(!ossOrderValue.Tax)
{
while select salesLineTax
where salesLineTax.SalesId == oldSalesId
{
tax += Tax::calcTaxAmount(salesLineTax.TaxGroup, salesLineTax.TaxItemGroup, Systemdateget(), salesLineTax.CurrencyCode,
salesLineTax.LineAmount + ossOrderValue.ShippingCharges, TaxModuleType::Sales);
}

ossOrderValue.Tax = tax;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s