/** * <p>Make additional preparations on entity copy.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ @Override public final void makeAddPrepareForCopy(final Map<String, Object> pAddParam, final SalesInvoice pEntity) throws Exception { pEntity.setTotalTaxes(BigDecimal.ZERO); pEntity.setSubtotal(BigDecimal.ZERO); if (pEntity.getReversedId() == null) { pEntity.setPaymentTotal(BigDecimal.ZERO); pEntity.setPaymentDescription(""); } }
pEntity.setPrepaymentFrom(getSrvOrm() .retrieveEntity(pReqVars, pEntity.getPrepaymentFrom())); if (pEntity.getReversedId() == null && pEntity.getPrepaymentFrom() .getSalesInvoiceId() != null && !pEntity.getHasMadeAccEntries()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "prepayment_already_in_use"); if (pEntity.getReversedId() == null && !pEntity.getPrepaymentFrom() .getCustomer().getItsId().equals(pEntity.getCustomer().getItsId())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, if (pEntity.getReversedId() != null && pEntity.getPrepaymentFrom() != null && pEntity.getPaymentTotal().compareTo(pEntity.getPrepaymentFrom() .getItsTotal()) != 0) { "reverse_payments_first"); if (pEntity.getReversedId() != null && pEntity.getPrepaymentFrom() == null && pEntity.getPaymentTotal().compareTo(BigDecimal.ZERO) != 0) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "reverse_payments_first"); if (pEntity.getReversedId() == null) { calculateTotalPayment(pReqVars, pEntity);
pEntity.setPrepaymentFrom(getSrvOrm().retrieveEntity(pEntity .getPrepaymentFrom())); if (pEntity.getReversedId() == null && pEntity.getPrepaymentFrom() .getSalesInvoiceId() != null && !pEntity.getHasMadeAccEntries()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "prepayment_already_in_use"); if (pEntity.getReversedId() == null && !pEntity.getPrepaymentFrom() .getCustomer().getItsId().equals(pEntity.getCustomer().getItsId())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, if (pEntity.getReversedId() != null && pEntity.getPrepaymentFrom() != null && pEntity.getPaymentTotal().compareTo(pEntity.getPrepaymentFrom() .getItsTotal()) != 0) { "reverse_payments_first"); if (pEntity.getReversedId() != null && pEntity.getPrepaymentFrom() == null && pEntity.getPaymentTotal().compareTo(BigDecimal.ZERO) != 0) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "reverse_payments_first"); if (pEntity.getReversedId() == null) { calculateTotalPayment(pEntity);
/** * <p>Make save preparations before insert/update block if it's need.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ @Override public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam, final PaymentFrom pEntity) throws Exception { //BeigeORM refresh: pEntity.setAccCash(getSrvOrm() .retrieveEntity(pEntity.getAccCash())); if (pEntity.getAccCash().getSubaccType() != null && pEntity.getSubaccCashId() == null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "select_subaccount"); } SalesInvoice purchaseInvoice = getSrvOrm().retrieveEntity(pEntity .getSalesInvoice()); if (!purchaseInvoice.getHasMadeAccEntries() || purchaseInvoice.getReversedId() != null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "purchase_invoice_must_be_accounted"); } pEntity.setSalesInvoice(purchaseInvoice); }
/** * <p>Make save preparations before insert/update block if it's need.</p> * @param pAddParam additional param * @param pEntity entity * @param pRequestData Request Data * @throws Exception - an exception **/ @Override public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam, final PaymentFrom pEntity, final IRequestData pRequestData) throws Exception { //BeigeORM refresh: pEntity.setAccCash(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getAccCash())); if (pEntity.getAccCash().getSubaccType() != null && pEntity.getSubaccCashId() == null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "select_subaccount"); } if (pEntity.getSalesInvoice() != null) { SalesInvoice salesInvoice = getSrvOrm() .retrieveEntity(pAddParam, pEntity.getSalesInvoice()); if (!salesInvoice.getHasMadeAccEntries() || salesInvoice.getReversedId() != null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "sales_invoice_must_be_accounted"); } pEntity.setSalesInvoice(salesInvoice); } }
if (parameterMap.get("actionAdd") != null && "makeAccEntries".equals(parameterMap.get("actionAdd")[0])) { if (pEntity.getReversedId() != null) { if (pEntity.getReversedId() != null) { pEntity.getPrepaymentFrom().setSalesInvoiceId(null); } else {
String actionAdd = pRequestData.getParameter("actionAdd"); if ("makeAccEntries".equals(actionAdd)) { if (pEntity.getReversedId() != null) { pEntity.setForeignTotalTaxes(reversed.getForeignTotalTaxes().negate()); pEntity.setForeignTotal(reversed.getForeignTotal().negate()); reversed.setItsId(pEntity.getReversedId()); sil.setItsOwner(reversed); List<SalesInvoiceLine> reversedLines = getSrvOrm(). if (pEntity.getReversedId() != null) { pEntity.getPrepaymentFrom().setSalesInvoiceId(null); } else {