Add address fields to sales invoices and implement related validations

- Introduced new columns `address`, `latitude`, and `longitude` in the `sales_invoices` table to store location details.
- Updated the `SalesInvoicesService` to handle the new fields, including validation for address format and geographical coordinates.
- Enhanced the `SalesInvoiceDto` and related data transfer objects to include the new fields for API requests and responses.
- Added unit and e2e tests to ensure proper handling of the new fields and validate their integration within the sales invoice workflow.
- Created a new migration script to apply the database schema changes for the sales invoices.
This commit is contained in:
shancheas
2026-09-01 09:50:19 +07:00
parent 23028abd48
commit 0e73d14381
23 changed files with 444 additions and 33 deletions
+1
View File
@@ -47,3 +47,4 @@ export {
type OrderDefault,
type OrderType,
} from './order-clause';
export { parseQueryIdList } from './parse-query-id-list';
@@ -0,0 +1,20 @@
import { parseQueryIdList } from './parse-query-id-list';
describe('parseQueryIdList', () => {
it('splits comma-separated and array values', () => {
expect(parseQueryIdList('cus-1,cus-2')).toEqual(['cus-1', 'cus-2']);
expect(parseQueryIdList(['cus-1', 'cus-2'])).toEqual(['cus-1', 'cus-2']);
expect(parseQueryIdList(['cus-1,cus-2', 'cus-3'])).toEqual([
'cus-1',
'cus-2',
'cus-3',
]);
expect(parseQueryIdList('cus-1,cus-1,cus-2')).toEqual(['cus-1', 'cus-2']);
});
it('returns undefined for empty input', () => {
expect(parseQueryIdList(undefined)).toBeUndefined();
expect(parseQueryIdList('')).toBeUndefined();
expect(parseQueryIdList([])).toBeUndefined();
});
});
@@ -0,0 +1,11 @@
export function parseQueryIdList(value: unknown): string[] | undefined {
if (value == null || value === '') {
return undefined;
}
const items = Array.isArray(value) ? value : [value];
const ids = items
.flatMap((item) => String(item).split(','))
.map((item) => item.trim())
.filter(Boolean);
return ids.length > 0 ? [...new Set(ids)] : undefined;
}