update migrations and create base migration. set discount and tax to sale invoices
This commit is contained in:
+86
-52
@@ -7,6 +7,7 @@ CREATE TABLE `admin_accounts` (
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `admin_accounts_account_id_key`(`account_id`),
|
||||
INDEX `admin_accounts_admin_id_fkey`(`admin_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -275,28 +276,18 @@ CREATE TABLE `providers` (
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumer_devices` (
|
||||
`uuid` VARCHAR(255) NOT NULL,
|
||||
`app_version` VARCHAR(20) NOT NULL,
|
||||
`build_number` VARCHAR(20) NOT NULL,
|
||||
`platform` VARCHAR(100) NOT NULL,
|
||||
`brand` VARCHAR(100) NOT NULL,
|
||||
`model` VARCHAR(100) NOT NULL,
|
||||
`device` VARCHAR(100) NOT NULL,
|
||||
`publisher` ENUM('DIRECT', 'CAFE_BAZAR', 'MAYKET') NOT NULL,
|
||||
`os_version` VARCHAR(20) NOT NULL,
|
||||
`sdk_version` VARCHAR(20) NOT NULL,
|
||||
`release_number` VARCHAR(20) NOT NULL,
|
||||
`user_agent` VARCHAR(100) NULL,
|
||||
`browser_name` VARCHAR(100) NULL,
|
||||
`fcm_token` VARCHAR(100) NULL,
|
||||
CREATE TABLE `consumer_account_device` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`device_id` VARCHAR(191) NOT NULL,
|
||||
`device_name` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `consumer_devices_uuid_key`(`uuid`),
|
||||
INDEX `consumer_devices_consumer_id_fkey`(`consumer_id`),
|
||||
PRIMARY KEY (`uuid`)
|
||||
UNIQUE INDEX `consumer_account_device_device_id_key`(`device_id`),
|
||||
UNIQUE INDEX `consumer_account_device_consumer_account_id_key`(`consumer_account_id`),
|
||||
INDEX `consumer_account_device_consumer_account_id_idx`(`consumer_account_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
@@ -325,6 +316,7 @@ CREATE TABLE `consumer_accounts` (
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `consumer_accounts_account_id_key`(`account_id`),
|
||||
INDEX `consumer_accounts_consumer_id_fkey`(`consumer_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -381,6 +373,8 @@ CREATE TABLE `business_activities` (
|
||||
`guild_id` VARCHAR(191) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `business_activities_consumer_id_fkey`(`consumer_id`),
|
||||
INDEX `business_activities_guild_id_fkey`(`guild_id`),
|
||||
UNIQUE INDEX `business_activities_economic_code_consumer_id_key`(`economic_code`, `consumer_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -395,6 +389,7 @@ CREATE TABLE `complexes` (
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`business_activity_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `complexes_business_activity_id_fkey`(`business_activity_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -415,9 +410,23 @@ CREATE TABLE `poses` (
|
||||
|
||||
UNIQUE INDEX `poses_serial_number_key`(`serial_number`),
|
||||
UNIQUE INDEX `poses_account_id_key`(`account_id`),
|
||||
INDEX `poses_complex_id_fkey`(`complex_id`),
|
||||
INDEX `poses_device_id_fkey`(`device_id`),
|
||||
INDEX `poses_provider_id_fkey`(`provider_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumer_account_good_favorites` (
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
`good_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `consumer_account_good_favorites_good_id_idx`(`good_id`),
|
||||
INDEX `consumer_account_good_favorites_consumer_account_id_idx`(`consumer_account_id`),
|
||||
PRIMARY KEY (`consumer_account_id`, `good_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `goods` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
@@ -427,7 +436,7 @@ CREATE TABLE `goods` (
|
||||
`description` TEXT NULL,
|
||||
`local_sku` VARCHAR(100) NULL,
|
||||
`barcode` VARCHAR(100) NULL,
|
||||
`base_sale_price` DECIMAL(15, 0) NULL DEFAULT 0.00,
|
||||
`base_sale_price` DECIMAL(15, 0) NULL DEFAULT 0,
|
||||
`image_url` VARCHAR(255) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
@@ -440,6 +449,9 @@ CREATE TABLE `goods` (
|
||||
UNIQUE INDEX `goods_local_sku_key`(`local_sku`),
|
||||
UNIQUE INDEX `goods_barcode_key`(`barcode`),
|
||||
INDEX `goods_category_id_idx`(`category_id`),
|
||||
INDEX `goods_business_activity_id_fkey`(`business_activity_id`),
|
||||
INDEX `goods_measure_unit_id_fkey`(`measure_unit_id`),
|
||||
INDEX `goods_sku_id_fkey`(`sku_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -456,6 +468,8 @@ CREATE TABLE `good_categories` (
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`deleted_at` TIMESTAMP(0) NULL,
|
||||
|
||||
INDEX `good_categories_complex_id_fkey`(`complex_id`),
|
||||
INDEX `good_categories_guild_id_fkey`(`guild_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -489,7 +503,6 @@ CREATE TABLE `stock_keeping_units` (
|
||||
`code` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`VAT` DECIMAL(5, 2) NOT NULL,
|
||||
`type` ENUM('GOLD') NOT NULL,
|
||||
`is_public` BOOLEAN NOT NULL DEFAULT true,
|
||||
`is_domestic` BOOLEAN NOT NULL DEFAULT false,
|
||||
`guild_id` VARCHAR(191) NOT NULL,
|
||||
@@ -498,6 +511,7 @@ CREATE TABLE `stock_keeping_units` (
|
||||
|
||||
UNIQUE INDEX `stock_keeping_units_code_key`(`code`),
|
||||
INDEX `stock_keeping_units_code_idx`(`code`),
|
||||
INDEX `stock_keeping_units_guild_id_fkey`(`guild_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -571,12 +585,18 @@ CREATE TABLE `sales_invoices` (
|
||||
`customer_id` VARCHAR(191) NULL,
|
||||
`consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
`pos_id` VARCHAR(191) NOT NULL,
|
||||
`settlement_type` ENUM('CASH', 'CREDIT', 'MIXED') NOT NULL,
|
||||
`discount_amount` DECIMAL(15, 2) NULL,
|
||||
`tax_amount` DECIMAL(15, 2) NULL,
|
||||
|
||||
UNIQUE INDEX `sales_invoices_code_key`(`code`),
|
||||
UNIQUE INDEX `sales_invoices_tax_id_key`(`tax_id`),
|
||||
UNIQUE INDEX `sales_invoices_ref_id_key`(`ref_id`),
|
||||
INDEX `sales_invoices_ref_id_idx`(`ref_id`),
|
||||
INDEX `sales_invoices_tax_id_idx`(`tax_id`),
|
||||
INDEX `sales_invoices_consumer_account_id_fkey`(`consumer_account_id`),
|
||||
INDEX `sales_invoices_customer_id_fkey`(`customer_id`),
|
||||
INDEX `sales_invoices_pos_id_fkey`(`pos_id`),
|
||||
UNIQUE INDEX `sales_invoices_invoice_number_pos_id_key`(`invoice_number`, `pos_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -599,8 +619,12 @@ CREATE TABLE `sales_invoice_items` (
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
`good_id` VARCHAR(191) NOT NULL,
|
||||
`service_id` VARCHAR(191) NULL,
|
||||
`discount_amount` DECIMAL(15, 2) NULL,
|
||||
`tax_amount` DECIMAL(15, 2) NULL,
|
||||
|
||||
INDEX `sales_invoice_items_invoice_id_good_id_idx`(`invoice_id`, `good_id`),
|
||||
INDEX `sales_invoice_items_good_id_fkey`(`good_id`),
|
||||
INDEX `sales_invoice_items_service_id_fkey`(`service_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -608,16 +632,19 @@ CREATE TABLE `sales_invoice_items` (
|
||||
CREATE TABLE `sale_invoice_tsp_attempts` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`attempt_no` INTEGER NOT NULL,
|
||||
`status` ENUM('SUCCESS', 'FAILURE', 'NOT_SEND', 'QUEUED') NOT NULL,
|
||||
`request_payload` JSON NULL,
|
||||
`response_payload` JSON NULL,
|
||||
`status` ENUM('NOT_SEND', 'QUEUED', 'FISCAL_QUEUED', 'SEND_FAILURE', 'SUCCESS', 'FAILURE') NOT NULL,
|
||||
`message` TEXT NOT NULL,
|
||||
`sent_at` TIMESTAMP(0) NULL,
|
||||
`received_at` TIMESTAMP(0) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
`provider_request_payload` JSON NOT NULL,
|
||||
`raw_request_payload` JSON NOT NULL,
|
||||
`error_message` TEXT NULL,
|
||||
`fiscal_warnings` JSON NULL,
|
||||
`provider_response` JSON NULL,
|
||||
`validation_errors` JSON NULL,
|
||||
|
||||
UNIQUE INDEX `sale_invoice_tsp_attempts_invoice_id_key`(`invoice_id`),
|
||||
INDEX `sale_invoice_tsp_attempts_status_idx`(`status`),
|
||||
INDEX `sale_invoice_tsp_attempts_invoice_id_idx`(`invoice_id`),
|
||||
UNIQUE INDEX `sale_invoice_tsp_attempts_invoice_id_attempt_no_key`(`invoice_id`, `attempt_no`),
|
||||
@@ -666,7 +693,7 @@ CREATE TABLE `services` (
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`deleted_at` TIMESTAMP(0) NULL,
|
||||
`category_id` VARCHAR(191) NULL,
|
||||
`base_sale_price` DECIMAL(15, 0) NOT NULL DEFAULT 0.00,
|
||||
`base_sale_price` DECIMAL(15, 0) NOT NULL DEFAULT 0,
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
`complex_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
@@ -693,10 +720,10 @@ CREATE TABLE `service_categories` (
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `admin_accounts` ADD CONSTRAINT `admin_accounts_admin_id_fkey` FOREIGN KEY (`admin_id`) REFERENCES `admins`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `admin_accounts` ADD CONSTRAINT `admin_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `admin_accounts` ADD CONSTRAINT `admin_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `admin_accounts` ADD CONSTRAINT `admin_accounts_admin_id_fkey` FOREIGN KEY (`admin_id`) REFERENCES `admins`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `devices` ADD CONSTRAINT `devices_brand_id_fkey` FOREIGN KEY (`brand_id`) REFERENCES `device_brands`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -771,35 +798,38 @@ ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_account_id_fke
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_provider_id_fkey` FOREIGN KEY (`provider_id`) REFERENCES `providers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_devices` ADD CONSTRAINT `consumer_devices_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_accounts` ADD CONSTRAINT `consumer_accounts_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `consumer_account_device` ADD CONSTRAINT `consumer_account_device_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_accounts` ADD CONSTRAINT `consumer_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers_individual` ADD CONSTRAINT `consumers_individual_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `consumer_accounts` ADD CONSTRAINT `consumer_accounts_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers_individual` ADD CONSTRAINT `consumers_individual_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers_legal` ADD CONSTRAINT `consumers_legal_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `consumers_individual` ADD CONSTRAINT `consumers_individual_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumers_legal` ADD CONSTRAINT `consumers_legal_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `business_activities` ADD CONSTRAINT `business_activities_guild_id_fkey` FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `consumers_legal` ADD CONSTRAINT `consumers_legal_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `business_activities` ADD CONSTRAINT `business_activities_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `business_activities` ADD CONSTRAINT `business_activities_guild_id_fkey` FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `complexes` ADD CONSTRAINT `complexes_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `poses` ADD CONSTRAINT `poses_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `poses` ADD CONSTRAINT `poses_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
@@ -810,59 +840,62 @@ ALTER TABLE `poses` ADD CONSTRAINT `poses_device_id_fkey` FOREIGN KEY (`device_i
|
||||
ALTER TABLE `poses` ADD CONSTRAINT `poses_provider_id_fkey` FOREIGN KEY (`provider_id`) REFERENCES `providers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `poses` ADD CONSTRAINT `poses_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `consumer_account_good_favorites` ADD CONSTRAINT `consumer_account_good_favorites_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_sku_id_fkey` FOREIGN KEY (`sku_id`) REFERENCES `stock_keeping_units`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_measure_unit_id_fkey` FOREIGN KEY (`measure_unit_id`) REFERENCES `measure_units`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `good_categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE `consumer_account_good_favorites` ADD CONSTRAINT `consumer_account_good_favorites_good_id_fkey` FOREIGN KEY (`good_id`) REFERENCES `goods`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `good_categories` ADD CONSTRAINT `good_categories_guild_id_fkey` FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `good_categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_measure_unit_id_fkey` FOREIGN KEY (`measure_unit_id`) REFERENCES `measure_units`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `goods` ADD CONSTRAINT `goods_sku_id_fkey` FOREIGN KEY (`sku_id`) REFERENCES `stock_keeping_units`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `good_categories` ADD CONSTRAINT `good_categories_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `stock_keeping_units` ADD CONSTRAINT `stock_keeping_units_guild_id_fkey` FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `good_categories` ADD CONSTRAINT `good_categories_guild_id_fkey` FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `stock_keeping_units` ADD CONSTRAINT `stock_keeping_units_guild_id_fkey` FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `customer_individuals` ADD CONSTRAINT `customer_individuals_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_ref_id_fkey` FOREIGN KEY (`ref_id`) REFERENCES `sales_invoices`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_customer_id_fkey` FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_pos_id_fkey` FOREIGN KEY (`pos_id`) REFERENCES `poses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_ref_id_fkey` FOREIGN KEY (`ref_id`) REFERENCES `sales_invoices`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_good_id_fkey` FOREIGN KEY (`good_id`) REFERENCES `goods`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_items` ADD CONSTRAINT `sales_invoice_items_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE RESTRICT 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;
|
||||
|
||||
@@ -877,3 +910,4 @@ ALTER TABLE `sales_invoice_payment_terminal_info` ADD CONSTRAINT `sales_invoice_
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `services` ADD CONSTRAINT `services_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `service_categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `type` on the `stock_keeping_units` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `stock_keeping_units` DROP COLUMN `type`;
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `request_payload` on the `sale_invoice_tsp_attempts` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `response_payload` on the `sale_invoice_tsp_attempts` table. All the data in the column will be lost.
|
||||
- Added the required column `raw_request_payload` to the `sale_invoice_tsp_attempts` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `sale_invoice_tsp_attempts` DROP FOREIGN KEY `sale_invoice_tsp_attempts_invoice_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `sale_invoice_tsp_attempts_invoice_id_key` ON `sale_invoice_tsp_attempts`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sale_invoice_tsp_attempts`
|
||||
ADD COLUMN `provider_request_payload` JSON NULL,
|
||||
ADD COLUMN `provider_response_payload` JSON NULL,
|
||||
ADD COLUMN `raw_request_payload` JSON NOT NULL;
|
||||
|
||||
UPDATE `sale_invoice_tsp_attempts`
|
||||
SET `provider_response_payload` = `response_payload`;
|
||||
UPDATE `sale_invoice_tsp_attempts`
|
||||
SET `raw_request_payload` = `request_payload`;
|
||||
|
||||
ALTER TABLE `sale_invoice_tsp_attempts`
|
||||
DROP COLUMN `response_payload`,
|
||||
DROP COLUMN `request_payload`;
|
||||
|
||||
-- AddForeignKey
|
||||
-- Check if the foreign key constraint already exists before adding it
|
||||
SET @constraint_exists = (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE CONSTRAINT_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'customer_legal'
|
||||
AND CONSTRAINT_NAME = 'customer_legal_business_activity_id_fkey'
|
||||
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
|
||||
);
|
||||
|
||||
SET @sql = IF(@constraint_exists = 0,
|
||||
'ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;',
|
||||
'SELECT "Foreign key constraint customer_legal_business_activity_id_fkey already exists" as message;'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `consumer_devices` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `consumer_devices` DROP FOREIGN KEY `consumer_devices_consumer_id_fkey`;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE `consumer_devices`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumer_account_device` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`device_id` VARCHAR(191) NOT NULL,
|
||||
`device_name` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `consumer_account_device_device_id_key`(`device_id`),
|
||||
UNIQUE INDEX `consumer_account_device_consumer_account_id_key`(`consumer_account_id`),
|
||||
INDEX `consumer_account_device_consumer_account_id_idx`(`consumer_account_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_account_device` ADD CONSTRAINT `consumer_account_device_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sale_invoice_tsp_attempts` ADD CONSTRAINT `sale_invoice_tsp_attempts_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,16 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumer_account_goods_favorites` (
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
`goods_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `consumer_account_goods_favorites_goods_id_idx`(`goods_id`),
|
||||
INDEX `consumer_account_goods_favorites_consumer_account_id_idx`(`consumer_account_id`),
|
||||
PRIMARY KEY (`consumer_account_id`, `goods_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_account_goods_favorites` ADD CONSTRAINT `consumer_account_goods_favorites_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_account_goods_favorites` ADD CONSTRAINT `consumer_account_goods_favorites_goods_id_fkey` FOREIGN KEY (`goods_id`) REFERENCES `goods`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `consumer_account_goods_favorites` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `consumer_account_goods_favorites` DROP FOREIGN KEY `consumer_account_goods_favorites_consumer_account_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `consumer_account_goods_favorites` DROP FOREIGN KEY `consumer_account_goods_favorites_goods_id_fkey`;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE `consumer_account_goods_favorites`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumer_account_good_favorites` (
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
`good_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `consumer_account_good_favorites_good_id_idx`(`good_id`),
|
||||
INDEX `consumer_account_good_favorites_consumer_account_id_idx`(`consumer_account_id`),
|
||||
PRIMARY KEY (`consumer_account_id`, `good_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_account_good_favorites` ADD CONSTRAINT `consumer_account_good_favorites_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_account_good_favorites` ADD CONSTRAINT `consumer_account_good_favorites_good_id_fkey` FOREIGN KEY (`good_id`) REFERENCES `goods`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,10 +0,0 @@
|
||||
-- Add as nullable first to support existing rows, backfill, then enforce NOT NULL
|
||||
ALTER TABLE `sales_invoices`
|
||||
ADD COLUMN `settlement_type` ENUM('CASH', 'CREDIT', 'MIXED') NULL;
|
||||
|
||||
UPDATE `sales_invoices`
|
||||
SET `settlement_type` = 'CASH'
|
||||
WHERE `settlement_type` IS NULL;
|
||||
|
||||
ALTER TABLE `sales_invoices`
|
||||
MODIFY `settlement_type` ENUM('CASH', 'CREDIT', 'MIXED') NOT NULL;
|
||||
@@ -1,26 +0,0 @@
|
||||
-- 1. Add the new columns
|
||||
ALTER TABLE `sale_invoice_tsp_attempts`
|
||||
ADD COLUMN `error_message` TEXT NULL,
|
||||
ADD COLUMN `fiscal_warnings` JSON NULL,
|
||||
ADD COLUMN `provider_response` JSON NULL,
|
||||
ADD COLUMN `validation_errors` JSON NULL;
|
||||
|
||||
-- 2. Copy data from the old column to the new JSON column
|
||||
-- Note: We use a check to ensure we don't try to move invalid data
|
||||
UPDATE `sale_invoice_tsp_attempts`
|
||||
SET `provider_response` = CAST(`provider_response_payload` AS JSON)
|
||||
WHERE `provider_response_payload` IS NOT NULL AND JSON_VALID(`provider_response_payload`);
|
||||
|
||||
-- 3. SANITIZE 'provider_request_payload' before converting to JSON
|
||||
-- This replaces empty strings or invalid JSON with a default empty object '{}'
|
||||
UPDATE `sale_invoice_tsp_attempts`
|
||||
SET `provider_request_payload` = '{}'
|
||||
WHERE `provider_request_payload` IS NULL
|
||||
OR `provider_request_payload` = ''
|
||||
OR JSON_VALID(`provider_request_payload`) = 0;
|
||||
|
||||
-- 4. Perform the final modifications and drop the old column
|
||||
ALTER TABLE `sale_invoice_tsp_attempts`
|
||||
DROP COLUMN `provider_response_payload`,
|
||||
MODIFY `status` ENUM('NOT_SEND', 'QUEUED', 'FISCAL_QUEUED', 'SEND_FAILURE', 'SUCCESS', 'FAILURE') NOT NULL,
|
||||
MODIFY `provider_request_payload` JSON NOT NULL;
|
||||
@@ -1,15 +1,13 @@
|
||||
model AdminAccount {
|
||||
id String @id @default(ulid())
|
||||
|
||||
id String @id @default(ulid())
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
admin_id String
|
||||
admin Admin @relation(fields: [admin_id], references: [id])
|
||||
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
admin_id String
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
admin Admin @relation(fields: [admin_id], references: [id])
|
||||
|
||||
@@index([admin_id], map: "admin_accounts_admin_id_fkey")
|
||||
@@map("admin_accounts")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
model ConsumerAccountDevice {
|
||||
id String @id @default(ulid())
|
||||
device_id String @unique
|
||||
device_name String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
device_id String @unique
|
||||
device_name String?
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
consumer_account_id String @unique
|
||||
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id])
|
||||
|
||||
|
||||
@@ -1,23 +1 @@
|
||||
// model ConsumerDevices {
|
||||
// uuid String @id @unique @db.VarChar(255)
|
||||
// app_version String @db.VarChar(20)
|
||||
// build_number String @db.VarChar(20)
|
||||
// platform String @db.VarChar(100)
|
||||
// brand String @db.VarChar(100)
|
||||
// model String @db.VarChar(100)
|
||||
// device String @db.VarChar(100)
|
||||
// publisher ApplicationPublisher
|
||||
// os_version String @db.VarChar(20)
|
||||
// sdk_version String @db.VarChar(20)
|
||||
// release_number String @db.VarChar(20)
|
||||
// user_agent String? @db.VarChar(100)
|
||||
// browser_name String? @db.VarChar(100)
|
||||
// fcm_token String? @db.VarChar(100)
|
||||
// created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
// updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
// consumer_id String
|
||||
// consumer Consumer @relation(fields: [consumer_id], references: [id])
|
||||
|
||||
// @@index([consumer_id], map: "consumer_devices_consumer_id_fkey")
|
||||
// @@map("consumer_devices")
|
||||
// }
|
||||
|
||||
@@ -1,37 +1,31 @@
|
||||
model ConsumerAccount {
|
||||
id String @id @default(ulid())
|
||||
role ConsumerRole
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
consumer_id String
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id])
|
||||
|
||||
account_id String @unique()
|
||||
account Account @relation(fields: [account_id], references: [id])
|
||||
|
||||
pos Pos?
|
||||
permission PermissionConsumer?
|
||||
account_allocation LicenseAccountAllocation?
|
||||
id String @id @default(ulid())
|
||||
role ConsumerRole
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
consumer_id String
|
||||
account_id String @unique
|
||||
account_device ConsumerAccountDevice?
|
||||
sales_invoices SalesInvoice[]
|
||||
consumer_account_good_favorites ConsumerAccountGoodFavorite[]
|
||||
account Account @relation(fields: [account_id], references: [id])
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id])
|
||||
account_allocation LicenseAccountAllocation?
|
||||
permission PermissionConsumer?
|
||||
pos Pos?
|
||||
sales_invoices SalesInvoice[]
|
||||
|
||||
@@index([consumer_id], map: "consumer_accounts_consumer_id_fkey")
|
||||
@@map("consumer_accounts")
|
||||
}
|
||||
|
||||
model Consumer {
|
||||
id String @id @default(ulid())
|
||||
type ConsumerType
|
||||
status ConsumerStatus @default(ACTIVE)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
accounts ConsumerAccount[]
|
||||
id String @id @default(ulid())
|
||||
type ConsumerType
|
||||
status ConsumerStatus @default(ACTIVE)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
business_activities BusinessActivity[]
|
||||
// devices ConsumerDevices[]
|
||||
accounts ConsumerAccount[]
|
||||
individual ConsumerIndividual?
|
||||
legal ConsumerLegal?
|
||||
|
||||
@@ -43,15 +37,12 @@ model ConsumerIndividual {
|
||||
last_name String
|
||||
mobile_number String
|
||||
national_code String
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
partner_id String
|
||||
partner Partner @relation(fields: [partner_id], references: [id])
|
||||
|
||||
consumer_id String @id
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id], onDelete: Cascade)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
partner_id String
|
||||
consumer_id String @id
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id], onDelete: Cascade)
|
||||
partner Partner @relation(fields: [partner_id], references: [id])
|
||||
|
||||
@@unique([mobile_number, consumer_id])
|
||||
@@unique([partner_id, national_code])
|
||||
@@ -61,107 +52,94 @@ model ConsumerIndividual {
|
||||
model ConsumerLegal {
|
||||
name String
|
||||
registration_code String
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
partner_id String
|
||||
partner Partner @relation(fields: [partner_id], references: [id])
|
||||
|
||||
consumer_id String @id
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id], onDelete: Cascade)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
partner_id String
|
||||
consumer_id String @id
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id], onDelete: Cascade)
|
||||
partner Partner @relation(fields: [partner_id], references: [id])
|
||||
|
||||
@@unique([partner_id, registration_code])
|
||||
@@map("consumers_legal")
|
||||
}
|
||||
|
||||
model BusinessActivity {
|
||||
id String @id @default(ulid())
|
||||
id String @id @default(ulid())
|
||||
economic_code String
|
||||
name String
|
||||
fiscal_id String
|
||||
partner_token String
|
||||
invoice_number_sequence Decimal @default(1) @db.Decimal(20, 0)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
guild_id String
|
||||
guild Guild @relation(fields: [guild_id], references: [id])
|
||||
|
||||
consumer_id String
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id])
|
||||
|
||||
license_activation LicenseActivation?
|
||||
complexes Complex[]
|
||||
permission_businesses PermissionBusiness[]
|
||||
goods Good[]
|
||||
customer_individuals CustomerIndividual[]
|
||||
customer_legals CustomerLegal[]
|
||||
invoice_number_sequence Decimal @default(1) @db.Decimal(20, 0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
guild_id String
|
||||
consumer_id String
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id])
|
||||
guild Guild @relation(fields: [guild_id], references: [id])
|
||||
complexes Complex[]
|
||||
customer_individuals CustomerIndividual[]
|
||||
customer_legals CustomerLegal[]
|
||||
goods Good[]
|
||||
license_activation LicenseActivation?
|
||||
permission_businesses PermissionBusiness[]
|
||||
|
||||
@@unique([economic_code, consumer_id])
|
||||
@@index([consumer_id], map: "business_activities_consumer_id_fkey")
|
||||
@@index([guild_id], map: "business_activities_guild_id_fkey")
|
||||
@@map("business_activities")
|
||||
}
|
||||
|
||||
model Complex {
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
branch_code String
|
||||
address String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
branch_code String
|
||||
address String?
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
business_activity_id String
|
||||
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
|
||||
pos_list Pos[]
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
good_categories GoodCategory[]
|
||||
permission_complexes PermissionComplex[]
|
||||
pos_list Pos[]
|
||||
|
||||
@@index([business_activity_id], map: "complexes_business_activity_id_fkey")
|
||||
@@map("complexes")
|
||||
}
|
||||
|
||||
model Pos {
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
model String?
|
||||
serial_number String? @unique()
|
||||
status POSStatus @default(ACTIVE)
|
||||
pos_type POSType
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
complex_id String
|
||||
complex Complex @relation(fields: [complex_id], references: [id])
|
||||
|
||||
device_id String?
|
||||
device Device? @relation(fields: [device_id], references: [id])
|
||||
|
||||
provider_id String?
|
||||
provider Provider? @relation(fields: [provider_id], references: [id])
|
||||
|
||||
account_id String @unique
|
||||
account ConsumerAccount @relation(fields: [account_id], references: [id])
|
||||
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
model String?
|
||||
serial_number String? @unique
|
||||
status POSStatus @default(ACTIVE)
|
||||
pos_type POSType
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
complex_id String
|
||||
device_id String?
|
||||
provider_id String?
|
||||
account_id String @unique
|
||||
permission_pos PermissionPos[]
|
||||
account ConsumerAccount @relation(fields: [account_id], references: [id])
|
||||
complex Complex @relation(fields: [complex_id], references: [id])
|
||||
device Device? @relation(fields: [device_id], references: [id])
|
||||
provider Provider? @relation(fields: [provider_id], references: [id])
|
||||
sales_invoices SalesInvoice[]
|
||||
|
||||
@@index([complex_id], map: "poses_complex_id_fkey")
|
||||
@@index([device_id], map: "poses_device_id_fkey")
|
||||
@@index([provider_id], map: "poses_provider_id_fkey")
|
||||
@@map("poses")
|
||||
}
|
||||
|
||||
model ConsumerAccountGoodFavorite {
|
||||
created_at DateTime @default(now())
|
||||
|
||||
created_at DateTime @default(now())
|
||||
consumer_account_id String
|
||||
good_id String
|
||||
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id], onDelete: Cascade)
|
||||
good Good @relation(fields: [good_id], references: [id], onDelete: Cascade)
|
||||
|
||||
good_id String
|
||||
good Good @relation(fields: [good_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([consumer_account_id, good_id]) // unique pair
|
||||
@@id([consumer_account_id, good_id])
|
||||
@@index([good_id])
|
||||
@@index([consumer_account_id])
|
||||
@@map("consumer_account_good_favorites")
|
||||
|
||||
@@ -1,53 +1,50 @@
|
||||
model Good {
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(255)
|
||||
is_default_guild_good Boolean @default(false)
|
||||
pricing_model GoodPricingModel
|
||||
description String? @db.Text
|
||||
local_sku String? @unique() @db.VarChar(100)
|
||||
barcode String? @unique() @db.VarChar(100)
|
||||
base_sale_price Decimal? @default(0.00) @db.Decimal(15, 0)
|
||||
image_url String? @db.VarChar(255)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
sku_id String
|
||||
sku StockKeepingUnits @relation(fields: [sku_id], references: [id])
|
||||
|
||||
measure_unit_id String
|
||||
measure_unit MeasureUnits @relation(fields: [measure_unit_id], references: [id])
|
||||
|
||||
category_id String?
|
||||
category GoodCategory? @relation(fields: [category_id], references: [id])
|
||||
|
||||
business_activity_id String?
|
||||
business_activity BusinessActivity? @relation(fields: [business_activity_id], references: [id])
|
||||
|
||||
sales_invoice_items SalesInvoiceItem[]
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(255)
|
||||
is_default_guild_good Boolean @default(false)
|
||||
pricing_model GoodPricingModel
|
||||
description String? @db.Text
|
||||
local_sku String? @unique @db.VarChar(100)
|
||||
barcode String? @unique @db.VarChar(100)
|
||||
base_sale_price Decimal? @default(0) @db.Decimal(15, 0)
|
||||
image_url String? @db.VarChar(255)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
sku_id String
|
||||
measure_unit_id String
|
||||
category_id String?
|
||||
business_activity_id String?
|
||||
consumer_account_good_favorites ConsumerAccountGoodFavorite[]
|
||||
business_activity BusinessActivity? @relation(fields: [business_activity_id], references: [id])
|
||||
category GoodCategory? @relation(fields: [category_id], references: [id])
|
||||
measure_unit MeasureUnits @relation(fields: [measure_unit_id], references: [id])
|
||||
sku StockKeepingUnits @relation(fields: [sku_id], references: [id])
|
||||
sales_invoice_items SalesInvoiceItem[]
|
||||
|
||||
@@index([category_id])
|
||||
@@index([business_activity_id], map: "goods_business_activity_id_fkey")
|
||||
@@index([measure_unit_id], map: "goods_measure_unit_id_fkey")
|
||||
@@index([sku_id], map: "goods_sku_id_fkey")
|
||||
@@map("goods")
|
||||
}
|
||||
|
||||
model GoodCategory {
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(100)
|
||||
description String? @db.Text
|
||||
image_url String? @db.VarChar(255)
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(100)
|
||||
description String? @db.Text
|
||||
image_url String? @db.VarChar(255)
|
||||
complex_id String?
|
||||
is_default_guild_good Boolean @default(false)
|
||||
is_default_guild_good Boolean @default(false)
|
||||
guild_id String?
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
complex Complex? @relation(fields: [complex_id], references: [id])
|
||||
guild Guild? @relation(fields: [guild_id], references: [id])
|
||||
goods Good[]
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
goods Good[]
|
||||
guild Guild? @relation(fields: [guild_id], references: [id])
|
||||
complex Complex? @relation(fields: [complex_id], references: [id])
|
||||
|
||||
@@index([complex_id], map: "good_categories_complex_id_fkey")
|
||||
@@index([guild_id], map: "good_categories_guild_id_fkey")
|
||||
@@map("good_categories")
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
model Guild {
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
invoice_template InvoiceTemplateType
|
||||
code String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
invoice_template InvoiceTemplateType
|
||||
code String?
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
business_activities BusinessActivity[]
|
||||
good_categories GoodCategory[]
|
||||
stockKeepingUnits StockKeepingUnits[]
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
model MeasureUnits {
|
||||
id String @id @default(ulid())
|
||||
code String @unique
|
||||
name String
|
||||
|
||||
id String @id @default(ulid())
|
||||
code String @unique
|
||||
name String
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @updatedAt @db.Timestamp(0)
|
||||
|
||||
goods Good[]
|
||||
goods Good[]
|
||||
|
||||
@@map("measure_units")
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
model StockKeepingUnits {
|
||||
id String @id @default(ulid())
|
||||
code String @unique
|
||||
id String @id @default(ulid())
|
||||
code String @unique
|
||||
name String
|
||||
VAT Decimal @db.Decimal(5, 2)
|
||||
is_public Boolean @default(true)
|
||||
is_domestic Boolean @default(false)
|
||||
|
||||
guild_id String
|
||||
guild Guild @relation(fields: [guild_id], references: [id])
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
goods Good[]
|
||||
VAT Decimal @db.Decimal(5, 2)
|
||||
is_public Boolean @default(true)
|
||||
is_domestic Boolean @default(false)
|
||||
guild_id String
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
goods Good[]
|
||||
guild Guild @relation(fields: [guild_id], references: [id])
|
||||
|
||||
@@index([code])
|
||||
@@index([guild_id], map: "stock_keeping_units_guild_id_fkey")
|
||||
@@map("stock_keeping_units")
|
||||
}
|
||||
|
||||
@@ -1,34 +1,28 @@
|
||||
model Customer {
|
||||
id String @id @default(ulid())
|
||||
is_favorite Boolean? @default(false)
|
||||
type CustomerType
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
individual CustomerIndividual?
|
||||
legal CustomerLegal?
|
||||
|
||||
id String @id @default(ulid())
|
||||
is_favorite Boolean? @default(false)
|
||||
type CustomerType
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
individual CustomerIndividual?
|
||||
legal CustomerLegal?
|
||||
sales_invoices SalesInvoice[]
|
||||
|
||||
@@map("customers")
|
||||
}
|
||||
|
||||
model CustomerIndividual {
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
national_id String @db.Char(10)
|
||||
mobile_number String @db.Char(15)
|
||||
|
||||
postal_code String @db.Char(10)
|
||||
economic_code String? @db.Char(10)
|
||||
|
||||
customer_id String @id
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
national_id String @db.Char(10)
|
||||
mobile_number String @db.Char(15)
|
||||
postal_code String @db.Char(10)
|
||||
economic_code String? @db.Char(10)
|
||||
customer_id String @id
|
||||
business_activity_id String
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: id)
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([business_activity_id, national_id])
|
||||
@@index([business_activity_id])
|
||||
@@ -36,16 +30,14 @@ model CustomerIndividual {
|
||||
}
|
||||
|
||||
model CustomerLegal {
|
||||
name String @db.VarChar(255)
|
||||
economic_code String @db.Char(10)
|
||||
registration_number String? @db.Char(20)
|
||||
postal_code String @db.Char(10)
|
||||
|
||||
customer_id String @id
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
name String @db.VarChar(255)
|
||||
economic_code String @db.Char(10)
|
||||
registration_number String? @db.Char(20)
|
||||
postal_code String @db.Char(10)
|
||||
customer_id String @id
|
||||
business_activity_id String
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: id)
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([business_activity_id, economic_code])
|
||||
@@index([business_activity_id])
|
||||
|
||||
@@ -9,16 +9,6 @@ enum PaymentMethodType {
|
||||
OTHER
|
||||
}
|
||||
|
||||
enum UnitType {
|
||||
COUNT
|
||||
GRAM
|
||||
KILOGRAM
|
||||
MILLILITER
|
||||
LITER
|
||||
METER
|
||||
HOUR
|
||||
}
|
||||
|
||||
enum GoodPricingModel {
|
||||
STANDARD
|
||||
GOLD
|
||||
@@ -50,18 +40,6 @@ enum BusinessRole {
|
||||
OPERATOR
|
||||
}
|
||||
|
||||
enum LicenseType {
|
||||
BASIC
|
||||
PRO
|
||||
ENTERPRISE
|
||||
}
|
||||
|
||||
enum LicenseStatus {
|
||||
ACTIVE
|
||||
EXPIRED
|
||||
SUSPENDED
|
||||
}
|
||||
|
||||
enum POSType {
|
||||
PSP
|
||||
MOBILE
|
||||
@@ -69,11 +47,6 @@ enum POSType {
|
||||
API
|
||||
}
|
||||
|
||||
enum UserType {
|
||||
LEGAL
|
||||
INDIVIDUAL
|
||||
}
|
||||
|
||||
enum AccountType {
|
||||
ADMIN
|
||||
PROVIDER
|
||||
@@ -81,17 +54,6 @@ enum AccountType {
|
||||
CONSUMER
|
||||
}
|
||||
|
||||
enum UserStatus {
|
||||
ACTIVE
|
||||
INACTIVE
|
||||
}
|
||||
|
||||
enum AccountRole {
|
||||
OWNER
|
||||
OPERATOR
|
||||
ACCOUNTANT
|
||||
}
|
||||
|
||||
enum AccountStatus {
|
||||
ACTIVE
|
||||
SUSPENDED
|
||||
@@ -114,11 +76,6 @@ enum ProviderRole {
|
||||
OPERATOR
|
||||
}
|
||||
|
||||
enum ProviderStatus {
|
||||
ACTIVE
|
||||
SUSPENDED
|
||||
}
|
||||
|
||||
enum ConsumerRole {
|
||||
OWNER
|
||||
MANAGER
|
||||
@@ -130,11 +87,6 @@ enum ConsumerStatus {
|
||||
SUSPENDED
|
||||
}
|
||||
|
||||
enum TokenType {
|
||||
ACCESS
|
||||
REFRESH
|
||||
}
|
||||
|
||||
enum ApplicationPlatform {
|
||||
ANDROID
|
||||
IOS
|
||||
@@ -146,12 +98,6 @@ enum ApplicationReleaseType {
|
||||
ALPHA
|
||||
}
|
||||
|
||||
enum ApplicationPublisher {
|
||||
DIRECT
|
||||
CAFE_BAZAR
|
||||
MAYKET
|
||||
}
|
||||
|
||||
enum ConsumerType {
|
||||
INDIVIDUAL
|
||||
LEGAL
|
||||
@@ -184,15 +130,6 @@ enum TspProviderRequestType {
|
||||
RETURN
|
||||
}
|
||||
|
||||
enum TspProviderCustomerType {
|
||||
Unknown
|
||||
Known
|
||||
}
|
||||
|
||||
enum SKUGuildType {
|
||||
GOLD
|
||||
}
|
||||
|
||||
enum InvoiceTemplateType {
|
||||
SALE
|
||||
FX_SALE
|
||||
|
||||
@@ -1,92 +1,86 @@
|
||||
model SalesInvoice {
|
||||
id String @id @default(uuid())
|
||||
code String @unique @db.VarChar(100)
|
||||
total_amount Decimal @db.Decimal(15, 2)
|
||||
invoice_number Int @db.Int()
|
||||
invoice_date DateTime @default(now()) @db.Timestamp(0)
|
||||
type TspProviderRequestType
|
||||
settlement_type InvoiceSettlementType
|
||||
tax_id String? @unique @db.VarChar(32)
|
||||
|
||||
notes String? @db.Text
|
||||
unknown_customer Json? @db.Json
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
|
||||
main_id String? @db.VarChar(50)
|
||||
ref_id String? @unique @db.VarChar(50)
|
||||
reference_invoice SalesInvoice? @relation("SalesInvoiceReference", fields: [ref_id], references: [id])
|
||||
|
||||
customer_id String?
|
||||
customer Customer? @relation(fields: [customer_id], references: [id])
|
||||
|
||||
id String @id @default(uuid())
|
||||
code String @unique @db.VarChar(100)
|
||||
total_amount Decimal @db.Decimal(15, 2)
|
||||
invoice_number Int
|
||||
invoice_date DateTime @default(now()) @db.Timestamp(0)
|
||||
type TspProviderRequestType
|
||||
tax_id String? @unique @db.VarChar(32)
|
||||
notes String? @db.Text
|
||||
unknown_customer Json?
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
main_id String? @db.VarChar(50)
|
||||
ref_id String? @unique @db.VarChar(50)
|
||||
customer_id String?
|
||||
consumer_account_id String
|
||||
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id])
|
||||
|
||||
pos_id String
|
||||
pos Pos @relation(fields: [pos_id], references: [id])
|
||||
|
||||
referenced_by SalesInvoice? @relation("SalesInvoiceReference")
|
||||
items SalesInvoiceItem[]
|
||||
payments SalesInvoicePayment[]
|
||||
tsp_attempts SaleInvoiceTspAttempts[]
|
||||
pos_id String
|
||||
settlement_type InvoiceSettlementType
|
||||
discount_amount Decimal? @db.Decimal(15, 2)
|
||||
tax_amount Decimal? @db.Decimal(15, 2)
|
||||
tsp_attempts SaleInvoiceTspAttempts[]
|
||||
items SalesInvoiceItem[]
|
||||
payments SalesInvoicePayment[]
|
||||
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id])
|
||||
customer Customer? @relation(fields: [customer_id], references: [id])
|
||||
pos Pos @relation(fields: [pos_id], references: [id])
|
||||
reference_invoice SalesInvoice? @relation("SalesInvoiceReference", fields: [ref_id], references: [id])
|
||||
referenced_by SalesInvoice? @relation("SalesInvoiceReference")
|
||||
|
||||
@@unique([invoice_number, pos_id])
|
||||
@@index([ref_id])
|
||||
@@index([tax_id])
|
||||
@@index([consumer_account_id], map: "sales_invoices_consumer_account_id_fkey")
|
||||
@@index([customer_id], map: "sales_invoices_customer_id_fkey")
|
||||
@@index([pos_id], map: "sales_invoices_pos_id_fkey")
|
||||
@@map("sales_invoices")
|
||||
}
|
||||
|
||||
model SalesInvoiceItem {
|
||||
id String @id @default(ulid())
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
measure_unit_text String @db.VarChar(50)
|
||||
measure_unit_code String @db.VarChar(50)
|
||||
sku_code String @db.VarChar(50)
|
||||
sku_vat Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
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)
|
||||
discount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
notes String? @db.Text
|
||||
|
||||
payload Json?
|
||||
good_snapshot Json
|
||||
|
||||
invoice_id String
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
|
||||
good_id String
|
||||
good Good @relation(fields: [good_id], references: [id])
|
||||
|
||||
service_id String?
|
||||
service Service? @relation(fields: [service_id], references: [id])
|
||||
id String @id @default(ulid())
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
measure_unit_text String @db.VarChar(50)
|
||||
measure_unit_code String @db.VarChar(50)
|
||||
sku_code String @db.VarChar(50)
|
||||
sku_vat Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
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)
|
||||
discount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
notes String? @db.Text
|
||||
payload Json?
|
||||
good_snapshot Json
|
||||
invoice_id String
|
||||
good_id String
|
||||
service_id String?
|
||||
discount_amount Decimal? @db.Decimal(15, 2)
|
||||
tax_amount Decimal? @db.Decimal(15, 2)
|
||||
good Good @relation(fields: [good_id], references: [id])
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
service Service? @relation(fields: [service_id], references: [id])
|
||||
|
||||
@@index([invoice_id, good_id])
|
||||
@@index([good_id], map: "sales_invoice_items_good_id_fkey")
|
||||
@@index([service_id], map: "sales_invoice_items_service_id_fkey")
|
||||
@@map("sales_invoice_items")
|
||||
}
|
||||
|
||||
model SaleInvoiceTspAttempts {
|
||||
id String @id @default(ulid())
|
||||
|
||||
attempt_no Int
|
||||
status TspProviderResponseStatus
|
||||
|
||||
raw_request_payload Json
|
||||
id String @id @default(ulid())
|
||||
attempt_no Int
|
||||
status TspProviderResponseStatus
|
||||
message String @db.Text
|
||||
sent_at DateTime? @db.Timestamp(0)
|
||||
received_at DateTime? @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
invoice_id String
|
||||
provider_request_payload Json
|
||||
provider_response Json?
|
||||
message String @db.Text
|
||||
error_message String? @db.Text
|
||||
validation_errors Json?
|
||||
raw_request_payload Json
|
||||
error_message String? @db.Text
|
||||
fiscal_warnings Json?
|
||||
|
||||
sent_at DateTime? @db.Timestamp(0)
|
||||
received_at DateTime? @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
invoice_id String
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id], onDelete: Cascade)
|
||||
provider_response Json?
|
||||
validation_errors Json?
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([invoice_id, attempt_no])
|
||||
@@index([status])
|
||||
@@ -95,35 +89,30 @@ model SaleInvoiceTspAttempts {
|
||||
}
|
||||
|
||||
model SalesInvoicePayment {
|
||||
id String @id @default(ulid())
|
||||
amount Decimal @db.Decimal(15, 2)
|
||||
id String @id @default(ulid())
|
||||
amount Decimal @db.Decimal(15, 2)
|
||||
payment_method PaymentMethodType
|
||||
paid_at DateTime @db.Timestamp(0)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
invoice_id String
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
|
||||
terminal_info SalesInvoicePaymentTerminalInfo?
|
||||
paid_at DateTime @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
invoice_id String
|
||||
terminal_info SalesInvoicePaymentTerminalInfo?
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
|
||||
@@index([invoice_id])
|
||||
@@map("sales_invoice_payments")
|
||||
}
|
||||
|
||||
model SalesInvoicePaymentTerminalInfo {
|
||||
id String @id @default(ulid())
|
||||
id String @id @default(ulid())
|
||||
terminal_id String
|
||||
stan String
|
||||
rrn String
|
||||
transaction_date_time DateTime
|
||||
customer_card_no String?
|
||||
description String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
payment_id String @unique
|
||||
payment SalesInvoicePayment @relation(fields: [payment_id], references: [id])
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
payment_id String @unique
|
||||
payment SalesInvoicePayment @relation(fields: [payment_id], references: [id])
|
||||
|
||||
@@unique([terminal_id, stan, rrn, payment_id])
|
||||
@@map("sales_invoice_payment_terminal_info")
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
model Service {
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(255)
|
||||
description String? @db.Text
|
||||
sku String @unique() @db.VarChar(100)
|
||||
local_sku String? @unique() @db.VarChar(100)
|
||||
barcode String? @unique() @db.VarChar(100)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
category_id String?
|
||||
base_sale_price Decimal @default(0.00) @db.Decimal(15, 0)
|
||||
account_id String
|
||||
complex_id String
|
||||
|
||||
category ServiceCategory? @relation(fields: [category_id], references: [id])
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(255)
|
||||
description String? @db.Text
|
||||
sku String @unique @db.VarChar(100)
|
||||
local_sku String? @unique @db.VarChar(100)
|
||||
barcode String? @unique @db.VarChar(100)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
category_id String?
|
||||
base_sale_price Decimal @default(0) @db.Decimal(15, 0)
|
||||
account_id String
|
||||
complex_id String
|
||||
sales_invoice_items SalesInvoiceItem[]
|
||||
category ServiceCategory? @relation(fields: [category_id], references: [id])
|
||||
|
||||
@@index([category_id])
|
||||
@@map("services")
|
||||
@@ -30,8 +29,7 @@ model ServiceCategory {
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
services Service[]
|
||||
services Service[]
|
||||
|
||||
@@map("service_categories")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user