package com.reallinkbilling.add;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.ArrayList;
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.ProductBarcodeDetailsDAO;
import com.reallinkbilling.DAO.PurchaseInvoiceInformationDAO;
import com.reallinkbilling.DAO.PurchaseProductInfoDAO;
import com.reallinkbilling.ajax.GetNewProductCodeForNewProduct;
import com.reallinkbilling.resource.GetListResource;

public class AddProductToPurchaseInvoiceType2 extends ActionSupport implements SessionAware,Serializable{

    private static final long serialVersionUID = -5375687134990140583L;
    private SessionMap<String,Object> sessionMap;  
    private HttpSession session;

    private String paymentType;
    private String purchaseDateTime;
    private String supplierName;
    private String invoiceNumber;
    private boolean addToStock;
    private String rateType;
    private String taxId;
    private String purchaseUnit;
    private String salesUnit;
    private String hsnCode;
    private Float defaultBarcodeQty;
    private String rackNumber;

    private String baseProductName;
    private String sizeList; // comma separated
    private String purchasePriceList; // comma separated
    private String qtyList; // comma separated
    private String mrpList; // comma separated

    // Popup-provided arrays
    private String [] variantSize;
    private String [] variantPrice;
    private String [] variantQty;
    private String [] variantMrp;

    private Map<String,String> taxList = new LinkedHashMap<String,String>();
    private Map<String,String> unitList = new LinkedHashMap<String,String>();
    private Map<String,String> paymentTypeList = new  LinkedHashMap<String,String>();
    private String paymentDefaultValue;
    private Map<String,String> rateTypeList = new  LinkedHashMap<String,String>();
    private String rateTyprDefaultValue;

    private PurchaseInvoiceInformationDAO purchaseInvoiceInformationDAO = null;
    private List<PurchaseProductInfoDAO> purchaseProductInfoList = null;
    private DecimalFormat df;
    // Totals for footer UI
    private Float totalPurchaseAmount;
    private Float totalNettAmount;
    private Float totalCGST;
    private Float totalSGST;
    private Float totalIGST;

