Update order and delivery details to show quantity and units

Adjust data structures and queries in server storage to reflect new quantity and unit fields, replacing palettes and packages, and renaming expectedDate to plannedDate.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7c468936-2a88-4686-ac0a-84921a45222d
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/7c468936-2a88-4686-ac0a-84921a45222d/X8f62sk
This commit is contained in:
michaelschal committed 2025-08-13 11:58:06 +00:00
1 parent fc67bd00c9
commit fbe4900132
2 files changed
+60 -34

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

+60 -34
View File
@@ -306,10 +306,10 @@ export class DatabaseStorage implements IStorage {
id: orders.id, id: orders.id,
supplierId: orders.supplierId, supplierId: orders.supplierId,
groupId: orders.groupId, groupId: orders.groupId,
expectedDate: orders.expectedDate, plannedDate: orders.plannedDate,
status: orders.status, status: orders.status,
palettes: orders.palettes, quantity: orders.quantity,
packages: orders.packages, unit: orders.unit,
notes: orders.notes, notes: orders.notes,
createdBy: orders.createdBy, createdBy: orders.createdBy,
createdAt: orders.createdAt, createdAt: orders.createdAt,
@@ -334,10 +334,10 @@ export class DatabaseStorage implements IStorage {
id: orders.id, id: orders.id,
supplierId: orders.supplierId, supplierId: orders.supplierId,
groupId: orders.groupId, groupId: orders.groupId,
expectedDate: orders.expectedDate, plannedDate: orders.plannedDate,
status: orders.status, status: orders.status,
palettes: orders.palettes, quantity: orders.quantity,
packages: orders.packages, unit: orders.unit,
notes: orders.notes, notes: orders.notes,
createdBy: orders.createdBy, createdBy: orders.createdBy,
createdAt: orders.createdAt, createdAt: orders.createdAt,
@@ -350,22 +350,22 @@ export class DatabaseStorage implements IStorage {
.leftJoin(groups, eq(orders.groupId, groups.id)) .leftJoin(groups, eq(orders.groupId, groups.id))
.where( .where(
and( and(
gte(orders.expectedDate, startDate), gte(orders.plannedDate, startDate),
lte(orders.expectedDate, endDate) lte(orders.plannedDate, endDate)
) )
); );
if (groupIds && groupIds.length > 0) { if (groupIds && groupIds.length > 0) {
query = query.where( query = query.where(
and( and(
gte(orders.expectedDate, startDate), gte(orders.plannedDate, startDate),
lte(orders.expectedDate, endDate), lte(orders.plannedDate, endDate),
inArray(orders.groupId, groupIds) inArray(orders.groupId, groupIds)
) )
); );
} }
return await query.orderBy(desc(orders.expectedDate)); return await query.orderBy(desc(orders.plannedDate));
} }
async getOrder(id: number): Promise<OrderWithRelations | undefined> { async getOrder(id: number): Promise<OrderWithRelations | undefined> {
@@ -374,10 +374,10 @@ export class DatabaseStorage implements IStorage {
id: orders.id, id: orders.id,
supplierId: orders.supplierId, supplierId: orders.supplierId,
groupId: orders.groupId, groupId: orders.groupId,
expectedDate: orders.expectedDate, plannedDate: orders.plannedDate,
status: orders.status, status: orders.status,
palettes: orders.palettes, quantity: orders.quantity,
packages: orders.packages, unit: orders.unit,
notes: orders.notes, notes: orders.notes,
createdBy: orders.createdBy, createdBy: orders.createdBy,
createdAt: orders.createdAt, createdAt: orders.createdAt,
@@ -422,8 +422,8 @@ export class DatabaseStorage implements IStorage {
scheduledDate: deliveries.scheduledDate, scheduledDate: deliveries.scheduledDate,
deliveredDate: deliveries.deliveredDate, deliveredDate: deliveries.deliveredDate,
status: deliveries.status, status: deliveries.status,
palettes: deliveries.palettes, quantity: deliveries.quantity,
packages: deliveries.packages, unit: deliveries.unit,
blNumber: deliveries.blNumber, blNumber: deliveries.blNumber,
blAmount: deliveries.blAmount, blAmount: deliveries.blAmount,
invoiceReference: deliveries.invoiceReference, invoiceReference: deliveries.invoiceReference,
@@ -458,8 +458,8 @@ export class DatabaseStorage implements IStorage {
scheduledDate: deliveries.scheduledDate, scheduledDate: deliveries.scheduledDate,
deliveredDate: deliveries.deliveredDate, deliveredDate: deliveries.deliveredDate,
status: deliveries.status, status: deliveries.status,
palettes: deliveries.palettes, quantity: deliveries.quantity,
packages: deliveries.packages, unit: deliveries.unit,
blNumber: deliveries.blNumber, blNumber: deliveries.blNumber,
blAmount: deliveries.blAmount, blAmount: deliveries.blAmount,
invoiceReference: deliveries.invoiceReference, invoiceReference: deliveries.invoiceReference,
@@ -506,8 +506,8 @@ export class DatabaseStorage implements IStorage {
scheduledDate: deliveries.scheduledDate, scheduledDate: deliveries.scheduledDate,
deliveredDate: deliveries.deliveredDate, deliveredDate: deliveries.deliveredDate,
status: deliveries.status, status: deliveries.status,
palettes: deliveries.palettes, quantity: deliveries.quantity,
packages: deliveries.packages, unit: deliveries.unit,
blNumber: deliveries.blNumber, blNumber: deliveries.blNumber,
blAmount: deliveries.blAmount, blAmount: deliveries.blAmount,
invoiceReference: deliveries.invoiceReference, invoiceReference: deliveries.invoiceReference,
@@ -610,11 +610,10 @@ export class DatabaseStorage implements IStorage {
let query = db let query = db
.select({ .select({
id: publicities.id, id: publicities.id,
name: publicities.name, pubNumber: publicities.pubNumber,
description: publicities.description, designation: publicities.designation,
startDate: publicities.startDate, startDate: publicities.startDate,
endDate: publicities.endDate, endDate: publicities.endDate,
imageUrl: publicities.imageUrl,
year: publicities.year, year: publicities.year,
createdBy: publicities.createdBy, createdBy: publicities.createdBy,
createdAt: publicities.createdAt, createdAt: publicities.createdAt,
@@ -628,7 +627,7 @@ export class DatabaseStorage implements IStorage {
const results = await query.orderBy(desc(publicities.createdAt)); const results = await query.orderBy(desc(publicities.createdAt));
const publicityIds = results.map(p => p.id); const publicityIds = results.map((p: any) => p.id);
const participations = publicityIds.length > 0 const participations = publicityIds.length > 0
? await db ? await db
.select({ .select({
@@ -641,11 +640,11 @@ export class DatabaseStorage implements IStorage {
.where(inArray(publicityParticipations.publicityId, publicityIds)) .where(inArray(publicityParticipations.publicityId, publicityIds))
: []; : [];
return results.map(publicity => ({ return results.map((publicity: any) => ({
...publicity, ...publicity,
participations: participations participations: participations
.filter(p => p.publicityId === publicity.id) .filter((p: any) => p.publicityId === publicity.id)
.map(p => ({ .map((p: any) => ({
publicityId: p.publicityId, publicityId: p.publicityId,
groupId: p.groupId, groupId: p.groupId,
group: p.group!, group: p.group!,
@@ -839,8 +838,13 @@ export class MemStorage implements IStorage {
id: 'admin', id: 'admin',
username: 'admin', username: 'admin',
email: 'admin@example.com', email: 'admin@example.com',
passwordHash: 'admin', // In real app, this would be hashed name: 'Admin',
firstName: 'Admin',
lastName: 'User',
profileImageUrl: null,
password: 'admin', // In real app, this would be hashed
role: 'admin', role: 'admin',
passwordChanged: false,
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
}; };
@@ -851,6 +855,13 @@ export class MemStorage implements IStorage {
id: 1, id: 1,
name: 'Magasin Test', name: 'Magasin Test',
color: '#3B82F6', color: '#3B82F6',
nocodbConfigId: null,
nocodbTableName: null,
invoiceColumnName: null,
nocodbBlColumnName: null,
nocodbAmountColumnName: null,
nocodbSupplierColumnName: null,
webhookUrl: null,
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
}; };
@@ -861,9 +872,9 @@ export class MemStorage implements IStorage {
const testSupplier: Supplier = { const testSupplier: Supplier = {
id: 1, id: 1,
name: 'Fournisseur Test', name: 'Fournisseur Test',
email: 'test@supplier.com', contact: 'test@supplier.com',
phone: '0123456789', phone: '0123456789',
address: '123 Rue Test', hasDlc: false,
automaticReconciliation: false, automaticReconciliation: false,
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
@@ -1033,8 +1044,14 @@ export class MemStorage implements IStorage {
async createNocodbConfig(config: InsertNocodbConfig): Promise<NocodbConfig> { async createNocodbConfig(config: InsertNocodbConfig): Promise<NocodbConfig> {
const newConfig: NocodbConfig = { const newConfig: NocodbConfig = {
...config,
id: 1, id: 1,
name: config.name,
baseUrl: config.baseUrl,
projectId: config.projectId,
apiToken: config.apiToken,
description: config.description || null,
isActive: config.isActive ?? true,
createdBy: config.createdBy || null,
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
}; };
@@ -1048,9 +1065,9 @@ export class MemStorage implements IStorage {
baseUrl: config.baseUrl || 'https://nocodb.example.com', baseUrl: config.baseUrl || 'https://nocodb.example.com',
projectId: config.projectId || 'test-project', projectId: config.projectId || 'test-project',
apiToken: config.apiToken || 'test-token', apiToken: config.apiToken || 'test-token',
description: config.description || 'Development configuration', description: config.description || null,
isActive: config.isActive ?? true, isActive: config.isActive ?? true,
createdBy: config.createdBy || 'admin', createdBy: config.createdBy || null,
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
}; };
@@ -1067,8 +1084,17 @@ export class MemStorage implements IStorage {
async createInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache> { async createInvoiceVerificationCache(cache: InsertInvoiceVerificationCache): Promise<InvoiceVerificationCache> {
const newCache: InvoiceVerificationCache = { const newCache: InvoiceVerificationCache = {
...cache,
id: 1, id: 1,
cacheKey: cache.cacheKey,
groupId: cache.groupId,
invoiceReference: cache.invoiceReference,
supplierName: cache.supplierName || null,
exists: cache.exists,
matchType: cache.matchType,
errorMessage: cache.errorMessage || null,
cacheHit: cache.cacheHit || false,
apiCallTime: cache.apiCallTime || null,
expiresAt: cache.expiresAt,
createdAt: new Date(), createdAt: new Date(),
updatedAt: new Date(), updatedAt: new Date(),
}; };