/** * <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 MoveItemsLine createEntityWithOwner( final Map<String, Object> pAddParam, final MoveItems pEntityItsOwner) throws Exception { MoveItemsLine entity = new MoveItemsLine(); entity.setIsNew(true); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setItsOwner(pEntityItsOwner); return entity; }
/** * <p>Get for owner's ID.</p> * @return Long **/ @Override public final Long getOwnerId() { return this.getItsOwner().getItsId(); }
final MoveItemsLine pEntity, final IRequestData pRequestData) throws Exception { if (pEntity.getIsNew()) { if (pEntity.getItsQuantity().doubleValue() <= 0) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "quantity_less_or_equal_zero"); pEntity.setItsQuantity(pEntity.getItsQuantity().setScale( accSettings.getQuantityPrecision(), accSettings.getRoundingMode())); pEntity.setItsOwner(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getItsOwner())); getSrvOrm().insertEntity(pAddParam, pEntity); pEntity.setIsNew(false); this.srvWarehouseEntry.move(pAddParam, pEntity, pEntity .getWarehouseSiteFrom(), pEntity.getWarehouseSiteTo()); pEntity.getItsOwner().setItsVersion(ownerVersion); getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner()); pAddParam.put("nextEntity", pEntity.getItsOwner()); pAddParam.put("nameOwnerEntity", MoveItems.class.getSimpleName()); return null;
typeCodeMap.put(new MoveItems().constTypeCode(), MoveItems.class); typeCodeMap.put(new MoveItemsLine().constTypeCode(), MoveItemsLine.class); typeCodeMap.put(new SalesReturn().constTypeCode(),
/** * <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 MoveItemsLine retrieveCopyEntity( final Map<String, Object> pAddParam, final Object pId) throws Exception { MoveItemsLine entity = getSrvOrm().retrieveCopyEntity( MoveItemsLine.class, pId); @SuppressWarnings("unchecked") Map<String, String[]> parameterMap = (Map<String, String[]>) pAddParam. get("parameterMap"); if (parameterMap.get("actionAdd") != null && "reverse".equals(parameterMap.get("actionAdd")[0])) { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "reverse_not_supported"); } entity.setItsQuantity(BigDecimal.ZERO); entity.setIsNew(true); addAccSettingsIntoAttrs(pAddParam); return entity; }
/** * <p>Insert immutable line 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 MoveItemsLine pEntity, final boolean isEntityDetached) throws Exception { if (pEntity.getIsNew()) { if (pEntity.getItsQuantity().doubleValue() <= 0) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "quantity_less_or_equal_zero"); } pEntity.setItsQuantity(pEntity.getItsQuantity().setScale( getSrvAccSettings().lazyGetAccSettings().getQuantityPrecision(), getSrvAccSettings().lazyGetAccSettings().getRoundingMode())); getSrvOrm().insertEntity(pEntity); MoveItems itsOwner = getSrvOrm().retrieveEntityById( MoveItems.class, pEntity.getItsOwner().getItsId()); pEntity.setItsOwner(itsOwner); srvWarehouseEntry.move(pAddParam, pEntity, pEntity .getWarehouseSiteFrom(), pEntity.getWarehouseSiteTo()); } else { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "edit_not_allowed"); } }
typeCodeMap.put(new MoveItems().constTypeCode(), MoveItems.class); typeCodeMap.put(new MoveItemsLine().constTypeCode(), MoveItemsLine.class); typeCodeMap.put(new SalesReturn().constTypeCode(),
/** * <p>Create entity.</p> * @param pAddParam additional param * @return entity instance * @throws Exception - an exception **/ @Override public final MoveItemsLine createEntity( final Map<String, Object> pAddParam) throws Exception { MoveItemsLine entity = new MoveItemsLine(); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setIsNew(true); MoveItems itsOwner = new MoveItems(); entity.setItsOwner(itsOwner); addAccSettingsIntoAttrs(pAddParam); return entity; }
/** * <p>Get for document Date.</p> * @return Date **/ @Override public final Date getDocumentDate() { return this.getItsOwner().getItsDate(); }
/** * <p>Create entity with its itsOwner e.g. invoice line * for invoice.</p> * @param pAddParam additional param * @param pIdEntityItsOwner entity itsOwner ID * @return entity instance * @throws Exception - an exception **/ @Override public final MoveItemsLine createEntityWithOwnerById( final Map<String, Object> pAddParam, final Object pIdEntityItsOwner) throws Exception { MoveItemsLine entity = new MoveItemsLine(); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setIsNew(true); MoveItems itsOwner = new MoveItems(); itsOwner.setItsId(Long.valueOf(pIdEntityItsOwner.toString())); entity.setItsOwner(itsOwner); addAccSettingsIntoAttrs(pAddParam); return entity; }
/** * <p>Get for document Date.</p> * @return Date **/ @Override public final Date getDocumentDate() { return this.getItsOwner().getItsDate(); }
/** * <p>Get Owner Type.</p> * @return Integer **/ @Override public final Integer getOwnerType() { return this.getItsOwner().constTypeCode(); }
/** * <p>Get for owner's ID.</p> * @return Long **/ @Override public final Long getOwnerId() { return this.getItsOwner().getItsId(); }