    @SuppressWarnings("unchecked")
    public String execute() {
        String result = "login";
        session=ServletActionContext.getRequest().getSession(false); 
        if(session==null || session.getAttribute("login")==null){ 
            addActionMessage("Please Logout and Login again !");
            return "error";
        }

        paymentTypeList.put("CASH","CASH");
        paymentTypeList.put("CREDIT","CREDIT");
        this.setPaymentDefaultValue("CREDIT");
        
        this.getRateTypeList().put("INCLUDINGGST", "Including GST");
        this.getRateTypeList().put("EXCLUDINGGST", "Excluding GST");

        if(this.getRateType()==null || this.getRateType().trim().equals(""))
        {
            this.setRateType("INCLUDINGGST");
        }

        this.setRateTyprDefaultValue(this.getRateType());

        if(this.getDefaultBarcodeQty()==null){ this.setDefaultBarcodeQty(1.0F); }
        if(this.getHsnCode()==null || this.getHsnCode().trim().equals("")) { this.setHsnCode("NA"); }
        if(this.getRackNumber()==null || this.getRackNumber().trim().equals("")) { this.setRackNumber("NA"); }

        purchaseInvoiceInformationDAO = (PurchaseInvoiceInformationDAO) this.getSessionMap().get("purchaseInformation");
        purchaseProductInfoList = (List<PurchaseProductInfoDAO>) this.getSessionMap().get("purchaseProductList");
        if(purchaseInvoiceInformationDAO == null){ purchaseInvoiceInformationDAO = new PurchaseInvoiceInformationDAO(); }
        if(purchaseProductInfoList == null){ purchaseProductInfoList = new ArrayList<PurchaseProductInfoDAO>(); }

        df = new DecimalFormat("#.##");

        // Validate required fields
        boolean hasErr = false;
        if(this.getSupplierName()==null || this.getSupplierName().trim().equals("")) { addActionError("Supplier/Party Name is required."); hasErr = true; }
        if(this.getInvoiceNumber()==null || this.getInvoiceNumber().trim().equals("")) { addActionError("Invoice Number is required."); hasErr = true; }
        if(this.getPurchaseDateTime()==null || this.getPurchaseDateTime().trim().equals("")) { addActionError("Purchase Date is required."); hasErr = true; }
        if(this.getBaseProductName()==null || this.getBaseProductName().trim().equals("")) { addActionError("Base Product Name is required."); hasErr = true; }
        if(this.getTaxId()==null || this.getTaxId().trim().equals("")) { addActionError("Please select Tax %."); hasErr = true; }
        if(this.getPurchaseUnit()==null || this.getPurchaseUnit().trim().equals("")) { addActionError("Please select Purchase Unit."); hasErr = true; }
        if(this.getSalesUnit()==null || this.getSalesUnit().trim().equals("")) { this.setSalesUnit(this.getPurchaseUnit()); }
        if(hasErr)
        {
            taxList = GetListResource.GetTaxList(this.getSessionMap());
            unitList = GetListResource.GetUnitList();
            return "input";
        }

        Map<String,String> taxInfo = GetListResource.GetTaxNamePercentage(this.getTaxId(),this.getSessionMap());
        String taxName = taxInfo.get("TAX-NAME");
        String taxPercentageStr = taxInfo.get("TAX-PERCENTAGE");
        Float taxPercentage = 0.0F;
        try{ taxPercentage = Float.parseFloat(taxPercentageStr); }catch(Exception e){}

        // Populate purchase header info
        try{
            String supplierFull = this.getSupplierName();
            String[] supplierInfo = (supplierFull!=null? supplierFull.split("-") : new String[]{"","",""});
            if(purchaseInvoiceInformationDAO.getPurchaseId()==null || purchaseInvoiceInformationDAO.getPurchaseId().trim().equals("")){
                purchaseInvoiceInformationDAO.setPurchaseId("NA");
            }
            purchaseInvoiceInformationDAO.setSupplierId(supplierInfo.length>0?supplierInfo[0]:"NA");
            purchaseInvoiceInformationDAO.setSupplierName(supplierInfo.length>1?supplierInfo[1]:supplierFull);
            purchaseInvoiceInformationDAO.setSupplierDetails(supplierFull);
            purchaseInvoiceInformationDAO.setInvoiceNumber(this.getInvoiceNumber());
            purchaseInvoiceInformationDAO.setOtherExpense(0.0F);
            purchaseInvoiceInformationDAO.setFrightCharges(0.0F);
            purchaseInvoiceInformationDAO.setInvoiceImage(null);
            purchaseInvoiceInformationDAO.setPurchaseDate(this.getPurchaseDateTime());
            purchaseInvoiceInformationDAO.setAddToStock(this.isAddToStock());
            purchaseInvoiceInformationDAO.setRateType(this.getRateType());
        }catch(Exception ignore){}

        String[] sizes;
        String[] prices;
        String[] qtys;
        String[] mrps;

        if(this.getVariantSize()!=null && this.getVariantSize().length>0)
        {
            sizes = this.getVariantSize();
            prices = this.getVariantPrice()!=null? this.getVariantPrice() : new String[this.getVariantSize().length];
            qtys = this.getVariantQty()!=null? this.getVariantQty() : new String[this.getVariantSize().length];
            mrps = this.getVariantMrp()!=null? this.getVariantMrp() : new String[this.getVariantSize().length];
        }
        else
        {
            sizes = (this.getSizeList()!=null? this.getSizeList().split(",") : new String[0]);
            prices = (this.getPurchasePriceList()!=null && this.getPurchasePriceList().trim().length()>0)? this.getPurchasePriceList().split(",") : new String[sizes.length];
            qtys = (this.getQtyList()!=null && this.getQtyList().trim().length()>0)? this.getQtyList().split(",") : new String[sizes.length];
            mrps = (this.getMrpList()!=null && this.getMrpList().trim().length()>0)? this.getMrpList().split(",") : new String[sizes.length];
        }

        if(sizes.length==0)
        {
            addActionError("Please enter at least one Size.");
            taxList = GetListResource.GetTaxList(this.getSessionMap());
            unitList = GetListResource.GetUnitList();
            return "input";
        }

        for(int i=0;i<sizes.length;i++)
        {
            String size = sizes[i].trim().toUpperCase();
            if(size.length()==0) continue;

            Float priceF = 0.0F; try{ priceF = (prices!=null && i<prices.length && prices[i]!=null && prices[i].trim().length()>0)? Float.parseFloat(prices[i].trim()) : 0.0F; }catch(Exception e){ addActionError("Invalid price for size "+size); }
            Float qtyF = 1.0F; try{ qtyF = (qtys!=null && i<qtys.length && qtys[i]!=null && qtys[i].trim().length()>0)? Float.parseFloat(qtys[i].trim()) : 1.0F; }catch(Exception e){ addActionError("Invalid quantity for size "+size); }
            Float mrpF = priceF; try{ mrpF = (mrps!=null && i<mrps.length && mrps[i]!=null && mrps[i].trim().length()>0)? Float.parseFloat(mrps[i].trim()) : priceF; }catch(Exception e){ addActionError("Invalid MRP for size "+size); }
            if(priceF < 0){ addActionError("Price must be >= 0 for size "+size); }
            if(qtyF <= 0){ addActionError("Quantity must be > 0 for size "+size); }

            // Build variant name and alias/code
            String productName = (this.getBaseProductName()!=null? this.getBaseProductName().trim().toUpperCase() : "ITEM") + " " + size;
            String initials = "";
            for(String p : (this.getBaseProductName()!=null? this.getBaseProductName().trim().split(" ") : new String[]{"I"}))
            { if(p!=null && p.length()>0){ initials += Character.toUpperCase(p.charAt(0)); } }
            String alias = initials + "-" + size;
            String shortCode = GetNewProductCodeForNewProduct.getRandomNumber((String)this.getSessionMap().get("shopId"));

            // Detect duplicate by product name; if exists, only update rates/MRP and recompute amounts, keep quantity same
            int existingIndex = -1;
            for(int idx=0; idx<purchaseProductInfoList.size(); idx++)
            {
                PurchaseProductInfoDAO existing = purchaseProductInfoList.get(idx);
                if(existing.getProductName()!=null && existing.getProductName().equalsIgnoreCase(productName))
                { existingIndex = idx; break; }
            }

            Float effectiveQty = qtyF;
            if(existingIndex >= 0)
            {
                // Use existing quantity for recalculation
                PurchaseProductInfoDAO existing = purchaseProductInfoList.get(existingIndex);
                effectiveQty = (existing.getQuantity()!=null? existing.getQuantity() : 1.0F);

                float sgst=0F,cgst=0F,igst=0F;
                float totalAmtAfterDis = priceF * effectiveQty;
                if("INCLUDINGGST".equals(this.getRateType()))
                {
                    float basicTax = taxPercentage+100.0F;
                    float nettAmount = (totalAmtAfterDis / basicTax) * 100.0F;
                    float totalTax = totalAmtAfterDis - nettAmount;
                    if(taxName!=null && taxName.toUpperCase().contains("IGST"))
                    { igst = totalTax; }
                    else { sgst = totalTax/2.0F; cgst = totalTax/2.0F; }
                    existing.setNettAmount((float)(Math.round(nettAmount * 100) / 100.0));
                    existing.setSgst((float)(Math.round(sgst * 100) / 100.0));
                    existing.setCgst((float)(Math.round(cgst * 100) / 100.0));
                    existing.setIgst((float)(Math.round(igst * 100) / 100.0));
                    existing.setGrossAmount(totalAmtAfterDis);
                }
                else
                {
                    float totalTax = totalAmtAfterDis * (taxPercentage / 100.0F);
                    if(taxName!=null && taxName.toUpperCase().contains("IGST"))
                    { igst = totalTax; }
                    else { sgst = totalTax/2.0F; cgst = totalTax/2.0F; }
                    existing.setNettAmount((float)(Math.round(totalAmtAfterDis * 100) / 100.0));
                    existing.setSgst((float)(Math.round(sgst * 100) / 100.0));
                    existing.setCgst((float)(Math.round(cgst * 100) / 100.0));
                    existing.setIgst((float)(Math.round(igst * 100) / 100.0));
                    existing.setGrossAmount(existing.getNettAmount()+existing.getSgst()+existing.getCgst()+existing.getIgst());
                }
                existing.setPurchaseRate(priceF);
                existing.setSalesPrice(mrpF);
                existing.setAmount(priceF * effectiveQty);
                existing.setTaxId(this.getTaxId());
                existing.setTaxPercentage(taxPercentage);
                existing.setPurchaseUnit(this.getPurchaseUnit());
                existing.setSalesUnit(this.getSalesUnit()!=null?this.getSalesUnit():this.getPurchaseUnit());
                existing.setHsnCode(this.getHsnCode()!=null?this.getHsnCode():"NA");
                existing.setSerialBatchNo("NA");
                // skip adding new row
            }
            else
            {
                // Prepare product info item
                PurchaseProductInfoDAO item = new PurchaseProductInfoDAO();
                item.setProductId(shortCode); // temp; final id will resolve on save
                item.setProductName(productName);
                item.setPurchaseRate(priceF);
                item.setPurchaseUnit(this.getPurchaseUnit());
                item.setSalesUnit(this.getSalesUnit()!=null?this.getSalesUnit():this.getPurchaseUnit());
                item.setQuantity(qtyF);
                item.setDiscount(0.0F);
                item.setDiscountType("PERCENTAGE");
                item.setAmount(priceF * qtyF);
                item.setTaxId(this.getTaxId());
                item.setTaxPercentage(taxPercentage);
                item.setHsnCode(this.getHsnCode()!=null?this.getHsnCode():"NA");
                item.setAddedToDB(false);
                // Ensure serial/batch never null for DB insert
                item.setSerialBatchNo("NA");
                // Keep the entered MRP/Sales rate for reference (for product master)
                item.setSalesPrice(mrpF);

                float sgst=0F,cgst=0F,igst=0F;
                float totalAmtAfterDis = priceF * qtyF;
                if("INCLUDINGGST".equals(this.getRateType()))
                {
                    float basicTax = taxPercentage+100.0F;
                    float nettAmount = (totalAmtAfterDis / basicTax) * 100.0F;
                    float totalTax = totalAmtAfterDis - nettAmount;
                    if(taxName!=null && taxName.toUpperCase().contains("IGST"))
                    { igst = totalTax; }
                    else { sgst = totalTax/2.0F; cgst = totalTax/2.0F; }
                    item.setNettAmount((float)(Math.round(nettAmount * 100) / 100.0));
                    item.setSgst((float)(Math.round(sgst * 100) / 100.0));
                    item.setCgst((float)(Math.round(cgst * 100) / 100.0));
                    item.setIgst((float)(Math.round(igst * 100) / 100.0));
                    item.setGrossAmount(totalAmtAfterDis);
                }
                else
                {
                    float totalTax = totalAmtAfterDis * (taxPercentage / 100.0F);
                    if(taxName!=null && taxName.toUpperCase().contains("IGST"))
                    { igst = totalTax; }
                    else { sgst = totalTax/2.0F; cgst = totalTax/2.0F; }
                    item.setNettAmount((float)(Math.round(totalAmtAfterDis * 100) / 100.0));
                    item.setSgst((float)(Math.round(sgst * 100) / 100.0));
                    item.setCgst((float)(Math.round(cgst * 100) / 100.0));
                    item.setIgst((float)(Math.round(igst * 100) / 100.0));
                    item.setGrossAmount(item.getNettAmount()+item.getSgst()+item.getCgst()+item.getIgst());
                }

                purchaseProductInfoList.add(item);
            }

            // Prepare barcode details in session for each size variant
            try{
                @SuppressWarnings("unchecked")
                Map<String,ProductBarcodeDetailsDAO> barcodeDetailsMap = (Map<String,ProductBarcodeDetailsDAO>) this.getSessionMap().get("barcodeProductDetails");
                if(barcodeDetailsMap == null){ barcodeDetailsMap = new HashMap<String, ProductBarcodeDetailsDAO>(); }
                ProductBarcodeDetailsDAO detailsDAO = new ProductBarcodeDetailsDAO();
                detailsDAO.setProductId(shortCode);
                detailsDAO.setProductCode(shortCode);
                detailsDAO.setProductNameEn(productName);
                detailsDAO.setProductNameMr(productName);
                detailsDAO.setTaxId(Integer.parseInt(this.getTaxId()!=null?this.getTaxId():"0"));
                detailsDAO.setTaxPercentage(taxPercentage);
                detailsDAO.setSalesUnit(this.getSalesUnit()!=null?this.getSalesUnit():this.getPurchaseUnit());
                detailsDAO.setHsnSacCode(this.getHsnCode());
                detailsDAO.setBarcodeMRP(mrpF);
                detailsDAO.setDiscountType("PERCENTAGE");
                detailsDAO.setDiscount(0.0F);
                detailsDAO.setSalesPrice(mrpF);
                detailsDAO.setBarCodeQuantity(this.getDefaultBarcodeQty()!=null?this.getDefaultBarcodeQty():1.0F);
                barcodeDetailsMap.put(shortCode, detailsDAO);
                this.getSessionMap().put("barcodeProductDetails", barcodeDetailsMap);
            }catch(Exception ignore){}
        }

        // Totals and session
        float floatTotalPurchaseAmount = 0.0F, floatTotalCGST=0.0F, floatTotalSGST=0.0F, floatTotalIGST=0.0F, floatTotalNettAmount=0.0F;
        for (PurchaseProductInfoDAO p : purchaseProductInfoList)
        {
            floatTotalPurchaseAmount += p.getGrossAmount();
            floatTotalCGST += p.getCgst();
            floatTotalSGST += p.getSgst();
            floatTotalIGST += p.getIgst();
            floatTotalNettAmount += p.getNettAmount();
        }
        this.setTotalPurchaseAmount(floatTotalPurchaseAmount);
        this.setTotalNettAmount(floatTotalNettAmount);
        this.setTotalCGST(floatTotalCGST);
        this.setTotalSGST(floatTotalSGST);
        this.setTotalIGST(floatTotalIGST);
        // Persist totals and header info into session header DAO for JSP/discount AJAX
        try{
            purchaseInvoiceInformationDAO.setTotalNettAmount(this.getTotalNettAmount());
            purchaseInvoiceInformationDAO.setTotalCGST(this.getTotalCGST());
            purchaseInvoiceInformationDAO.setTotalSGST(this.getTotalSGST());
            purchaseInvoiceInformationDAO.setTotalIGST(this.getTotalIGST());
            purchaseInvoiceInformationDAO.setPurchaseTotalAmount(this.getTotalPurchaseAmount());
            purchaseInvoiceInformationDAO.setPaymentType(this.getPaymentType());
            if(purchaseInvoiceInformationDAO.getPurchaseAmountPaid() == null){ purchaseInvoiceInformationDAO.setPurchaseAmountPaid(0.0F); }
        }catch(Exception ignore){}
        purchaseInvoiceInformationDAO.setPurchaseSaved(false);
        this.getSessionMap().put("purchaseInformation", purchaseInvoiceInformationDAO);
        this.getSessionMap().put("purchaseProductList", purchaseProductInfoList);

        taxList = GetListResource.GetTaxList(this.getSessionMap());
        unitList = GetListResource.GetUnitList();

        return "success";
    }

