/** * <p>Query loader.</p> * @param pFileName File Name * @return String * @throws Exception - an exception **/ public final String lazyGetQuery(final String pFileName) throws Exception { if (this.queries.get(pFileName) == null) { String flName = "/" + "accounting" + "/" + "journalEntries" + "/" + pFileName + ".sql"; this.queries.put(pFileName, loadString(flName)); } return this.queries.get(pFileName); }
final IDoc pEntity) throws Exception { Calendar calCurrYear = Calendar.getInstance(); calCurrYear.setTime(getSrvAccSettings().lazyGetAccSettings() .getCurrentAccYear()); calCurrYear.set(Calendar.MONTH, 0); if (sourcesLine.getIsUsed() && sourcesLine.getSourceType().equals(pEntity.constTypeCode())) { String query = lazyGetQuery(sourcesLine.getFileName()); String idName = "ITSID"; if (pEntity.getIdBirth() != null) { recordSet = getSrvDatabase().retrieveRecords(query); if (recordSet.moveToFirst()) { Long itsDateLong = null; do { AccountingEntry accEntry = new AccountingEntry(); accEntry.setIdDatabaseBirth(getSrvDatabase().getIdDatabase()); if (itsDateLong == null) { itsDateLong = getSrvDatabase().getSrvRecordRetriever() .getDate(recordSet.getRecordSet(), "ITSDATE").getTime(); getSrvBalance().handleNewAccountEntry(null, null, new Date(itsDateLong)); //This is for SrvBalanceStd only!!! String accDebitId = getSrvDatabase().getSrvRecordRetriever() .getString(recordSet.getRecordSet(), "ACCDEBIT"); Account accDebit = new Account(); accDebit.setItsId(accDebitId); accEntry.setAccDebit(accDebit);
final IDoc pReversing, final IDoc pReversed) throws Exception { List<AccountingEntry> sources = getSrvOrm().retrieveListWithConditions( AccountingEntry.class, " where SOURCETYPE=" + pReversing.constTypeCode() + " and SOURCEID=" + pReversing.getReversedId() for (AccountingEntry source : sources) { if (!source.getIdDatabaseBirth() .equals(getSrvDatabase().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_reverse_foreign_acconting_entries"); getSrvBalance().handleNewAccountEntry(null, null, new Date(itsDateLong)); //This is for SrvBalanceStd only!!! accEntry.setIdDatabaseBirth(getSrvDatabase().getIdDatabase()); accEntry.setSourceType(pReversing.constTypeCode()); Long reversingDocId = pReversing.getItsId(); accEntry.setDescription(getSrvI18n().getMsg("made_at") + " " + getDateFormatter().format(new Date()) + " " + getSrvI18n() .getMsg("by") + " " + getSrvI18n().getMsg(pReversing.getClass() .getSimpleName() + "short") + " #" + pReversing.getIdDatabaseBirth() + "-" + reversingDocId + ", " + getDateFormatter() .format(pReversing.getItsDate()) + ", " + getSrvI18n().getMsg("reversed_entry_n") + source .getIdDatabaseBirth() + "-" + source.getItsId() + " " + pReversing.getDescription());
/** * <p>Get SrvAccEntry in lazy mode.</p> * @return SrvAccEntry - SrvAccEntry * @throws Exception - an exception */ public final synchronized SrvAccEntry<RS> lazyGetSrvAccEntry() throws Exception { if (this.srvAccEntry == null) { this.srvAccEntry = new SrvAccEntry<RS>(factoryAppBeans.lazyGetSrvOrm(), factoryAppBeans.lazyGetSrvDatabase(), lazyGetSrvTypeCodeAccSources(), lazyGetSrvAccSettings(), lazyGetSrvBalanceStd(), factoryAppBeans.lazyGetSrvI18n(), lazyGetEntryDateFormatter()); } return this.srvAccEntry; }
/** * <p>Retrieve accounting entries for document.</p> * @param pAddParam additional param * @param pEntity a document * @throws Exception - an exception **/ @Override public final List<AccountingEntry> retrieveAccEntriesFor( final Map<String, Object> pAddParam, final IDoc pEntity) throws Exception { Long docId = pEntity.getItsId(); if (pEntity.getIdBirth() != null) { docId = pEntity.getIdBirth(); } List<AccountingEntry> result = getSrvOrm().retrieveListWithConditions( pAddParam, AccountingEntry.class, " where SOURCETYPE=" + pEntity.constTypeCode() + " and SOURCEID=" + docId + " and SOURCEDATABASEBIRTH=" + pEntity.getIdDatabaseBirth()); return result; }
final IDoc pEntity) throws Exception { Calendar calCurrYear = Calendar.getInstance(new Locale("en", "US")); calCurrYear.setTime(getSrvAccSettings().lazyGetAccSettings(pAddParam) .getCurrentAccYear()); calCurrYear.set(Calendar.MONTH, 0); if (sourcesLine.getIsUsed() && sourcesLine.getSourceType().equals(pEntity.constTypeCode())) { String query = lazyGetQuery(sourcesLine.getFileName()); String idName = "ITSID"; if (pEntity.getIdBirth() != null) { recordSet = getSrvDatabase().retrieveRecords(query); if (recordSet.moveToFirst()) { Long itsDateLong = null; do { AccountingEntry accEntry = new AccountingEntry(); accEntry.setIdDatabaseBirth(getSrvDatabase().getIdDatabase()); if (itsDateLong == null) { itsDateLong = pEntity.getItsDate().getTime(); getSrvBalance().handleNewAccountEntry(pAddParam, null, null, new Date(itsDateLong)); //This is for SrvBalanceStd only!!! accEntry.setSubaccDebit(recordSet.getString("SUBACCDEBIT")); accEntry.setDebit(BigDecimal.valueOf(recordSet.getDouble("DEBIT")) .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam) .getCostPrecision(), getSrvAccSettings() .lazyGetAccSettings(pAddParam).getRoundingMode())); String accCreditId = recordSet.getString("ACCCREDIT");
final IDoc pReversing, final IDoc pReversed) throws Exception { List<AccountingEntry> sources = getSrvOrm().retrieveListWithConditions( pAddParam, AccountingEntry.class, " where SOURCETYPE=" + pReversing.constTypeCode() + " and SOURCEID=" for (AccountingEntry source : sources) { if (!source.getIdDatabaseBirth() .equals(getSrvDatabase().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_reverse_foreign_acconting_entries"); getSrvBalance().handleNewAccountEntry(pAddParam, null, null, new Date(itsDateLong)); //This is for SrvBalanceStd only!!! accEntry.setIdDatabaseBirth(getSrvDatabase().getIdDatabase()); accEntry.setSourceType(pReversing.constTypeCode()); Long reversingDocId = pReversing.getItsId(); accEntry.setDescription(getSrvI18n().getMsg("made_at", langDef) + " " + dateFormat.format(new Date()) + " " + getSrvI18n() .getMsg("by", langDef) + " " + getSrvI18n().getMsg(pReversing.getClass() .getSimpleName() + "short", langDef) + " #" + pReversing.getIdDatabaseBirth() + "-" + reversingDocId + ", " + dateFormat.format(pReversing.getItsDate()) + ", " + getSrvI18n().getMsg("reversed_entry_n", langDef) + source .getIdDatabaseBirth() + "-" + source.getItsId()); accEntry.setReversedId(source.getItsId());
/** * <p>Get SrvAccEntry in lazy mode.</p> * @return SrvAccEntry - SrvAccEntry * @throws Exception - an exception */ public final SrvAccEntry<RS> lazyGetSrvAccEntry() throws Exception { String beanName = getSrvAccEntryName(); @SuppressWarnings("unchecked") SrvAccEntry<RS> srvAccEntry = (SrvAccEntry<RS>) this.factoryAppBeans.getBeansMap().get(beanName); if (srvAccEntry == null) { srvAccEntry = new SrvAccEntry<RS>(this.factoryAppBeans .lazyGetSrvOrm(), this.factoryAppBeans.lazyGetSrvDatabase(), lazyGetSrvTypeCodeAccSources(), lazyGetSrvAccSettings(), lazyGetSrvBalanceStd(), this.factoryAppBeans.lazyGetSrvI18n()); this.factoryAppBeans.getBeansMap().put(beanName, srvAccEntry); this.factoryAppBeans.lazyGetLogger().info(null, FactoryAccServices.class, beanName + " has been created."); } return srvAccEntry; }
/** * <p>Retrieve accounting entries for document.</p> * @param pAddParam additional param * @param pEntity a document * @throws Exception - an exception **/ @Override public final List<AccountingEntry> retrieveAccEntriesFor( final Map<String, Object> pAddParam, final IDoc pEntity) throws Exception { Long docId = pEntity.getItsId(); if (pEntity.getIdBirth() != null) { docId = pEntity.getIdBirth(); } List<AccountingEntry> result = getSrvOrm().retrieveListWithConditions( AccountingEntry.class, " where SOURCETYPE=" + pEntity.constTypeCode() + " and SOURCEID=" + docId + " and SOURCEDATABASEBIRTH=" + pEntity.getIdDatabaseBirth()); return result; }
/** * <p>Query loader.</p> * @param pFileName File Name * @return String * @throws Exception - an exception **/ public final String lazyGetQuery(final String pFileName) throws Exception { if (this.queries.get(pFileName) == null) { String flName = "/" + "accounting" + "/" + "journalEntries" + "/" + pFileName + ".sql"; this.queries.put(pFileName, loadString(flName)); } return this.queries.get(pFileName); }