Align cutting families with Olist production data
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 1m17s

This commit is contained in:
Cauê Faleiros
2026-08-12 14:09:29 -03:00
parent e7edb5c483
commit a574b032e0
11 changed files with 137 additions and 30 deletions

View File

@@ -11,6 +11,7 @@ const {
test('normalizeFamilyKey accepts only known cut families', () => {
assert.equal(normalizeFamilyKey('blcs'), 'BLCS');
assert.equal(normalizeFamilyKey(' BLOS '), 'BLOS');
assert.equal(normalizeFamilyKey('blrm'), 'BLRM');
assert.equal(normalizeFamilyKey('OUTROS'), '');
assert.equal(normalizeFamilyKey('unknown'), '');
});
@@ -21,10 +22,12 @@ test('normalizeFamilyYields keeps positive numeric yield rules', () => {
BLOS: 0,
BLMC: -1,
BLPM: '12.5',
BLRM: '17',
OUTROS: 99
}), {
BLCS: 50,
BLPM: 12.5
BLPM: 12.5,
BLRM: 17
});
});

View File

@@ -16,6 +16,27 @@ test('extractObservationFields reads Brazilian production notes without using th
});
});
test('extractObservationFields supports the validated Olist bobbin multiplier, lot, kg and ribana formats', () => {
const result = extractObservationFields('FORNECEDOR: ALTUS\nBOBINAS: 07(X2) - 287KG\nRENDIMENTO: 5,55 - 494KG\n- Lote 01\nRIBANA: 3,59');
assert.deepEqual(result, {
supplier: 'ALTUS',
lotCode: '01',
yieldPiecesPerKg: 5.55,
rollQuantity: 14,
fabricKg: 287,
ribKg: 3.59
});
});
test('extractObservationFields reads standalone KG lines for fabric weight', () => {
const result = extractObservationFields('FORNECEDOR: GOL\nBOBINAS: 06\nKG : 204,38\nRENDIMENTO: 5,0\nLote 02');
assert.equal(result.rollQuantity, 6);
assert.equal(result.fabricKg, 204.38);
assert.equal(result.lotCode, '02');
});
test('parseFinalizedProductionOrderCsv supports multiline observations and skips non-finalized OPs', () => {
const csv = `id_op,numero_op,sku_produto,descricao_produto,quantidade_produzida,data_emissao,data_conclusao,situacao,observacoes,pedido_relacionado\n1,10,BLCS.PTO.G,Camiseta preta G,100,2026-08-01T00:00:00.000Z,2026-08-02T00:00:00.000Z,Finalizada,"FORNECEDOR: NEXSTAR\nRENDIMENTO: 5,44\nQUANTIDADE DE ROLOS: 30\nQUILOS DE MALHA: 577,90",PLANO-1\n2,11,BLCS.PTO.M,Camiseta preta M,100,2026-08-01,2026-08-02,Em andamento,Teste,`;
const result = parseFinalizedProductionOrderCsv(csv);