← スキル一覧に戻る

vendix-product-pricing
by Rzyfront
Monorepo con docker config para buildear la aplicacion en desarrollo de forma rapida.
⭐ 4🍴 1📅 2026年1月19日
SKILL.md
name: vendix-product-pricing description: > Patterns for advanced product pricing logic, rentability calculations, and reactive price management in Vendix. Trigger: When editing product schemas, pricing logic, or advanced product forms. license: Apache-2.0 metadata: author: gentleman-programming version: "1.0"
When to Use
- Implementing new pricing fields in Product or ProductVariant models.
- Building UI components that require bidirectional price/margin calculations.
- Handling tax-inclusive pricing displays in frontend.
- Managing "On Sale" (Offer) price logic.
Critical Patterns
1. Database Fields
Always include the four pillars of pricing in both products and product_variants tables:
cost_price: The acquisition cost.profit_margin: The target profitability percentage.base_price: The listing price (PVP) before taxes.sale_price: The promotional price (Offer).is_on_sale: Boolean flag to activate the offer.
2. Bidirectional Calculation Logic (Angular)
When one price field changes, others should update reactively:
- Margin -> Base Price:
base_price = cost_price * (1 + margin / 100) - Base Price -> Margin:
margin = ((base_price - cost_price) / cost_price) * 100(Only if cost > 0)
3. Tax Integration
The final price should always be calculated dynamically based on selected tax_categories:
final_price = base_price * (1 + sum(tax_rates))
Code Examples
Reactive Form Setup (Angular)
private setupPriceCalculations(form: FormGroup): void {
const costCtrl = form.get('cost_price');
const marginCtrl = form.get('profit_margin');
const basePriceCtrl = form.get('base_price');
// Cost or Margin changed -> Update Base Price
merge(costCtrl.valueChanges, marginCtrl.valueChanges).subscribe(() => {
const cost = Number(costCtrl.value || 0);
const margin = Number(marginCtrl.value || 0);
const basePrice = cost * (1 + margin / 100);
basePriceCtrl.setValue(basePrice, { emitEvent: false });
});
// Base Price changed -> Update Margin
basePriceCtrl.valueChanges.subscribe((val) => {
const cost = Number(costCtrl.value || 0);
if (cost > 0) {
const margin = ((val - cost) / cost) * 100;
marginCtrl.setValue(margin, { emitEvent: false });
}
});
}
Prisma Schema Fields
model products {
base_price Decimal @db.Decimal(12, 2)
cost_price Decimal? @db.Decimal(12, 2)
profit_margin Decimal? @db.Decimal(5, 2)
is_on_sale Boolean @default(false)
sale_price Decimal? @db.Decimal(12, 2)
}
Commands
# Regenerate Prisma client after adding pricing fields
npx prisma generate
# Apply pricing schema changes
npx prisma migrate dev --name add_pricing_fields
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です