feat: update validation and exception handling, refactor controller routes, and enhance sales invoice item DTO
- Removed global validation pipe and added a new ValidationExceptionFilter for better error handling. - Refactored controller routes to use underscores instead of hyphens for consistency. - Updated CreateSalesInvoiceItemDto to include new fields: quantity, unit_type, and payload. - Modified CreateSalesInvoiceDto to enforce items as an array with a minimum size. - Added Enums module to provide gold karat values through a dedicated endpoint. - Introduced new columns in the database schema for sales invoice items and goods.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `goods` ADD COLUMN `price_text` VARCHAR(100) NULL;
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `price_text` on the `goods` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `count` on the `sales_invoice_items` table. All the data in the column will be lost.
|
||||
- Added the required column `quantity` to the `sales_invoice_items` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `unit_type` to the `sales_invoice_items` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `sales_invoice_items` DROP FOREIGN KEY `sales_invoice_items_good_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `sales_invoice_items` DROP FOREIGN KEY `sales_invoice_items_service_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `sales_invoice_items_good_id_fkey` ON `sales_invoice_items`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `sales_invoice_items_service_id_fkey` ON `sales_invoice_items`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `goods` DROP COLUMN `price_text`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoice_items` DROP COLUMN `count`,
|
||||
ADD COLUMN `payload` JSON NULL,
|
||||
ADD COLUMN `quantity` DECIMAL(10, 0) NOT NULL,
|
||||
ADD COLUMN `unit_type` ENUM('COUNT', 'GRAM', 'KILOGRAM', 'LITER', 'METER', 'HOUR') NOT NULL,
|
||||
MODIFY `good_id` VARCHAR(191) NULL,
|
||||
MODIFY `service_id` VARCHAR(191) NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_good_id_fkey` FOREIGN KEY (`good_id`) REFERENCES `goods`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_service_id_fkey` FOREIGN KEY (`service_id`) REFERENCES `services`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -11,3 +11,17 @@ enum PurchaseReceiptStatus {
|
||||
PARTIALLY_PAID
|
||||
PAID
|
||||
}
|
||||
|
||||
enum SalesInvoiceType {
|
||||
GOOD
|
||||
SERVICE
|
||||
}
|
||||
|
||||
enum UnitType {
|
||||
COUNT
|
||||
GRAM
|
||||
KILOGRAM
|
||||
LITER
|
||||
METER
|
||||
HOUR
|
||||
}
|
||||
|
||||
@@ -13,19 +13,21 @@ model SalesInvoice {
|
||||
items SalesInvoiceItem[]
|
||||
sales_invoice_payments SalesInvoicePayment[]
|
||||
|
||||
@@index([customer_id])
|
||||
@@map("sales_invoices")
|
||||
}
|
||||
|
||||
model SalesInvoiceItem {
|
||||
id String @id @default(uuid())
|
||||
count Decimal @db.Decimal(10, 0)
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
unit_type UnitType
|
||||
unit_price Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
total_amount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
invoice_id String
|
||||
good_id String
|
||||
service_id String
|
||||
good_id String?
|
||||
service_id String?
|
||||
|
||||
payload Json?
|
||||
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
good Good? @relation(fields: [good_id], references: [id])
|
||||
|
||||
Reference in New Issue
Block a user