package main_package;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import report_package.DataBaseReportMethods;

@ManagedBean(name="printVoucher")
@ViewScoped
public class PrintVoucherBean implements Serializable
{
	String voucherNo="", type, paymentMode, vCategory, description, amount, vDateStr, amountInwords, signLabel;
	Date vDate;
	
	
	public PrintVoucherBean() 
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		
		voucherNo=(String) ss.getAttribute("voucherNo");
		vDate=(Date) ss.getAttribute("expDate");
		amount=(String) ss.getAttribute("amount");
		type=(String) ss.getAttribute("vchtype");
		description=(String) ss.getAttribute("payTo");
		vCategory=(String) ss.getAttribute("being");
		paymentMode=(String) ss.getAttribute("payMode");
		
		if(vDate!=null)
		{
			vDateStr=new SimpleDateFormat("dd/MM/yyyy").format(vDate);
		}
		
		if(amount.contains("."))
		{
			String arr[]=amount.split("\\.");
			amount=arr[0];
		}
		amountInwords="Rs. "+new DataBaseReportMethods().numberToWords(Integer.parseInt(amount))+" Only";
		
		
		if(type.equals("Transfer"))
		{
			signLabel="Signature";
		}
		else
		{
			signLabel="Receiver's Signature";
		}
	}
	public String getVoucherNo() {
		return voucherNo;
	}
	public void setVoucherNo(String voucherNo) {
		this.voucherNo = voucherNo;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getPaymentMode() {
		return paymentMode;
	}
	public void setPaymentMode(String paymentMode) {
		this.paymentMode = paymentMode;
	}
	public String getvCategory() {
		return vCategory;
	}
	public void setvCategory(String vCategory) {
		this.vCategory = vCategory;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getAmount() {
		return amount;
	}
	public void setAmount(String amount) {
		this.amount = amount;
	}
	public String getvDateStr() {
		return vDateStr;
	}
	public void setvDateStr(String vDateStr) {
		this.vDateStr = vDateStr;
	}
	public Date getvDate() {
		return vDate;
	}
	public void setvDate(Date vDate) {
		this.vDate = vDate;
	}
	public String getAmountInwords() {
		return amountInwords;
	}
	public void setAmountInwords(String amountInwords) {
		this.amountInwords = amountInwords;
	}
	
	public String getSignLabel() {
		return signLabel;
	}
	public void setSignLabel(String signLabel) {
		this.signLabel = signLabel;
	}
	
	
}
