fix: deduct available stock before production yield adjustment

This commit is contained in:
ar51
2026-10-12 11:57:24 +08:00
parent de6656dfe0
commit edefe52082
6 changed files with 246 additions and 80 deletions

View File

@@ -14,7 +14,7 @@ Expected:
- model parses successfully;
- quantity is accepted;
- the original demand of 10 remains visible in the reply and record, while the baseline and every recommended candidate call the API with 15 after dividing by 95% yield and rounding to a batch of five;
- original demand 10 remains visible; read each model's own stock first, then deduct it before applying 95% yield and rounding to five. With zero stock production is 15; stock of at least 10 gives zero production and retains the first stock-delivery result;
- the bot immediately adds the Feishu `OnIt` (typing) reaction to the original message after the valid trigger is accepted and before the API query starts;
- the controlled script uses the macOS system trust store and keeps TLS verification enabled;
- no temporary TLS-bypass parameter is required for the normal happy path;
@@ -84,7 +84,7 @@ Expected:
- the bot immediately adds the Feishu `OnIt` (typing) reaction to the original message after the continuation and active-context gates pass;
- the bot reuses the active model and quantity only for that same sender and chat;
- the continuation retains original demand 10 and again uses forecast quantity 15; it never compounds the adjustment to 20;
- continuation retains original demand 10 and computes each new candidate from its own current stock; with zero stock production is 15. It never compounds an earlier adjustment or reuses baseline stock;
- the bot queries candidate positions 5-8 in the unchanged rule order;
- the original model and candidate positions 1-4 are not queried or displayed again;
- unavailable candidates still consume their original positions and are summarized under `不可用候选`;
@@ -268,3 +268,13 @@ Expected:
```text
以上为内部候选方案,不构成客户正式交期承诺;需 AR516 或授权责任人结合库存、生产、采购、客户优先级和最新系统数据人工复核后使用。
```
## Stock-First Production Quantity Acceptance
- D=24, S=6: query D=24 to read stock, calculate net demand 18 and production 20, query with 20. Display shortage gap 18 and use the final API workdays/date and shortage details.
- D=24, S=0: production 30; D=25, S=6: net demand 19 and production exactly 20.
- D=24, S>=24: production 0, retain original-query stock-delivery result, no quantity=0 request. D=5, S=1: production 5, so reuse the first query.
- Different candidates use different stock and production quantities; initial and continuation batches retain original demand and never compound yield allowance.
- Missing/invalid stock is unavailable, never zero; changed stock between the two queries invalidates that model's result without an automatic retry.
- D=24, S=20: calculate net demand 4, production 5, but report delivery unavailable because the current API would take the stock shortcut with quantity=5; never claim full coverage or invent a date.
- New record metadata preserves each model's net/production/API quantities without changing existing table columns or historical records.