@SuppressWarnings("unchecked") public Double getCustomerTax(Long customerId, Double totalAmt) throws Exception { Double taxAmt = 0D; List<TsServiceTax> taxList = this.getDao() .list( "from TsServiceTax t where t.deletFlag = 0 " + "and exists(from TdCustomerInfoForm c where c.customGrpId = t.customgrpId and c.customerId = ?) " + "and t.feeType='X'", customerId); if (taxList.isEmpty()) { taxList = this.getDao() .listAll( "from TsServiceTax t where t.deletFlag = 0 and t.customgrpId is null and t.feeType='X'"); } for (TsServiceTax tax : taxList) { List<TsTaxCode> taxCodeList = this.getDao().listAll("from TsTaxCode c where c.taxCode = '" + tax.getTaxCode() + "'"); for (TsTaxCode code : taxCodeList) { if ("E".equals(code.getTaxType())) { taxAmt -= totalAmt * (code.getTaxRate() / 100); } else { taxAmt += totalAmt * (code.getTaxRate() / 100); } } } return Operate.formatDouble(taxAmt); }
@SuppressWarnings("unchecked") public TsTaxCode getCustomerTax(Long customerCode) throws Exception { TsTaxCode maxTaxCode = null; List<TsServiceTax> taxList = this.getDao() .list( "from TsServiceTax t where t.deletFlag = 0 " + "and exists(from TdCustomerInfoForm c where c.customGrpId = t.customgrpId and c.customerId = ?) " + "and t.feeType='X'", customerCode); if (taxList.isEmpty()) { taxList = this.getDao() .listAll( "from TsServiceTax t where t.deletFlag = 0 and t.customgrpId is null and t.feeType='X'"); } for (TsServiceTax tax : taxList) { List<TsTaxCode> taxCodeList = this.getDao().listAll("from TsTaxCode c where c.taxCode = '" + tax.getTaxCode() + "'"); for (TsTaxCode code : taxCodeList) { if (null == maxTaxCode || maxTaxCode.getTaxRate() < code.getTaxRate()) { maxTaxCode = code; } } } return maxTaxCode; }