My requirement is to update the sales totals based on custom fields data.
· Create two
separate fields in Sales order header.
o
Total Discount in Amount
o
Total Discount %
· The
user can enter either Total discount % or Total discount amount, if the user
has entered the discount %, the total discount amount need to be calculated and
show.
· If
the user has entered the total discount amount, then system need to calculate
the total discount % and show.
· Need
to calculate the total discount after the line discount calculation.
· The
calculated total discount value need to push it to on the Sales total form.
(Standard field).
· Once
it is pushed to standard field (Total discount), the system will take care of
postings.
[ ExtensionOf(tableStr(SalesTable))]
final class DaxSalesTable_Extension
{
public void modifiedField(FieldId _fieldId)
{
SalesLine salesLine;
select sum(LineAmount) from salesLine
where salesLine.SalesId == this.SalesId;
next modifiedField(_fieldId);
switch (_fieldId)
{
case fieldnum(SalesTable, TotalDiscountAmount):
this.TotalDiscountPercentage = this.TotalDiscountAmount/salesLine.LineAmount*100;
break;
case fieldnum(SalesTable, TotalDiscountPercentage):
this.TotalDiscountAmount = (this.TotalDiscountPercentage/100)*salesLine.LineAmount;
break;
}
}
[ExtensionOf(classStr(TradeTotals))]
internal final class DaxTradetotals_Extension
{
public DiscAmount totalEndDisc()
{
real oldvalue;
SalesTable salesTableloc = orderTable;
oldvalue = next totalEndDisc();
endDisc = salesTableloc.TotalDiscountAmount;
if(salesTableloc.SalesStatus == SalesStatus::Invoiced)
{
oldvalue = 0;
return oldvalue;
}
else
{
return endDisc;
}
}
}
}
Open Order Totals:
No comments:
Post a Comment