Wednesday, June 21, 2023

Total Discount in Sales order header.

·       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))]

internal final class DAX_SalesTable_Extension

   public void modifiedField(FieldId _fieldId)

    {      

  SalesTable      salestable = this;    

    SalesLine       salesline;       

 next modifiedField(_fieldId);   

     select sum(LineAmount) from salesline

             where salesline.SalesId == salestable.SalesId;   

     switch(_fieldId)      

  {      

      case fieldnum(salestable,DAX_TotalDiscountAmount):           

     this.DAX_TotalDiscountPercentahe = this.DAX_TotalDiscountAmount/salesLine.LineAmount*100;      

          break;          

  case fieldnum(salestable,DAX_TotalDiscountPercentahe):     

           this.DAX_TotalDiscountAmount = (this.DAX_TotalDiscountPercentahe/100)*salesLine.LineAmount;

                break;   

         default:    

    }   

 } 

 }


[ExtensionOf(classStr(TradeTotals))]
internal final class DAX_TradeTotals_Extension
{   
 public DiscAmount  totalEndDisc()    
{      
  SalesTable salestable;    
    endDisc =  next   totalEndDisc();     
   salestable = orderTable;      
  if(salestable.SalesStatus != SalesStatus::Invoiced)   
     {     
   enddisc = salestable.DAX_TotalDiscountAmount;      
  return enddisc;
        }       
 return endDisc; 
          }
  }











No comments:

Post a Comment

My Requirement is Delete option in Vendor Master for all roles except System Administrator

   [FormControlEventHandler(formControlStr(VendParameters, VendParameters_YNV_VendorMasterDeletionOption), FormControlEventType::Modified)] ...