• John Davies 14
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi
I have the following piece of code in an Apex Class
 
    public class LineItem {
        public String productCode {get; set;}
        public String productName {get; set;}
        public Decimal quantity {get; set;}
        public Decimal unitPrice {get; set;}
        public Decimal ListEX {get; set;}
        public Decimal ListSubtotal {get; set;}
        public Decimal VAT {get; set;}
        public Decimal subTotal {get; set;}
        public Decimal totalWithVAT {get; set;}
        
        
        public LineItem(String productCode, String productName, Decimal quantity, Decimal unitPrice, Decimal VAT , Decimal ListEX, Decimal ListSubtotal) {
            this.productCode = productCode;
            this.productName = productName;
            this.quantity = quantity;
            this.unitPrice = unitPrice;
            this.ListEX = ListEX ;
            this.ListSubtotal = ListSubtotal ;
            if ( VAT == null ) {
                this.VAT = 0.0;
            } else {
                this.VAT = VAT;
            }
            this.subTotal = (this.quantity * this.unitPrice).setScale(2);
            this.totalWithVAT = (this.quantity * (this.unitPrice + this.VAT)).setScale(2);
        }

I want to change how subTotal is calculated , I want to use a new field instead of unitPrice - how do I do that