Class DeviceAccountingService
java.lang.Object
org.bgerp.plugin.inventoru.service.DeviceAccountingService
Keeps a unit and the balance of its position in step whenever the unit itself is saved, deleted
or restored — from its card, from the equipment import or from the 1C stock import.
A unit is counted on a store when its position is serial tracked, it stands on that store
and it is not deleted; the balance of the position there is never below the units counted.
Writing
device.store_id directly, as the card and the import used to, put ten units on a
store whose balance stayed zero, and the first write-off there then failed on a discrepancy
nobody could explain. Here a unit is put on a store, moved or refused, and only through a
movement when the balance has to change.
Units not counted — position without serial tracking, or none — are saved as before.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat saving a unit means for the balance.static final classThe decision together with what it applies to.static enumWho saves the unit: decides whether placing it on a store 1C keeps is allowed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanWriteoffUnit(Device device) Whether writing this unit off by hand would go through — what the card asks before it draws the button.voidcheckDelete(Device device) Refuses to delete a counted unit: it would stop being counted while the balance it makes up stays.voidcheckWriteoffUnit(Device device) Refuses to write a unit off a warehouse by hand when that would not do what it promises.booleanisSerialTracked(int itemId) voidApplies what the configuration says about a unit becoming decommissioned: it goes back to the main store.plan(Device before, Device after, DeviceAccountingService.Source source) What savingafteroverbeforemeans for the balance; nothing is written.voidRestores a deleted unit.save(Device before, Device after, int userId, DeviceAccountingService.Source source, String comment) Saves the unit and writes the movement its new place requires, in the caller's transaction.uncovered(int itemId, int storeId)
-
Constructor Details
-
DeviceAccountingService
-
-
Method Details
-
normalize
Applies what the configuration says about a unit becoming decommissioned: it goes back to the main store. On a store 1C keeps it stays — the return is 1C's document, and the next stock import moves it; the card says so.- Throws:
SQLException
-
plan
public DeviceAccountingService.Plan plan(Device before, Device after, DeviceAccountingService.Source source) throws SQLException What savingafteroverbeforemeans for the balance; nothing is written.- Parameters:
before- the unit as stored now,nullfor a new one- Throws:
SQLException
-
describe
- Returns:
- a line for a preview: what the balance will see, or why it is refused.
- Throws:
SQLException
-
save
public DeviceAccountingService.Plan save(Device before, Device after, int userId, DeviceAccountingService.Source source, String comment) throws SQLException, BGMessageException Saves the unit and writes the movement its new place requires, in the caller's transaction.- Parameters:
before- the unit as stored now,nullfor a new one;after.idmatches itcomment- comment of the movement, says where the change came from- Throws:
BGMessageException- refused; nothing has been writtenSQLException
-
checkDelete
Refuses to delete a counted unit: it would stop being counted while the balance it makes up stays.- Throws:
SQLExceptionBGMessageException
-
restore
Restores a deleted unit. Coming back counted, it takes a place in the balance: against a balance no unit backs, if there is one; otherwise a receipt. On a store 1C keeps it comes back off every store — 1C places it.- Throws:
SQLExceptionBGMessageException
-
isSerialTracked
- Throws:
SQLException
-
checkWriteoffUnit
Refuses to write a unit off a warehouse by hand when that would not do what it promises. The write-off of one unit is the way out for equipment entered by mistake: it drops the balance by one and takes the unit off the books. That only holds for a position counted per unit — under a plain one the movement would lower the balance and leave the card standing on the warehouse, the very divergence this service exists to prevent. On a warehouse whose serial numbers 1C keeps the write-off would be undone by the next stock import, which sees the unit still standing there and proposes to bring it back.- Throws:
SQLExceptionBGMessageException
-
canWriteoffUnit
Whether writing this unit off by hand would go through — what the card asks before it draws the button. A button that is always refused on click is worse than no button: the person types a reason, presses save and is told the action was never possible.- Throws:
SQLException
-
uncovered
- Returns:
- balance of the position on the store minus the units counted there
- Throws:
SQLException
-