- Introduced `ProductsModule` to manage product data, including read and write controllers. - Created database migrations for the `products`, `sales_requests`, `sales_orders`, `sales_invoices`, and related tables, including constraints and unique indexes. - Implemented validation for product fields such as code, name, unit, and brand with corresponding utility functions. - Developed service and repository layers for handling product and sales data operations. - Added unit tests for the products and sales services, repositories, and controllers to ensure functionality and correctness. - Updated application module to include the new `ProductsModule` and related sales modules for better organization.
18 lines
594 B
TypeScript
18 lines
594 B
TypeScript
import { integer, pgTable, primaryKey, varchar } from 'drizzle-orm/pg-core';
|
|
|
|
/**
|
|
* Per-prefix daily counters used to generate document codes.
|
|
*/
|
|
export const documentSequences = pgTable(
|
|
'document_sequences',
|
|
{
|
|
prefix: varchar('prefix', { length: 8 }).notNull(),
|
|
period: varchar('period', { length: 8 }).notNull(),
|
|
lastValue: integer('last_value').notNull(),
|
|
},
|
|
(t) => [primaryKey({ columns: [t.prefix, t.period] })],
|
|
);
|
|
|
|
export type DocumentSequenceRow = typeof documentSequences.$inferSelect;
|
|
export type NewDocumentSequenceRow = typeof documentSequences.$inferInsert;
|