package com.tax.file.utils.invoice;

import java.text.SimpleDateFormat;

import com.tax.file.model.FinInvoice;
import com.tax.file.model.FinInvoiceDetail;
import com.tax.file.utils.invoice.OldCarInvoiceCellRead.SingletonHolder;
import com.yxcheng.token.utils.StringUtil;
/** 
 * 卷票单元格读取具体实现类
 * 
 * */ 
public class VolumeInvoiceCellRead extends AbstractInvoiceCellRead {
	
	
    private VolumeInvoiceCellRead(){
		
	}
	
	public static class SingletonHolder{
		private static VolumeInvoiceCellRead instance = new VolumeInvoiceCellRead();
	}
	
	public static  VolumeInvoiceCellRead getInstance(){
		return SingletonHolder.instance;
	}

	 /** 
     * 根据单元格序号和单元格的值设置发票模型的值
     * @param invoice 发票模型
     * @param cellNum 单元格序号
     * @param cellValue 单元格值
     * @throws Exception  
     */  
	@Override
	public void readCellInvoice(FinInvoice invoice, int cellNum, String cellValue) throws Exception{
	switch(cellNum){
     	case 1:
     		invoice.setInvkind(cellValue);
     		break;
     	case 2:
     		invoice.setInvnum(cellValue);
     		break;
     	case 3:
     		if(StringUtil.isNotEmpty(cellValue)){
     			invoice.setInvdate(new SimpleDateFormat("yyyy-MM-dd").parse(cellValue));
     		}
     		break;
     	case 4:
     		//invoice.setInvStatus(getInvStatus(cellValue));
     		break;
     	case 5:
     		invoice.setSellname(cellValue);
     		break;
     	case 6:
     		invoice.setSelltaxno(cellValue);
     		break;
     	case 7:
     		invoice.setBuyname(cellValue);
     		break;
     	case 8:
     		invoice.setBuytaxno(cellValue);
     		break;
     	case 9:
     		//invoice.setMachinePrinted(cellValue);
     		break;
     	case 10:
     		//invoice.setJqbh(cellValue);
     		break;
     	case 11:
     		//invoice.setReceivingClerk(cellValue);
     		break;
     	case 12:
     		invoice.setJym(cellValue);
     		break;
     }

	}

	/** 
     * 根据单元格序号和单元格的值设置发票明细模型的值
     * @param invoice 发票模型
     * @param invoiceDetail 单元格序号
     * @param cellValue 单元格值
     * @throws Exception  
     */  
	@Override
	public void readCellDetail(FinInvoiceDetail invoiceDetail, int cellNum, String cellValue,boolean flag) throws Exception {
		
		switch(cellNum){
			case 0:
				//invoiceDetail.setLineNo(Integer.parseInt(cellValue));
				break;
	     	case 1:
	     		invoiceDetail.setInvKind(cellValue);
	     		break;
	     	case 2:
	     		invoiceDetail.setInvNum(cellValue);
	     		break;
	     	case 3:
	     		invoiceDetail.setTaxClassCode(cellValue != null?cellValue.trim():null);
	     		break;
	     	case 4:
	     		invoiceDetail.setGname(cellValue);
	     		break;
	     	case 5:
	     		invoiceDetail.setPrice(cellValue);
	     		break;
	     	case 6:
	     		invoiceDetail.setGnum(cellValue);
	     		break;
	     	case 7:
	     		invoiceDetail.setInvCost(getDoubleValue(cellValue));
	     		break;
	     }
		
	}

}
