Add products and sales management modules with database schema and validation
- 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.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
isValidDocumentCode,
|
||||
isValidImageUrl,
|
||||
isValidLatitude,
|
||||
} from './sales-fields';
|
||||
|
||||
describe('sales fields', () => {
|
||||
it('accepts generated and user document codes', () => {
|
||||
expect(isValidDocumentCode('SR-20260824-0001')).toBe(true);
|
||||
expect(isValidDocumentCode('REQ_01')).toBe(true);
|
||||
expect(isValidDocumentCode('')).toBe(false);
|
||||
expect(isValidDocumentCode('SR 1')).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts http(s) image URLs only', () => {
|
||||
expect(isValidImageUrl('https://cdn.example.com/a.png')).toBe(true);
|
||||
expect(isValidImageUrl('ftp://x/a.png')).toBe(false);
|
||||
expect(isValidImageUrl('not-a-url')).toBe(false);
|
||||
});
|
||||
|
||||
it('validates latitude', () => {
|
||||
expect(isValidLatitude(-6.2)).toBe(true);
|
||||
expect(isValidLatitude(100)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user