Class SerialStockSync

java.lang.Object
org.bgerp.plugin.inventoru.sync1c.service.SerialStockSync

public class SerialStockSync extends Object
The stock of a serial tracked position on a store, reconciled per unit against 1C. 1C (series with balances per warehouse) reports such a position one row per serial number, so it is the master not only of how many units stand on a store but of which. The import compares the serial numbers 1C has on the store with the units counted there in ERP and proposes, for posting in "Pending incoming": a unit to come (ImportPending.ACTION_SERIAL_IN), a unit to leave (ImportPending.ACTION_SERIAL_OUT), and what the part of the balance without serial numbers must become (ImportPending.ACTION_UNCOVERED). A unit 1C places on a store where the balance was waiting for its serial number is attached right away, during the import: it changes no quantity, only says which unit the balance was — the first load of a list of units would otherwise be hundreds of rows to click through. Everything posted goes through movements and DeviceAccountingService, never by writing the balance: units and balance stay in step, and a unit that cannot come is named with the reason.
  • Constructor Details

    • SerialStockSync

      public SerialStockSync(Connection con)
  • Method Details

    • reconcile

      public void reconcile(int instanceId, EngineerWarehouse ew, int storeId, int itemId, List<Api1cStock> rows) throws SQLException
      Reconciles one serial tracked position on the store against the 1C rows of it.
      Parameters:
      rows - the 1C rows of the position; empty when it is absent from the answer — then every unit of it on the store leaves
      Throws:
      SQLException
    • describe

      public void describe(ImportPending p) throws SQLException
      Fills in what posting a proposal would do, or why it cannot — for the screen.
      Throws:
      SQLException
    • apply

      public void apply(ImportPending p, int userId, boolean acceptReturn) throws SQLException, BGMessageException
      Posts a proposal, claiming it first. A refusal is thrown; the caller's transaction takes back whatever was written.
      Parameters:
      acceptReturn - a unit written off in a process that 1C shows back on the store is taken back — without it such a unit is refused
      Throws:
      SQLException
      BGMessageException
    • applyAll

      public SerialStockSync.Result applyAll(List<ImportPending> list, int userId) throws SQLException
      Posts the proposals one by one: units coming first — they may attach to the unbacked balance before a correction takes it away — then units leaving, then the unbacked balance, then quantities. A refused one is rolled back alone and named in the result; the rest goes on.
      Throws:
      SQLException