package com.reallinkbilling.add;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.reallinkbilling.DAO.BillInformationDAO;
import com.reallinkbilling.DAO.BillProductInfoDAO;
import com.reallinkbilling.db.GetDBConnection;
import com.reallinkbilling.resource.GetListResource;

public class SaveAndPrintProforma extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = -4205886934505595095L;
	private HttpSession session;
	private SessionMap<String, Object> sessionMap;
	private BillInformationDAO proformaInfoDAO = null;
	private List<BillProductInfoDAO> productInfoList = null;
	private Map<String, String> taxList = new LinkedHashMap<String, String>();
	private Map<String, String> unitList = new LinkedHashMap<String, String>();
	private String defaultValue;
	private String billType;
	private String printType;
	private String customerName;
	private String billNumber;
	private String billDateTime;
	private String totalAmount;
	private String totalDiscount;
	private String totalAmouAfterDisount;
	private String totalPaybleAmount;
	private Float amountPaid;
	private Float transportCharge;
	private String returnAmount;
	private String comments;
	private String alternateMobileNumber;
	private boolean sendSMS;
	private boolean billSaved;
	private String addSideBarJs;

	// Proforma extra fields coming from save form
	private Integer validityDays;
	private String validityUpto;
	private String paymentTerms;
	private String deliveryTerms;
	private Float advancePercent;
	private Float advanceAmount;

	private String discountType;

	private Map<String, String> discountTypeList = new HashMap<String, String>();
	private Map<String, String> rateTypeList = new LinkedHashMap<String, String>();
	private String rateType;

	@SuppressWarnings("unchecked")
	public String execute() {

		String result = "login";
		session = ServletActionContext.getRequest().getSession(false);

		if (session == null || session.getAttribute("login") == null) {
			addActionMessage(this.getText("message.error.plzloginfirst"));
			result = "login";
		} else {

			String billInfoTable = "proforma_info";
			String billInfoProductTable = "product_proforma_info";

			String fullUserName = (String) this.getSessionMap().get("userFullName");

			String splitUserName[] = new String[5];

			String billedBy = "";
			try {
				splitUserName = fullUserName.split(" ");
				billedBy = splitUserName[0];

			} catch (Exception e) {
				billedBy = fullUserName;
			}

			String shopId = (String) this.getSessionMap().get("shopId");
			String shopCode = (String) this.getSessionMap().get("shopCode");

			String billDateTime = "";

			billDateTime = this.getProformaInfoDAO().getBillDate();

			if (billDateTime == null || billDateTime == "") {
				Date d = new Date();
				SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
				billDateTime = dateFormat.format(d);

			}

			Connection connection = null;
			PreparedStatement preparedStatement = null;
			ResultSet resultSet = null;

			String sql = "";
			String db = (String) session.getAttribute("db");

			this.setProductInfoList((List<BillProductInfoDAO>) this.getSessionMap().get("proformaProductList"));

			this.setProformaInfoDAO((BillInformationDAO) this.getSessionMap().get("proformaInformation"));

			// Update DAO with latest header fields from save form (validity/terms/advance/comment)
			if (this.getProformaInfoDAO() == null) {
				this.setProformaInfoDAO(new BillInformationDAO());
			}
			if (this.getComments() != null) {
				this.getProformaInfoDAO().setComments(this.getComments());
			}
			if (this.getValidityDays() != null) {
				this.getProformaInfoDAO().setValidityDays(this.getValidityDays());
			}
			if (this.getValidityUpto() != null && this.getValidityUpto().trim().length() > 0) {
				this.getProformaInfoDAO().setValidityUpto(this.getValidityUpto());
			}
			if (this.getPaymentTerms() != null) {
				this.getProformaInfoDAO().setPaymentTerms(this.getPaymentTerms());
			}
			if (this.getDeliveryTerms() != null) {
				this.getProformaInfoDAO().setDeliveryTerms(this.getDeliveryTerms());
			}
			if (this.getAdvancePercent() != null) {
				this.getProformaInfoDAO().setAdvancePercent(this.getAdvancePercent());
			}
			if (this.getAdvanceAmount() != null) {
				this.getProformaInfoDAO().setAdvanceAmount(this.getAdvanceAmount());
			}

			if (!this.getProformaInfoDAO().isBillSaved()) {

				float floatTotalAmount = 0.0F;
				float floatTotalDiscount = 0.0F;
				float floatTotalAmtAfterDiscount = 0.0F;

				for (BillProductInfoDAO infoDAO : this.getProductInfoList()) {
					floatTotalAmount = floatTotalAmount + infoDAO.getAmount();
					floatTotalAmtAfterDiscount = floatTotalAmtAfterDiscount + infoDAO.getAmountAfterDiscount();
					floatTotalDiscount = floatTotalDiscount + infoDAO.getProductTotalDiscount();

				}

				try {

					java.util.Date date = new java.util.Date();
					long t = date.getTime();
					java.sql.Time time = new java.sql.Time(t);

					connection = GetDBConnection.getDBConnection(db);
					connection.setAutoCommit(false);

					String[] custNameDetails = new String[5];
					try {
						String[] custNameDetails2 = this.getProformaInfoDAO().getCustomerName().split("-");

						if (custNameDetails2.length == 2) {
							custNameDetails = new String[3];

							custNameDetails[0] = "1";
							custNameDetails[1] = custNameDetails2[0];
							custNameDetails[2] = custNameDetails2[1];
						}

						else if (custNameDetails2.length < 2) {
							custNameDetails = new String[3];

							custNameDetails[0] = "1";
							custNameDetails[1] = this.getProformaInfoDAO().getCustomerName();
							custNameDetails[2] = "9999999999";
						} else if (custNameDetails2.length > 2) {
							custNameDetails = new String[3];
							custNameDetails[0] = custNameDetails2[0];
							custNameDetails[1] = custNameDetails2[1];
							custNameDetails[2] = custNameDetails2[2];
						} else if (custNameDetails2.length < 1) {
							custNameDetails = new String[3];
							custNameDetails[0] = "1";
							custNameDetails[1] = this.getProformaInfoDAO().getCustomerName();
							custNameDetails[2] = "9999999999";
						}

						this.getProformaInfoDAO().setCustomerName(
								custNameDetails[0] + "-" + custNameDetails[1] + "-" + custNameDetails[2]);

					} catch (Exception e) {
						custNameDetails[0] = "1";
						custNameDetails[1] = this.getProformaInfoDAO().getCustomerName();
						custNameDetails[2] = "9999999999";

						this.getProformaInfoDAO().setCustomerName(
								custNameDetails[0] + "-" + custNameDetails[1] + "-" + custNameDetails[2]);
					}

					String custId = "1";

					try {
						custId = custNameDetails[0];
					} catch (Exception e) {
						addActionError(this.getText("message.error.plzProvideCorrectCustomerIdAndName"));
					}

					if (this.getProformaInfoDAO().getBillNumber().equalsIgnoreCase("NA")) {

						sql = "SELECT proformanumber "
								+ "FROM "
								+ billInfoTable
								+ " WHERE shop_id = ? AND shop_code = ? ORDER BY proformanumber DESC LIMIT 1";

						preparedStatement = connection.prepareStatement(sql);
						preparedStatement.setString(1, shopId);
						preparedStatement.setString(2, shopCode);

						resultSet = preparedStatement.executeQuery();

						int newBillNumber = 0;
						if (resultSet.next()) {
							if (!(resultSet.getString(1) == null)) {
								newBillNumber = Integer.parseInt(resultSet.getString(1));

								this.getProformaInfoDAO().setBillNumber("" + (newBillNumber + 1));
							} else {
								newBillNumber = 1;
								this.getProformaInfoDAO().setBillNumber("" + (newBillNumber));

							}
						} else {
							newBillNumber = 1;
							this.getProformaInfoDAO().setBillNumber("" + (newBillNumber));
						}
					}
					if (resultSet != null) {
						resultSet.close();
						resultSet = null;
					}
					if (preparedStatement != null) {
						preparedStatement.close();
						preparedStatement = null;
					}

					if (getReturnAmount() == null || getReturnAmount().equals("")) {

						float amountPaid = 0.0F;
						try {
							amountPaid = this.getAmountPaid();

							this.setReturnAmount("" + (floatTotalAmtAfterDiscount - amountPaid));
						} catch (Exception e) {
						}

					}
					int countBillInfoInserted = 0;

					float transportChargeFloat = 0.0F;

					String user = (String) this.getSessionMap().get("userFullName");
					String shortName = "";

					try {
						shortName = user.split(" ")[0];
					} catch (Exception e) {
						shortName = user;
					}

					if (!this.getProformaInfoDAO().isBillInformationInserted()) {

						try {
							transportChargeFloat = this.getProformaInfoDAO().getTransportCharge();
						} catch (NumberFormatException nfe) {
						}

						sql = "INSERT INTO "
								+ billInfoTable
								+ "( "
								+ "proformanumber,"
								+ "shop_id,"
								+ "shop_code,"
								+ "proformatime,"
								+ "proformadate,"
								+ "customername,"
								+ "transportcharges,"
								+ "comments,"
								+ "proformatotalamount,"
								+ "custid, "
								+ "proforma_by,"
								+ "discount_type,"
								+ "validity_days,"
								+ "validity_upto,"
								+ "payment_terms,"
								+ "delivery_terms,"
								+ "advance_percent,"
								+ "advance_amount"
								+ " ) "
								+ "VALUES "
								+ "(?,?,?,?,STR_TO_DATE(?, '%d-%m-%Y'),?,?,?,?,?,?,?,?,?,?,?,?,?)";

						preparedStatement = connection.prepareStatement(sql);

						preparedStatement.setString(1, this.getProformaInfoDAO().getBillNumber());
						preparedStatement.setString(2, shopId);
						preparedStatement.setString(3, shopCode);
						preparedStatement.setTime(4, time);
						preparedStatement.setString(5, this.getProformaInfoDAO().getBillDate());
						preparedStatement.setString(6, this.getProformaInfoDAO().getCustomerName());
						preparedStatement.setFloat(7, this.getProformaInfoDAO().getTransportCharge());
						preparedStatement.setString(8, this.getProformaInfoDAO().getComments());
						preparedStatement.setString(9,
								"" + (floatTotalAmtAfterDiscount + this.getProformaInfoDAO().getTransportCharge()));
						preparedStatement.setString(10, custId);
						preparedStatement.setString(11, billedBy);
						preparedStatement.setString(12, "PERQUANTITY");
						preparedStatement.setInt(13, this.getProformaInfoDAO().getValidityDays() == null ? 0
								: this.getProformaInfoDAO().getValidityDays());
						preparedStatement.setString(14, this.getProformaInfoDAO().getValidityUpto());
						preparedStatement.setString(15, this.getProformaInfoDAO().getPaymentTerms());
						preparedStatement.setString(16, this.getProformaInfoDAO().getDeliveryTerms());
						preparedStatement.setFloat(17,
								this.getProformaInfoDAO().getAdvancePercent() == null ? 0.0F
										: this.getProformaInfoDAO().getAdvancePercent());
						preparedStatement.setFloat(18,
								this.getProformaInfoDAO().getAdvanceAmount() == null ? 0.0F
										: this.getProformaInfoDAO().getAdvanceAmount());

						

						countBillInfoInserted = preparedStatement.executeUpdate();
						

						if (preparedStatement != null) {
							preparedStatement.close();
							preparedStatement = null;
						}

					}

					if (countBillInfoInserted > 0) {

						int listSize = this.getProductInfoList().size();

						sql = "INSERT INTO "
								+ billInfoProductTable
								+ " ("
								+ "proformanumber,"
								+ "shop_id,"
								+ "shop_code,"
								+ "productname,"
								+ "salesunit,"
								+ "taxpercentage,"
								+ "salesrate,"
								+ "quanity,"
								+ "discountpercentage,"
								+ "discountrupees,"
								+ "productamount,"
								+ "productamtafterdiscount,"
								+ "grossamount,"
								+ "igst,"
								+ "cgst,"
								+ "sgst,"
								+ "productnamemarathi"
								+ ") values "
								+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

						preparedStatement = connection.prepareStatement(sql);

						for (BillProductInfoDAO productInfoDAO : this.getProductInfoList()) {

							DecimalFormat df = new DecimalFormat("##.##");

							preparedStatement.setString(1, this.getProformaInfoDAO().getBillNumber());
							preparedStatement.setString(2, shopId);
							preparedStatement.setString(3, shopCode);
							preparedStatement.setString(4, productInfoDAO.getProductName());
							preparedStatement.setString(5, productInfoDAO.getSalesUnit());
							preparedStatement.setString(6, productInfoDAO.getTaxId());
							preparedStatement.setFloat(7, productInfoDAO.getSalesRate());
							preparedStatement.setFloat(8, productInfoDAO.getQuantity());
							preparedStatement.setFloat(9, productInfoDAO.getDiscountPecentage());
							preparedStatement.setFloat(10, productInfoDAO.getDiscountRupees());
							preparedStatement.setFloat(11, productInfoDAO.getAmount());
							preparedStatement.setFloat(12, productInfoDAO.getAmountAfterDiscount());
							preparedStatement.setFloat(13, productInfoDAO.getGrossAmount());
							preparedStatement.setFloat(14, productInfoDAO.getIgst());
							preparedStatement.setFloat(15, productInfoDAO.getCgst());
							preparedStatement.setFloat(16, productInfoDAO.getSgst());
							preparedStatement.setString(17, productInfoDAO.getProductNameMarathi());

							preparedStatement.addBatch();

							listSize--;
						}

						int[] rowInstredCount = preparedStatement.executeBatch();

						if (rowInstredCount.length == this.getProductInfoList().size()) {
							if (countBillInfoInserted > 0) {
								this.getProformaInfoDAO().setBillInformationInserted(true);
							}

							this.getProformaInfoDAO().setBillSaved(true);
							this.setBillSaved(true);
							this.setBillDateTime(this.getProformaInfoDAO().getBillDate());
							this.setCustomerName(this.getProformaInfoDAO().getCustomerName());
							this.setBillNumber(this.getProformaInfoDAO().getBillNumber());
							this.setBillType(this.getProformaInfoDAO().getBillType());
							this.setAlternateMobileNumber(this.getProformaInfoDAO().getCustomerMobile());
							this.setSendSMS(this.getProformaInfoDAO().isSendSMS());
							this.setTotalAmount(""
									+ (floatTotalAmount + this.getProformaInfoDAO().getTransportCharge()));
							this.setTotalDiscount(""
									+ (floatTotalDiscount + this.getProformaInfoDAO().getTransportCharge()));
							this.setTotalAmouAfterDisount(""
									+ (floatTotalAmtAfterDiscount + this.getProformaInfoDAO().getTransportCharge()));

							this.setDefaultValue(this.getProformaInfoDAO().getPaymentType());

							try {
								this.setTaxList(GetListResource.GetTaxList(this.getSessionMap()));

							} catch (Exception e) {
							}

							unitList = GetListResource.GetUnitList();

							addActionMessage(this.getText("message.success.proformaDetailsSavedSuccessfully"));

							this.getSessionMap().put("proformaInformation", this.getProformaInfoDAO());
							this.getSessionMap().put("proformaProductList", this.getProductInfoList());

							connection.commit();
							result = SUCCESS;

						} else {
							result = "error";
							addActionError(this.getText("message.error.proformaNotSavedProperly"));
						}

					} else {
						result = "error";
						addActionError(this.getText("message.error.sryProformaDetailsNotSaved"));
					}

				} catch (SQLException e) {
					result = "error";
					try {
						connection.rollback();
					} catch (SQLException e1) {
					}
					addActionError(e.getErrorCode() + " || " + e.getMessage() + " ||1 "
							+ this.getText("message.error.sryProformaDetailsNotSaved"));
				} catch (IOException e) {
					result = "error";
					addActionError(e.getMessage() + " || " + e.getCause() + " ||2 "
							+ this.getText("message.error.sryProformaDetailsNotSaved"));
				} finally {
					if (resultSet != null) {
						try {
							resultSet.close();
							resultSet = null;
						} catch (SQLException sqe) {
						}
					}
					if (preparedStatement != null) {
						try {
							preparedStatement.close();
							preparedStatement = null;
						} catch (SQLException e) {
						}
					}
					if (connection != null) {

						try {
							connection.close();
							connection = null;
						} catch (SQLException e) {
						}
					}

				}
			} else {

				float floatTotalAmount = 0.0F;
				float floatTotalDiscount = 0.0F;
				float floatTotalAmtAfterDiscount = 0.0F;

				for (BillProductInfoDAO infoDAO : this.getProductInfoList()) {
					floatTotalAmount = floatTotalAmount + infoDAO.getAmount();
					floatTotalAmtAfterDiscount = floatTotalAmtAfterDiscount + infoDAO.getAmountAfterDiscount();
					floatTotalDiscount = floatTotalDiscount + infoDAO.getProductTotalDiscount();

				}

				this.getSessionMap().put("proformaProductList", this.getProductInfoList());

				setCustomerName(this.getProformaInfoDAO().getCustomerName());
				setBillNumber(this.getProformaInfoDAO().getBillNumber());
				setBillType(this.getProformaInfoDAO().getBillType());
				setTransportCharge(this.getProformaInfoDAO().getTransportCharge());

				setAlternateMobileNumber(this.getProformaInfoDAO().getCustomerMobile());
				setSendSMS(this.getProformaInfoDAO().isSendSMS());
				float transportCharge = 0.0F;

				if (!this.getProformaInfoDAO().getTransportCharge().equals("")) {

					try {
						transportCharge = this.getProformaInfoDAO().getTransportCharge();
					} catch (NumberFormatException nfe) {
						addActionError(this.getText("message.error.plzProvideCorrectTransportationAmount"));
					}
				}

				if (!hasActionErrors()) {
					setTotalAmount("" + (floatTotalAmount));
					setTotalDiscount("" + floatTotalDiscount);
					setTotalAmouAfterDisount("" + (floatTotalAmtAfterDiscount));
					addActionMessage(this.getText("message.success.productAddedSuccessfullyToList"));
				} else {
					setTotalAmount("" + floatTotalAmount);
					setTotalDiscount("" + floatTotalDiscount);
					setTotalAmouAfterDisount("" + floatTotalAmtAfterDiscount);
					addActionMessage(this.getText("message.success.productAddedSuccessfullyToList"));
				}

				setDefaultValue(this.getProformaInfoDAO().getPaymentType());

				try {
					this.setTaxList(GetListResource.GetTaxList(this.getSessionMap()));

				} catch (Exception e) {
				}

				unitList = GetListResource.GetUnitList();
				this.getSessionMap().put("proformaInformation", this.getProformaInfoDAO());
				this.getSessionMap().put("proformaProductList", this.getProductInfoList());
				result = "success";
				addActionError(this.getText("message.error.proformaAlreadySaved"));
			}

		}
		return result;
	}

	@SuppressWarnings("unchecked")
	@Override
	public void validate() {

		productInfoList = (List<BillProductInfoDAO>) this.getSessionMap().get("proformaProductList");
		proformaInfoDAO = (BillInformationDAO) this.getSessionMap().get("proformaInformation");

		this.setAddSideBarJs("FALSE");

		discountTypeList.put("", "Select Discount Type");
		discountTypeList.put("By Quantity", "By Quantity");
		discountTypeList.put("By Percentage", "By Percentage");
		discountTypeList.put("By Direct Amount", "By Direct Amount");

		this.getRateTypeList().put("INCLUDEGST", "WITH GST");
		this.getRateTypeList().put("EXCLUDEGST", "WITH-OUT GST");

		this.setRateType(((HashMap<String, String>) this.getSessionMap().get("shop_settings"))
				.get("default_rate_type"));

		float floatTotalAmount = 0.0F;
		float floatTotalDiscount = 0.0F;
		float floatTotalAmtAfterDiscount = 0.0F;

		for (BillProductInfoDAO infoDAO : this.getProductInfoList()) {
			floatTotalAmount = floatTotalAmount + infoDAO.getAmount();
			floatTotalAmtAfterDiscount = floatTotalAmtAfterDiscount + infoDAO.getAmountAfterDiscount();
			floatTotalDiscount = floatTotalDiscount + infoDAO.getProductTotalDiscount();

		}

		this.setTransportCharge(this.getProformaInfoDAO().getTransportCharge());
		this.setCustomerName(this.getProformaInfoDAO().getCustomerName());
		this.setBillNumber(this.getProformaInfoDAO().getBillNumber());
		this.setBillType(this.getProformaInfoDAO().getBillType());
		this.setBillDateTime(this.getProformaInfoDAO().getBillDate());
		float transportCharge = 0.0F;
		if (!this.getProformaInfoDAO().getTransportCharge().equals("")) {

			try {
				transportCharge = this.getProformaInfoDAO().getTransportCharge();
			} catch (NumberFormatException nfe) {
				addActionError(this.getText("message.error.plzProvideCorrectTransportationAmount"));
			}
		}

		this.setTotalAmount("" + (floatTotalAmount + transportCharge));
		this.setTotalDiscount("" + floatTotalDiscount);
		this.setTotalPaybleAmount("" + (floatTotalAmount + transportCharge));
		this.setTotalAmouAfterDisount("" + (floatTotalAmtAfterDiscount + transportCharge));

		this.setDefaultValue(this.getProformaInfoDAO().getPaymentType());
		try {
			this.setTaxList(GetListResource.GetTaxList(this.getSessionMap()));

		} catch (Exception e) {
		}
		unitList = GetListResource.GetUnitList();
		session = ServletActionContext.getRequest().getSession(false);

		this.getSessionMap().put("proformaInformation", this.getProformaInfoDAO());
		this.getSessionMap().put("proformaProductList", this.getProductInfoList());

	}

	@Override
	public void setSession(Map<String, Object> map) {
		sessionMap = (SessionMap<String, Object>) map;
	}

	public HttpSession getSession() {
		return session;
	}

	public void setSession(HttpSession session) {
		this.session = session;
	}

	public SessionMap<String, Object> getSessionMap() {
		return sessionMap;
	}

	public void setSessionMap(SessionMap<String, Object> sessionMap) {
		this.sessionMap = sessionMap;
	}

	public BillInformationDAO getProformaInfoDAO() {
		return proformaInfoDAO;
	}

	public void setProformaInfoDAO(BillInformationDAO proformaInfoDAO) {
		this.proformaInfoDAO = proformaInfoDAO;
	}

	public List<BillProductInfoDAO> getProductInfoList() {
		return productInfoList;
	}

	public void setProductInfoList(List<BillProductInfoDAO> productInfoList) {
		this.productInfoList = productInfoList;
	}

	public Map<String, String> getTaxList() {
		return taxList;
	}

	public void setTaxList(Map<String, String> taxList) {
		this.taxList = taxList;
	}

	public Map<String, String> getUnitList() {
		return unitList;
	}

	public void setUnitList(Map<String, String> unitList) {
		this.unitList = unitList;
	}

	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	public String getBillType() {
		return billType;
	}

	public void setBillType(String billType) {
		this.billType = billType;
	}

	public String getPrintType() {
		return printType;
	}

	public void setPrintType(String printType) {
		this.printType = printType;
	}

	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	public String getBillNumber() {
		return billNumber;
	}

	public void setBillNumber(String billNumber) {
		this.billNumber = billNumber;
	}

	public String getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(String totalAmount) {
		this.totalAmount = totalAmount;
	}

	public String getTotalDiscount() {
		return totalDiscount;
	}

	public void setTotalDiscount(String totalDiscount) {
		this.totalDiscount = totalDiscount;
	}

	public String getTotalAmouAfterDisount() {
		return totalAmouAfterDisount;
	}

	public void setTotalAmouAfterDisount(String totalAmouAfterDisount) {
		this.totalAmouAfterDisount = totalAmouAfterDisount;
	}

	public String getTotalPaybleAmount() {
		return totalPaybleAmount;
	}

	public void setTotalPaybleAmount(String totalPaybleAmount) {
		this.totalPaybleAmount = totalPaybleAmount;
	}

	public Float getAmountPaid() {
		return amountPaid;
	}

	public void setAmountPaid(Float amountPaid) {
		this.amountPaid = amountPaid;
	}

	public String getReturnAmount() {
		return returnAmount;
	}

	public void setReturnAmount(String returnAmount) {
		this.returnAmount = returnAmount;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getAlternateMobileNumber() {
		return alternateMobileNumber;
	}

	public void setAlternateMobileNumber(String alternateMobileNumber) {
		this.alternateMobileNumber = alternateMobileNumber;
	}

	public boolean isSendSMS() {
		return sendSMS;
	}

	public void setSendSMS(boolean sendSMS) {
		this.sendSMS = sendSMS;
	}

	public boolean isBillSaved() {
		return billSaved;
	}

	public void setBillSaved(boolean billSaved) {
		this.billSaved = billSaved;
	}

	public String getBillDateTime() {
		return billDateTime;
	}

	public void setBillDateTime(String billDateTime) {
		this.billDateTime = billDateTime;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public Float getTransportCharge() {
		return transportCharge;
	}

	public void setTransportCharge(Float transportCharge) {
		this.transportCharge = transportCharge;
	}

	public String getAddSideBarJs() {
		return addSideBarJs;
	}

	public void setAddSideBarJs(String addSideBarJs) {
		this.addSideBarJs = addSideBarJs;
	}

	public String getDiscountType() {
		return discountType;
	}

	public void setDiscountType(String discountType) {
		this.discountType = discountType;
	}

	public Map<String, String> getDiscountTypeList() {
		return discountTypeList;
	}

	public void setDiscountTypeList(Map<String, String> discountTypeList) {
		this.discountTypeList = discountTypeList;
	}

	public Map<String, String> getRateTypeList() {
		return rateTypeList;
	}

	public void setRateTypeList(Map<String, String> rateTypeList) {
		this.rateTypeList = rateTypeList;
	}

	public String getRateType() {
		return rateType;
	}

	public void setRateType(String rateType) {
		this.rateType = rateType;
	}

	// Extra header fields accessors
	public Integer getValidityDays() {
		return validityDays;
	}

	public void setValidityDays(Integer validityDays) {
		this.validityDays = validityDays;
	}

	public String getValidityUpto() {
		return validityUpto;
	}

	public void setValidityUpto(String validityUpto) {
		this.validityUpto = validityUpto;
	}

	public String getPaymentTerms() {
		return paymentTerms;
	}

	public void setPaymentTerms(String paymentTerms) {
		this.paymentTerms = paymentTerms;
	}

	public String getDeliveryTerms() {
		return deliveryTerms;
	}

	public void setDeliveryTerms(String deliveryTerms) {
		this.deliveryTerms = deliveryTerms;
	}

	public Float getAdvancePercent() {
		return advancePercent;
	}

	public void setAdvancePercent(Float advancePercent) {
		this.advancePercent = advancePercent;
	}

	public Float getAdvanceAmount() {
		return advanceAmount;
	}

	public void setAdvanceAmount(Float advanceAmount) {
		this.advanceAmount = advanceAmount;
	}
}

