@dynamatix/cat-shared 0.0.140 → 0.0.141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -316,8 +316,23 @@ function applyAuditMiddleware(schema, collectionName) {
316
316
  // --- Add pound prefix if needed ---
317
317
  const dataType = fieldTypeMap[field];
318
318
  if (dataType === 'pound') {
319
- if (displayOldValue != null && displayOldValue !== '') displayOldValue = `£${displayOldValue}`;
320
- if (displayNewValue != null && displayNewValue !== '') displayNewValue = `£${displayNewValue}`;
319
+ const formatPoundValue = (rawValue) => {
320
+ if (rawValue == null || rawValue === '') return rawValue;
321
+ const stringValue = typeof rawValue === 'string' ? rawValue.trim() : String(rawValue);
322
+ if (stringValue === '') return rawValue;
323
+ const valueSansSymbol = stringValue.startsWith('£') ? stringValue.slice(1) : stringValue;
324
+ const numericString = valueSansSymbol.replace(/,/g, '');
325
+ const numericValue = Number(numericString);
326
+ if (!Number.isFinite(numericValue)) return `£${valueSansSymbol}`;
327
+ const decimalPart = numericString.split('.')[1];
328
+ const formatted = numericValue.toLocaleString('en-GB', {
329
+ minimumFractionDigits: decimalPart ? decimalPart.length : 0,
330
+ maximumFractionDigits: decimalPart ? decimalPart.length : 20
331
+ });
332
+ return `£${formatted}`;
333
+ };
334
+ displayOldValue = formatPoundValue(displayOldValue);
335
+ displayNewValue = formatPoundValue(displayNewValue);
321
336
  }
322
337
  if (displayOldValue !== displayNewValue) {
323
338
  const fieldDescription = await resolveDescription(field, result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamatix/cat-shared",
3
- "version": "0.0.140",
3
+ "version": "0.0.141",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",