@Path("/SaveTax") @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public boolean saveTax(IncomeTax tax) { E1 e1 = dao.getE1DAO() .findById(new E1Id(tax.getId().getTaxPayerId(), tax.getId().getYear()), false); if (e1 != null) return dao.getE1DAO().submitIncomeTax(tax); return false; }
@Path("/tax") @GET @Produces("application/json") public IncomeTax calculateAndSaveTax( @QueryParam("tId") int taxpayerId, @QueryParam("year") int year) { // getE1 // getObj() // getFinalIncome // GET CHILD'S & infand from table 3 // IS RETIRED // βάζω περιορισμό στο αφορολόγιτο έως >0 && <= 12000€ boolean is65Retired = false; boolean isMarriage = false; boolean isYoung = false; IncomeTax incomeTax = null; E1Id key = new E1Id(taxpayerId, year); E1 e1 = dao.getE1DAO().findById(key, true); if (e1 == null) return incomeTax; isMarriage = e1.getMarriage() == 1; E1objectiveSpending objSpend = dao.getE1DAO().getObjectiveSpendingByE1Id(key); E1expensesRemovedFromTotalIncome erfti = dao.getE1DAO().getExpensesRemovedFromTotalIncomeByE1Id(key); E1infoData info = dao.getE1DAO().getInfoDataByE1Id(key); E1reduceTax reduceTax = dao.getE1DAO().getReduceTaxByE1Id(key); E1taxableIncomes taxable = dao.getE1DAO().getTaxableIncomesByE1Id(key); try { if (info != null) { is65Retired = Utils.toSafeInteger(info.get_013()) == 1; isYoung = Utils.toSafeInteger(info.get_017()) == 1; } float principalTotalTaxableIncome = getPrincipalTaxableIncome(erfti, taxable, objSpend, isMarriage, is65Retired); float princepalNoTax = getPrincipalNoTax(reduceTax, isYoung, is65Retired, principalTotalTaxableIncome); if (info != null) { is65Retired = Utils.toSafeInteger(info.get_014()) == 1; isYoung = Utils.toSafeInteger(info.get_018()) == 1; } float wifeTotalTaxableIncome = getWifeTaxableIncome(erfti, taxable, objSpend, isMarriage, is65Retired); float wifeNoTax = getWifeNoTax(reduceTax, isYoung, is65Retired, wifeTotalTaxableIncome); // incomeTax = new IncomeTax(new IncomeTaxId(taxpayerId, year), // getTax(principalTotalTaxableIncome, princepalNoTax), // getTax(wifeTotalTaxableIncome, wifeNoTax)); // incomeTax.setE1(e1); incomeTax = new IncomeTax( e1, getTax(principalTotalTaxableIncome, princepalNoTax), getTax(wifeTotalTaxableIncome, wifeNoTax)); incomeTax.setId(new IncomeTaxId(taxpayerId, year)); dao.getE1DAO().submitIncomeTax(incomeTax); incomeTax.setE1(null); } catch (Exception ex) { log.error("Calculate Tax error :", ex); } return incomeTax; }