final WageLine pEntity, final IRequestData pRequestData) throws Exception { if (!pEntity.getIdDatabaseBirth().equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_change_foreign_src"); .retrieveEntity(pAddParam, pEntity.getItsOwner())); "attempt_to_change_accounted_document"); getSrvOrm().deleteEntity(pAddParam, pEntity); updateOwner(pAddParam, pEntity); pAddParam.put("nextEntity", pEntity.getItsOwner());
final AccSettings pAs) throws Exception { pReqVars.put("SalesReturnLineitsOwnerdeepLevel", 1); List<SalesReturnLine> igls = getSrvOrm().retrieveListWithConditions( pReqVars, SalesReturnLine.class, "where SALESRETURNLINE.TAXCATEGORY is not null" txRest = txRest.subtract(taxTot); getSrvOrm().updateEntity(pReqVars, ilnt.get(i));
/** * <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>Retrieve entries for lines owner id/type.</p> * @param pAddParam additional param * @param pOwnerTypeCode Owner Type code * @param pOwnerId Owner ID * @return warehouse entries made by this document * @throws Exception - an exception **/ @Override public final List<WarehouseEntry> retrieveEntriesForOwner( final Map<String, Object> pAddParam, final Integer pOwnerTypeCode, final Long pOwnerId) throws Exception { String tblNm = WarehouseEntry.class.getSimpleName().toUpperCase(); String where = " where SOURCEOWNERTYPE=" + pOwnerTypeCode + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and SOURCEOWNERID=" + pOwnerId; return getSrvOrm() .retrieveListWithConditions(pAddParam, WarehouseEntry.class, where); }
/** * <p>Get match foreign given ID.</p> * @param pReqVars additional param * @param pId ID * @return match foreign * @throws Exception an Exception **/ public final MatchForeign getFor(final Map<String, Object> pReqVars, final Long pId) throws Exception { MatchForeign mf = getSrvOrm().retrieveEntityById(pReqVars, MatchForeign.class, pId); mf.setItsLines(getSrvOrm().retrieveListWithConditions(pReqVars, MatchForeignLine.class, "where ITSOWNER=" + pId)); return mf; }
final IRequestData pRequestData) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_entry_for_foreign_src"); .retrieveEntity(pAddParam, pEntity.getAccCredit())); if (pEntity.getAccCredit().getSubaccType() != null && pEntity.getSubaccCreditId() == null) { .retrieveEntity(pAddParam, pEntity.getAccDebit())); if (pEntity.getAccDebit().getSubaccType() != null && pEntity.getSubaccDebitId() == null) { getSrvOrm().insertEntity(pAddParam, pEntity); pEntity.setIsNew(false); AccountingEntries itsOwner = getSrvOrm().retrieveEntityById(pAddParam, AccountingEntries.class, pEntity.getSourceId()); itsOwner.setTotalCredit(BigDecimal.valueOf(totals[1]).setScale( accSettings.getCostPrecision(), accSettings.getRoundingMode())); getSrvOrm().updateEntity(pAddParam, itsOwner); getSrvBalance().handleNewAccountEntry(pAddParam, null, null,
pReqVars.put("DebtorCreditorneededFields", ndFlDc); pEntity.setItsOwner(getSrvOrm() .retrieveEntity(pReqVars, pEntity.getItsOwner())); pReqVars.remove("DebtorCreditorneededFields"); pReqVars.remove("DebtorCreditortaxDestinationdeepLevel"); pEntity.setService(getSrvOrm() .retrieveEntity(pReqVars, pEntity.getService())); boolean isTaxable = as.getIsExtractSalesTaxFromSales() && !pEntity .getItsOwner().getOmitTaxes() && !pEntity.getItsOwner().getCustomer() pReqVars.put("DestTaxServSelLnitsOwnerdeepLevel", 1); List<DestTaxServSelLn> dtls = getSrvOrm() .retrieveListWithConditions(pReqVars, DestTaxServSelLn.class, "where ITSOWNER=" + pEntity.getService().getItsId()); pReqVars.remove("DestTaxServSelLnitsOwnerdeepLevel"); pReqVars.put("InvItemTaxCategoryLineitsOwnerdeepLevel", 1); List<InvItemTaxCategoryLine> itcls = getSrvOrm() .retrieveListWithConditions(pReqVars, InvItemTaxCategoryLine.class, "where ITSOWNER=" + pEntity.getTaxCategory().getItsId()); new SalesInvoiceServiceTaxLine(); iitl.setIsNew(true); iitl.setIdDatabaseBirth(this.srvOrm.getIdDatabase()); iitl.setItsTotal(addTx); iitl.setTax(itcl.getTax()); getSrvOrm().insertEntity(pReqVars, pEntity);
final Wage pWage) throws Exception { List<WageTaxTableEmployee> wttel = getSrvOrm() .retrieveListWithConditions(pAddParam, WageTaxTableEmployee.class, "where EMPLOYEE=" + pWage.getEmployee().getItsId()); if (wttel != null && wttel.size() > 0) { getSrvOrm().deleteEntityWhere(pAddParam, WageTaxLine.class, "ITSOWNER=" + pWage.getItsId()); BigDecimal bigDecimal100 = new BigDecimal("100.00"); String ownerFldName = "itsOwner"; pWage.setItsLines(getSrvOrm() .retrieveListForField(pAddParam, wlfr, ownerFldName)); Map<WageType, BigDecimal> empleeTotTaxLnMap = new HashMap<WageType, BigDecimal>(); .retrieveEntity(pAddParam, wtte.getItsOwner().getTax())); .retrieveListForField(pAddParam, wttlfr, ownerFldName)); .retrieveListForField(pAddParam, wttt, ownerFldName)); BigDecimal totalTaxableForTax = BigDecimal.ZERO; for (WageLine wl : pWage.getItsLines()) { WageTaxLine wtl = new WageTaxLine(); wtl.setIsNew(true); wtl.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wtl.setItsOwner(pWage); wtl.setAllowance(wtte.getAllowance());
/** * <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; }
.retrieveEntity(pAddParam, pEntity.getItsOwner())); getSrvOrm().insertEntity(pAddParam, pEntity); pEntity.setIsNew(false); } else { getSrvOrm().updateEntity(pAddParam, pEntity);
final IRequestData pRequestData) throws Exception { if (pEntity.getIsNew()) { this.srvOrm.insertEntity(pAddParam, pEntity); pEntity.setIsNew(false); } else { erec.setItsOwner(pEntity); pEntity.setErecipients(getSrvOrm() .retrieveListForField(pAddParam, erec, "itsOwner")); if (pEntity.getErecipients().size() == 0) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "choose_recipient"); pEntity.setEmailConnect(this.srvOrm.retrieveEntity(pAddParam, pEntity.getEmailConnect())); EmailStringProperty emStrProp = new EmailStringProperty(); emStrProp.setItsOwner(pEntity.getEmailConnect()); pEntity.getEmailConnect().setStringProperties(getSrvOrm() .retrieveListForField(pAddParam, emStrProp, "itsOwner")); EmailIntegerProperty emIntProp = new EmailIntegerProperty(); emIntProp.setItsOwner(pEntity.getEmailConnect()); pEntity.getEmailConnect().setIntegerProperties(getSrvOrm() .retrieveListForField(pAddParam, emIntProp, "itsOwner")); Eattachment eattach = new Eattachment(); eattach.setItsOwner(pEntity); pEntity.setEattachments(getSrvOrm() .retrieveListForField(pAddParam, eattach, "itsOwner")); getEmailSender().openConnection(pAddParam, pEntity.getEmailConnect()); getEmailSender().sendEmail(pAddParam, pEntity);
final SalesInvoice pInvoice, final String pLang, final boolean pIsOverseas) throws Exception { SalesInvoice inv = this.srvOrm.retrieveEntity(pReqVars, pInvoice); if (pIsOverseas) { Set<String> ndFlSil = new HashSet<String>(); pReqVars.put("InvItemneededFields", ndFlItUm); pReqVars.put("UnitOfMeasureneededFields", ndFlItUm); inv.setItsLines(getSrvOrm().retrieveListByQuery(pReqVars, SalesInvoiceLine.class, evalSalesInvOverseaseLinesSql(inv.getItsId().toString(), pLang))); pReqVars.put("SalesInvoiceLineitsOwnerdeepLevel", 1); //only ID inv.setItsLines(getSrvOrm(). retrieveListWithConditions(pReqVars, SalesInvoiceLine.class, "where REVERSEDID is null and ITSOWNER=" + inv.getItsId())); pReqVars.remove("SalesInvoiceLineitsOwnerdeepLevel"); pReqVars.put("SalesInvoiceTaxLineitsOwnerdeepLevel", 1); //only ID inv.setTaxesLines(getSrvOrm(). retrieveListForField(pReqVars, sitl, "itsOwner")); pReqVars.remove("SalesInvoiceTaxLineitsOwnerdeepLevel"); if (pIsOverseas) { pReqVars.put("ServiceToSaleneededFields", ndFlItUm); pReqVars.put("UnitOfMeasureneededFields", ndFlItUm); inv.setServices(getSrvOrm().retrieveListByQuery(pReqVars, SalesInvoiceServiceLine.class, evalSalesInvOverseaseServiceLinesSql( inv.getItsId().toString(), pLang)));
/** * <p> * Synchronize entity (that just read) with entity in database. * It just check if it's new. * </p> * @param pAddParam additional params * @param pEntity object * @return isNew if entity exist in database (need update) * @throws Exception - an exception **/ @Override public final boolean sync(final Map<String, Object> pAddParam, final Object pEntity) throws Exception { Object entityPbDb = getSrvOrm().retrieveEntity(pAddParam, pEntity); return entityPbDb == null; }
final AccSettings pAs, final RoundingMode pRm) throws Exception { pReqVars.put("SalesInvoiceTaxLineitsOwnerdeepLevel", 1); List<SalesReturnTaxLine> itls = getSrvOrm().retrieveListWithConditions( pReqVars, SalesReturnTaxLine.class, "where ITSOWNER=" + pItsOwner.getItsId()); .setScale(pAs.getPricePrecision(), pRm)); if (itl.getIsNew()) { getSrvOrm().insertEntity(pReqVars, itl); itl.setIsNew(false); } else { getSrvOrm().updateEntity(pReqVars, itl); if (countUpdatedItl < itls.size()) { for (int j = countUpdatedItl; j < itls.size(); j++) { getSrvOrm().deleteEntity(pReqVars, itls.get(j)); getSrvOrm().deleteEntity(pReqVars, prtln);
/** * <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; } }
this.replicationMethod.setItsId(replicationMethodId); this.replicationMethod = getSrvOrm() .retrieveEntity(pAddParam, this.replicationMethod); ReplExcludeAccountsDebit ead = new ReplExcludeAccountsDebit(); ead.setItsOwner(this.replicationMethod); this.replicationMethod.setExcludeDebitAccounts(getSrvOrm() .retrieveListForField(pAddParam, ead, "itsOwner")); ReplExcludeAccountsCredit eac = new ReplExcludeAccountsCredit(); eac.setItsOwner(this.replicationMethod); this.replicationMethod.setExcludeCreditAccounts(getSrvOrm() .retrieveListForField(pAddParam, eac, "itsOwner"));
this.srvDatabase.beginTransaction(); di = getSrvOrm() .retrieveEntityWithConditions(pAddParam, DatabaseInfo.class, ""); String requestedDatabaseIdStr = (String) pAddParam .get("requestedDatabaseId"); entities = getSrvOrm().retrieveList(pAddParam, pEntityClass); } else { entities = getSrvOrm() .retrieveListWithConditions(pAddParam, pEntityClass, conditions);
final AccountingEntry pEntity, final IRequestData pRequestData) throws Exception { AccountingEntry entity = this.srvOrm.retrieveEntity(pAddParam, pEntity); AccountingEntries doc = getSrvOrm().retrieveEntityById(pAddParam, AccountingEntries.class, entity.getSourceId()); if (!doc.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_entry_for_foreign_src"); entity.setItsId(null); entity.setIdBirth(null); entity.setIdDatabaseBirth(this.srvOrm.getIdDatabase()); entity.setItsDate(new Date()); entity.setSourceType(this.accountingEntriesTypeCode);
.retrieveEntity(pAddParam, pEntity.getManufacturingProcess())); pEntity.setInvItem(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getInvItem())); if (!(InvItem.FINISHED_PRODUCT_ID.equals(pEntity.getInvItem() .getItsType().getItsId()) || InvItem.MATERIAL_ID getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); if (pEntity.getReversedId() != null) { Manufacture reversed = getSrvOrm().retrieveEntityById(pAddParam, Manufacture.class, pEntity.getReversedId()); if (reversed.getReversedId() != null) { getSrvOrm().updateEntity(pAddParam, reversed); pEntity.setTheRest(BigDecimal.ZERO); } else {
final Object pEntity) throws Exception { APersistableBase entityPb = (APersistableBase) pEntity; int currDbId = getSrvOrm().getIdDatabase(); if (currDbId == entityPb.getIdDatabaseBirth()) { throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG, + " and " + tblNm + ".IDDATABASEBIRTH=" + entityPb.getIdDatabaseBirth(); APersistableBase entityPbDb = getSrvOrm() .retrieveEntityWithConditions(pAddParam, entityPb.getClass(), whereStr); entityPb.setIdBirth(entityPb.getItsId()); entityPb.setItsId(null);