/** * <p>It prepares database after import.</p> * @param pAddParam additional params * @throws Exception - an exception **/ @Override public final void make( final Map<String, Object> pAddParam) throws Exception { this.replicationMethod.setLastDateReplication(new Date()); getSrvOrm().updateEntity(pAddParam, this.replicationMethod); }
/** * <p>Process entity request.</p> * @param pAddParam additional param, e.g. return this line's * document in "nextEntity" for farther process * @param pRequestData Request Data * @param pEntity Entity to process * @return Entity processed for farther process or null * @throws Exception - an exception **/ @Override public final T process( final Map<String, Object> pAddParam, final T pEntity, final IRequestData pRequestData) throws Exception { if (pEntity.getIsNew()) { this.srvOrm.insertEntity(pAddParam, pEntity); pEntity.setIsNew(false); } else { this.srvOrm.updateEntity(pAddParam, pEntity); } return pEntity; }
/** * <p>Make other entries include reversing if it's need when save.</p> * @param pAddParam additional param * @param pEntity entity * @param pRequestData Request Data * @param pIsNew if entity was new * @throws Exception - an exception **/ @Override public final void makeOtherEntries(final Map<String, Object> pAddParam, final PaymentTo pEntity, final IRequestData pRequestData, final boolean pIsNew) throws Exception { String actionAdd = pRequestData.getParameter("actionAdd"); if ("makeAccEntries".equals(actionAdd)) { this.prcPurchaseInvoiceSave.calculateTotalPayment(pAddParam, pEntity.getPurchaseInvoice()); getSrvOrm().updateEntity(pAddParam, pEntity.getPurchaseInvoice()); } }
/** * <p>Make other entries include reversing if it's need when save.</p> * @param pAddParam additional param * @param pEntity entity * @param pRequestData Request Data * @param pIsNew if entity was new * @throws Exception - an exception **/ @Override public final void makeOtherEntries(final Map<String, Object> pAddParam, final PaymentFrom pEntity, final IRequestData pRequestData, final boolean pIsNew) throws Exception { String actionAdd = pRequestData.getParameter("actionAdd"); if ("makeAccEntries".equals(actionAdd)) { this.prcSalesInvoiceSave.calculateTotalPayment(pAddParam, pEntity .getSalesInvoice()); getSrvOrm().updateEntity(pAddParam, pEntity.getSalesInvoice()); } }
/** * <p>Update InvItemTaxCategory.</p> * @param pAddParam additional param * @param pOwner InvItemTaxCategory * @throws Exception - an exception **/ public final void updateInvItemTaxCategory( final Map<String, Object> pAddParam, final InvItemTaxCategory pOwner) throws Exception { InvItemTaxCategoryLine iitcl = new InvItemTaxCategoryLine(); iitcl.setItsOwner(pOwner); List<InvItemTaxCategoryLine> ptl = getSrvOrm() .retrieveListForField(pAddParam, iitcl, "itsOwner"); StringBuffer sb = new StringBuffer(""); int i = 0; BigDecimal aggrPercent = BigDecimal.ZERO; for (InvItemTaxCategoryLine pt : ptl) { aggrPercent = aggrPercent.add(pt.getItsPercentage()); if (i++ > 0) { sb.append(", "); } sb.append(pt.getTax().getItsName()); } pOwner.setAggrOnlyPercent(aggrPercent); pOwner.setTaxesDescription(sb.toString()); getSrvOrm().updateEntity(pAddParam, pOwner); }
/** * <p>Update InvItemTaxCategory.</p> * @param pAddParam additional param * @param pOwner InvItemTaxCategory * @throws Exception - an exception **/ public final void updateInvItemTaxCategory( final Map<String, Object> pAddParam, final InvItemTaxCategory pOwner) throws Exception { InvItemTaxCategoryLine iitcl = new InvItemTaxCategoryLine(); iitcl.setItsOwner(pOwner); List<InvItemTaxCategoryLine> ptl = getSrvOrm() .retrieveListForField(pAddParam, iitcl, "itsOwner"); StringBuffer sb = new StringBuffer(""); int i = 0; BigDecimal aggrPercent = BigDecimal.ZERO; for (InvItemTaxCategoryLine pt : ptl) { aggrPercent = aggrPercent.add(pt.getItsPercentage()); if (i++ > 0) { sb.append(", "); } sb.append(pt.getTax().getItsName()); } pOwner.setAggrOnlyPercent(aggrPercent); pOwner.setTaxesDescription(sb.toString()); getSrvOrm().updateEntity(pAddParam, pOwner); }
/** * <p>Handle new accounting entry is created to check dirty. * This is implementation of dirty check for all accounts.</p> * @param pAddParam additional param * @param pAcc account * @param pSubaccId subaccount ID * @param pDateAt date at * @throws Exception - an exception **/ @Override public final synchronized void handleNewAccountEntry( final Map<String, Object> pAddParam, final Account pAcc, final Long pSubaccId, final Date pDateAt) throws Exception { if (lazyGetBalanceAtAllDirtyCheck(pAddParam).getLeastAccountingEntryDate() .getTime() > pDateAt.getTime()) { if (getLogger().getIsShowDebugMessagesFor(getClass())) { getLogger().debug(null, SrvBalanceStd.class, "changing least last entry date from " + this.balanceAtAllDirtyCheck .getLeastAccountingEntryDate() + " to " + pDateAt); } this.balanceAtAllDirtyCheck .setLeastAccountingEntryDate(pDateAt); getSrvOrm() .updateEntity(pAddParam, this.balanceAtAllDirtyCheck); } }
/** * <p>Insert immutable line into DB.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ public final void updateOwner(final Map<String, Object> pAddParam, final WageLine pEntity) throws Exception { String query = "select sum(GROSSWAGE) as GROSSWAGE from " + WageLine.class .getSimpleName().toUpperCase() + " where ITSOWNER=" + pEntity.getItsOwner().getItsId(); Double total = getSrvDatabase().evalDoubleResult(query, "GROSSWAGE"); if (total == null) { total = 0d; } pEntity.getItsOwner().setItsTotal(BigDecimal.valueOf(total).setScale( getSrvAccSettings().lazyGetAccSettings(pAddParam).getPricePrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner()); }
/** * <p>Insert immutable line into DB.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ public final void updateOwner(final Map<String, Object> pAddParam, final WageLine pEntity) throws Exception { String query = "select sum(GROSSWAGE) as GROSSWAGE from " + WageLine.class .getSimpleName().toUpperCase() + " where ITSOWNER=" + pEntity.getItsOwner().getItsId(); Double total = getSrvDatabase().evalDoubleResult(query, "GROSSWAGE"); if (total == null) { total = 0d; } pEntity.getItsOwner().setItsTotal(BigDecimal.valueOf(total).setScale( getSrvAccSettings().lazyGetAccSettings(pAddParam).getPricePrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner()); }
/** * <p>Makes invoice tax line.</p> * @param pReqVars additional param * @param pItl PurchaseReturnTaxLine * @param pInvLn inventory line * @param pIsItemBasis Is Item Basis * @throws Exception an Exception **/ public final void makeItl(final Map<String, Object> pReqVars, final PurchaseReturnTaxLine pItl, final PurchaseInvoiceServiceLine pInvLn, final boolean pIsItemBasis) throws Exception { pItl.setItsTotal(pItl.getItsTotal().add(pInvLn.getTotalTaxes())); if (!pIsItemBasis) { pItl.setTaxableInvBas(pItl.getTaxableInvBas().add(pInvLn.getSubtotal())); } if (pItl.getIsNew()) { getSrvOrm().insertEntity(pReqVars, pItl); pItl.setIsNew(false); } else { getSrvOrm().updateEntity(pReqVars, pItl); } }
/** * <p>Makes invoice tax line.</p> * @param pReqVars additional param * @param pItl SalesReturnTaxLine * @param pInvLn inventory line * @param pIsItemBasis Is Item Basis * @throws Exception an Exception **/ public final void makeItl(final Map<String, Object> pReqVars, final SalesReturnTaxLine pItl, final SalesInvoiceServiceLine pInvLn, final boolean pIsItemBasis) throws Exception { pItl.setItsTotal(pItl.getItsTotal().add(pInvLn.getTotalTaxes())); if (!pIsItemBasis) { pItl.setTaxableInvBas(pItl.getTaxableInvBas().add(pInvLn.getSubtotal())); } if (pItl.getIsNew()) { getSrvOrm().insertEntity(pReqVars, pItl); pItl.setIsNew(false); } else { getSrvOrm().updateEntity(pReqVars, pItl); } }
/** * <p>Process entity request.</p> * @param pAddParam additional param, e.g. return this line's * document in "nextEntity" for farther process * @param pRequestData Request Data * @param pEntity Entity to process * @return Entity processed for farther process or null * @throws Exception - an exception **/ @Override public final T process( final Map<String, Object> pAddParam, final T pEntity, final IRequestData pRequestData) throws Exception { if (pEntity.getIsNew()) { this.srvOrm.insertEntity(pAddParam, pEntity); pEntity.setIsNew(false); } else { if (pEntity.getIdDatabaseBirth() != getSrvOrm().getIdDatabase()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_change_foreign_src"); } this.srvOrm.updateEntity(pAddParam, pEntity); } return pEntity; }
pItl.setIsNew(false); } else { getSrvOrm().updateEntity(pReqVars, pItl);
this.srvOrm.insertEntity(pAddParam, pEntity); } else { this.srvOrm.updateEntity(pAddParam, pEntity);
pReversed.setReversedId(pReversing.getItsId()); pReversed.setReversedIdDatabaseBirth(pReversing.getIdDatabaseBirth()); getSrvOrm().updateEntity(pReqVars, pReversed); this.srvAccEntry.reverseEntries(pReqVars, pReversing, pReversed);
/** * <p>Process entity request.</p> * @param pAddParam additional param, e.g. return this line's * document in "nextEntity" for farther process * @param pRequestData Request Data * @param pEntity Entity to process * @return Entity processed for farther process or null * @throws Exception - an exception **/ @Override public final AccountingEntry process( final Map<String, Object> pAddParam, final AccountingEntry pEntity, final IRequestData pRequestData) throws Exception { if (pEntity.getIsNew()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "forbidden_operation"); } else { if (pEntity.getIdDatabaseBirth() != getSrvOrm().getIdDatabase()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_change_foreign_src"); } AccountingEntry entity = this.srvOrm.retrieveEntity(pAddParam, pEntity); entity.setDescription(pEntity.getDescription()); this.srvOrm.updateEntity(pAddParam, entity); pRequestData.setAttribute("accSettings", this.srvAccSettings.lazyGetAccSettings(pAddParam)); return entity; } }
/** * <p>Insert immutable line into DB.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ public final void updateOwner(final Map<String, Object> pAddParam, final AdditionCostLine pEntity) throws Exception { String query = "select sum(ITSTOTAL) as ITSTOTAL from" + " ADDITIONCOSTLINE where ITSOWNER=" + pEntity.getItsOwner().getItsId(); Double total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL"); pEntity.getItsOwner().setTotalAdditionCost(BigDecimal.valueOf(total) .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); pEntity.getItsOwner().setItsTotal(pEntity.getItsOwner() .getTotalMaterialsCost().add(pEntity.getItsOwner() .getTotalAdditionCost()).setScale(getSrvAccSettings() .lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); pEntity.getItsOwner().setItsCost(pEntity.getItsOwner().getItsTotal() .divide(pEntity.getItsOwner().getItsQuantity(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner()); }
/** * <p>Insert immutable line into DB.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ public final void updateOwner(final Map<String, Object> pAddParam, final AdditionCostLine pEntity) throws Exception { String query = "select sum(ITSTOTAL) as ITSTOTAL from" + " ADDITIONCOSTLINE where ITSOWNER=" + pEntity.getItsOwner().getItsId(); Double total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL"); pEntity.getItsOwner().setTotalAdditionCost(BigDecimal.valueOf(total) .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); pEntity.getItsOwner().setItsTotal(pEntity.getItsOwner() .getTotalMaterialsCost().add(pEntity.getItsOwner() .getTotalAdditionCost()).setScale(getSrvAccSettings() .lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); pEntity.getItsOwner().setItsCost(pEntity.getItsOwner().getItsTotal() .divide(pEntity.getItsOwner().getItsQuantity(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner()); }
/** * <p>Evaluate period of stored balances according settings, * if it's changed then it switch on "current balances are dirty".</p> * @param pAddParam additional param * @return pPeriod EPeriod e.g. MONTHLY * @throws Exception - an exception **/ @Override public final synchronized EPeriod evalBalanceStorePeriod( final Map<String, Object> pAddParam) throws Exception { if (!lazyGetBalanceAtAllDirtyCheck(pAddParam).getBalanceStorePeriod() .equals(getSrvAccSettings().lazyGetAccSettings(pAddParam) .getBalanceStorePeriod())) { getLogger().info(null, SrvBalanceStd.class, "changing period from " + this.balanceAtAllDirtyCheck .getBalanceStorePeriod() + " to " + getSrvAccSettings() .lazyGetAccSettings(pAddParam).getBalanceStorePeriod()); this.balanceAtAllDirtyCheck .setBalanceStorePeriod(getSrvAccSettings().lazyGetAccSettings(pAddParam) .getBalanceStorePeriod()); this.balanceAtAllDirtyCheck.setIsPeriodChanged(true); this.balanceAtAllDirtyCheck .setCurrentBalanceDate(initDate); getSrvOrm() .updateEntity(pAddParam, this.balanceAtAllDirtyCheck); } return this.balanceAtAllDirtyCheck.getBalanceStorePeriod(); }
this.balanceAtAllDirtyCheck.setIsPeriodChanged(true); getSrvOrm() .updateEntity(pAddParam, this.balanceAtAllDirtyCheck);