feat: implement SalesInvoiceTspSwitchService and SalesInvoiceTspService for handling TSP provider interactions
- Add SalesInvoiceTspSwitchService to manage TSP provider selection and sending invoices. - Introduce SalesInvoiceTspService for creating, sending, and retrieving sales invoices. - Implement NamaProviderSwitchAdapter for communication with the NAMA TSP provider API. - Define DTOs for request and response structures specific to the NAMA provider. - Enhance error handling and logging for TSP provider interactions.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- 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;
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
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;
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
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;
|
||||
Reference in New Issue
Block a user