Revamp Done - Support for Individual and Jwellery module added

This commit is contained in:
2026-08-29 12:01:00 +05:30
parent eacca6aaea
commit cdc58c9bce
37 changed files with 4334 additions and 2935 deletions

View File

@@ -0,0 +1,32 @@
/// Utility functions for gold/silver purity factor calculation and formatting.
/// Standard rule: Purity is represented as a fraction between 0.0 and 1.0 (e.g. 0.916 for 22KT / 91.6%).
/// If a raw value > 1.0 is supplied (such as 91.6 or 75.0), it is normalized by dividing by 100 with a maximum of 1.0.
double normalizePurity(num? rawPurity) {
if (rawPurity == null || rawPurity <= 0) return 1.0;
double p = rawPurity.toDouble();
if (p > 1.0) {
p = p / 100.0;
}
if (p > 1.0) {
p = 1.0;
}
return p;
}
String formatPurity(num? rawPurity) {
final p = normalizePurity(rawPurity);
return p.toStringAsFixed(3);
}
/// Resolves purity factor prioritizing the category (metal grade e.g. 22KT -> 0.916)
/// then falling back to product-specific purity or 1.0.
double resolvePurity({num? categoryPurity, num? productPurity}) {
if (categoryPurity != null && categoryPurity > 0) {
return normalizePurity(categoryPurity);
}
if (productPurity != null && productPurity > 0) {
return normalizePurity(productPurity);
}
return 1.0;
}