Financial Calculations

Implement DECIMAL(19,2) financial calculations with conversion helpers in TypeScript.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/captjay98/livestockai --skill financial-calculations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Financial Calculations
Source: https://github.com/captjay98/livestockai/tree/main/.kiro/skills/financial-calculations
Command: npx skills add https://github.com/captjay98/livestockai --skill financial-calculations

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

LivestockAI relies on precise decimal arithmetic for financial calculations, preventing rounding errors and ensuring consistent currency handling across modules.

Core Features & Use Cases

  • Decimal precision: standardizes monetary values as DECIMAL(19,2) and provides conversion utilities (toDecimal, toNumber, toDbString) for safe calculations.
  • Currency utilities: centralizes currency formatting and arithmetic to reduce drift and improve reporting.
  • Profit & cost calculations: supports common patterns like batch total cost, profit, and cost breakdowns using a consistent API.

Quick Start

Use the provided currency utilities to compute the total cost for 100 units at 5.25 per unit.

Frequently Asked Questions about Financial Calculations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent rounding errors in decimal currency calculations within TypeScript?

To prevent rounding errors in decimal currency calculations, you can standardize monetary values as DECIMAL(19,2) and use TypeScript conversion helpers like toDecimal and toNumber for safe, precise arithmetic operations.

What is the best way to format currency and calculate profit across different modules?

The best way to format currency and calculate profit across modules is to use centralized currency utilities and a consistent API, which reduces formatting drift and ensures consistent cost breakdowns and batch totals in reports.

How do I convert TypeScript decimal values for database storage without losing precision?

To convert TypeScript decimal values for database storage without losing precision, use the toDbString conversion helper, which safely formats your precise calculations into a DECIMAL(19,2) compatible string.

Does LivestockAI support precise decimal arithmetic for batch total cost and profit calculations?

Yes, LivestockAI supports precise decimal arithmetic for batch total cost and profit calculations by providing standardized financial math utilities that ensure consistent currency handling across dashboards and reports.

Why do my financial calculations show inconsistent decimal precision across different dashboards?

Your financial calculations show inconsistent decimal precision because of drifting currency formatting; applying centralized decimal utilities and standardizing values as DECIMAL(19,2) resolves this drift across all modules.

Can I use standard TypeScript number types for pricing calculations in LivestockAI?

You should not use standard TypeScript number types for pricing calculations; instead, use the provided toDecimal and toNumber conversion helpers to maintain DECIMAL(19,2) precision and avoid floating-point errors.