feat: add WB API tax-calculator web app (Express backend + frontend) - #4
feat: add WB API tax-calculator web app (Express backend + frontend)#4minislon wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b0fc4b90a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const grossSales = sumByKeys(rows, ['retail_amount', 'retail_price_withdisc_rub']); | ||
| const returns = sumByKeys(rows, ['return_amount']); | ||
| const wbCommission = sumByKeys(rows, ['commission_percent', 'ppvz_sales_commission']); |
There was a problem hiding this comment.
Remove percentage field from commission expense sum
The expense aggregation mixes units by adding commission_percent together with ruble-denominated fields; when this endpoint returns a percent value per row (as the field name indicates), the code inflates wbCommission and therefore understates tax in the usn_income_expenses regime. Only monetary commission fields should be included in expense totals.
Useful? React with 👍 / 👎.
| return res.status(502).json({ error: 'WB API вернул неожиданный формат данных' }); | ||
| } | ||
|
|
||
| const grossSales = sumByKeys(rows, ['retail_amount', 'retail_price_withdisc_rub']); |
There was a problem hiding this comment.
Avoid summing two sale amount fields per row
The grossSales calculation adds both retail_amount and retail_price_withdisc_rub for every record, so any WB response where both keys are populated will count the same sale twice and overstate income, which directly skews tax output for both supported regimes.
Useful? React with 👍 / 👎.
Motivation
Description
server.js) exposingPOST /api/wb-tax/calculatewhich calls the WB report endpoint, aggregates rows and computes tax for two regimes (УСН Доходы 6% with insurance reduction, and УСН Доходы-Расходы 15% with 1% minimum).public/(index.html,app.js,style.css) with a form to submit WB token, date range and parameters and to display the computed results and raw JSON details.package.json(start/dev/check scripts,expressdependency), generatedpackage-lock.json, and a basic.gitignore.README.mdwith run and deploy instructions (local run withnpm install && npm start, and recommended platforms such as Render), and a note about the deprecated WB endpoint and suggested migration targets.Testing
npm installwhich completed successfully.npm run check(node --check server.js && node --check public/app.js) and passed.node server.js+curl http://localhost:3000which returned the frontend HTML. All automated checks succeeded.Codex Task