package com.tax.file.utils.invoice;

import java.text.SimpleDateFormat;

import com.tax.file.model.FinCuspay;
import com.tax.file.model.FinCuspayDetail;
import com.yxcheng.token.utils.StringUtil;
/** 
 * 海关缴款书票单元格读取具体实现类
 * 
 * */ 
public class FinCuspayCellRead extends AbstractInvoiceCellRead {
	
	
    private FinCuspayCellRead(){
		
	}
	
	public static class SingletonHolder{
		private static FinCuspayCellRead instance = new FinCuspayCellRead();
	}
	
	public static  FinCuspayCellRead getInstance(){
		return SingletonHolder.instance;
	}

	 /** 
     * 根据单元格序号和单元格的值设置发票主模型的值
     * @param invoice 发票模型
     * @param cellNum 单元格序号
     * @param cellValue 单元格值
     * @throws Exception  
     */   
	public static void readCellCuspay(FinCuspay invoice, int cellNum, String cellValue) throws Exception{
		
	switch(cellNum){
     	case 1:
     		invoice.setPayNo(cellValue);
     		break;
     	case 2:
     		if(StringUtil.isNotEmpty(cellValue)){
     			invoice.setFillDate(new SimpleDateFormat("yyyy-MM-dd").parse(cellValue));
     		}
     		break;
     	case 3:
     		invoice.setPayUnitOneName(cellValue);
     		break;
     	case 4:
     		invoice.setPayUnitOneTaxno(cellValue);
     		break;
     	case 5:
     		invoice.setPayUnitTwoName(cellValue);
     		break;
     	case 6:
     		invoice.setPayUnitTwoTaxno(cellValue);
     		break;
     	case 7:
     		invoice.setImportPortCode(cellValue);
     		break;
     	case 8:
     		invoice.setTaxAmount(getBigDecimalValue(cellValue));
     		break;
     	case 9:
     		invoice.setImcomeOrgan(cellValue);
     		break;
     	case 10:
     		invoice.setApplyUnitCode(cellValue);
     		break;
     	case 11:
     		invoice.setCustomsUnitCode(cellValue);
     		break;
     	case 12:
     		invoice.setTradeWay(cellValue);
     		break;
     	case 13:
     		invoice.setBudgetSubjectsCode(cellValue);
     		break;
     	case 14:
     		invoice.setCollectionTreasuryCode(cellValue);
     		break;
     	case 15:
     		invoice.setContractNo(cellValue);
     		break;
     	case 16:
     		invoice.setTransport(cellValue);
     		break;
     	case 17:
     		if(StringUtil.isNotEmpty(cellValue)){
     			invoice.setPaymentTerm(new SimpleDateFormat("yyyy-MM-dd").parse(cellValue));
     		}
     		break;
     	case 18:
     		invoice.setDeliveryNo(cellValue);
     		break;
     	case 19:
     		invoice.setDataFrom(cellValue);;
     		break;
     }

	}
	
	/** 
     * 根据单元格序号和单元格的值设置发票明细模型的值
     * @param cuspayDetail 明细模型
     * @param cellNum 单元格序号
     * @param cellValue 单元格值
     * @throws Exception  
     */  
	public static void readCellDetail(FinCuspayDetail cuspayDetail, int cellNum, String cellValue) throws Exception {
		
		switch(cellNum){
		case 0:
			//cuspayDetail.setLineNo(Integer.parseInt(cellValue));
			break;
     	case 1:
     		cuspayDetail.setPayNo(cellValue);
     		break;
     	case 2:
     		cuspayDetail.setTaxno(cellValue);
     		break;
     	case 3:
     		cuspayDetail.setGname(cellValue);
     		break;
     	case 4:
     		cuspayDetail.setPayTaxesPrice(cellValue);
     		break;
     	case 5:
     		cuspayDetail.setGnum(cellValue);
     		break;
     	case 6:
     		cuspayDetail.setGpiece(cellValue);
     		break;
     	case 7:
     		cuspayDetail.setInvRate(getBigDecimalValue(cellValue));
     		break;
     	case 8:
     		cuspayDetail.setTaxAmount(getBigDecimalValue(cellValue));
     		break;
		}
	}

}
