package devopsdistilled.operp.server.data.entity.business;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import devopsdistilled.operp.server.data.entity.Entiti;

@MappedSuperclass
public abstract class BusinessDesc<B extends Business<?, ?>, DR extends BusinessDescRow<?>>
		extends Entiti<Long> {

	private static final long serialVersionUID = 7790361115068372068L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	protected Long businessDescId;

	@OneToOne(mappedBy = "businessDesc")
	protected B business;

	@OneToMany(mappedBy = "businessDesc", cascade = CascadeType.ALL)
	protected List<DR> descRows = new LinkedList<>();

	private Double discountAmount = 0.0;

	private Double TotalAmount = 0.0;

	public Double getDiscountAmount() {
		return discountAmount;
	}

	public void setDiscountAmount(Double discountAmount) {
		this.discountAmount = discountAmount;
	}

	public Double getTotalAmount() {
		return TotalAmount;
	}

	public void setTotalAmount(Double totalAmount) {
		TotalAmount = totalAmount;
	}

	public List<DR> getDescRows() {
		return descRows;
	}

	public void setDescRows(List<DR> descRows) {
		this.descRows = descRows;
	}

	@Override
	public Long id() {
		return businessDescId;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}

}

@@ -938,16 +938,50 @@
 = 0.0;%0A%0A
+%09// Total Amount without Discount%0A
 %09private
@@ -988,17 +988,17 @@
  Double 
-T
+t
 otalAmou
@@ -1162,32 +1162,94 @@
 discountAmount;%0A
+%09%09business.setAmount(getTotalAmount() - getDiscountAmount());%0A
 %09%7D%0A%0A%09public Doub
@@ -1279,17 +1279,17 @@
 %09return 
-T
+t
 otalAmou
@@ -1348,17 +1348,22 @@
 nt) %7B%0A%09%09
-T
+this.t
 otalAmou
@@ -1372,32 +1372,94 @@
  = totalAmount;%0A
+%09%09business.setAmount(getTotalAmount() - getDiscountAmount());%0A
 %09%7D%0A%0A%09public List

Update Business.amout on businessDesc update