feat: add DTOs and services for tax switch integration

- Created SendBulkSaleInvoicesDto for handling bulk sale invoice requests.
- Implemented TaxSwitchSendPayloadDto and related DTOs for tax switch item payloads and results.
- Developed SalesInvoiceTaxSwitchService to manage tax switch operations, including sending and retrieving tax information.
- Added SalesInvoiceTaxService for handling sales invoice tax logic, including bulk sending and persistence of results.
- Introduced NamaTaxSwitchAdapter to interact with the tax switch service, simulating external API responses.
- Created SendBulkSalesInvoicesDto for POS module to handle bulk sales invoice requests.
This commit is contained in:
2026-04-27 22:11:05 +03:30
parent dee96b6e91
commit 58a7c359d8
68 changed files with 7896 additions and 3534 deletions
@@ -0,0 +1,80 @@
/*
Warnings:
- You are about to drop the column `account_id` on the `sales_invoices` table. All the data in the column will be lost.
- A unique constraint covering the columns `[invoice_number,pos_id]` on the table `sales_invoices` will be added. If there are existing duplicate values, this will fail.
- Added the required column `fiscal_id` to the `business_activities` table without a default value. This is not possible if the table is not empty.
- Added the required column `partner_token` to the `business_activities` table without a default value. This is not possible if the table is not empty.
- Added the required column `consumer_account_id` to the `sales_invoices` table without a default value. This is not possible if the table is not empty.
- Added the required column `invoice_number` to the `sales_invoices` table without a default value. This is not possible if the table is not empty.
- Made the column `invoice_date` on table `sales_invoices` required. This step will fail if there are existing NULL values in that column.
*/
-- DropForeignKey
ALTER TABLE `sales_invoices` DROP FOREIGN KEY `sales_invoices_account_id_fkey`;
-- DropIndex
DROP INDEX `sales_invoices_account_id_fkey` ON `sales_invoices`;
-- AlterTable
ALTER TABLE `business_activities` ADD COLUMN `fiscal_id` VARCHAR(191) NOT NULL DEFAULT '',
ADD COLUMN `partner_token` VARCHAR(191) NOT NULL DEFAULT '';
-- AlterTable
ALTER TABLE `sales_invoice_items` ADD COLUMN `good_snapshot` JSON NULL;
-- AlterTable
ALTER TABLE `sales_invoice_payments` MODIFY `paid_at` TIMESTAMP(0) NOT NULL,
MODIFY `created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0);
-- AlterTable
ALTER TABLE `sales_invoices` DROP COLUMN `account_id`,
ADD COLUMN `consumer_account_id` VARCHAR(191) NOT NULL,
ADD COLUMN `invoice_number` INTEGER NOT NULL,
MODIFY `invoice_date` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0);
-- 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` (
`id` VARCHAR(191) NOT NULL,
`attempt_no` INTEGER NOT NULL,
`status` VARCHAR(50) NOT NULL,
`tax_id` VARCHAR(191) 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),
`fiscal_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`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateIndex
CREATE UNIQUE INDEX `sales_invoices_invoice_number_pos_id_key` ON `sales_invoices`(`invoice_number`, `pos_id`);
-- 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 `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;
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE `business_activities` ALTER COLUMN `fiscal_id` DROP DEFAULT,
ALTER COLUMN `partner_token` DROP DEFAULT;