feat(SPG-330) REST API CUD Tax Data
parent
73547451d4
commit
d7937217ab
|
@ -30,6 +30,8 @@ import { ItemModule } from './modules/item-related/item/item.module';
|
||||||
import { ItemModel } from './modules/item-related/item/data/models/item.model';
|
import { ItemModel } from './modules/item-related/item/data/models/item.model';
|
||||||
import { SeasonTypeModule } from './modules/season-related/season-type/season-type.module';
|
import { SeasonTypeModule } from './modules/season-related/season-type/season-type.module';
|
||||||
import { SeasonTypeModel } from './modules/season-related/season-type/data/models/season-type.model';
|
import { SeasonTypeModel } from './modules/season-related/season-type/data/models/season-type.model';
|
||||||
|
import { TaxModule } from './modules/transaction/tax/tax.module';
|
||||||
|
import { TaxModel } from './modules/transaction/tax/data/models/tax.model';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -52,6 +54,7 @@ import { SeasonTypeModel } from './modules/season-related/season-type/data/model
|
||||||
ItemCategoryModel,
|
ItemCategoryModel,
|
||||||
LogModel,
|
LogModel,
|
||||||
SeasonTypeModel,
|
SeasonTypeModel,
|
||||||
|
TaxModel,
|
||||||
UserModel,
|
UserModel,
|
||||||
VipCategoryModel,
|
VipCategoryModel,
|
||||||
VipCodeModel,
|
VipCodeModel,
|
||||||
|
@ -75,6 +78,7 @@ import { SeasonTypeModel } from './modules/season-related/season-type/data/model
|
||||||
ItemModule,
|
ItemModule,
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
|
TaxModule,
|
||||||
VipCategoryModule,
|
VipCategoryModule,
|
||||||
VipCodeModule,
|
VipCodeModule,
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ export enum MODULE_NAME {
|
||||||
ITEM = 'items',
|
ITEM = 'items',
|
||||||
ITEM_CATEGORY = 'item-categories',
|
ITEM_CATEGORY = 'item-categories',
|
||||||
SEASON_TYPE = 'season-types',
|
SEASON_TYPE = 'season-types',
|
||||||
|
TAX = 'taxes',
|
||||||
TENANT = 'tenants',
|
TENANT = 'tenants',
|
||||||
USER = 'users',
|
USER = 'users',
|
||||||
USER_PRIVILEGE = 'user-privileges',
|
USER_PRIVILEGE = 'user-privileges',
|
||||||
|
|
|
@ -4,6 +4,7 @@ export enum TABLE_NAME {
|
||||||
ITEM_CATEGORY = 'item_categories',
|
ITEM_CATEGORY = 'item_categories',
|
||||||
LOG = 'logs',
|
LOG = 'logs',
|
||||||
SEASON_TYPE = 'season_types',
|
SEASON_TYPE = 'season_types',
|
||||||
|
TAX = 'taxes',
|
||||||
TENANT = 'tenants',
|
TENANT = 'tenants',
|
||||||
USER = 'users',
|
USER = 'users',
|
||||||
USER_PRIVILEGE = 'user_privileges',
|
USER_PRIVILEGE = 'user_privileges',
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class Tax1718161138278 implements MigrationInterface {
|
||||||
|
name = 'Tax1718161138278';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TYPE "public"."taxes_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE "taxes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "status" "public"."taxes_status_enum" NOT NULL DEFAULT 'draft', "name" character varying NOT NULL, "value" integer NOT NULL DEFAULT '0', CONSTRAINT "PK_6c58c9cbb420c4f65e3f5eb8162" PRIMARY KEY ("id"))`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP TABLE "taxes"`);
|
||||||
|
await queryRunner.query(`DROP TYPE "public"."taxes_status_enum"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
|
import { TaxEntity } from '../../domain/entities/tax.entity';
|
||||||
|
import { Column, Entity } from 'typeorm';
|
||||||
|
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||||
|
|
||||||
|
@Entity(TABLE_NAME.TAX)
|
||||||
|
export class TaxModel extends BaseStatusModel<TaxEntity> implements TaxEntity {
|
||||||
|
@Column('varchar', { name: 'name' })
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column('int', { name: 'value', default: 0 })
|
||||||
|
value: number;
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||||
|
import { TaxEntity } from '../../domain/entities/tax.entity';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { TaxModel } from '../models/tax.model';
|
||||||
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TaxDataService extends BaseDataService<TaxEntity> {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(TaxModel, CONNECTION_NAME.DEFAULT)
|
||||||
|
private repo: Repository<TaxModel>,
|
||||||
|
) {
|
||||||
|
super(repo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||||
|
|
||||||
|
export class TaxChangeStatusEvent {
|
||||||
|
constructor(public readonly data: IEvent) {}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||||
|
|
||||||
|
export class TaxCreatedEvent {
|
||||||
|
constructor(public readonly data: IEvent) {}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||||
|
|
||||||
|
export class TaxDeletedEvent {
|
||||||
|
constructor(public readonly data: IEvent) {}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||||
|
|
||||||
|
export class TaxUpdatedEvent {
|
||||||
|
constructor(public readonly data: IEvent) {}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||||
|
|
||||||
|
export interface TaxEntity extends BaseStatusEntity {
|
||||||
|
name: string;
|
||||||
|
value: number;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxChangeStatusEvent } from '../../entities/event/tax-change-status.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ActiveTaxManager extends BaseUpdateStatusManager<TaxEntity> {
|
||||||
|
getResult(): string {
|
||||||
|
return `Success active data ${this.result.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxChangeStatusEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxChangeStatusEvent } from '../../entities/event/tax-change-status.event';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class BatchActiveTaxManager extends BaseBatchUpdateStatusManager<TaxEntity> {
|
||||||
|
validateData(data: TaxEntity): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxChangeStatusEvent,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult(): BatchResult {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxChangeStatusEvent } from '../../entities/event/tax-change-status.event';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class BatchConfirmTaxManager extends BaseBatchUpdateStatusManager<TaxEntity> {
|
||||||
|
validateData(data: TaxEntity): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxChangeStatusEvent,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult(): BatchResult {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxDeletedEvent } from '../../entities/event/tax-deleted.event';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class BatchDeleteTaxManager extends BaseBatchDeleteManager<TaxEntity> {
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateData(data: TaxEntity): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxDeletedEvent,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult(): BatchResult {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxChangeStatusEvent } from '../../entities/event/tax-change-status.event';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class BatchInactiveTaxManager extends BaseBatchUpdateStatusManager<TaxEntity> {
|
||||||
|
validateData(data: TaxEntity): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxChangeStatusEvent,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getResult(): BatchResult {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxChangeStatusEvent } from '../../entities/event/tax-change-status.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ConfirmTaxManager extends BaseUpdateStatusManager<TaxEntity> {
|
||||||
|
getResult(): string {
|
||||||
|
return `Success active data ${this.result.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxChangeStatusEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
columnUniques,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||||
|
import { TaxCreatedEvent } from '../../entities/event/tax-created.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CreateTaxManager extends BaseCreateManager<TaxEntity> {
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get uniqueColumns(): columnUniques[] {
|
||||||
|
return [{ column: 'name' }];
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxCreatedEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxDeletedEvent } from '../../entities/event/tax-deleted.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class DeleteTaxManager extends BaseDeleteManager<TaxEntity> {
|
||||||
|
getResult(): string {
|
||||||
|
return `Success`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxDeletedEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxChangeStatusEvent } from '../../entities/event/tax-change-status.event';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class InactiveTaxManager extends BaseUpdateStatusManager<TaxEntity> {
|
||||||
|
getResult(): string {
|
||||||
|
return `Success inactive data ${this.result.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxChangeStatusEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
||||||
|
import { TaxEntity } from '../../entities/tax.entity';
|
||||||
|
import { TaxModel } from '../../../data/models/tax.model';
|
||||||
|
import { TaxUpdatedEvent } from '../../entities/event/tax-updated.event';
|
||||||
|
import {
|
||||||
|
EventTopics,
|
||||||
|
columnUniques,
|
||||||
|
validateRelations,
|
||||||
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UpdateTaxManager extends BaseUpdateManager<TaxEntity> {
|
||||||
|
async validateProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get validateRelations(): validateRelations[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
get uniqueColumns(): columnUniques[] {
|
||||||
|
return [{ column: 'name' }];
|
||||||
|
}
|
||||||
|
|
||||||
|
get entityTarget(): any {
|
||||||
|
return TaxModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
get eventTopics(): EventTopics[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
topic: TaxUpdatedEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { CreateTaxManager } from './managers/create-tax.manager';
|
||||||
|
import { TaxDataService } from '../../data/services/tax-data.service';
|
||||||
|
import { TaxEntity } from '../entities/tax.entity';
|
||||||
|
import { DeleteTaxManager } from './managers/delete-tax.manager';
|
||||||
|
import { UpdateTaxManager } from './managers/update-tax.manager';
|
||||||
|
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
||||||
|
import { ActiveTaxManager } from './managers/active-tax.manager';
|
||||||
|
import { InactiveTaxManager } from './managers/inactive-tax.manager';
|
||||||
|
import { ConfirmTaxManager } from './managers/confirm-tax.manager';
|
||||||
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
import { BatchConfirmTaxManager } from './managers/batch-confirm-tax.manager';
|
||||||
|
import { BatchInactiveTaxManager } from './managers/batch-inactive-tax.manager';
|
||||||
|
import { BatchActiveTaxManager } from './managers/batch-active-tax.manager';
|
||||||
|
import { BatchDeleteTaxManager } from './managers/batch-delete-tax.manager';
|
||||||
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TaxDataOrchestrator extends BaseDataTransactionOrchestrator<TaxEntity> {
|
||||||
|
constructor(
|
||||||
|
private createManager: CreateTaxManager,
|
||||||
|
private updateManager: UpdateTaxManager,
|
||||||
|
private deleteManager: DeleteTaxManager,
|
||||||
|
private activeManager: ActiveTaxManager,
|
||||||
|
private confirmManager: ConfirmTaxManager,
|
||||||
|
private inactiveManager: InactiveTaxManager,
|
||||||
|
private batchDeleteManager: BatchDeleteTaxManager,
|
||||||
|
private batchActiveManager: BatchActiveTaxManager,
|
||||||
|
private batchConfirmManager: BatchConfirmTaxManager,
|
||||||
|
private batchInactiveManager: BatchInactiveTaxManager,
|
||||||
|
private serviceData: TaxDataService,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data): Promise<TaxEntity> {
|
||||||
|
this.createManager.setData(data);
|
||||||
|
this.createManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.createManager.execute();
|
||||||
|
return this.createManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(dataId, data): Promise<TaxEntity> {
|
||||||
|
this.updateManager.setData(dataId, data);
|
||||||
|
this.updateManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.updateManager.execute();
|
||||||
|
return this.updateManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(dataId): Promise<String> {
|
||||||
|
this.deleteManager.setData(dataId);
|
||||||
|
this.deleteManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.deleteManager.execute();
|
||||||
|
return this.deleteManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchDelete(dataIds: string[]): Promise<BatchResult> {
|
||||||
|
this.batchDeleteManager.setData(dataIds);
|
||||||
|
this.batchDeleteManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.batchDeleteManager.execute();
|
||||||
|
return this.batchDeleteManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async active(dataId): Promise<String> {
|
||||||
|
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||||
|
this.activeManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.activeManager.execute();
|
||||||
|
return this.activeManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchActive(dataIds: string[]): Promise<BatchResult> {
|
||||||
|
this.batchActiveManager.setData(dataIds, STATUS.ACTIVE);
|
||||||
|
this.batchActiveManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.batchActiveManager.execute();
|
||||||
|
return this.batchActiveManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async confirm(dataId): Promise<String> {
|
||||||
|
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||||
|
this.confirmManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.confirmManager.execute();
|
||||||
|
return this.confirmManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchConfirm(dataIds: string[]): Promise<BatchResult> {
|
||||||
|
this.batchConfirmManager.setData(dataIds, STATUS.ACTIVE);
|
||||||
|
this.batchConfirmManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.batchConfirmManager.execute();
|
||||||
|
return this.batchConfirmManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async inactive(dataId): Promise<String> {
|
||||||
|
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||||
|
this.inactiveManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.inactiveManager.execute();
|
||||||
|
return this.inactiveManager.getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
async batchInactive(dataIds: string[]): Promise<BatchResult> {
|
||||||
|
this.batchInactiveManager.setData(dataIds, STATUS.INACTIVE);
|
||||||
|
this.batchInactiveManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||||
|
await this.batchInactiveManager.execute();
|
||||||
|
return this.batchInactiveManager.getResult();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||||
|
import { TaxEntity } from '../../domain/entities/tax.entity';
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsNumber, IsString } from 'class-validator';
|
||||||
|
|
||||||
|
export class TaxDto extends BaseStatusDto implements TaxEntity {
|
||||||
|
@ApiProperty({
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
example: 'PPN',
|
||||||
|
})
|
||||||
|
@IsString()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
example: 10,
|
||||||
|
})
|
||||||
|
@IsNumber()
|
||||||
|
value: number;
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
import {
|
||||||
|
Body,
|
||||||
|
Controller,
|
||||||
|
Delete,
|
||||||
|
Param,
|
||||||
|
Patch,
|
||||||
|
Post,
|
||||||
|
Put,
|
||||||
|
} from '@nestjs/common';
|
||||||
|
import { TaxDataOrchestrator } from '../domain/usecases/tax-data.orchestrator';
|
||||||
|
import { TaxDto } from './dto/tax.dto';
|
||||||
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { TaxEntity } from '../domain/entities/tax.entity';
|
||||||
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
|
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
||||||
|
import { Public } from 'src/core/guards';
|
||||||
|
|
||||||
|
@ApiTags(`${MODULE_NAME.TAX.split('-').join(' ')} - data`)
|
||||||
|
@Controller(MODULE_NAME.TAX)
|
||||||
|
@Public(false)
|
||||||
|
@ApiBearerAuth('JWT')
|
||||||
|
export class TaxDataController {
|
||||||
|
constructor(private orchestrator: TaxDataOrchestrator) {}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: TaxDto): Promise<TaxEntity> {
|
||||||
|
return await this.orchestrator.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put('/batch-delete')
|
||||||
|
async batchDeleted(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
|
return await this.orchestrator.batchDelete(body.ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id/active')
|
||||||
|
async active(@Param('id') dataId: string): Promise<String> {
|
||||||
|
return await this.orchestrator.active(dataId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put('/batch-active')
|
||||||
|
async batchActive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
|
return await this.orchestrator.batchActive(body.ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id/confirm')
|
||||||
|
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||||
|
return await this.orchestrator.confirm(dataId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put('/batch-confirm')
|
||||||
|
async batchConfirm(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
|
return await this.orchestrator.batchConfirm(body.ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id/inactive')
|
||||||
|
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||||
|
return await this.orchestrator.inactive(dataId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put('/batch-inactive')
|
||||||
|
async batchInactive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
|
return await this.orchestrator.batchInactive(body.ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(
|
||||||
|
@Param('id') dataId: string,
|
||||||
|
@Body() data: TaxDto,
|
||||||
|
): Promise<TaxEntity> {
|
||||||
|
return await this.orchestrator.update(dataId, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') dataId: string): Promise<String> {
|
||||||
|
return await this.orchestrator.delete(dataId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
|
import { TaxDataService } from './data/services/tax-data.service';
|
||||||
|
import { TaxReadService } from './data/services/tax-read.service';
|
||||||
|
import { TaxReadController } from './infrastructure/tax-read.controller';
|
||||||
|
import { TaxReadOrchestrator } from './domain/usecases/tax-read.orchestrator';
|
||||||
|
import { TaxDataController } from './infrastructure/tax-data.controller';
|
||||||
|
import { TaxDataOrchestrator } from './domain/usecases/tax-data.orchestrator';
|
||||||
|
import { CreateTaxManager } from './domain/usecases/managers/create-tax.manager';
|
||||||
|
import { CqrsModule } from '@nestjs/cqrs';
|
||||||
|
import { IndexTaxManager } from './domain/usecases/managers/index-tax.manager';
|
||||||
|
import { DeleteTaxManager } from './domain/usecases/managers/delete-tax.manager';
|
||||||
|
import { UpdateTaxManager } from './domain/usecases/managers/update-tax.manager';
|
||||||
|
import { ActiveTaxManager } from './domain/usecases/managers/active-tax.manager';
|
||||||
|
import { ConfirmTaxManager } from './domain/usecases/managers/confirm-tax.manager';
|
||||||
|
import { InactiveTaxManager } from './domain/usecases/managers/inactive-tax.manager';
|
||||||
|
import { DetailTaxManager } from './domain/usecases/managers/detail-tax.manager';
|
||||||
|
import { BatchDeleteTaxManager } from './domain/usecases/managers/batch-delete-tax.manager';
|
||||||
|
import { BatchActiveTaxManager } from './domain/usecases/managers/batch-active-tax.manager';
|
||||||
|
import { BatchConfirmTaxManager } from './domain/usecases/managers/batch-confirm-tax.manager';
|
||||||
|
import { BatchInactiveTaxManager } from './domain/usecases/managers/batch-inactive-tax.manager';
|
||||||
|
import { TaxModel } from './data/models/tax.model';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
ConfigModule.forRoot(),
|
||||||
|
TypeOrmModule.forFeature([TaxModel], CONNECTION_NAME.DEFAULT),
|
||||||
|
CqrsModule,
|
||||||
|
],
|
||||||
|
controllers: [TaxDataController, TaxReadController],
|
||||||
|
providers: [
|
||||||
|
IndexTaxManager,
|
||||||
|
DetailTaxManager,
|
||||||
|
CreateTaxManager,
|
||||||
|
DeleteTaxManager,
|
||||||
|
UpdateTaxManager,
|
||||||
|
ActiveTaxManager,
|
||||||
|
ConfirmTaxManager,
|
||||||
|
InactiveTaxManager,
|
||||||
|
BatchDeleteTaxManager,
|
||||||
|
BatchActiveTaxManager,
|
||||||
|
BatchConfirmTaxManager,
|
||||||
|
BatchInactiveTaxManager,
|
||||||
|
|
||||||
|
TaxDataService,
|
||||||
|
TaxReadService,
|
||||||
|
|
||||||
|
TaxDataOrchestrator,
|
||||||
|
TaxReadOrchestrator,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class TaxModule {}
|
Loading…
Reference in New Issue