财务分析 Skill
Use the bundled scripts to convert an Amazon settlement detail sheet and a SKU cost sheet into:
- A row-level profit analysis table
- A SKU summary with gross profit, margin, return rate, missing-cost checks, and risk tags
- An employee-facing Excel workbook
- A browser-ready HTML dashboard with SKU search, risk drill-down, print, and CSV export
Keep the workflow deterministic. Reuse the provided scripts instead of rewriting parsing or workbook-generation logic.
Before any sales, profit, return-rate, success-rate, or SKU summary, exclude pencil case, pencil pouch, pen case, pen pouch, and pen bag. If physical legacy inventory exists, report it only as 历史遗留清退; never include it in normal operating totals.
快速用法
$financial-analysis
请分析这两份亚马逊财务表,生成 Excel 利润核算表和 HTML 可视化看板,并重点标出亏损 SKU、低毛利 SKU、高退货 SKU、缺失成本 SKU。
Workflow
- Read references/finance-rules.md before interpreting transaction types.
- Inspect the input workbook and locate:
- The transaction detail sheet with headers such as
type, order id, sku, quantity, and total
- The cost sheet with
SKU, unit product cost, and first-leg cost
- Run
scripts/run_finance_analysis.py to produce normalized JSON, HTML, and Excel outputs.
- Review the generated summary:
- Confirm
Transfer rows are excluded
- Confirm
Order rows consume product and first-leg cost
- Confirm
Refund rows add costs back
- Confirm
FBA Customer Return Fee remains a standalone loss
- If margin outliers or missing costs appear, use the SKU summary and missing-cost section to explain the issue.
- Use the risk center to prioritize loss-making, low-margin, high-return, and missing-cost SKUs.
Input Expectations
- Transaction sheet:
- One header row
- Columns for
type, order id, sku, quantity, product sales, and total
- Cost sheet:
- One SKU per row
- Unit product cost in USD
- Unit first-leg cost in USD
- Optional rule transcript or notes file for audit context
If headers are not in English, map them explicitly before running the scripts or adapt the parser in scripts/run_finance_analysis.py.
Calculation Rules
- Use Amazon
total as the post-platform-fee settlement amount for the row.
- Apply cost impact by transaction type:
Order, Pedido, Liquidations: subtract product cost and first-leg cost
Refund, Refund_Retrocharge: add product cost and first-leg cost back
FBA Customer Return Fee: keep as a direct loss with no cost reversal
Transfer: exclude from profitability
Adjustment, Service Fee, FBA Inventory Fee, blank or unknown administrative rows: keep total only unless business rules say otherwise
- Define row gross profit as:
gross_profit = total + signed_product_cost + signed_first_leg_cost
Read references/finance-rules.md when you need the business explanation behind these signs.
Commands
Use the bundled Python runtime when available. The main entrypoint is:
python3 scripts/run_finance_analysis.py \
--report-xlsx /path/to/report.xlsx \
--report-sheet 财务报表 \
--cost-xlsx /path/to/cost.xlsx \
--cost-sheet 成本表 \
--output-dir /path/to/output
The script writes:
analysis.json
amazon_finance_dashboard.html
amazon_finance_profit_analysis.xlsx
Output Interpretation
Summary / dashboard output:
- Headline settlement amount
- Product-cost impact
- First-leg-cost impact
- Running gross profit
SKU Analysis:
- Focus on SKUs with enough order volume to be meaningful
- Prioritize low-margin SKUs and high return-rate SKUs
Missing Costs:
- Any SKU without a cost match weakens the gross-profit result
- Fix the cost sheet first, then rerun the analysis
Resources
references/finance-rules.md: business logic extracted from the meeting transcript
scripts/run_finance_analysis.py: parser, aggregator, insight builder, and HTML generator
scripts/build_workbook.mjs: employee-facing Excel generator using @oai/artifact-tool
Only patch the parsing logic when the source workbook structure genuinely differs. Do not create ad hoc formulas manually if the bundled scripts already cover the calculation path.
1---2name: financial-analysis3description: Analyze Amazon settlement reports together with SKU cost sheets and accounting rules to calculate running gross profit, refund impact, return-fee losses, and SKU-level profitability. Use when Codex needs to turn Amazon financial exports (`.xlsx`, `.csv`) plus product-cost mappings into employee-facing Excel or HTML analysis, especially for order/refund/customer-return-fee workflows and low-margin SKU diagnosis.4---56# 财务分析 Skill78Use the bundled scripts to convert an Amazon settlement detail sheet and a SKU cost sheet into:910- A row-level profit analysis table11- A SKU summary with gross profit, margin, return rate, missing-cost checks, and risk tags12- An employee-facing Excel workbook13- A browser-ready HTML dashboard with SKU search, risk drill-down, print, and CSV export1415Keep the workflow deterministic. Reuse the provided scripts instead of rewriting parsing or workbook-generation logic.1617Before any sales, profit, return-rate, success-rate, or SKU summary, exclude `pencil case`, `pencil pouch`, `pen case`, `pen pouch`, and `pen bag`. If physical legacy inventory exists, report it only as `历史遗留清退`; never include it in normal operating totals.1819## 快速用法2021```text22$financial-analysis23请分析这两份亚马逊财务表,生成 Excel 利润核算表和 HTML 可视化看板,并重点标出亏损 SKU、低毛利 SKU、高退货 SKU、缺失成本 SKU。24```2526## Workflow27281. Read [references/finance-rules.md](references/finance-rules.md) before interpreting transaction types.292. Inspect the input workbook and locate:30 - The transaction detail sheet with headers such as `type`, `order id`, `sku`, `quantity`, and `total`31 - The cost sheet with `SKU`, unit product cost, and first-leg cost323. Run `scripts/run_finance_analysis.py` to produce normalized JSON, HTML, and Excel outputs.334. Review the generated summary:34 - Confirm `Transfer` rows are excluded35 - Confirm `Order` rows consume product and first-leg cost36 - Confirm `Refund` rows add costs back37 - Confirm `FBA Customer Return Fee` remains a standalone loss385. If margin outliers or missing costs appear, use the SKU summary and missing-cost section to explain the issue.396. Use the risk center to prioritize loss-making, low-margin, high-return, and missing-cost SKUs.4041## Input Expectations4243- Transaction sheet:44 - One header row45 - Columns for `type`, `order id`, `sku`, `quantity`, `product sales`, and `total`46- Cost sheet:47 - One SKU per row48 - Unit product cost in USD49 - Unit first-leg cost in USD50- Optional rule transcript or notes file for audit context5152If headers are not in English, map them explicitly before running the scripts or adapt the parser in `scripts/run_finance_analysis.py`.5354## Calculation Rules5556- Use Amazon `total` as the post-platform-fee settlement amount for the row.57- Apply cost impact by transaction type:58 - `Order`, `Pedido`, `Liquidations`: subtract product cost and first-leg cost59 - `Refund`, `Refund_Retrocharge`: add product cost and first-leg cost back60 - `FBA Customer Return Fee`: keep as a direct loss with no cost reversal61 - `Transfer`: exclude from profitability62 - `Adjustment`, `Service Fee`, `FBA Inventory Fee`, blank or unknown administrative rows: keep `total` only unless business rules say otherwise63- Define row gross profit as:64 - `gross_profit = total + signed_product_cost + signed_first_leg_cost`6566Read [references/finance-rules.md](references/finance-rules.md) when you need the business explanation behind these signs.6768## Commands6970Use the bundled Python runtime when available. The main entrypoint is:7172```bash73python3 scripts/run_finance_analysis.py \74 --report-xlsx /path/to/report.xlsx \75 --report-sheet 财务报表 \76 --cost-xlsx /path/to/cost.xlsx \77 --cost-sheet 成本表 \78 --output-dir /path/to/output79```8081The script writes:8283- `analysis.json`84- `amazon_finance_dashboard.html`85- `amazon_finance_profit_analysis.xlsx`8687## Output Interpretation8889- `Summary` / dashboard output:90 - Headline settlement amount91 - Product-cost impact92 - First-leg-cost impact93 - Running gross profit94- `SKU Analysis`:95 - Focus on SKUs with enough order volume to be meaningful96 - Prioritize low-margin SKUs and high return-rate SKUs97- `Missing Costs`:98 - Any SKU without a cost match weakens the gross-profit result99 - Fix the cost sheet first, then rerun the analysis100101## Resources102103- `references/finance-rules.md`: business logic extracted from the meeting transcript104- `scripts/run_finance_analysis.py`: parser, aggregator, insight builder, and HTML generator105- `scripts/build_workbook.mjs`: employee-facing Excel generator using `@oai/artifact-tool`106107Only patch the parsing logic when the source workbook structure genuinely differs. Do not create ad hoc formulas manually if the bundled scripts already cover the calculation path.