    @Override
    public void validate()
    {
        // Always repopulate lists for the JSP on validation failure
        this.setTaxList(GetListResource.GetTaxList(this.getSessionMap()));
        this.setUnitList(GetListResource.GetUnitList());

        if(this.getRateType()==null || this.getRateType().trim().equals(""))
        {
            this.setRateType("INCLUDINGGST");
            this.setRateTyprDefaultValue("INCLUDINGGST");
        }

        boolean hasError = false;
        if(this.getPurchaseDateTime()==null || this.getPurchaseDateTime().trim().equals(""))
        { addActionError("Purchase Date is required."); hasError = true; }
        if(this.getSupplierName()==null || this.getSupplierName().trim().equals(""))
        { addActionError("Supplier/Party Name is required."); hasError = true; }
        if(this.getInvoiceNumber()==null || this.getInvoiceNumber().trim().equals(""))
        { addActionError("Invoice Number is required."); hasError = true; }
        if(this.getBaseProductName()==null || this.getBaseProductName().trim().equals(""))
        { addActionError("Base Product Name is required."); hasError = true; }
        if(this.getTaxId()==null || this.getTaxId().trim().equals(""))
        { addActionError("Please select Tax %."); hasError = true; }
        if(this.getPurchaseUnit()==null || this.getPurchaseUnit().trim().equals(""))
        { addActionError("Please select Purchase Unit."); hasError = true; }

        // Validate sizes and popup arrays
        String[] sizes = null;
        if(this.getVariantSize()!=null && this.getVariantSize().length>0)
        {
            sizes = this.getVariantSize();
            // Validate paired arrays
            for(int i=0;i<sizes.length;i++)
            {
                String s = sizes[i]!=null?sizes[i].trim():"";
                if(s.length()==0){ addActionError("One of the sizes is empty."); hasError = true; }
                try{ if(this.getVariantPrice()!=null && i<this.getVariantPrice().length && this.getVariantPrice()[i]!=null && this.getVariantPrice()[i].trim().length()>0) Float.parseFloat(this.getVariantPrice()[i].trim()); }catch(Exception e){ addActionError("Invalid price for size "+s+"."); hasError = true; }
                try{ if(this.getVariantQty()!=null && i<this.getVariantQty().length && this.getVariantQty()[i]!=null && this.getVariantQty()[i].trim().length()>0) { float q = Float.parseFloat(this.getVariantQty()[i].trim()); if(q<=0) { addActionError("Quantity must be > 0 for size "+s+"."); hasError = true; } } }catch(Exception e){ addActionError("Invalid quantity for size "+s+"."); hasError = true; }
                try{ if(this.getVariantMrp()!=null && i<this.getVariantMrp().length && this.getVariantMrp()[i]!=null && this.getVariantMrp()[i].trim().length()>0) Float.parseFloat(this.getVariantMrp()[i].trim()); }catch(Exception e){ addActionError("Invalid MRP for size "+s+"."); hasError = true; }
            }
        }
        else
        {
            if(this.getSizeList()==null || this.getSizeList().trim().equals(""))
            { addActionError("Please enter at least one Size and use the popup to fill details."); hasError = true; }
        }

        // Default values
        if(this.getDefaultBarcodeQty()==null){ this.setDefaultBarcodeQty(1.0F); }
        if(this.getHsnCode()==null || this.getHsnCode().trim().equals("")) { this.setHsnCode("NA"); }
        if(this.getSalesUnit()==null || this.getSalesUnit().trim().equals("")) { this.setSalesUnit(this.getPurchaseUnit()); }
        if(this.getRackNumber()==null || this.getRackNumber().trim().equals("")) { this.setRackNumber("NA"); }
    }

