1use super::function_card::{ArgumentInfo, FunctionCard};
9
10pub const BUSINESS_CARDS: &[FunctionCard] = &[
12 FunctionCard {
16 identifier: "round_to",
17 signature: "round_to(number, decimals)",
18 brief: "Round a number to a specific number of decimal places.",
19 description: "Rounds the input number to the specified number of decimal places using \
20 standard rounding rules. This function is essential for financial \
21 calculations where precision matters, such as currency calculations, \
22 percentage formatting, and display formatting. The rounding follows \
23 'round half up' behavior for financial accuracy.",
24 arguments: &[
25 &ArgumentInfo {
26 label: "number",
27 description: "Number to round",
28 type_hint: "f64",
29 optional: false,
30 },
31 &ArgumentInfo {
32 label: "decimals",
33 description: "Number of decimal places to round to",
34 type_hint: "f64",
35 optional: false,
36 },
37 ],
38 returns: "Rounded number (f64)",
39 errors: "None - always succeeds",
40 categories: &["business"],
41 examples: &[
42 "round_to(123.4567, 2) => 123.46",
43 "round_to(99.999, 2) => 100.00",
44 "round_to(1000.1, 0) => 1000",
45 ],
46 },
47
48 FunctionCard {
52 identifier: "percent_of",
53 signature: "percent_of(number, total)",
54 brief: "Calculate what percentage a number is of a total.",
55 description: "Calculates what percentage the first number represents of the total. \
56 This function is commonly used in business analytics to calculate \
57 completion rates, market share, performance metrics, and statistical \
58 analysis. Returns 0 when the total is 0 to avoid division by zero errors.",
59 arguments: &[
60 &ArgumentInfo {
61 label: "number",
62 description: "Part value to calculate percentage of",
63 type_hint: "f64",
64 optional: false,
65 },
66 &ArgumentInfo {
67 label: "total",
68 description: "Total value to compare against",
69 type_hint: "f64",
70 optional: false,
71 },
72 ],
73 returns: "Percentage value (f64)",
74 errors: "Returns 0 for zero total to avoid division by zero",
75 categories: &["business"],
76 examples: &[
77 "percent_of(25, 100) => 25",
78 "percent_of(50, 200) => 25",
79 "percent_of(15, 300) => 5",
80 ],
81 },
82
83 FunctionCard {
85 identifier: "increase",
86 signature: "increase(number, percent)",
87 brief: "Increase a number by a specified percentage.",
88 description: "Calculates the result of increasing a number by a given percentage. \
89 This function is essential for calculating price increases, salary \
90 raises, growth projections, and inflation adjustments. The percentage \
91 should be provided as a whole number (e.g., 10 for 10%).",
92 arguments: &[
93 &ArgumentInfo {
94 label: "number",
95 description: "Base number to increase",
96 type_hint: "f64",
97 optional: false,
98 },
99 &ArgumentInfo {
100 label: "percent",
101 description: "Percentage to increase by (e.g., 10 for 10%)",
102 type_hint: "f64",
103 optional: false,
104 },
105 ],
106 returns: "Increased number (f64)",
107 errors: "None - always succeeds",
108 categories: &["business"],
109 examples: &[
110 "increase(100, 10) => 110",
111 "increase(50, 20) => 60",
112 "increase(200, 5) => 210",
113 ],
114 },
115
116 FunctionCard {
118 identifier: "decrease",
119 signature: "decrease(number, percent)",
120 brief: "Decrease a number by a specified percentage.",
121 description: "Calculates the result of decreasing a number by a given percentage. \
122 This function is commonly used for calculating discounts, price reductions, \
123 depreciation, and cost savings. The percentage should be provided as a \
124 whole number (e.g., 10 for 10%).",
125 arguments: &[
126 &ArgumentInfo {
127 label: "number",
128 description: "Base number to decrease",
129 type_hint: "f64",
130 optional: false,
131 },
132 &ArgumentInfo {
133 label: "percent",
134 description: "Percentage to decrease by (e.g., 10 for 10%)",
135 type_hint: "f64",
136 optional: false,
137 },
138 ],
139 returns: "Decreased number (f64)",
140 errors: "None - always succeeds",
141 categories: &["business"],
142 examples: &[
143 "decrease(100, 10) => 90",
144 "decrease(50, 20) => 40",
145 "decrease(200, 5) => 190",
146 ],
147 },
148
149 FunctionCard {
153 identifier: "gross_margin",
154 signature: "gross_margin(cost, price)",
155 brief: "Calculate gross margin percentage from cost and selling price.",
156 description: "Calculates the gross margin as a percentage, which represents the \
157 profitability of individual products or services. Gross margin is \
158 calculated as ((price - cost) / price) * 100. This metric is crucial \
159 for pricing strategy, profitability analysis, and cost management.",
160 arguments: &[
161 &ArgumentInfo {
162 label: "cost",
163 description: "Cost of goods sold or production cost",
164 type_hint: "f64",
165 optional: false,
166 },
167 &ArgumentInfo {
168 label: "price",
169 description: "Selling price or revenue",
170 type_hint: "f64",
171 optional: false,
172 },
173 ],
174 returns: "Gross margin percentage (f64)",
175 errors: "Returns 0 for zero price to avoid division by zero",
176 categories: &["business"],
177 examples: &[
178 "gross_margin(70, 100) => 30",
179 "gross_margin(50, 75) => 33.33",
180 "gross_margin(80, 100) => 20",
181 ],
182 },
183
184 FunctionCard {
186 identifier: "markup",
187 signature: "markup(cost, percent)",
188 brief: "Calculate selling price by applying markup to cost.",
189 description: "Calculates the selling price by applying a markup percentage to the \
190 cost. This function is used in retail and manufacturing to determine \
191 selling prices based on desired profit margins. The markup percentage \
192 represents the amount added to the cost price.",
193 arguments: &[
194 &ArgumentInfo {
195 label: "cost",
196 description: "Cost price or production cost",
197 type_hint: "f64",
198 optional: false,
199 },
200 &ArgumentInfo {
201 label: "percent",
202 description: "Markup percentage to apply (e.g., 25 for 25%)",
203 type_hint: "f64",
204 optional: false,
205 },
206 ],
207 returns: "Selling price with markup applied (f64)",
208 errors: "None - always succeeds",
209 categories: &["business"],
210 examples: &[
211 "markup(100, 25) => 125",
212 "markup(80, 50) => 120",
213 "markup(200, 10) => 220",
214 ],
215 },
216
217 FunctionCard {
219 identifier: "growth",
220 signature: "growth(from, to)",
221 brief: "Calculate period-over-period growth percentage.",
222 description: "Calculates the percentage growth from one period to another. This \
223 function is essential for financial analysis, performance tracking, \
224 and business reporting. Growth rate is calculated as ((to - from) / from) * 100. \
225 Negative results indicate decline.",
226 arguments: &[
227 &ArgumentInfo {
228 label: "from",
229 description: "Starting value or previous period",
230 type_hint: "f64",
231 optional: false,
232 },
233 &ArgumentInfo {
234 label: "to",
235 description: "Ending value or current period",
236 type_hint: "f64",
237 optional: false,
238 },
239 ],
240 returns: "Growth percentage (f64)",
241 errors: "Returns 0 for zero starting value to avoid division by zero",
242 categories: &["business"],
243 examples: &[
244 "growth(100, 120) => 20",
245 "growth(200, 180) => -10",
246 "growth(50, 75) => 50",
247 ],
248 },
249
250 FunctionCard {
252 identifier: "runway",
253 signature: "runway(funding, monthly_expenses)",
254 brief: "Calculate how many months funding will last.",
255 description: "Calculates the financial runway in months based on available funding \
256 and monthly expenses. This function is critical for startups and \
257 businesses to understand their cash flow sustainability and plan \
258 accordingly for fundraising or cost reduction.",
259 arguments: &[
260 &ArgumentInfo {
261 label: "funding",
262 description: "Available funding or cash balance",
263 type_hint: "f64",
264 optional: false,
265 },
266 &ArgumentInfo {
267 label: "monthly_expenses",
268 description: "Monthly operating expenses",
269 type_hint: "f64",
270 optional: false,
271 },
272 ],
273 returns: "Months of runway (f64)",
274 errors: "Returns 0 for zero or negative monthly expenses",
275 categories: &["business"],
276 examples: &[
277 "runway(100000, 10000) => 10",
278 "runway(50000, 5000) => 10",
279 "runway(25000, 10000) => 2.5",
280 ],
281 },
282
283 FunctionCard {
285 identifier: "monthly_payment",
286 signature: "monthly_payment(principal, rate, years)",
287 brief: "Calculate monthly loan payment using amortization formula.",
288 description: "Calculates the monthly payment for a loan based on principal amount, \
289 annual interest rate, and loan term in years. This function uses the \
290 standard amortization formula and is essential for mortgage calculations, \
291 loan planning, and financial budgeting.",
292 arguments: &[
293 &ArgumentInfo {
294 label: "principal",
295 description: "Loan principal amount",
296 type_hint: "f64",
297 optional: false,
298 },
299 &ArgumentInfo {
300 label: "rate",
301 description: "Annual interest rate as percentage (e.g., 5 for 5%)",
302 type_hint: "f64",
303 optional: false,
304 },
305 &ArgumentInfo {
306 label: "years",
307 description: "Loan term in years",
308 type_hint: "f64",
309 optional: false,
310 },
311 ],
312 returns: "Monthly payment amount (f64)",
313 errors: "Returns principal/periods for zero interest rate",
314 categories: &["business"],
315 examples: &[
316 "monthly_payment(100000, 5, 30) => 536.82",
317 "monthly_payment(20000, 3, 5) => 359.37",
318 "monthly_payment(10000, 0, 2) => 416.67",
319 ],
320 },
321
322 FunctionCard {
324 identifier: "break_even",
325 signature: "break_even(fixed_costs, price, variable_cost)",
326 brief: "Calculate break-even point in units.",
327 description: "Calculates the break-even point, which is the number of units that must \
328 be sold to cover all costs. This function is fundamental for business \
329 planning, pricing strategy, and cost-volume-profit analysis. The break-even \
330 point is where total revenue equals total costs.",
331 arguments: &[
332 &ArgumentInfo {
333 label: "fixed_costs",
334 description: "Fixed costs that don't change with volume",
335 type_hint: "f64",
336 optional: false,
337 },
338 &ArgumentInfo {
339 label: "price",
340 description: "Selling price per unit",
341 type_hint: "f64",
342 optional: false,
343 },
344 &ArgumentInfo {
345 label: "variable_cost",
346 description: "Variable cost per unit",
347 type_hint: "f64",
348 optional: false,
349 },
350 ],
351 returns: "Break-even point in units (f64)",
352 errors: "Returns 0 if contribution margin is zero or negative",
353 categories: &["business"],
354 examples: &[
355 "break_even(10000, 20, 10) => 1000",
356 "break_even(5000, 25, 15) => 500",
357 "break_even(20000, 50, 30) => 1000",
358 ],
359 },
360
361 FunctionCard {
363 identifier: "roi",
364 signature: "roi(investment, return_amount)",
365 brief: "Calculate return on investment percentage.",
366 description: "Calculates the return on investment (ROI) as a percentage, which \
367 measures the profitability of an investment relative to its cost. \
368 ROI is calculated as ((return - investment) / investment) * 100 and \
369 is a key metric for investment analysis, performance evaluation, and \
370 capital allocation decisions.",
371 arguments: &[
372 &ArgumentInfo {
373 label: "investment",
374 description: "Initial investment amount",
375 type_hint: "f64",
376 optional: false,
377 },
378 &ArgumentInfo {
379 label: "return_amount",
380 description: "Total return amount from investment",
381 type_hint: "f64",
382 optional: false,
383 },
384 ],
385 returns: "Return on investment percentage (f64)",
386 errors: "Returns 0 for zero investment to avoid division by zero",
387 categories: &["business"],
388 examples: &[
389 "roi(1000, 1200) => 20",
390 "roi(5000, 6000) => 20",
391 "roi(10000, 8000) => -20",
392 ],
393 },
394
395 FunctionCard {
397 identifier: "split_amount",
398 signature: "split_amount(percentages, total)",
399 brief: "Split an amount proportionally based on percentages.",
400 description: "Splits a total amount across multiple categories based on percentage \
401 allocations. This function is useful for budget allocation, revenue \
402 sharing, cost distribution, and resource allocation. The percentages \
403 are automatically normalized to ensure they sum to 100%.",
404 arguments: &[
405 &ArgumentInfo {
406 label: "percentages",
407 description: "Array of percentage allocations",
408 type_hint: "Vec<f64>",
409 optional: false,
410 },
411 &ArgumentInfo {
412 label: "total",
413 description: "Total amount to split",
414 type_hint: "f64",
415 optional: false,
416 },
417 ],
418 returns: "Array of split amounts (Vec<f64>)",
419 errors: "Returns array of zeros if percentage sum is zero",
420 categories: &["business"],
421 examples: &[
422 "split_amount((40, 30, 30), 1000) => (400, 300, 300)",
423 "split_amount((50, 50), 100) => (50, 50)",
424 "split_amount((25, 25, 25, 25), 200) => (50, 50, 50, 50)",
425 ],
426 },
427
428 FunctionCard {
430 identifier: "tax_inclusive",
431 signature: "tax_inclusive(amount, tax_rate)",
432 brief: "Calculate amount including tax.",
433 description: "Calculates the total amount including tax by adding the specified tax \
434 rate to the base amount. This function is commonly used in e-commerce, \
435 invoicing, and financial calculations where tax needs to be included in \
436 the final price.",
437 arguments: &[
438 &ArgumentInfo {
439 label: "amount",
440 description: "Base amount before tax",
441 type_hint: "f64",
442 optional: false,
443 },
444 &ArgumentInfo {
445 label: "tax_rate",
446 description: "Tax rate as percentage (e.g., 8 for 8%)",
447 type_hint: "f64",
448 optional: false,
449 },
450 ],
451 returns: "Total amount including tax (f64)",
452 errors: "None - always succeeds",
453 categories: &["business"],
454 examples: &[
455 "tax_inclusive(100, 8) => 108",
456 "tax_inclusive(50, 10) => 55",
457 "tax_inclusive(200, 5) => 210",
458 ],
459 },
460
461 FunctionCard {
463 identifier: "tax_exclusive",
464 signature: "tax_exclusive(amount, tax_rate)",
465 brief: "Calculate amount excluding tax.",
466 description: "Calculates the base amount excluding tax from a total amount that \
467 includes tax. This function is useful for reverse tax calculations, \
468 invoice processing, and financial reporting where the pre-tax amount \
469 needs to be determined.",
470 arguments: &[
471 &ArgumentInfo {
472 label: "amount",
473 description: "Total amount including tax",
474 type_hint: "f64",
475 optional: false,
476 },
477 &ArgumentInfo {
478 label: "tax_rate",
479 description: "Tax rate as percentage (e.g., 8 for 8%)",
480 type_hint: "f64",
481 optional: false,
482 },
483 ],
484 returns: "Base amount excluding tax (f64)",
485 errors: "None - always succeeds",
486 categories: &["business"],
487 examples: &[
488 "tax_exclusive(108, 8) => 100",
489 "tax_exclusive(55, 10) => 50",
490 "tax_exclusive(210, 5) => 200",
491 ],
492 },
493];