Fix client detail customer identity
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m17s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m17s
This commit is contained in:
@@ -1,8 +1,21 @@
|
||||
import type { DateRange, OrderData } from '../types';
|
||||
import { parseOrderDate } from '../dataService';
|
||||
import type { DateRange, OrderData } from '../types.ts';
|
||||
|
||||
const SIZE_SUFFIX_PATTERN = /\s+-\s+(?:(?:PP|P|M|G|GG|XG|XGG|EG|EGG|EXG|U|UNICO|ÚNICO|\d{2})(?:\/(?:PP|P|M|G|GG|XG|XGG|EG|EGG|EXG|U|UNICO|ÚNICO|\d{2}))*)$/i;
|
||||
|
||||
export const parseOrderDate = (dateStr: string): Date => {
|
||||
if (!dateStr) return new Date(0);
|
||||
if (dateStr.includes('T')) return new Date(dateStr);
|
||||
const parts = dateStr.split(/[-/]/);
|
||||
if (parts.length === 3) {
|
||||
if (parts[0].length === 4) {
|
||||
return new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]));
|
||||
}
|
||||
return new Date(Number(parts[2]), Number(parts[1]) - 1, Number(parts[0]));
|
||||
}
|
||||
const fallback = new Date(dateStr);
|
||||
return Number.isNaN(fallback.getTime()) ? new Date(0) : fallback;
|
||||
};
|
||||
|
||||
export const getBaseProductName = (description: string): string => {
|
||||
const productName = description.trim();
|
||||
if (productName.toLocaleUpperCase('pt-BR').startsWith('ETIQUETA')) {
|
||||
@@ -13,7 +26,11 @@ export const getBaseProductName = (description: string): string => {
|
||||
};
|
||||
|
||||
export const getClientDisplayName = (order: OrderData): string => {
|
||||
return order.Nome_Cliente || `Cliente Desconhecido (Pedido ${order.Valor_Pedido})`;
|
||||
return order.Nome_Cliente || 'Cliente Desconhecido';
|
||||
};
|
||||
|
||||
export const getOrderCustomerKey = (order: OrderData): string => {
|
||||
return order.Fone_Cliente || `name:${getClientDisplayName(order)}`;
|
||||
};
|
||||
|
||||
export const isOrderInDateRange = (order: OrderData, dateRange: DateRange): boolean => {
|
||||
|
||||
Reference in New Issue
Block a user