/** * <p>Make other entries include reversing if it's need when save.</p> * @param pAddParam additional param * @param pEntity entity * @param pIsNew if entity was new * @throws Exception - an exception **/ @Override public final void makeOtherEntries(final Map<String, Object> pAddParam, final PaymentFrom pEntity, final boolean pIsNew) throws Exception { @SuppressWarnings("unchecked") Map<String, String[]> parameterMap = (Map<String, String[]>) pAddParam. get("parameterMap"); if (parameterMap.get("actionAdd") != null && "makeAccEntries".equals(parameterMap.get("actionAdd")[0])) { this.srvSalesInvoice.calculateTotalPayment(pEntity .getSalesInvoice()); getSrvOrm().updateEntity(pEntity.getSalesInvoice()); } }
/** * <p>Create entity.</p> * @param pAddParam additional param * @return entity instance * @throws Exception - an exception **/ @Override public final PaymentFrom createEntity( final Map<String, Object> pAddParam) throws Exception { PaymentFrom entity = new PaymentFrom(); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setItsDate(new Date()); entity.setIsNew(true); addAccSettingsIntoAttrs(pAddParam); addTypeCodeIntoAttrs(pAddParam); return entity; }
/** * <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); }