static void NetAmountwithdiscounts(Args _args)
{
SalesLine salesline;
PriceDisc_Price priceDisc_Price = PriceDisc_Price::construct();
PriceDisc_LineDisc priceDisc_LineDisc = PriceDisc_LineDisc::construct();
InventDim inventDim;
AmountCur LineAmount;
salesline = SalesLine::findInventTransId("015331");
priceDisc_Price.parmModuleType( ModuleInventPurchSales::Sales);
priceDisc_Price.parmItemId(salesline.ItemId);
priceDisc_Price.parmInventDim(salesline.inventDim());
priceDisc_Price.parmUnitID(salesline.SalesUnit);
priceDisc_Price.parmPriceDate(systemDateGet());
priceDisc_Price.parmQty(salesline.SalesQty);
//priceDisc_Price.parmAccountNum(SalesTable::find(salesline.SalesId).CustAccount);
priceDisc_Price.parmCurrencyCode(salesline.CurrencyCode);
priceDisc_Price.parmPriceGroupId("");
priceDisc_LineDisc.parmAccountLineDiscCode();
priceDisc_LineDisc.parmItemLineDiscCode(InventTableModule::find(salesline.ItemId, ModuleInventPurchSales::Sales).LineDisc);
priceDisc_LineDisc.findLineDiscAgreement();
print priceDisc_Price.price();
print priceDisc_Price.priceUnit();
print priceDisc_LineDisc.discAmount(); //linedisc
print priceDisc_LineDisc.discPct(); //LinePercent
pause;
/* LineAmount = PriceDisc::price2Amount(priceDisc_Price.price(),
priceDisc_Price.priceUnit(), //1
PriceDisc::discAmount(SalesParameters::find().Disc, priceDisc_LineDisc.discAmount(), 0),//should call this,
1, // deliver now
1,
0,
PriceDisc::discPercent(SalesParameters::find().Disc, priceDisc_LineDisc.discPct(), 0),
"USD",
0,
true);
print LineAmount;
pause;*/
}
===========================================================
PriceDiscPolicyCheckPolicy checkPolicy;
SalesLine salesline = _salesline;
salesline.ManualEntryChangepolicy = 0;
salesline.SystemEntryChangePolicy = 0;
checkPolicy = PriceDiscPolicyCheckPolicy::newFromParm(salesline.PriceDiscResultFields::parmPriceDiscResultFields());
if(salesline)
{
salesline.selectForUpdate(true);
ttsBegin;
salesline.salesPurchLine::resetPriceAgreement();
salesline.setPriceAgreement(salesline.inventDim(), null ,false,null);
//salesline.LineAmount = salesline.calcLineAmountForced(salesline.SalesQty, checkPolicy);
salesline.update();
ttsCommit;
}
return salesline;
{
SalesLine salesline;
PriceDisc_Price priceDisc_Price = PriceDisc_Price::construct();
PriceDisc_LineDisc priceDisc_LineDisc = PriceDisc_LineDisc::construct();
InventDim inventDim;
AmountCur LineAmount;
salesline = SalesLine::findInventTransId("015331");
priceDisc_Price.parmModuleType( ModuleInventPurchSales::Sales);
priceDisc_Price.parmItemId(salesline.ItemId);
priceDisc_Price.parmInventDim(salesline.inventDim());
priceDisc_Price.parmUnitID(salesline.SalesUnit);
priceDisc_Price.parmPriceDate(systemDateGet());
priceDisc_Price.parmQty(salesline.SalesQty);
//priceDisc_Price.parmAccountNum(SalesTable::find(salesline.SalesId).CustAccount);
priceDisc_Price.parmCurrencyCode(salesline.CurrencyCode);
priceDisc_Price.parmPriceGroupId("");
priceDisc_LineDisc.parmAccountLineDiscCode();
priceDisc_LineDisc.parmItemLineDiscCode(InventTableModule::find(salesline.ItemId, ModuleInventPurchSales::Sales).LineDisc);
priceDisc_LineDisc.findLineDiscAgreement();
print priceDisc_Price.price();
print priceDisc_Price.priceUnit();
print priceDisc_LineDisc.discAmount(); //linedisc
print priceDisc_LineDisc.discPct(); //LinePercent
pause;
/* LineAmount = PriceDisc::price2Amount(priceDisc_Price.price(),
priceDisc_Price.priceUnit(), //1
PriceDisc::discAmount(SalesParameters::find().Disc, priceDisc_LineDisc.discAmount(), 0),//should call this,
1, // deliver now
1,
0,
PriceDisc::discPercent(SalesParameters::find().Disc, priceDisc_LineDisc.discPct(), 0),
"USD",
0,
true);
print LineAmount;
pause;*/
}
===========================================================
PriceDiscPolicyCheckPolicy checkPolicy;
SalesLine salesline = _salesline;
salesline.ManualEntryChangepolicy = 0;
salesline.SystemEntryChangePolicy = 0;
checkPolicy = PriceDiscPolicyCheckPolicy::newFromParm(salesline.PriceDiscResultFields::parmPriceDiscResultFields());
if(salesline)
{
salesline.selectForUpdate(true);
ttsBegin;
salesline.salesPurchLine::resetPriceAgreement();
salesline.setPriceAgreement(salesline.inventDim(), null ,false,null);
//salesline.LineAmount = salesline.calcLineAmountForced(salesline.SalesQty, checkPolicy);
salesline.update();
ttsCommit;
}
return salesline;
No comments:
Post a Comment