/** * <p>Retrieve other data of entity e.g. warehouse entries.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ @Override public final void retrieveOtherDataFor(final Map<String, Object> pAddParam, final PaymentFrom pEntity) throws Exception { addTypeCodeIntoAttrs(pAddParam); }
/** * <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 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 SrvPaymentFrom service.</p> * @param pSrvName Service Name * @return SrvPaymentFrom PaymentFrom service * @throws Exception - an exception */ public final synchronized SrvPaymentFrom<RS> createSrvPaymentFrom(final String pSrvName) throws Exception { String srvSalesInvoiceName = "srv" + SalesInvoice.class .getSimpleName(); @SuppressWarnings("unchecked") SrvSalesInvoice<RS> srvSalesInvoice = (SrvSalesInvoice<RS>) factoryAppBeans.getBeansMap().get(srvSalesInvoiceName); if (srvSalesInvoice == null) { srvSalesInvoice = createSrvSalesInvoice(srvSalesInvoiceName); } SrvPaymentFrom<RS> srvEntity = new SrvPaymentFrom<RS>(factoryAppBeans .lazyGetSrvOrm(), srvSalesInvoice, lazyGetSrvAccSettings(), lazyGetSrvAccEntry(), factoryAppBeans.lazyGetSrvI18n(), lazyGetEntryDateFormatter(), lazyGetSrvTypeCodeSubacc()); factoryAppBeans.getBeansMap().put(pSrvName, srvEntity); return srvEntity; }
/** * <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 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 PaymentFrom pEntity) throws Exception { if (pEntity.getReversedId() == null) { pEntity.setSalesInvoice(null); } addTypeCodeIntoAttrs(pAddParam); }