/** * <p>Create AccountingEntries.</p> * @param pAddParam additional param * @return AccountingEntries request(or) scoped bean * @throws Exception - an exception */ @Override public final AccountingEntries create( final Map<String, Object> pAddParam) throws Exception { AccountingEntries object = new AccountingEntries(); object.setIsNew(false); object.setIdDatabaseBirth(this.databaseId); object.setItsDate(new Date()); return object; }
/** * <p>Retrieve owned list of entities for itsOwner. * E.g. invoices lines for invoice</p> * @param pAddParam additional param * @param pEntityItsOwner itsOwner * @return owned list of business objects * @throws Exception - an exception */ @Override public final List<AccountingEntry> retrieveOwnedList( final Map<String, Object> pAddParam, final AccountingEntries pEntityItsOwner) throws Exception { return retrieveOwnedListById(pAddParam, pEntityItsOwner.getItsId()); }
/** * <p>Retrieve copy of entity from DB by given ID.</p> * @param pAddParam additional param * @param pId ID * @return entity or null * @throws Exception - an exception **/ @Override public final AccountingEntries retrieveCopyEntity( final Map<String, Object> pAddParam, final Object pId) throws Exception { AccountingEntries entity = getSrvOrm() .retrieveCopyEntity(AccountingEntries.class, pId); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setItsDate(new Date()); entity.setIsNew(true); addAccSettingsIntoAttrs(pAddParam); return entity; } }
AccountingEntries doc = getSrvOrm().retrieveEntityById(pAddParam, AccountingEntries.class, pEntity.getSourceId()); if (!doc.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, pEntity.setItsDate(new Date()); pEntity.setSourceType(this.accountingEntriesTypeCode); pEntity.setSourceDatabaseBirth(doc.getIdDatabaseBirth()); String docDescription; if (doc.getDescription() != null) { docDescription = doc.getDescription(); } else { docDescription = ""; DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef)); pEntity.setDescription(getSrvI18n().getMsg(AccountingEntries.class .getSimpleName() + "short", langDef) + " #" + doc.getIdDatabaseBirth() + "-" + doc.getItsId() + ", " + dateFormat.format(doc.getItsDate()) + ". " + docDescription); //only local allowed pEntity.setIsNew(true); pRequestData.setAttribute("entity", pEntity); pRequestData.setAttribute("AccountingEntriesVersion", doc.getItsVersion()); pRequestData.setAttribute("mngUvds", this.mngUvdSettings); pRequestData.setAttribute("srvOrm", this.srvOrm);
itsOwner.setItsVersion(ownerVersion); String query = "select sum(DEBIT) as DEBIT, sum(CREDIT) as CREDIT from " + "ACCOUNTINGENTRY where SOURCETYPE=" + this.accountingEntriesTypeCode + " and SOURCEID=" + itsOwner.getItsId(); String[] columns = new String[]{"DEBIT", "CREDIT"}; Double[] totals = getSrvDatabase().evalDoubleResults(query, columns); itsOwner.setTotalDebit(BigDecimal.valueOf(totals[0]).setScale( accSettings.getCostPrecision(), accSettings.getRoundingMode())); itsOwner.setTotalCredit(BigDecimal.valueOf(totals[1]).setScale( accSettings.getCostPrecision(), accSettings.getRoundingMode())); getSrvOrm().updateEntity(pAddParam, itsOwner);
"select sum(DEBIT) as DEBIT, sum(CREDIT) as CREDIT from " + "ACCOUNTINGENTRY where SOURCETYPE=" + this.accountingEntriesTypeCode + " and SOURCEID=" + itsOwner.getItsId(); String[] columns = new String[]{"DEBIT", "CREDIT"}; Double[] totals = getSrvDatabase().evalDoubleResults(query, columns); itsOwner.setTotalDebit(BigDecimal.valueOf(totals[0]).setScale( getSrvAccSettings().lazyGetAccSettings().getCostPrecision(), getSrvAccSettings().lazyGetAccSettings().getRoundingMode())); itsOwner.setTotalCredit(BigDecimal.valueOf(totals[1]).setScale( getSrvAccSettings().lazyGetAccSettings().getCostPrecision(), getSrvAccSettings().lazyGetAccSettings().getRoundingMode()));
/** * <p>Create entity with its itsOwner e.g. invoice line * for invoice.</p> * @param pAddParam additional param * @param pEntityItsOwner itsOwner * @return entity instance * @throws Exception - an exception **/ @Override public final AccountingEntry createEntityWithOwner( final Map<String, Object> pAddParam, final AccountingEntries pEntityItsOwner) throws Exception { if (!pEntityItsOwner.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_entry_for_foreign_src"); } AccountingEntry entity = new AccountingEntry(); entity.setIsNew(true); entity.setItsDate(new Date()); entity.setSourceId(pEntityItsOwner.getItsId()); entity.setSourceType(this.accountingEntriesTypeCode); addAccSettingsIntoAttrs(pAddParam); return entity; }
final IRequestData pRequestData) throws Exception { AccountingEntries entity = this.srvOrm.retrieveEntity(pAddParam, pEntity); entity.setIsNew(false); pRequestData.setAttribute("entity", entity); pRequestData.setAttribute("mngUvds", this.mngUvdSettings); pRequestData.setAttribute("ownedListsMap", ownedListsMap); String where = "where SOURCETYPE=" + this.accountingEntriesTypeCode + " and SOURCEID=" + entity.getItsId(); List<AccountingEntry> entities = this.srvOrm .retrieveListWithConditions(pAddParam, AccountingEntry.class, where);
/** * <p>Save entity into DB.</p> * @param pAddParam additional param * @param pEntity entity * @param isEntityDetached ignored * @throws Exception - an exception **/ @Override public final void saveEntity(final Map<String, Object> pAddParam, final AccountingEntries pEntity, final boolean isEntityDetached) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_change_foreign_src"); } if (pEntity.getIsNew()) { getSrvOrm().insertEntity(pEntity); } else { getSrvOrm().updateEntity(pEntity); } }
AccountingEntries doc = getSrvOrm().retrieveEntityById( AccountingEntries.class, pIdOwner); if (!doc.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, entity.setSourceType(this.accountingEntriesTypeCode); entity.setDescription(getSrvI18n().getMsg(AccountingEntries.class .getSimpleName() + "short") + " #" + doc.getIdDatabaseBirth() + "-" + doc.getItsId() + ", " + getDateFormatter().format(doc.getItsDate()) + ". " + doc.getDescription()); //only local allowed addAccSettingsIntoAttrs(pAddParam); return entity;
AccountingEntries doc = getSrvOrm().retrieveEntityById(pAddParam, AccountingEntries.class, entity.getSourceId()); if (!doc.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, entity.setSourceType(this.accountingEntriesTypeCode); String docDescription; if (doc.getDescription() != null) { docDescription = doc.getDescription(); } else { docDescription = ""; DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef)); entity.setDescription(getSrvI18n().getMsg(AccountingEntries.class .getSimpleName() + "short", langDef) + " #" + doc.getIdDatabaseBirth() + "-" + doc.getItsId() + ", " + dateFormat.format(doc.getItsDate()) + ". " + docDescription); //only local allowed entity.setIsNew(true); pRequestData.setAttribute("entity", entity); pRequestData.setAttribute("AccountingEntriesVersion", doc.getItsVersion()); pRequestData.setAttribute("mngUvds", this.mngUvdSettings); pRequestData.setAttribute("srvOrm", this.srvOrm);
/** * <p>Create entity.</p> * @param pAddParam additional param * @return entity instance * @throws Exception - an exception **/ @Override public final AccountingEntries createEntity( final Map<String, Object> pAddParam) throws Exception { AccountingEntries entity = new AccountingEntries(); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setItsDate(new Date()); entity.setIsNew(true); addAccSettingsIntoAttrs(pAddParam); return entity; }
+ "," + entityPb.getIdDatabaseBirth()); entityPb.setSourceId(accountingEntries.getItsId());
+ "," + entityPb.getIdDatabaseBirth()); entityPb.setSourceId(accountingEntries.getItsId());