Actualiser assets/js/app.js
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
This commit is contained in:
+15
-8
@@ -7203,13 +7203,20 @@ function syncRecipeUseQtyUnitBadge() {
|
|||||||
|
|
||||||
// Structured quantity display for inventory cards.
|
// Structured quantity display for inventory cards.
|
||||||
// Returns { mainQty: '10', unitLabel: 'conf', packageDetail: 'da 36g', fraction: '¼' }
|
// Returns { mainQty: '10', unitLabel: 'conf', packageDetail: 'da 36g', fraction: '¼' }
|
||||||
function formatQuantityParts(qty, unit, defaultQty, packageUnit) {
|
function formatQuantityParts(qty, unit, defaultQty, packageUnit, displayUnitKey) {
|
||||||
const n = parseFloat(qty) || 0;
|
let n = parseFloat(qty) || 0;
|
||||||
const unitLabels = { 'pz': t('units.pz'), 'g': 'g', 'ml': 'ml', 'conf': t('units.conf') };
|
const unitLabels = { 'pz': t('units.pz'), 'g': 'g', 'ml': 'ml', 'conf': t('units.conf') };
|
||||||
const label = unitLabels[unit] || unit || t('units.pz');
|
const customUnit = displayUnitKey ? CUSTOM_UNITS.find(u => u.key === displayUnitKey && u.base_unit === unit) : null;
|
||||||
|
let label;
|
||||||
|
if (customUnit) {
|
||||||
|
n = n / customUnit.factor;
|
||||||
|
label = `${customUnit.icon} ${customUnit.label}`.trim();
|
||||||
|
} else {
|
||||||
|
label = unitLabels[unit] || unit || t('units.pz');
|
||||||
|
}
|
||||||
|
|
||||||
// Special handling for conf with partial packages
|
// Special handling for conf with partial packages (custom units never apply to conf)
|
||||||
if (unit === 'conf' && packageUnit && defaultQty > 0) {
|
if (!customUnit && unit === 'conf' && packageUnit && defaultQty > 0) {
|
||||||
const pkgLabel = unitLabels[packageUnit] || packageUnit;
|
const pkgLabel = unitLabels[packageUnit] || packageUnit;
|
||||||
const wholeConf = Math.floor(n + 0.001);
|
const wholeConf = Math.floor(n + 0.001);
|
||||||
const fractionalConf = Math.round((n - wholeConf) * 1000) / 1000;
|
const fractionalConf = Math.round((n - wholeConf) * 1000) / 1000;
|
||||||
@@ -7226,13 +7233,13 @@ function formatQuantityParts(qty, unit, defaultQty, packageUnit) {
|
|||||||
|
|
||||||
let mainQty;
|
let mainQty;
|
||||||
if (n === Math.floor(n)) mainQty = `${Math.floor(n)}`;
|
if (n === Math.floor(n)) mainQty = `${Math.floor(n)}`;
|
||||||
else if (unit === 'pz') mainQty = _pzFractionLabel(n);
|
else if (!customUnit && unit === 'pz') mainQty = _pzFractionLabel(n);
|
||||||
else mainQty = `${n.toFixed(1)}`;
|
else mainQty = `${n.toFixed(customUnit ? 2 : 1)}`;
|
||||||
|
|
||||||
let packageDetail = '';
|
let packageDetail = '';
|
||||||
let fraction = '';
|
let fraction = '';
|
||||||
// pz = piece count only; default_quantity may hold legacy avg weight — ignore for display
|
// pz = piece count only; default_quantity may hold legacy avg weight — ignore for display
|
||||||
if (unit !== 'conf' && unit !== 'pz' && defaultQty && defaultQty > 1) {
|
if (!customUnit && unit !== 'conf' && unit !== 'pz' && defaultQty && defaultQty > 1) {
|
||||||
const d = parseFloat(defaultQty);
|
const d = parseFloat(defaultQty);
|
||||||
const ratio = n / d;
|
const ratio = n / d;
|
||||||
const remainder = ratio - Math.floor(ratio);
|
const remainder = ratio - Math.floor(ratio);
|
||||||
|
|||||||
Reference in New Issue
Block a user