-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpricing-model.nbjs
More file actions
107 lines (107 loc) · 3.77 KB
/
pricing-model.nbjs
File metadata and controls
107 lines (107 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{
"cells": [
{
"type": "markdown",
"id": "header",
"content": "# Pricing Calculator\n\nConfigure your pricing parameters below:\n"
},
{
"type": "input",
"id": "price-input",
"label": "Price ($)",
"inputType": "number",
"variableName": "price",
"value": 20,
"props": {
"step": 1
}
},
{
"type": "input",
"id": "quantity-input",
"label": "Quantity",
"inputType": "number",
"variableName": "quantity",
"value": 1,
"props": {
"min": 1,
"step": 1
}
},
{
"type": "input",
"id": "discount-input",
"label": "Discount (%)",
"inputType": "range",
"variableName": "discountPercent",
"value": 0,
"props": {
"min": 0,
"max": 100,
"step": 1
}
},
{
"type": "formula",
"id": "subtotal-formula",
"variableName": "subtotal",
"formula": "$price * $quantity + 2"
},
{
"type": "formula",
"id": "discount-formula",
"variableName": "discount",
"formula": "$subtotal * ($discountPercent / 100)"
},
{
"type": "formula",
"id": "total-formula",
"variableName": "total",
"formula": "$subtotal - $discount"
},
{
"type": "markdown",
"id": "results-header",
"content": "<h3>Results:</h3>"
},
{
"type": "markdown",
"id": "subtotal-display",
"content": "**Subtotal:** ${{subtotal | round,2}}",
"variables": [
"subtotal"
]
},
{
"type": "markdown",
"id": "discount-display",
"content": "**Discount:** ${{discount | round,2}}",
"variables": [
"discount"
]
},
{
"type": "markdown",
"id": "total-display",
"content": "**Total:** {{total | currency}}",
"variables": [
"total"
]
},
{
"type": "code",
"id": "tax-calculation",
"code": "console.log('Starting tax calculation...');\n\nexports.taxRate = 0.08;\nconst initialTaxAmount = total * exports.taxRate;\n\nconsole.log('Initial calculation:', { total, taxRate: exports.taxRate, initialTaxAmount });\n\nif (total > 500) {\n exports.taxRate = 0.10;\n console.log('Luxury tax rate applied: 10%');\n} else if (total > 200) {\n exports.taxRate = 0.085;\n console.log('Medium tax rate applied: 8.5%');\n} else {\n console.log('Standard tax rate maintained: 8%');\n}\n\nexports.finalTaxAmount = total * exports.taxRate;\nexports.finalTotal = total + exports.finalTaxAmount;\n\nexports.calculationSummary = {\n pricing: { basePrice: price, quantity: quantity, subtotal: total },\n tax: { rate: exports.taxRate, amount: exports.finalTaxAmount, bracket: total > 500 ? 'luxury' : total > 200 ? 'medium' : 'standard' },\n totals: { beforeTax: total, afterTax: exports.finalTotal, savings: subtotal - total },\n metadata: { calculatedAt: new Date().toISOString(), breakdown: [subtotal, -discount, exports.finalTaxAmount] }\n};\n\nconsole.log('Final calculation:', exports.calculationSummary);\nconsole.info('Tax calculation completed successfully!');\n\n// Output summary for display\noutput(\n // Tax bracket info\n {\n taxBracket: exports.calculationSummary.tax.bracket,\n effectiveRate: exports.taxRate,\n totalSavings: exports.calculationSummary.totals.savings,\n finalAmount: exports.finalTotal\n },\n // Detailed breakdown\n exports.calculationSummary\n);"
},
{
"type": "markdown",
"id": "tax-display",
"content": "**Tax ({{taxRate | percent}}):** {{finalTaxAmount | currency}}<br>**Final Total:** {{finalTotal | currency}}",
"variables": [
"taxRate",
"finalTaxAmount",
"finalTotal"
]
}
]
}