Skip to content

feat: add WB API tax-calculator web app (Express backend + frontend) - #4

Open
minislon wants to merge 1 commit into
mainfrom
codex-4omo76
Open

feat: add WB API tax-calculator web app (Express backend + frontend)#4
minislon wants to merge 1 commit into
mainfrom
codex-4omo76

Conversation

@minislon

Copy link
Copy Markdown
Owner

Motivation

  • Provide a deployable web application that pulls sales reports from Wildberries and produces preliminary tax calculations for a selected period.
  • Replace the previous static toy app with a small server + UI so the WB token can be used immediately and results are aggregated server-side.
  • Keep integration practical while noting that the current WB report endpoint is deprecated and should be migrated to the newer finance endpoints in a follow-up change.

Description

  • Added an Express backend (server.js) exposing POST /api/wb-tax/calculate which calls the WB report endpoint, aggregates rows and computes tax for two regimes (УСН Доходы 6% with insurance reduction, and УСН Доходы-Расходы 15% with 1% minimum).
  • Added frontend under 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.
  • Project config and packaging updates: new package.json (start/dev/check scripts, express dependency), generated package-lock.json, and a basic .gitignore.
  • Updated README.md with run and deploy instructions (local run with npm install && npm start, and recommended platforms such as Render), and a note about the deprecated WB endpoint and suggested migration targets.

Testing

  • Installed dependencies with npm install which completed successfully.
  • Syntax checks were run with npm run check (node --check server.js && node --check public/app.js) and passed.
  • Basic runtime smoke test started the server and fetched the homepage using node server.js + curl http://localhost:3000 which returned the frontend HTML. All automated checks succeeded.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread server.js

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']);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread server.js
return res.status(502).json({ error: 'WB API вернул неожиданный формат данных' });
}

const grossSales = sumByKeys(rows, ['retail_amount', 'retail_price_withdisc_rub']);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant