fix: preserve Turkish decimal prices and verify preparation persistence

This commit is contained in:
2026-09-06 08:50:18 +03:00
parent b94ab97241
commit 311344306b
8 changed files with 387 additions and 10 deletions
+13 -1
View File
@@ -1,6 +1,6 @@
import {test} from 'node:test';
import assert from 'node:assert/strict';
import {quantityParts,validateBidRows,bidRowTotal} from '../src/services/bidValidation.js';
import {quantityParts,validateBidRows,bidRowTotal,parseBidPrice} from '../src/services/bidValidation.js';
import {yaziylaTL,teklifCetveliHtml} from '../src/services/bidDocs.js';
test('Turkish quantities, decimal quantities and units are preserved',()=>{
assert.deepEqual(quantityParts('2.138.330 puan'),{miktar:2138330,birim:'puan'});
@@ -22,3 +22,15 @@ test('100 rows retain Turkish names and escaped content in printable sheet',()=>
assert.equal((out.match(/Ölçüm <kit>/g)||[]).length,100);
assert.ok(out.includes('İğdır'));assert.ok(out.includes('2.000,00'));
});
test('Turkish decimal price is identical in row total and printable sheet',()=>{
const row={name:'Kit',quantity:'2 adet',birimFiyat:'125,50'};
assert.equal(parseBidPrice(row.birimFiyat),125.5);
assert.equal(parseBidPrice('1.250,50'),1250.5);
assert.equal(bidRowTotal(row),251);
const html=teklifCetveliHtml({},[row],251);
assert.ok(html.includes('125,50'));assert.ok(html.includes('251,00'));
assert.ok(!html.includes('25.100'));
for(const value of ['', '125,,50','1e3','125 TL','1.2.3','-20','125,']) assert.equal(parseBidPrice(value),null);
assert.equal(bidRowTotal({quantity:'1000000000 adet',birimFiyat:'999999999999999'}),null);
});