    public String[] getVariantSize() { return variantSize; }
    public void setVariantSize(String[] variantSize) { this.variantSize = variantSize; }
    public String[] getVariantPrice() { return variantPrice; }
    public void setVariantPrice(String[] variantPrice) { this.variantPrice = variantPrice; }
    public String[] getVariantQty() { return variantQty; }
    public void setVariantQty(String[] variantQty) { this.variantQty = variantQty; }
    public String[] getVariantMrp() { return variantMrp; }
    public void setVariantMrp(String[] variantMrp) { this.variantMrp = variantMrp; }

    public void setSession(Map<String, Object> map) {  sessionMap=(SessionMap<String, Object>)map; }
    public SessionMap<String, Object> getSessionMap() { return sessionMap; }

    public String getPaymentType() { return paymentType; }
    public void setPaymentType(String paymentType) { this.paymentType = paymentType; }
    public String getPurchaseDateTime() { return purchaseDateTime; }
    public void setPurchaseDateTime(String purchaseDateTime) { this.purchaseDateTime = purchaseDateTime; }
    public String getSupplierName() { return supplierName; }
    public void setSupplierName(String supplierName) { this.supplierName = supplierName; }
    public String getInvoiceNumber() { return invoiceNumber; }
    public void setInvoiceNumber(String invoiceNumber) { this.invoiceNumber = invoiceNumber; }
    public boolean isAddToStock() { return addToStock; }
    public void setAddToStock(boolean addToStock) { this.addToStock = addToStock; }
    public String getRateType() { return rateType; }
    public void setRateType(String rateType) { this.rateType = rateType; }
    public String getTaxId() { return taxId; }
    public void setTaxId(String taxId) { this.taxId = taxId; }
    public String getPurchaseUnit() { return purchaseUnit; }
    public void setPurchaseUnit(String purchaseUnit) { this.purchaseUnit = purchaseUnit; }
    public String getSalesUnit() { return salesUnit; }
    public void setSalesUnit(String salesUnit) { this.salesUnit = salesUnit; }
    public String getHsnCode() { return hsnCode; }
    public void setHsnCode(String hsnCode) { this.hsnCode = hsnCode; }
    public Float getDefaultBarcodeQty() { return defaultBarcodeQty; }
    public void setDefaultBarcodeQty(Float defaultBarcodeQty) { this.defaultBarcodeQty = defaultBarcodeQty; }
    public String getRackNumber() { return rackNumber; }
    public void setRackNumber(String rackNumber) { this.rackNumber = rackNumber; }
    public String getBaseProductName() { return baseProductName; }
    public void setBaseProductName(String baseProductName) { this.baseProductName = baseProductName; }
    public String getSizeList() { return sizeList; }
    public void setSizeList(String sizeList) { this.sizeList = sizeList; }
    public String getPurchasePriceList() { return purchasePriceList; }
    public void setPurchasePriceList(String purchasePriceList) { this.purchasePriceList = purchasePriceList; }
    public String getQtyList() { return qtyList; }
    public void setQtyList(String qtyList) { this.qtyList = qtyList; }
    public String getMrpList() { return mrpList; }
    public void setMrpList(String mrpList) { this.mrpList = mrpList; }
    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 Map<String, String> getPaymentTypeList() { return paymentTypeList; }
    public void setPaymentTypeList(Map<String, String> paymentTypeList) { this.paymentTypeList = paymentTypeList; }
    public String getPaymentDefaultValue() { return paymentDefaultValue; }
    public void setPaymentDefaultValue(String paymentDefaultValue) { this.paymentDefaultValue = paymentDefaultValue; }
    public Map<String, String> getRateTypeList() { return rateTypeList; }
    public void setRateTypeList(Map<String, String> rateTypeList) { this.rateTypeList = rateTypeList; }
    public String getRateTyprDefaultValue() { return rateTyprDefaultValue; }
    public void setRateTyprDefaultValue(String rateTyprDefaultValue) { this.rateTyprDefaultValue = rateTyprDefaultValue; }

    public Float getTotalPurchaseAmount() { return totalPurchaseAmount; }
    public void setTotalPurchaseAmount(Float totalPurchaseAmount) { this.totalPurchaseAmount = totalPurchaseAmount; }
    public Float getTotalNettAmount() { return totalNettAmount; }
    public void setTotalNettAmount(Float totalNettAmount) { this.totalNettAmount = totalNettAmount; }
    public Float getTotalCGST() { return totalCGST; }
    public void setTotalCGST(Float totalCGST) { this.totalCGST = totalCGST; }
    public Float getTotalSGST() { return totalSGST; }
    public void setTotalSGST(Float totalSGST) { this.totalSGST = totalSGST; }
    public Float getTotalIGST() { return totalIGST; }
    public void setTotalIGST(Float totalIGST) { this.totalIGST = totalIGST; }
}


