Files
AutoBOM/VBA_BOMConverter/Modules/M09_BOMExtractor.bas
Misaka_Company e086dee920
All checks were successful
NTFY Notification / notify (push) Successful in 4s
feat: implement BIP upload worksheet with quantity calculation fix
This commit implements the BIP upload worksheet functionality for ERP system integration and fixes a critical bug in quantity calculation.

Changes:
1. Added BIP upload configuration constants to M04_Config.bas
   - BIP_UPLOAD_SHEET_NAME = "BIP上传"
   - BIP_ROW_NUMBER_BASE = 7000
   - BIP_SUPPLY_MODE = "一般发料"
   - BIP_ISSUE_ORG = "重庆布莱迪仪器仪表有限公司"

2. Extended input data reading to 4 columns (M09_BOMExtractor.bas)
   - Column D: Product Code (产品编码)
   - Updated ReadInputModels to read columns A:D

3. Added product code mapping in main flow
   - Created productCodeMap Dictionary to store order number -> product code mappings
   - Stored product codes during input processing loop

4. Created WriteBIPUploadResults function
   - Generates 9-column BIP upload worksheet
   - Implements row number generation (7000 + material sequence number)
   - Resets sequence counter for each new order
   - Includes all rows (including error rows)
   - Formats worksheet with borders, column widths, and freeze panes

5. **CRITICAL FIX**: Corrected quantity calculation logic
   - Added order quantity lookup from inputModels
   - Changed from: materialQty = result(12) (BOM base quantity only)
   - Changed to: finalQty = bomQty * currentOrderQty
   - Applied fix to both "生产数量" (column 3) and "计划出库数量" (column 9)
   - Updated comment to clarify result(12) is BOM base quantity

Output Format (9 columns):
1. 来源单据号 (Source Document Number) - Production Order No
2. 产品编码 (Product Code)
3. 生产数量 (Production Quantity) = Order Qty × Material Qty
4. 行号 (Row Number) = 7000 + sequence (resets per order)
5. 材料编码 (Material Code)
6. 供应方式 (Supply Mode) = "一般发料"
7. 需用日期 (Required Date) = Current date (yyyy/m/d format)
8. 发料组织 (Issue Organization) = "重庆布莱迪仪器仪表有限公司"
9. 计划出库数量 (Planned Output Qty) = Order Qty × Material Qty

Business Rules Implemented:
- Error rows are included (material code is empty, quantities are 0)
- Empty product codes are written as empty strings
- Row numbers reset to 7001 for each new order
- Material quantities are correctly calculated as order quantity × BOM quantity

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-26 14:41:58 +08:00

47 KiB