xx
This commit is contained in:
48
CLAUDE.md
48
CLAUDE.md
@@ -70,7 +70,9 @@ AccountingEntries.xlsx (Final accounting entry table)
|
||||
- Creates debit/credit entries following Chinese accounting standards
|
||||
- Merges cells for same ReceivedAmount groups
|
||||
- Marks validation failures with pink background (#FAD1D4)
|
||||
- Applies fixed exchange rate to currency conversions
|
||||
- Marks debit/credit imbalance with yellow background (#fff799)
|
||||
- Applies fixed exchange rate to currency conversions (3 decimal places)
|
||||
- Sets "核算项目" to empty for 到账金额 debit entries
|
||||
|
||||
3. **`analyze_excel.py`** - Structure Analysis Utility
|
||||
- Debugging tool to inspect merged cells
|
||||
@@ -103,20 +105,25 @@ AccountingEntries.xlsx (Final accounting entry table)
|
||||
1. **Debit Entry (到账金额)** - 1 record per ReceivedAmount
|
||||
- Account: `1002.02` - 银行存款 - 中行USD
|
||||
- Currency: 美元 (USD)
|
||||
- Amount: `ReceivedAmount × EXCHANGE_RATE`
|
||||
- Amount: `ReceivedAmount × EXCHANGE_RATE` (3 decimal places)
|
||||
- 核算项目: Empty (left blank)
|
||||
|
||||
2. **Debit Entry (手续费)** - Only if HandlingFee > 0
|
||||
- Account: `5603.03` - 财务费用-手续费
|
||||
- Currency: 人民币 (RMB)
|
||||
- Amount: `HandlingFee × EXCHANGE_RATE`
|
||||
- Amount: `HandlingFee × EXCHANGE_RATE` (3 decimal places)
|
||||
|
||||
3. **Credit Entries (订单明细)** - 1 record per Order
|
||||
- Account: `1122` - 应收账款
|
||||
- Currency: 美元 (USD)
|
||||
- Amount: `Order.Amount × EXCHANGE_RATE`
|
||||
- Amount: `Order.Amount × EXCHANGE_RATE` (3 decimal places)
|
||||
- **Display Order.Amount in "应收账款" column**
|
||||
- Skip orders where Amount is null
|
||||
|
||||
**Balance Verification**:
|
||||
- After generating debit and credit entries for each record, the system verifies: `|SUM(Debit) - SUM(Credit)| < 0.001`
|
||||
- If imbalanced, all entries for that record are marked with yellow background (#fff799)
|
||||
|
||||
### Special Processing Logic
|
||||
|
||||
#### Merged Cell Handling (process_excel.py:33-69)
|
||||
@@ -126,11 +133,14 @@ AccountingEntries.xlsx (Final accounting entry table)
|
||||
- Merged cell value read from top-left corner (min_row, min_col)
|
||||
|
||||
#### Validation and Error Marking
|
||||
- **checkRes calculation**: `abs((ReceivedAmount + HandlingFee) - Sum(Order[].Amount)) < 0.01`
|
||||
- **Error marking**: Pink background (#FAD1D4) applied to all entries where checkRes = false
|
||||
- **checkRes calculation**: `abs((ReceivedAmount + HandlingFee) - Sum(Order[].Amount)) < 0.01` (from extraction phase)
|
||||
- **Balance verification**: Per-record debit/credit validation with tolerance: `abs(SUM(Debit) - SUM(Credit)) < 0.001`
|
||||
- **Error marking priority**:
|
||||
1. Yellow background (#fff799) for debit/credit imbalance
|
||||
2. Pink background (#FAD1D4) for checkRes = false
|
||||
- Background color applied **before** cell merging to ensure visibility
|
||||
|
||||
#### Cell Merging Strategy (generate_accounting_entries.py:178-206)
|
||||
#### Cell Merging Strategy (generate_accounting_entries.py:179-215)
|
||||
- Groups entries by `(ReceivedAmount, HandlingFee)` key
|
||||
- Merges "到账金额" (column A) and "手续费" (column B) for consecutive rows
|
||||
- Centers content vertically and horizontally
|
||||
@@ -201,17 +211,24 @@ python3 generate_accounting_entries.py
|
||||
|
||||
3. **Order filtering**: Skip rows where OrderNum is None or empty string
|
||||
|
||||
4. **Amount precision**: All calculations rounded to 2 decimal places
|
||||
4. **Amount precision**:
|
||||
- Exchange rate calculations: **3 decimal places** (e.g., 25656.992)
|
||||
- Debit/credit balance tolerance: **0.001**
|
||||
|
||||
5. **UTF-8 encoding**: All files use UTF-8 encoding
|
||||
5. **核算项目 (Accounting dimension)**:
|
||||
- 到账金额 (Received amount debit): **Empty/blank**
|
||||
- 手续费 (Fee debit): **Empty/blank**
|
||||
- 订单明细 (Order credit): Account name
|
||||
|
||||
6. **Error handling**:
|
||||
6. **UTF-8 encoding**: All files use UTF-8 encoding
|
||||
|
||||
7. **Error handling**:
|
||||
- File not found: Exit with error message
|
||||
- Invalid sheet: Exit with error message
|
||||
- Invalid data: Log and skip row
|
||||
- checkRes=false: Mark but continue processing
|
||||
|
||||
7. **Performance**: Handles 300+ rows of Excel data generating 500+ accounting entries in <10 seconds
|
||||
8. **Performance**: Handles 300+ rows of Excel data generating 500+ accounting entries in <10 seconds
|
||||
|
||||
## Testing Guidance
|
||||
|
||||
@@ -231,6 +248,15 @@ python3 generate_accounting_entries.py
|
||||
|
||||
## Version History
|
||||
|
||||
- **v1.3** (2025-10-20): Enhanced accounting entry validation
|
||||
- Changed amount precision to **3 decimal places** for exchange rate calculations
|
||||
- Added per-record debit/credit balance verification with 0.001 tolerance
|
||||
- Added yellow background (#fff799) marking for imbalanced entries
|
||||
- Set 核算项目 to empty for 到账金额 debit entries
|
||||
- Updated balance verification tolerance to 0.001
|
||||
|
||||
- **v1.2** (2025-10-17): Added exchange rate file support (`exchange_rate.txt`), intelligent rate validation, improved error handling
|
||||
|
||||
- **v1.1** (2025-01-17): Optimized accounting rules - removed redundant debit entries, simplified single-order logic
|
||||
|
||||
- **v1.0** (2025-01-17): Initial release with extraction, generation, validation, and error marking features
|
||||
|
||||
Reference in New Issue
Block a user