| @@ -113,7 +113,7 @@ open class StockLedgerFixExportService( | |||||
| writer.write("-- stock-ledger-fix patch\n") | writer.write("-- stock-ledger-fix patch\n") | ||||
| writer.write("-- from $from inclusive to ${toExclusive.minusDays(1)} inclusive (date < $toExclusive)\n") | writer.write("-- from $from inclusive to ${toExclusive.minusDays(1)} inclusive (date < $toExclusive)\n") | ||||
| writer.write("-- parts=${parts.joinToString(",")}\n") | writer.write("-- parts=${parts.joinToString(",")}\n") | ||||
| writer.write("-- apply order: 1.0 inventory → 2.1 delete ledger + stock_out lot → ledger(+2.3) UPDATE → 2.7 SIL/SOL/adjustment record then ADJ INSERT → 2.6 stock_lot_day\n") | |||||
| writer.write("-- apply order: 1.0 lot outQty NULL→0 then inventory → 2.1 delete ledger + stock_out lot → ledger(+2.3) UPDATE → 2.7a lot inQty + SIL/SOL/adjustment record then ADJ INSERT → 2.6 stock_lot_day\n") | |||||
| writer.write("-- INNER JOIN id: target rows without matching id are skipped on UPDATE\n") | writer.write("-- INNER JOIN id: target rows without matching id are skipped on UPDATE\n") | ||||
| if (want23 && !want10) { | if (want23 && !want10) { | ||||
| writer.write("-- WARN: 2.3 without 1.0 — new inventory ids may be missing on target; prefer include 1.0\n") | writer.write("-- WARN: 2.3 without 1.0 — new inventory ids may be missing on target; prefer include 1.0\n") | ||||
| @@ -153,6 +153,9 @@ open class StockLedgerFixExportService( | |||||
| } | } | ||||
| private fun writeExportInventory10(writer: BufferedWriter, jdbc: NamedParameterJdbcTemplate) { | private fun writeExportInventory10(writer: BufferedWriter, jdbc: NamedParameterJdbcTemplate) { | ||||
| writer.write("-- === 1.0 lot line outQty NULL → 0 (before inventory; trigger may run, next block overwrites buckets) ===\n") | |||||
| writer.write(StockLedgerFixInventorySql.ZERO_NULL_OUT_QTY_SQL.trim()) | |||||
| writer.write(";\n\n") | |||||
| writer.write("-- === 1.0 inventory (INSERT with fixed id + UPDATE qty/status) ===\n") | writer.write("-- === 1.0 inventory (INSERT with fixed id + UPDATE qty/status) ===\n") | ||||
| var batch = 0 | var batch = 0 | ||||
| jdbc.query( | jdbc.query( | ||||