commit melhorias compras1
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-21 21:04:40 +02:00
parent 976271f948
commit 12dd6df28a
108 changed files with 4391 additions and 408 deletions
@@ -0,0 +1,70 @@
import { Input } from '@/components/ui/input';
export function convertedQuantity(milli: string): string {
if (!/^\d+$/.test(milli)) return 'Não disponível';
const padded = milli.padStart(4, '0');
return `${padded.slice(0, -3)},${padded.slice(-3)}`;
}
export type ReceiptConversion = {
numerator: string;
denominator: string;
source: string;
version: string;
};
export function ReceiptConversionFields({
value,
onChange,
documentUnit,
stockUnit,
}: {
value: ReceiptConversion;
onChange: (value: ReceiptConversion) => void;
documentUnit: string;
stockUnit: string;
}) {
return (
<fieldset className="space-y-3 rounded border p-3">
<legend>
Conversão de {documentUnit} para {stockUnit}
</legend>
<p className="text-sm">
A compra conserva {documentUnit}. O stock e os lotes usam{' '}
{stockUnit}. O factor, fonte e versão ficam congelados nesta
linha.
</p>
{(
[
['numerator', 'Numerador'],
['denominator', 'Denominador'],
['source', 'Fonte do factor'],
['version', 'Versão da fonte'],
] as const
).map(([key, label]) => (
<label className="block space-y-1" key={key}>
<span>{label}</span>
<Input
required
value={value[key]}
maxLength={
key === 'source' ? 500 : key === 'version' ? 100 : 9
}
pattern={
key === 'numerator' || key === 'denominator'
? '[1-9][0-9]{0,8}'
: undefined
}
onChange={(event) =>
onChange({ ...value, [key]: event.target.value })
}
/>
</label>
))}
<p className="text-xs">
Quantidade física = quantidade aceite × numerador ÷ denominador.
Não há arredondamento automático.
</p>
</fieldset>
);
}