KO
베타 번역

@core / pricing

1.0.1 ▾
인증됨MIT
GitHub

원가 기반 가격: 카테고리/공급사/상품별 마진 규칙, .99 반올림, 마진 경고, EU 30일 가격 이력

코드파일 6개컨텍스트약 485토큰검사 통과

설치

$genpm add @core/pricing

포함 내용

  • src/lib/pricing/에 소스 코드, 파일 6개. (16.4kB)
  • src/lib/pricing/AGENTS.md에 AI 규칙, 그리고 IDE 규칙 파일.
  • @core/catalog, @core/contracts, @core/db, @core/money을(를) 자동으로 해결합니다.

README

@core/pricing

genpm license

Pricing from cost: markup rules by category/supplier/product, charm rounding, margin alerts and EU 30-day price history

A GenPM module: source code + AI rules + MCP config, injected into your project instead of hidden in node_modules. The code lands in src/lib/pricing, pinned to a verified commit, and you own it.

Install

genpm add @core/pricing

No genpm yet? curl -fsSL https://genpm.net/install.sh | sh (macOS/Linux), irm https://genpm.net/install.ps1 | iex (Windows), or one-off with npx @genpm-net/cli add @core/pricing.

Or let your AI agent do it: run genpm mcp setup once, then ask "add @core/pricing with genpm" in Claude Code, Cursor, VS Code, Windsurf, Codex or Gemini CLI. It shows you a dry-run plan before writing anything.

What it does

Turns costs into selling prices and keeps price changes honest. Rules (scope all / category / supplier / product, cost range, markup in basis points, fixed add-on, charm rounding, minimum margin, priority) pick the most specific match; repriceProduct applies them to variants with a cost. Every price change goes to price_history, which gives the EU "prior price" (lowest of the 30 days before the current price) for any sale badge. Tables: price_rules, price_history.

Setup

After genpm add, follow these steps (your AI agent finds the same steps in src/lib/pricing/AGENTS.md and can do them for you):

  1. Migrations as in src/lib/db/AGENTS.md.
  2. Create rules in the admin (priceRulesAdminResource in src/genpm/admin.ts, permissions pricing:read|update), e.g. markupBps: 15000 (+150 %), rounding .99.
  3. Change prices only with setVariantPrice(variantId, amount) (also from the admin and supplier syncs) so history is kept.
  4. Product pages: show a crossed-out price only with honestCompareAt(variantId); never with a typed "compare at".
  5. Simulate before applying: repriceProduct(productId, { apply: false }) returns old/new price and margin per variant.
  6. Verify: lower a price, honestCompareAt returns the lowest price of the previous 30 days.

What's inside

Paths are relative to src/lib/pricing.

  • index.ts — public API: upsertPriceRule, priceFromCost, applyRule, repriceProduct, setVariantPrice, priorPrice, honestCompareAt, lowMarginVariants, priceRulesAdminResource.
  • pricing.ts — logic. admin.ts — admin resource. schema.ts — tables.

At a glance

Security

GenPM installs a 40-character commit SHA (never a branch), verifies an Ed25519-signed manifest, never runs install scripts and scans AI rules for prompt injection. Details: genpm.net/docs/security.

License

MIT — see LICENSE. Browse the full catalog at genpm.net.

@core/pricing 신고

패키지를 신고하려면 GitHub로 로그인하세요.