/** * <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>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>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; }
accSettings.getQuantityPrecision(), accSettings.getRoundingMode())); pEntity.setItsOwner(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getItsOwner())); getSrvOrm().insertEntity(pAddParam, pEntity);
/** * <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"); } }