feat: add stock keeping units management
- Created migration to drop `type` column from `stock_keeping_units` table. - Added `Guild` model to Prisma schema. - Implemented `BusinessActivitiesQueryService` for querying business activities. - Developed `GoodsSharedService` for handling goods creation and updates. - Introduced DTOs for creating and updating stock keeping units. - Created controller and service for managing stock keeping units. - Implemented response DTOs for stock keeping units service. - Established module for stock keeping units management.
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `admin_accounts` DROP FOREIGN KEY `admin_accounts_account_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `partner_accounts` DROP FOREIGN KEY `partner_accounts_account_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `provider_accounts` DROP FOREIGN KEY `provider_accounts_account_id_fkey`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `guilds` ADD COLUMN `invoice_template` ENUM('SALE', 'FX_SALE', 'GOLD_JEWELRY', 'CONTRACT', 'UTILITY', 'AIR_TICKET', 'EXPORT', 'BILL_OF_LADING', 'PETROCHEMICAL', 'COMMODITY_EXCHANGE', 'INSURANCE') NOT NULL DEFAULT 'GOLD_JEWELRY';
|
||||
|
||||
-- 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;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `fiscal_switch_type` on the `partners` table. All the data in the column will be lost.
|
||||
- The values [CHECK] on the enum `sales_invoice_payments_payment_method` will be removed. If these variants are still used in the database, this will fail.
|
||||
- You are about to drop the `sale_invoice_fiscal_attempts` table. If the table is not empty, all the data it contains will be lost.
|
||||
- You are about to drop the `sale_invoice_fiscals` table. If the table is not empty, all the data it contains will be lost.
|
||||
- Made the column `good_snapshot` on table `sales_invoice_items` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `good_id` on table `sales_invoice_items` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `sale_invoice_fiscal_attempts` DROP FOREIGN KEY `sale_invoice_fiscal_attempts_fiscal_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `sale_invoice_fiscals` DROP FOREIGN KEY `sale_invoice_fiscals_invoice_id_fkey`;
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE `sales_invoice_items` DROP FOREIGN KEY `sales_invoice_items_good_id_fkey`;
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX `sales_invoice_items_good_id_fkey` ON `sales_invoice_items`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `business_activities` ADD COLUMN `invoice_number_sequence` VARCHAR(191) NOT NULL DEFAULT '1';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `partners` DROP COLUMN `fiscal_switch_type`,
|
||||
ADD COLUMN `tsp_provider` ENUM('NAMA', 'SUN') NOT NULL DEFAULT 'NAMA';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoice_items` MODIFY `good_snapshot` JSON NOT NULL,
|
||||
MODIFY `good_id` VARCHAR(191) NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoice_payments` MODIFY `payment_method` ENUM('CHEQUE', 'SET_OFF', 'CASH', 'TERMINAL', 'PAYMENT_GATEWAY', 'CARD', 'BANK', 'OTHER') NOT NULL;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE `sale_invoice_fiscal_attempts`;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE `sale_invoice_fiscals`;
|
||||
|
||||
-- CreateTable
|
||||
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,
|
||||
`tax_id` VARCHAR(191) NULL,
|
||||
`type` ENUM('MAIN', 'UPDATE', 'REVOKE', 'REMOVE') NOT NULL,
|
||||
`request_payload` JSON NULL,
|
||||
`response_payload` JSON NULL,
|
||||
`error_message` TEXT 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,
|
||||
|
||||
UNIQUE INDEX `sale_invoice_tsp_attempts_tax_id_key`(`tax_id`),
|
||||
UNIQUE INDEX `sale_invoice_tsp_attempts_invoice_id_key`(`invoice_id`),
|
||||
INDEX `sale_invoice_tsp_attempts_status_idx`(`status`),
|
||||
INDEX `sale_invoice_tsp_attempts_tax_id_idx`(`tax_id`),
|
||||
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`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- 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 `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,14 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to alter the column `invoice_number_sequence` on the `business_activities` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `Decimal(20,0)`.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `business_activities` MODIFY `invoice_number_sequence` DECIMAL(20, 0) NOT NULL DEFAULT 1;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `guilds` ALTER COLUMN `invoice_template` DROP DEFAULT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `stock_keeping_units` ALTER COLUMN `type` DROP DEFAULT;
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `type` on the `sale_invoice_tsp_attempts` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[ref_id]` on the table `sales_invoices` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `type` to the `sales_invoices` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `sale_invoice_tsp_attempts` DROP COLUMN `type`;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `sales_invoices` ADD COLUMN `main_id` VARCHAR(50) NULL,
|
||||
ADD COLUMN `ref_id` VARCHAR(50) NULL,
|
||||
ADD COLUMN `type` ENUM('ORIGINAL', 'CORRECTION', 'REVOKE', 'RETURN') NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `sales_invoices_ref_id_key` ON `sales_invoices`(`ref_id`);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX `sales_invoices_ref_id_idx` ON `sales_invoices`(`ref_id`);
|
||||
|
||||
-- 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;
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `error_message` on the `sale_invoice_tsp_attempts` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `tax_id` on the `sale_invoice_tsp_attempts` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[tax_id]` on the table `sales_invoices` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `message` to the `sale_invoice_tsp_attempts` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- 1) Add new columns in a backward-compatible way
|
||||
ALTER TABLE `sale_invoice_tsp_attempts`
|
||||
ADD COLUMN `message` TEXT NULL;
|
||||
|
||||
ALTER TABLE `sales_invoices`
|
||||
ADD COLUMN `tax_id` VARCHAR(32) NULL;
|
||||
|
||||
-- 2) Backfill message from old error_message, fallback to a default text
|
||||
UPDATE `sale_invoice_tsp_attempts`
|
||||
SET `message` = COALESCE(`error_message`, 'وضعیت ارسال فاکتور ثبت شد.')
|
||||
WHERE `message` IS NULL;
|
||||
|
||||
-- 3) Backfill tax_id to sales_invoices from attempts
|
||||
UPDATE `sales_invoices` si
|
||||
JOIN `sale_invoice_tsp_attempts` sita ON sita.`invoice_id` = si.`id`
|
||||
SET si.`tax_id` = sita.`tax_id`
|
||||
WHERE sita.`tax_id` IS NOT NULL
|
||||
AND si.`tax_id` IS NULL;
|
||||
|
||||
-- 4) Enforce required constraint after backfill
|
||||
ALTER TABLE `sale_invoice_tsp_attempts`
|
||||
MODIFY `message` TEXT NOT NULL;
|
||||
|
||||
-- 5) Remove old indexes/columns after successful data move
|
||||
DROP INDEX `sale_invoice_tsp_attempts_tax_id_idx` ON `sale_invoice_tsp_attempts`;
|
||||
DROP INDEX `sale_invoice_tsp_attempts_tax_id_key` ON `sale_invoice_tsp_attempts`;
|
||||
|
||||
ALTER TABLE `sale_invoice_tsp_attempts`
|
||||
DROP COLUMN `error_message`,
|
||||
DROP COLUMN `tax_id`;
|
||||
|
||||
-- 6) Add indexes on new tax_id location
|
||||
CREATE UNIQUE INDEX `sales_invoices_tax_id_key` ON `sales_invoices`(`tax_id`);
|
||||
CREATE INDEX `sales_invoices_tax_id_idx` ON `sales_invoices`(`tax_id`);
|
||||
+71
-57
@@ -56,6 +56,7 @@ CREATE TABLE `devices` (
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`brand_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `devices_brand_id_idx`(`brand_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -70,6 +71,7 @@ CREATE TABLE `license_charged_transactions` (
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `license_charged_transactions_tracking_code_key`(`tracking_code`),
|
||||
INDEX `license_charged_transactions_partner_id_idx`(`partner_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -81,6 +83,7 @@ CREATE TABLE `licenses` (
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`charge_transaction_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `licenses_charge_transaction_id_idx`(`charge_transaction_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -111,6 +114,7 @@ CREATE TABLE `license_renew_charge_transaction` (
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `license_renew_charge_transaction_tracking_code_key`(`tracking_code`),
|
||||
INDEX `license_renew_charge_transaction_partner_id_idx`(`partner_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -123,6 +127,8 @@ CREATE TABLE `license_renew` (
|
||||
`charge_transaction_id` VARCHAR(191) NOT NULL,
|
||||
`activation_id` VARCHAR(191) NULL,
|
||||
|
||||
INDEX `license_renew_activation_id_idx`(`activation_id`),
|
||||
INDEX `license_renew_charge_transaction_id_idx`(`charge_transaction_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -137,6 +143,7 @@ CREATE TABLE `partner_account_quota_charge_transaction` (
|
||||
`partner_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `partner_account_quota_charge_transaction_tracking_code_key`(`tracking_code`),
|
||||
INDEX `partner_account_quota_charge_transaction_partner_id_idx`(`partner_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -147,6 +154,7 @@ CREATE TABLE `partner_account_quota_credit` (
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`charge_transaction_id` VARCHAR(191) NULL,
|
||||
|
||||
INDEX `partner_account_quota_credit_charge_transaction_id_idx`(`charge_transaction_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -161,6 +169,7 @@ CREATE TABLE `license_account_allocation` (
|
||||
|
||||
UNIQUE INDEX `license_account_allocation_account_id_key`(`account_id`),
|
||||
UNIQUE INDEX `license_account_allocation_credit_id_key`(`credit_id`),
|
||||
INDEX `license_account_allocation_license_activation_id_idx`(`license_activation_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -174,6 +183,7 @@ CREATE TABLE `partner_accounts` (
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `partner_accounts_account_id_key`(`account_id`),
|
||||
INDEX `partner_accounts_partner_id_fkey`(`partner_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -183,10 +193,10 @@ CREATE TABLE `partners` (
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`code` VARCHAR(191) NOT NULL,
|
||||
`status` ENUM('ACTIVE', 'SUSPENDED') NOT NULL DEFAULT 'ACTIVE',
|
||||
`fiscal_switch_type` ENUM('NAMA', 'SUN') NOT NULL,
|
||||
`logo_url` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`tsp_provider` ENUM('NAMA', 'SUN') NOT NULL DEFAULT 'NAMA',
|
||||
|
||||
UNIQUE INDEX `partners_code_key`(`code`),
|
||||
PRIMARY KEY (`id`)
|
||||
@@ -208,6 +218,7 @@ CREATE TABLE `permission_poses` (
|
||||
`pos_id` VARCHAR(191) NOT NULL,
|
||||
`permission_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `permission_poses_pos_id_fkey`(`pos_id`),
|
||||
UNIQUE INDEX `permission_poses_permission_id_pos_id_key`(`permission_id`, `pos_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -219,6 +230,7 @@ CREATE TABLE `permission_complexes` (
|
||||
`complex_id` VARCHAR(191) NOT NULL,
|
||||
`permission_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `permission_complexes_complex_id_fkey`(`complex_id`),
|
||||
UNIQUE INDEX `permission_complexes_permission_id_complex_id_key`(`permission_id`, `complex_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -230,6 +242,7 @@ CREATE TABLE `permission_business_activities` (
|
||||
`business_id` VARCHAR(191) NOT NULL,
|
||||
`permission_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
INDEX `permission_business_activities_business_id_fkey`(`business_id`),
|
||||
UNIQUE INDEX `permission_business_activities_permission_id_business_id_key`(`permission_id`, `business_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -244,6 +257,7 @@ CREATE TABLE `provider_accounts` (
|
||||
`account_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `provider_accounts_account_id_key`(`account_id`),
|
||||
INDEX `provider_accounts_provider_id_fkey`(`provider_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -281,6 +295,7 @@ CREATE TABLE `consumer_devices` (
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `consumer_devices_uuid_key`(`uuid`),
|
||||
INDEX `consumer_devices_consumer_id_fkey`(`consumer_id`),
|
||||
PRIMARY KEY (`uuid`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -360,6 +375,7 @@ CREATE TABLE `business_activities` (
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`fiscal_id` VARCHAR(191) NOT NULL,
|
||||
`partner_token` VARCHAR(191) NOT NULL,
|
||||
`invoice_number_sequence` DECIMAL(20, 0) NOT NULL DEFAULT 1,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`guild_id` VARCHAR(191) NOT NULL,
|
||||
@@ -443,6 +459,18 @@ CREATE TABLE `good_categories` (
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `guilds` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`invoice_template` ENUM('SALE', 'FX_SALE', 'GOLD_JEWELRY', 'CONTRACT', 'UTILITY', 'AIR_TICKET', 'EXPORT', 'BILL_OF_LADING', 'PETROCHEMICAL', 'COMMODITY_EXCHANGE', 'INSURANCE') NOT NULL,
|
||||
`code` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `measure_units` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
@@ -461,9 +489,10 @@ 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 DEFAULT 'GOLD',
|
||||
`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,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
|
||||
@@ -524,17 +553,6 @@ CREATE TABLE `customer_legal` (
|
||||
PRIMARY KEY (`customer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `guilds` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`code` VARCHAR(191) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sales_invoices` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
@@ -542,15 +560,23 @@ CREATE TABLE `sales_invoices` (
|
||||
`total_amount` DECIMAL(15, 2) NOT NULL,
|
||||
`invoice_number` INTEGER NOT NULL,
|
||||
`invoice_date` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`type` ENUM('ORIGINAL', 'CORRECTION', 'REVOKE', 'RETURN') NOT NULL,
|
||||
`tax_id` VARCHAR(32) NULL,
|
||||
`notes` TEXT NULL,
|
||||
`unknown_customer` JSON NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`main_id` VARCHAR(50) NULL,
|
||||
`ref_id` VARCHAR(50) NULL,
|
||||
`customer_id` VARCHAR(191) NULL,
|
||||
`consumer_account_id` VARCHAR(191) NOT NULL,
|
||||
`pos_id` VARCHAR(191) NOT 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`),
|
||||
UNIQUE INDEX `sales_invoices_invoice_number_pos_id_key`(`invoice_number`, `pos_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -569,9 +595,9 @@ CREATE TABLE `sales_invoice_items` (
|
||||
`discount` DECIMAL(15, 2) NOT NULL DEFAULT 0.00,
|
||||
`notes` TEXT NULL,
|
||||
`payload` JSON NULL,
|
||||
`good_snapshot` JSON NULL,
|
||||
`good_snapshot` JSON NOT NULL,
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
`good_id` VARCHAR(191) NULL,
|
||||
`good_id` VARCHAR(191) NOT NULL,
|
||||
`service_id` VARCHAR(191) NULL,
|
||||
|
||||
INDEX `sales_invoice_items_invoice_id_good_id_idx`(`invoice_id`, `good_id`),
|
||||
@@ -579,37 +605,22 @@ CREATE TABLE `sales_invoice_items` (
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sale_invoice_fiscals` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`retry_count` INTEGER NOT NULL DEFAULT 0,
|
||||
`last_attempt_at` TIMESTAMP(0) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sale_invoice_fiscals_invoice_id_key`(`invoice_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sale_invoice_fiscal_attempts` (
|
||||
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,
|
||||
`tax_id` VARCHAR(191) NULL,
|
||||
`type` ENUM('MAIN', 'UPDATE', 'REVOKE', 'REMOVE') NOT NULL,
|
||||
`request_payload` JSON NULL,
|
||||
`response_payload` JSON NULL,
|
||||
`error_message` TEXT 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),
|
||||
`fiscal_id` VARCHAR(191) NOT NULL,
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sale_invoice_fiscal_attempts_tax_id_key`(`tax_id`),
|
||||
INDEX `sale_invoice_fiscal_attempts_status_idx`(`status`),
|
||||
INDEX `sale_invoice_fiscal_attempts_tax_id_idx`(`tax_id`),
|
||||
UNIQUE INDEX `sale_invoice_fiscal_attempts_fiscal_id_attempt_no_key`(`fiscal_id`, `attempt_no`),
|
||||
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`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -617,7 +628,7 @@ CREATE TABLE `sale_invoice_fiscal_attempts` (
|
||||
CREATE TABLE `sales_invoice_payments` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`amount` DECIMAL(15, 2) NOT NULL,
|
||||
`payment_method` ENUM('TERMINAL', 'CASH', 'SET_OFF', 'CARD', 'BANK', 'CHECK', 'OTHER') NOT NULL,
|
||||
`payment_method` ENUM('CHEQUE', 'SET_OFF', 'CASH', 'TERMINAL', 'PAYMENT_GATEWAY', 'CARD', 'BANK', 'OTHER') NOT NULL,
|
||||
`paid_at` TIMESTAMP(0) NOT NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`invoice_id` VARCHAR(191) NOT NULL,
|
||||
@@ -685,7 +696,7 @@ CREATE TABLE `service_categories` (
|
||||
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 `admin_accounts` ADD CONSTRAINT `admin_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`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 `devices` ADD CONSTRAINT `devices_brand_id_fkey` FOREIGN KEY (`brand_id`) REFERENCES `device_brands`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -697,19 +708,19 @@ ALTER TABLE `license_charged_transactions` ADD CONSTRAINT `license_charged_trans
|
||||
ALTER TABLE `licenses` ADD CONSTRAINT `licenses_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `license_charged_transactions`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses_activated` ADD CONSTRAINT `licenses_activated_license_id_fkey` FOREIGN KEY (`license_id`) REFERENCES `licenses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `licenses_activated` ADD CONSTRAINT `licenses_activated_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `licenses_activated` ADD CONSTRAINT `licenses_activated_business_activity_id_fkey` FOREIGN KEY (`business_activity_id`) REFERENCES `business_activities`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `licenses_activated` ADD CONSTRAINT `licenses_activated_license_id_fkey` FOREIGN KEY (`license_id`) REFERENCES `licenses`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew_charge_transaction` ADD CONSTRAINT `license_renew_charge_transaction_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `license_renew_charge_transaction`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_activation_id_fkey` FOREIGN KEY (`activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_activation_id_fkey` FOREIGN KEY (`activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
ALTER TABLE `license_renew` ADD CONSTRAINT `license_renew_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `license_renew_charge_transaction`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_charge_transaction` ADD CONSTRAINT `partner_account_quota_charge_transaction_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -717,9 +728,6 @@ ALTER TABLE `partner_account_quota_charge_transaction` ADD CONSTRAINT `partner_a
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_account_quota_credit` ADD CONSTRAINT `partner_account_quota_credit_charge_transaction_id_fkey` FOREIGN KEY (`charge_transaction_id`) REFERENCES `partner_account_quota_charge_transaction`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_license_activation_id_fkey` FOREIGN KEY (`license_activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
@@ -727,19 +735,22 @@ ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocat
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_credit_id_fkey` FOREIGN KEY (`credit_id`) REFERENCES `partner_account_quota_credit`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `license_account_allocation` ADD CONSTRAINT `license_account_allocation_license_activation_id_fkey` FOREIGN KEY (`license_activation_id`) REFERENCES `licenses_activated`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `partner_accounts` ADD CONSTRAINT `partner_accounts_partner_id_fkey` FOREIGN KEY (`partner_id`) REFERENCES `partners`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_consumers` ADD CONSTRAINT `permission_consumers_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_pos_id_fkey` FOREIGN KEY (`pos_id`) REFERENCES `poses`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `permission_poses` ADD CONSTRAINT `permission_poses_pos_id_fkey` FOREIGN KEY (`pos_id`) REFERENCES `poses`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `permission_complexes` ADD CONSTRAINT `permission_complexes_complex_id_fkey` FOREIGN KEY (`complex_id`) REFERENCES `complexes`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -754,10 +765,10 @@ ALTER TABLE `permission_business_activities` ADD CONSTRAINT `permission_business
|
||||
ALTER TABLE `permission_business_activities` ADD CONSTRAINT `permission_business_activities_permission_id_fkey` FOREIGN KEY (`permission_id`) REFERENCES `permission_consumers`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_provider_id_fkey` FOREIGN KEY (`provider_id`) REFERENCES `providers`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `provider_accounts` ADD CONSTRAINT `provider_accounts_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
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;
|
||||
@@ -819,6 +830,9 @@ ALTER TABLE `good_categories` ADD CONSTRAINT `good_categories_guild_id_fkey` FOR
|
||||
-- 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;
|
||||
|
||||
-- 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;
|
||||
|
||||
@@ -831,6 +845,9 @@ ALTER TABLE `customer_legal` ADD CONSTRAINT `customer_legal_customer_id_fkey` FO
|
||||
-- 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;
|
||||
|
||||
@@ -844,16 +861,13 @@ ALTER TABLE `sales_invoices` ADD CONSTRAINT `sales_invoices_pos_id_fkey` FOREIGN
|
||||
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_good_id_fkey` FOREIGN KEY (`good_id`) REFERENCES `goods`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
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_service_id_fkey` FOREIGN KEY (`service_id`) REFERENCES `services`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sale_invoice_fiscals` ADD CONSTRAINT `sale_invoice_fiscals_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sale_invoice_fiscal_attempts` ADD CONSTRAINT `sale_invoice_fiscal_attempts_fiscal_id_fkey` FOREIGN KEY (`fiscal_id`) REFERENCES `sale_invoice_fiscals`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
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;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sales_invoice_payments` ADD CONSTRAINT `sales_invoice_payments_invoice_id_fkey` FOREIGN KEY (`invoice_id`) REFERENCES `sales_invoices`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
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`;
|
||||
@@ -14,40 +14,14 @@ model AdminAccount {
|
||||
}
|
||||
|
||||
model Admin {
|
||||
id String @id @default(ulid())
|
||||
mobile_number String @unique()
|
||||
national_code String? @unique()
|
||||
id String @id @default(ulid())
|
||||
mobile_number String @unique
|
||||
national_code String? @unique
|
||||
first_name String
|
||||
last_name String
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
accounts AdminAccount[]
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
accounts AdminAccount[]
|
||||
|
||||
@@map("admins")
|
||||
}
|
||||
|
||||
// model LegalProfile {
|
||||
// user_id String @id
|
||||
// company_name String
|
||||
// register_no String @unique()
|
||||
// representative_name String?
|
||||
// representative_national_id String?
|
||||
|
||||
// // user User @relation(fields: [user_id], references: [id])
|
||||
|
||||
// @@map("legal_profiles")
|
||||
// }
|
||||
|
||||
// model IndividualProfile {
|
||||
// user_id String @id
|
||||
// national_code String @unique()
|
||||
// first_name String
|
||||
// last_name String
|
||||
// birth_date DateTime?
|
||||
// mobile_number String
|
||||
// // user User @relation(fields: [user_id], references: [id])
|
||||
|
||||
// @@map("individual_profiles")
|
||||
// }
|
||||
|
||||
@@ -1,56 +1,13 @@
|
||||
model Account {
|
||||
id String @id @default(ulid())
|
||||
username String @unique()
|
||||
password String
|
||||
status AccountStatus
|
||||
type AccountType
|
||||
|
||||
id String @id @default(ulid())
|
||||
username String @unique
|
||||
password String
|
||||
status AccountStatus
|
||||
type AccountType
|
||||
admin_account AdminAccount?
|
||||
provider_account ProviderAccount?
|
||||
partner_account PartnerAccount?
|
||||
consumer_account ConsumerAccount?
|
||||
|
||||
// admin_account_id String? @unique
|
||||
// admin_account AdminAccount? @relation(fields: [admin_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
// provider_account_id String? @unique
|
||||
// provider_account ProviderAccount? @relation(fields: [provider_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
// partner_account_id String? @unique
|
||||
// partner_account PartnerAccount? @relation(fields: [partner_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
// consumer_account_id String? @unique
|
||||
// consumer_account ConsumerAccount? @relation(fields: [consumer_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
// tokens Token[]
|
||||
// refresh_tokens RefreshToken[]
|
||||
partner_account PartnerAccount?
|
||||
provider_account ProviderAccount?
|
||||
|
||||
@@map("accounts")
|
||||
}
|
||||
|
||||
// model Token {
|
||||
// id String @id @d @uniqueefault(ulid())
|
||||
// token String @unique
|
||||
// type TokenType
|
||||
// created_at DateTime @default(now())
|
||||
// expires_at DateTime
|
||||
|
||||
// account_id String
|
||||
// account Account @relation(fields: [account_id], references: [id])
|
||||
|
||||
// @@unique([type, account_id])
|
||||
// @@map("tokens")
|
||||
// }
|
||||
|
||||
// model VerificationCode {
|
||||
// id String @id @default(ulid())
|
||||
// code String
|
||||
// is_used Boolean @default(false)
|
||||
// created_at DateTime @default(now())
|
||||
// expires_at DateTime
|
||||
|
||||
// account_id String
|
||||
// account Account @relation(fields: [account_id], references: [id])
|
||||
|
||||
// @@map("verification_codes")
|
||||
// }
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
model DeviceBrand {
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
devices Device[]
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
devices Device[]
|
||||
|
||||
@@map("device_brands")
|
||||
}
|
||||
|
||||
model Device {
|
||||
id String @id @default(ulid())
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
os_version String?
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
brand_id String
|
||||
brand DeviceBrand @relation(fields: [brand_id], references: [id])
|
||||
poses Pos[]
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
brand_id String
|
||||
|
||||
brand DeviceBrand @relation(fields: [brand_id], references: [id])
|
||||
poses Pos[]
|
||||
|
||||
@@index([brand_id])
|
||||
@@map("devices")
|
||||
}
|
||||
|
||||
@@ -1,133 +1,115 @@
|
||||
model LicenseChargeTransaction {
|
||||
id String @id @default(ulid())
|
||||
id String @id @default(ulid())
|
||||
activation_expires_at DateTime
|
||||
tracking_code String @unique()
|
||||
tracking_code String @unique
|
||||
purchased_count Int
|
||||
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])
|
||||
licenses License[]
|
||||
|
||||
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])
|
||||
|
||||
licenses License[]
|
||||
|
||||
@@index([partner_id])
|
||||
@@map("license_charged_transactions")
|
||||
}
|
||||
|
||||
model License {
|
||||
id String @id @default(ulid())
|
||||
accounts_limit Int @default(2)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
accounts_limit Int @default(2)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
charge_transaction_id String
|
||||
charge_transaction LicenseChargeTransaction @relation(fields: [charge_transaction_id], references: [id])
|
||||
activation LicenseActivation?
|
||||
|
||||
activation LicenseActivation?
|
||||
|
||||
@@index([charge_transaction_id])
|
||||
@@map("licenses")
|
||||
}
|
||||
|
||||
model LicenseActivation {
|
||||
id String @id @unique() @default(ulid())
|
||||
starts_at DateTime
|
||||
expires_at DateTime
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
license_id String @unique
|
||||
license License @relation(fields: [license_id], references: [id])
|
||||
|
||||
business_activity_id String @unique
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
|
||||
license_renews LicenseRenew[]
|
||||
account_allocations LicenseAccountAllocation[]
|
||||
id String @id @unique @default(ulid())
|
||||
starts_at DateTime
|
||||
expires_at DateTime
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
license_id String @unique
|
||||
business_activity_id String @unique
|
||||
account_allocations LicenseAccountAllocation[]
|
||||
license_renews LicenseRenew[]
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
license License @relation(fields: [license_id], references: [id])
|
||||
|
||||
@@map("licenses_activated")
|
||||
}
|
||||
|
||||
model LicenseRenewChargeTransaction {
|
||||
id String @id @default(ulid())
|
||||
id String @id @default(ulid())
|
||||
activation_expires_at DateTime
|
||||
tracking_code String @unique()
|
||||
tracking_code String @unique
|
||||
purchased_count Int
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
partner_id String
|
||||
license_renews LicenseRenew[]
|
||||
partner Partner @relation(fields: [partner_id], references: [id])
|
||||
|
||||
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])
|
||||
|
||||
license_renews LicenseRenew[]
|
||||
|
||||
@@index([partner_id])
|
||||
@@map("license_renew_charge_transaction")
|
||||
}
|
||||
|
||||
model LicenseRenew {
|
||||
id String @id @default(ulid())
|
||||
expires_at DateTime
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
expires_at DateTime
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
charge_transaction_id String
|
||||
activation_id String?
|
||||
activation LicenseActivation? @relation(fields: [activation_id], references: [id])
|
||||
charge_transaction LicenseRenewChargeTransaction @relation(fields: [charge_transaction_id], references: [id])
|
||||
|
||||
activation_id String?
|
||||
activation LicenseActivation? @relation(fields: [activation_id], references: [id])
|
||||
|
||||
@@index([activation_id])
|
||||
@@index([charge_transaction_id])
|
||||
@@map("license_renew")
|
||||
}
|
||||
|
||||
model PartnerAccountQuotaChargeTransaction {
|
||||
id String @id @default(ulid())
|
||||
id String @id @default(ulid())
|
||||
activation_expires_at DateTime
|
||||
tracking_code String @unique()
|
||||
tracking_code String @unique
|
||||
purchased_count Int
|
||||
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])
|
||||
credits PartnerAccountQuotaCredit[]
|
||||
|
||||
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])
|
||||
|
||||
credits PartnerAccountQuotaCredit[]
|
||||
|
||||
@@index([partner_id])
|
||||
@@map("partner_account_quota_charge_transaction")
|
||||
}
|
||||
|
||||
model PartnerAccountQuotaCredit {
|
||||
id String @id @default(ulid())
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
charge_transaction_id String?
|
||||
allocation LicenseAccountAllocation?
|
||||
charge_transaction PartnerAccountQuotaChargeTransaction? @relation(fields: [charge_transaction_id], references: [id])
|
||||
|
||||
allocation LicenseAccountAllocation?
|
||||
|
||||
@@index([charge_transaction_id])
|
||||
@@map("partner_account_quota_credit")
|
||||
}
|
||||
|
||||
model LicenseAccountAllocation {
|
||||
id String @id @default(ulid())
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
license_activation_id String?
|
||||
license_activation LicenseActivation? @relation(fields: [license_activation_id], references: [id])
|
||||
|
||||
account_id String? @unique
|
||||
account ConsumerAccount? @relation(fields: [account_id], references: [id])
|
||||
|
||||
credit_id String? @unique
|
||||
credit PartnerAccountQuotaCredit? @relation(fields: [credit_id], references: [id])
|
||||
account_id String? @unique
|
||||
credit_id String? @unique
|
||||
account ConsumerAccount? @relation(fields: [account_id], references: [id])
|
||||
credit PartnerAccountQuotaCredit? @relation(fields: [credit_id], references: [id])
|
||||
license_activation LicenseActivation? @relation(fields: [license_activation_id], references: [id])
|
||||
|
||||
@@index([license_activation_id])
|
||||
@@map("license_account_allocation")
|
||||
}
|
||||
|
||||
@@ -1,36 +1,32 @@
|
||||
model PartnerAccount {
|
||||
id String @id @default(ulid())
|
||||
role PartnerRole
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @updatedAt @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
role PartnerRole
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @updatedAt @db.Timestamp(0)
|
||||
partner_id String
|
||||
partner Partner @relation(fields: [partner_id], references: [id])
|
||||
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
partner Partner @relation(fields: [partner_id], references: [id])
|
||||
|
||||
@@index([partner_id], map: "partner_accounts_partner_id_fkey")
|
||||
@@map("partner_accounts")
|
||||
}
|
||||
|
||||
model Partner {
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
code String @unique()
|
||||
status PartnerStatus @default(ACTIVE)
|
||||
tsp_provider TspProviderType @default(NAMA)
|
||||
logo_url String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @updatedAt @db.Timestamp(0)
|
||||
|
||||
accounts PartnerAccount[]
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
code String @unique
|
||||
status PartnerStatus @default(ACTIVE)
|
||||
logo_url String?
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @updatedAt @db.Timestamp(0)
|
||||
tsp_provider TspProviderType @default(NAMA)
|
||||
consumers_individual ConsumerIndividual[]
|
||||
consumers_legal ConsumerLegal[]
|
||||
license_charge_transactions LicenseChargeTransaction[]
|
||||
account_quota_charge_transactions PartnerAccountQuotaChargeTransaction[]
|
||||
license_renew_charge_transactions LicenseRenewChargeTransaction[]
|
||||
account_quota_charge_transactions PartnerAccountQuotaChargeTransaction[]
|
||||
accounts PartnerAccount[]
|
||||
|
||||
@@map("partners")
|
||||
}
|
||||
|
||||
@@ -1,54 +1,49 @@
|
||||
model PermissionConsumer {
|
||||
id String @id @default(ulid())
|
||||
|
||||
consumer_account_id String @unique
|
||||
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id], onDelete: Cascade)
|
||||
|
||||
pos_permissions PermissionPos[]
|
||||
complex_permissions PermissionComplex[]
|
||||
id String @id @default(ulid())
|
||||
consumer_account_id String @unique
|
||||
business_permissions PermissionBusiness[]
|
||||
complex_permissions PermissionComplex[]
|
||||
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id], onDelete: Cascade)
|
||||
pos_permissions PermissionPos[]
|
||||
|
||||
@@map("permission_consumers")
|
||||
}
|
||||
|
||||
model PermissionPos {
|
||||
id String @id @default(ulid())
|
||||
role POSRole
|
||||
|
||||
id String @id @default(ulid())
|
||||
role POSRole
|
||||
pos_id String
|
||||
permission_id String
|
||||
|
||||
pos Pos @relation(fields: [pos_id], references: [id], onDelete: Cascade)
|
||||
permission PermissionConsumer @relation(fields: [permission_id], references: [id], onDelete: Cascade)
|
||||
permission PermissionConsumer @relation(fields: [permission_id], references: [id], onDelete: Cascade)
|
||||
pos Pos @relation(fields: [pos_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([permission_id, pos_id])
|
||||
@@index([pos_id], map: "permission_poses_pos_id_fkey")
|
||||
@@map("permission_poses")
|
||||
}
|
||||
|
||||
model PermissionComplex {
|
||||
id String @id @default(ulid())
|
||||
role ComplexRole
|
||||
|
||||
id String @id @default(ulid())
|
||||
role ComplexRole
|
||||
complex_id String
|
||||
permission_id String
|
||||
|
||||
complex Complex @relation(fields: [complex_id], references: [id], onDelete: Cascade)
|
||||
permission PermissionConsumer @relation(fields: [permission_id], references: [id], onDelete: Cascade)
|
||||
complex Complex @relation(fields: [complex_id], references: [id], onDelete: Cascade)
|
||||
permission PermissionConsumer @relation(fields: [permission_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([permission_id, complex_id])
|
||||
@@index([complex_id], map: "permission_complexes_complex_id_fkey")
|
||||
@@map("permission_complexes")
|
||||
}
|
||||
|
||||
model PermissionBusiness {
|
||||
id String @id @default(ulid())
|
||||
role BusinessRole
|
||||
|
||||
id String @id @default(ulid())
|
||||
role BusinessRole
|
||||
business_id String
|
||||
permission_id String
|
||||
|
||||
business BusinessActivity @relation(fields: [business_id], references: [id], onDelete: Cascade)
|
||||
permission PermissionConsumer @relation(fields: [permission_id], references: [id], onDelete: Cascade)
|
||||
business BusinessActivity @relation(fields: [business_id], references: [id], onDelete: Cascade)
|
||||
permission PermissionConsumer @relation(fields: [permission_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([permission_id, business_id])
|
||||
@@index([business_id], map: "permission_business_activities_business_id_fkey")
|
||||
@@map("permission_business_activities")
|
||||
}
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
model ProviderAccount {
|
||||
id String @id @default(ulid())
|
||||
role ProviderRole
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
id String @id @default(ulid())
|
||||
role ProviderRole
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
provider_id String
|
||||
provider Provider @relation(fields: [provider_id], references: [id])
|
||||
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
account_id String @unique
|
||||
account Account @relation(fields: [account_id], references: [id], onDelete: Cascade)
|
||||
provider Provider @relation(fields: [provider_id], references: [id])
|
||||
|
||||
@@index([provider_id], map: "provider_accounts_provider_id_fkey")
|
||||
@@map("provider_accounts")
|
||||
}
|
||||
|
||||
model Provider {
|
||||
id String @id @default(ulid())
|
||||
code String @unique()
|
||||
status PartnerStatus @default(ACTIVE)
|
||||
name String
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
|
||||
accounts ProviderAccount[]
|
||||
pos_list Pos[]
|
||||
id String @id @default(ulid())
|
||||
code String @unique
|
||||
status PartnerStatus @default(ACTIVE)
|
||||
name String
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
pos_list Pos[]
|
||||
accounts ProviderAccount[]
|
||||
|
||||
@@map("providers")
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
model ConsumerDevices {
|
||||
uuid String @id @unique() @db.VarChar(255)
|
||||
uuid String @id @unique @db.VarChar(255)
|
||||
app_version String @db.VarChar(20)
|
||||
build_number String @db.VarChar(20)
|
||||
platform String @db.VarChar(100)
|
||||
@@ -13,12 +13,11 @@ model ConsumerDevices {
|
||||
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])
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@ model ApplicationReleasedInfo {
|
||||
release_type ApplicationReleaseType
|
||||
platform ApplicationPlatform
|
||||
notes Json?
|
||||
|
||||
release_date DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
release_date DateTime @default(now()) @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
|
||||
@@map("application_released_info")
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ model Guild {
|
||||
|
||||
business_activities BusinessActivity[]
|
||||
good_categories GoodCategory[]
|
||||
stockKeepingUnits StockKeepingUnits[]
|
||||
|
||||
@@map("guilds")
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
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)
|
||||
type SKUGuildType
|
||||
is_public Boolean @default(true)
|
||||
is_domestic Boolean @default(false)
|
||||
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)
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
// generator client {
|
||||
// provider = "prisma-client-js"
|
||||
// // output = "../../src/generated/prisma"
|
||||
// // moduleFormat = "cjs"
|
||||
// previewFeatures = ["views"]
|
||||
// }
|
||||
|
||||
// datasource db {
|
||||
// provider = "mysql"
|
||||
// }
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client"
|
||||
output = "../../src/generated/prisma"
|
||||
moduleFormat = "cjs"
|
||||
previewFeatures = ["views"]
|
||||
moduleFormat = "cjs"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
|
||||
+176
-176
@@ -1,6 +1,5 @@
|
||||
import { PasswordUtil } from '@/common/utils/password.util'
|
||||
import { generateTrackingCode } from '@/common/utils/tracking-code-generator.util'
|
||||
import { ConsumerType, GoodPricingModel, TspProviderType } from '@/generated/prisma/enums'
|
||||
import { GoodPricingModel } from '@/generated/prisma/enums'
|
||||
import { GoodCreateManyInput } from '@/generated/prisma/models'
|
||||
import { prisma } from '../src/lib/prisma'
|
||||
|
||||
@@ -123,6 +122,12 @@ async function main() {
|
||||
skipDuplicates: true,
|
||||
})
|
||||
|
||||
const geramMeasureUnit = await tx.measureUnits.findFirst({
|
||||
where: {
|
||||
code: '63',
|
||||
},
|
||||
})
|
||||
|
||||
// ****************** GUILD Start ****************** //
|
||||
let guilds = await tx.guild.findMany()
|
||||
if (!guilds.length) {
|
||||
@@ -133,11 +138,6 @@ async function main() {
|
||||
code: 'Gold',
|
||||
invoice_template: 'GOLD_JEWELRY',
|
||||
},
|
||||
{
|
||||
name: 'میوه و ترهبار',
|
||||
code: 'Fruit',
|
||||
invoice_template: 'SALE',
|
||||
},
|
||||
],
|
||||
})
|
||||
guilds = await tx.guild.findMany()
|
||||
@@ -234,49 +234,49 @@ async function main() {
|
||||
zivarCategory.id,
|
||||
GoodPricingModel.GOLD,
|
||||
'2720000044696',
|
||||
'63',
|
||||
geramMeasureUnit!.id,
|
||||
),
|
||||
await goodFactory(
|
||||
'النگو',
|
||||
zivarCategory.id,
|
||||
GoodPricingModel.GOLD,
|
||||
'2720000044665',
|
||||
'63',
|
||||
geramMeasureUnit!.id,
|
||||
),
|
||||
await goodFactory(
|
||||
'انگشتر',
|
||||
zivarCategory.id,
|
||||
GoodPricingModel.GOLD,
|
||||
'2720000044672',
|
||||
'63',
|
||||
geramMeasureUnit!.id,
|
||||
),
|
||||
await goodFactory(
|
||||
'دستبند',
|
||||
zivarCategory.id,
|
||||
GoodPricingModel.GOLD,
|
||||
'2720000044689',
|
||||
'63',
|
||||
geramMeasureUnit!.id,
|
||||
),
|
||||
await goodFactory(
|
||||
'زنجیر',
|
||||
zivarCategory.id,
|
||||
GoodPricingModel.GOLD,
|
||||
'2720000044702',
|
||||
'63',
|
||||
geramMeasureUnit!.id,
|
||||
),
|
||||
await goodFactory(
|
||||
'سرویس',
|
||||
zivarCategory.id,
|
||||
GoodPricingModel.GOLD,
|
||||
'2720000044733',
|
||||
'63',
|
||||
geramMeasureUnit!.id,
|
||||
),
|
||||
await goodFactory(
|
||||
'گوشواره',
|
||||
zivarCategory.id,
|
||||
GoodPricingModel.GOLD,
|
||||
'2720000044726',
|
||||
'63',
|
||||
geramMeasureUnit!.id,
|
||||
),
|
||||
].filter((item): item is GoodCreateManyInput => item !== null)
|
||||
goodItems.push(...preparedGoodItems)
|
||||
@@ -395,178 +395,178 @@ async function main() {
|
||||
}
|
||||
|
||||
// ****************** partner Start ****************** //
|
||||
let partner = await tx.partner.findFirst()
|
||||
let license = await tx.license.findFirst()
|
||||
if (!partner) {
|
||||
partner = await tx.partner.create({
|
||||
data: {
|
||||
name: 'تیس',
|
||||
code: 'TIS',
|
||||
status: 'ACTIVE',
|
||||
tsp_provider: TspProviderType.NAMA,
|
||||
accounts: {
|
||||
create: {
|
||||
role: 'OWNER',
|
||||
account: {
|
||||
create: {
|
||||
username: 'tis',
|
||||
password: await PasswordUtil.hash('123456'),
|
||||
status: 'ACTIVE',
|
||||
type: 'PARTNER',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
if (partner && !license) {
|
||||
await tx.$transaction(async tx => {
|
||||
const startOfToday = new Date()
|
||||
startOfToday.setHours(0, 0, 0, 0)
|
||||
// let partner = await tx.partner.findFirst()
|
||||
// let license = await tx.license.findFirst()
|
||||
// if (!partner) {
|
||||
// partner = await tx.partner.create({
|
||||
// data: {
|
||||
// name: 'تیس',
|
||||
// code: 'TIS',
|
||||
// status: 'ACTIVE',
|
||||
// tsp_provider: TspProviderType.NAMA,
|
||||
// accounts: {
|
||||
// create: {
|
||||
// role: 'OWNER',
|
||||
// account: {
|
||||
// create: {
|
||||
// username: 'tis',
|
||||
// password: await PasswordUtil.hash('123456'),
|
||||
// status: 'ACTIVE',
|
||||
// type: 'PARTNER',
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// }
|
||||
// if (partner && !license) {
|
||||
// await tx.$transaction(async tx => {
|
||||
// const startOfToday = new Date()
|
||||
// startOfToday.setHours(0, 0, 0, 0)
|
||||
|
||||
const month = startOfToday.getMonth()
|
||||
let year = startOfToday.getFullYear()
|
||||
let expMonth = month + 3
|
||||
if (expMonth > 11) {
|
||||
expMonth = expMonth - 11
|
||||
year = year + 1
|
||||
}
|
||||
// const month = startOfToday.getMonth()
|
||||
// let year = startOfToday.getFullYear()
|
||||
// let expMonth = month + 3
|
||||
// if (expMonth > 11) {
|
||||
// expMonth = expMonth - 11
|
||||
// year = year + 1
|
||||
// }
|
||||
|
||||
startOfToday.setFullYear(year)
|
||||
startOfToday.setMonth(expMonth)
|
||||
// startOfToday.setFullYear(year)
|
||||
// startOfToday.setMonth(expMonth)
|
||||
|
||||
const transaction = await tx.licenseChargeTransaction.create({
|
||||
data: {
|
||||
activation_expires_at: startOfToday,
|
||||
purchased_count: 1,
|
||||
tracking_code: generateTrackingCode('LIC', 6),
|
||||
partner: {
|
||||
connect: {
|
||||
id: partner.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
})
|
||||
if (transaction)
|
||||
license = await tx.license.create({
|
||||
data: {
|
||||
charge_transaction: {
|
||||
connect: {
|
||||
id: transaction.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
// const transaction = await tx.licenseChargeTransaction.create({
|
||||
// data: {
|
||||
// activation_expires_at: startOfToday,
|
||||
// purchased_count: 1,
|
||||
// tracking_code: generateTrackingCode('LIC', 6),
|
||||
// partner: {
|
||||
// connect: {
|
||||
// id: partner.id,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// select: {
|
||||
// id: true,
|
||||
// },
|
||||
// })
|
||||
// if (transaction)
|
||||
// license = await tx.license.create({
|
||||
// data: {
|
||||
// charge_transaction: {
|
||||
// connect: {
|
||||
// id: transaction.id,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
|
||||
// ****************** BA Start ****************** //
|
||||
const ba = await tx.businessActivity.count()
|
||||
// // ****************** BA Start ****************** //
|
||||
// const ba = await tx.businessActivity.count()
|
||||
|
||||
if (!ba && license) {
|
||||
const startOfToday = new Date()
|
||||
startOfToday.setHours(0, 0, 0, 0)
|
||||
// if (!ba && license) {
|
||||
// const startOfToday = new Date()
|
||||
// startOfToday.setHours(0, 0, 0, 0)
|
||||
|
||||
let year = startOfToday.getFullYear()
|
||||
let expYear = year + 1
|
||||
// if (expMonth > 11) {
|
||||
// expMonth = expMonth - 11
|
||||
// year = year + 1
|
||||
// }
|
||||
// let year = startOfToday.getFullYear()
|
||||
// let expYear = year + 1
|
||||
// // if (expMonth > 11) {
|
||||
// // expMonth = expMonth - 11
|
||||
// // year = year + 1
|
||||
// // }
|
||||
|
||||
startOfToday.setFullYear(expYear)
|
||||
// startOfToday.setFullYear(expYear)
|
||||
|
||||
await tx.businessActivity.create({
|
||||
data: {
|
||||
name: 'طلا فروشی',
|
||||
economic_code: '0111111111',
|
||||
fiscal_id: '0111111111',
|
||||
partner_token: 'TIS-BA-001',
|
||||
license_activation: {
|
||||
create: {
|
||||
expires_at: startOfToday,
|
||||
starts_at: new Date(),
|
||||
license: {
|
||||
connect: {
|
||||
id: license.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
consumer: {
|
||||
create: {
|
||||
type: ConsumerType.INDIVIDUAL,
|
||||
individual: {
|
||||
create: {
|
||||
first_name: 'محمد',
|
||||
last_name: 'زرگر',
|
||||
mobile_number: '09120258155',
|
||||
national_code: '1234567890',
|
||||
partner: {
|
||||
connect: {
|
||||
id: partner.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
accounts: {
|
||||
create: {
|
||||
role: 'OWNER',
|
||||
account: {
|
||||
create: {
|
||||
username: 'zargar',
|
||||
password: await PasswordUtil.hash('123456'),
|
||||
status: 'ACTIVE',
|
||||
type: 'CONSUMER',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
guild: {
|
||||
connect: {
|
||||
id: guilds[0].id,
|
||||
},
|
||||
},
|
||||
complexes: {
|
||||
create: {
|
||||
name: 'فروشگاه طلای مرکزی',
|
||||
address: 'تهران، خیابان جمهوری',
|
||||
branch_code: '12332',
|
||||
// await tx.businessActivity.create({
|
||||
// data: {
|
||||
// name: 'طلا فروشی',
|
||||
// economic_code: '0111111111',
|
||||
// fiscal_id: '0111111111',
|
||||
// partner_token: 'TIS-BA-001',
|
||||
// license_activation: {
|
||||
// create: {
|
||||
// expires_at: startOfToday,
|
||||
// starts_at: new Date(),
|
||||
// license: {
|
||||
// connect: {
|
||||
// id: license.id,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// consumer: {
|
||||
// create: {
|
||||
// type: ConsumerType.INDIVIDUAL,
|
||||
// individual: {
|
||||
// create: {
|
||||
// first_name: 'محمد',
|
||||
// last_name: 'زرگر',
|
||||
// mobile_number: '09120258155',
|
||||
// national_code: '1234567890',
|
||||
// partner: {
|
||||
// connect: {
|
||||
// id: partner.id,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// accounts: {
|
||||
// create: {
|
||||
// role: 'OWNER',
|
||||
// account: {
|
||||
// create: {
|
||||
// username: 'zargar',
|
||||
// password: await PasswordUtil.hash('123456'),
|
||||
// status: 'ACTIVE',
|
||||
// type: 'CONSUMER',
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// guild: {
|
||||
// connect: {
|
||||
// id: guilds[0].id,
|
||||
// },
|
||||
// },
|
||||
// complexes: {
|
||||
// create: {
|
||||
// name: 'فروشگاه طلای مرکزی',
|
||||
// address: 'تهران، خیابان جمهوری',
|
||||
// branch_code: '12332',
|
||||
|
||||
// pos_list: {
|
||||
// create: {
|
||||
// name: 'لاین ۱',
|
||||
// pos_type: POSType.WEB,
|
||||
// status: 'ACTIVE',
|
||||
// account: {
|
||||
// create: {
|
||||
// role: 'OPERATOR',
|
||||
// account_allocation: {
|
||||
// // pos_list: {
|
||||
// // create: {
|
||||
// // name: 'لاین ۱',
|
||||
// // pos_type: POSType.WEB,
|
||||
// // status: 'ACTIVE',
|
||||
// // account: {
|
||||
// // create: {
|
||||
// // role: 'OPERATOR',
|
||||
// // account_allocation: {
|
||||
|
||||
// },
|
||||
// account: {
|
||||
// create: {
|
||||
// username: 'line1',
|
||||
// password: await PasswordUtil.hash('123456'),
|
||||
// status: 'ACTIVE',
|
||||
// type: 'CONSUMER',
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
// // },
|
||||
// // account: {
|
||||
// // create: {
|
||||
// // username: 'line1',
|
||||
// // password: await PasswordUtil.hash('123456'),
|
||||
// // status: 'ACTIVE',
|
||||
// // type: 'CONSUMER',
|
||||
// // },
|
||||
// // },
|
||||
// // }
|
||||
// // }
|
||||
// // },
|
||||
// // },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// }
|
||||
// ****************** BA Start ****************** //
|
||||
|
||||
// ****************** provider Start ****************** //
|
||||
|
||||
Reference in New Issue
Block a user