fix(lastleg): account return carton outbound stock atomically
This commit is contained in:
@@ -9,7 +9,7 @@ const domesticSchemas = ['baiyue_auth', 'baiyue_iam', 'baiyue_order', 'baiyue_wa
|
||||
const overseasSchemas = ['baiyue_lastleg', 'baiyue_lastlag_warehouse']
|
||||
|
||||
test('两个入口分别只操作八个主业务库与两个仓储业务库,包括限定名引用', () => {
|
||||
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 223], [overseas, overseasSchemas, domesticSchemas, 135]]) {
|
||||
for (const [sql, allowed, other, count] of [[cn, domesticSchemas, overseasSchemas, 223], [overseas, overseasSchemas, domesticSchemas, 136]]) {
|
||||
assert.deepEqual([...sql.matchAll(/^CREATE DATABASE IF NOT EXISTS (\w+)/gm)].map(m => m[1]), allowed)
|
||||
assert.deepEqual([...new Set([...sql.matchAll(/^USE (\w+);/gm)].map(m => m[1]))], allowed)
|
||||
const body = sql.replace(/^--.*$/gm, '')
|
||||
@@ -28,10 +28,19 @@ test('纯初始化禁止迁移、数据回填、清理、重复建表和提前
|
||||
assert.doesNotMatch(body.replace(/^CREATE TRIGGER [\s\S]*?\$\$/gm, ''), /^\s*(?:UPDATE|DELETE FROM|REPLACE INTO)\b/gmi)
|
||||
assert.doesNotMatch(body, /CREATE TABLE IF NOT EXISTS/i)
|
||||
assert.equal((body.match(/AS initialization_status/g) ?? []).length, 1)
|
||||
assert.match(body.trim(), /SELECT 'PASS' AS initialization_status, '(CN|OVERSEAS)' AS region, (223|135) AS initialized_tables;$/)
|
||||
assert.match(body.trim(), /SELECT 'PASS' AS initialization_status, '(CN|OVERSEAS)' AS region, (223|136) AS initialized_tables;$/)
|
||||
}
|
||||
})
|
||||
|
||||
test('退货出库不可变流水限制重复扣减并保存数量守恒快照', () => {
|
||||
const journal = table(overseas, 'baiyue_lastleg', 'll_return_inventory_outbound_movement')
|
||||
assert.match(journal, /UNIQUE KEY uk_ll_return_outbound_pick_sku\(outbound_pick_id,sku_code\)/i)
|
||||
assert.match(journal, /UNIQUE KEY uk_ll_return_outbound_carton_sku\(customer_id,carton_id,sku_code\)/i)
|
||||
assert.match(journal, /CHECK\(quantity>0 AND total_after>=0 AND available_after>=0/i)
|
||||
assert.match(journal, /total_before-total_after=quantity AND available_before-available_after=quantity/i)
|
||||
assert.match(journal, /cartons_before-cartons_after=1 AND total_after>=available_after/i)
|
||||
})
|
||||
|
||||
test('平台管理员由外部bcrypt引导,强制首登改密且不创建客户', () => {
|
||||
const accounts = seedRows(cn, 'auth_account')
|
||||
assert.equal(accounts.length, 1)
|
||||
|
||||
Reference in New Issue
Block a user