Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
feat: finish v1 cte
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielDeSouzza committed May 28, 2024
1 parent 546c458 commit cff1f71
Show file tree
Hide file tree
Showing 26 changed files with 249 additions and 45 deletions.
6 changes: 6 additions & 0 deletions prisma/dbml/schema.dbml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ Table physical_customer_quote {
mass Float [not null]
volume Float [not null]
nf_value Float [not null]
nf_serie String [not null]
nf_number String [not null]
digital_signature String [unique, not null]
created_at DateTime [default: `now()`, not null]
updated_at DateTime [default: `now()`, not null]
CreatedBy users [not null]
Expand Down Expand Up @@ -570,6 +573,9 @@ Table legal_client_quote {
mass Float [not null]
volume Float [not null]
nf_value Float [not null]
nf_serie String [not null]
nf_number String [not null]
digital_signature String [unique, not null]
LegalClientOrder legal_orders [not null]
created_at DateTime [default: `now()`, not null]
updated_at DateTime [default: `now()`, not null]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Warnings:
- A unique constraint covering the columns `[digital_signature]` on the table `legal_client_quote` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[digital_signature]` on the table `physical_customer_quote` will be added. If there are existing duplicate values, this will fail.
- Added the required column `digital_signature` to the `legal_client_quote` table without a default value. This is not possible if the table is not empty.
- Added the required column `nf_number` to the `legal_client_quote` table without a default value. This is not possible if the table is not empty.
- Added the required column `nf_serie` to the `legal_client_quote` table without a default value. This is not possible if the table is not empty.
- Added the required column `digital_signature` to the `physical_customer_quote` table without a default value. This is not possible if the table is not empty.
- Added the required column `nf_number` to the `physical_customer_quote` table without a default value. This is not possible if the table is not empty.
- Added the required column `nf_serie` to the `physical_customer_quote` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "legal_client_quote" ADD COLUMN "digital_signature" TEXT NOT NULL,
ADD COLUMN "nf_number" TEXT NOT NULL,
ADD COLUMN "nf_serie" TEXT NOT NULL;

-- AlterTable
ALTER TABLE "physical_customer_quote" ADD COLUMN "digital_signature" TEXT NOT NULL,
ADD COLUMN "nf_number" TEXT NOT NULL,
ADD COLUMN "nf_serie" TEXT NOT NULL;

-- CreateIndex
CREATE UNIQUE INDEX "legal_client_quote_digital_signature_key" ON "legal_client_quote"("digital_signature");

-- CreateIndex
CREATE UNIQUE INDEX "physical_customer_quote_digital_signature_key" ON "physical_customer_quote"("digital_signature");
39 changes: 23 additions & 16 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -434,26 +434,30 @@ model OutsourcedTransportCompanyContract {
}

model PhysicalCustomerQuoteTable {
id String @id @default(uuid())
cod_quote String
kind_service String
form_payment String
recipient_id String
Recipient Recipient @relation(fields: [recipient_id], references: [id])
Sender Sender @relation(fields: [senderId], references: [id])
senderId String
who_pays String
adress_origin_id String
AdressOrigin Adresses @relation("adress_origin_quote_physical", fields: [adress_origin_id], references: [id])
adress_destiny_id String
AdressDestiny Adresses @relation("adress_destiny_quote_physical", fields: [adress_destiny_id], references: [id])
type_merchandise String
amount Int
id String @id @default(uuid())
cod_quote String
kind_service String
form_payment String
recipient_id String
Recipient Recipient @relation(fields: [recipient_id], references: [id])
Sender Sender @relation(fields: [senderId], references: [id])
senderId String
who_pays String
adress_origin_id String
AdressOrigin Adresses @relation("adress_origin_quote_physical", fields: [adress_origin_id], references: [id])
adress_destiny_id String
AdressDestiny Adresses @relation("adress_destiny_quote_physical", fields: [adress_destiny_id], references: [id])
type_merchandise String
amount Int
description String
mass Float
volume Float
nf_value Float
nf_serie String
nf_number String
digital_signature String @unique
created_at DateTime @default(now())
updated_at DateTime @default(now())
CreatedBy User @relation("created_by", fields: [created_by], references: [id])
Expand Down Expand Up @@ -663,6 +667,9 @@ model LegalClientQuoteTable {
mass Float
volume Float
nf_value Float
nf_serie String
nf_number String
digital_signature String @unique
LegalClientOrder LegalClientOrder[]
created_at DateTime @default(now())
updated_at DateTime @default(now())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { type AdressesType } from 'domain/entities/QuoteTables/AdressesType';
import { type ILegalClientQuoteTable } from 'domain/entities/QuoteTables/LegalClientQuoteTable/LegalClientQuoteTable';

export abstract class CreateLegalClientQuoteTableDTO
implements ILegalClientQuoteTable
{
export abstract class CreateLegalClientQuoteTableDTO {
id?: string;
codQuote: string;
kindService: string;
Expand All @@ -22,4 +19,6 @@ export abstract class CreateLegalClientQuoteTableDTO
created_by: string;
updated_by: string;
icms_id?: string;
nf_serie: string;
nf_number: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { type AdressesType } from 'domain/entities/QuoteTables/AdressesType';
import { type ILegalClientQuoteTable } from 'domain/entities/QuoteTables/LegalClientQuoteTable/LegalClientQuoteTable';

export abstract class UpdateLegalClientQuoteTableDTO
implements Partial<ILegalClientQuoteTable>
{
export abstract class UpdateLegalClientQuoteTableDTO {
id?: string;
kindService?: string;
formPayment?: string;
Expand All @@ -20,4 +17,6 @@ export abstract class UpdateLegalClientQuoteTableDTO
nf_value?: number;
updated_by: string;
icms_id?: string;
nf_serie?: string;
nf_number?: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { type AdressesType } from 'domain/entities/QuoteTables/AdressesType';
import { type ILegalClientQuoteTable } from 'domain/entities/QuoteTables/LegalClientQuoteTable/LegalClientQuoteTable';

export abstract class UpdateManyLegalClientQuoteTableDTO
implements Partial<ILegalClientQuoteTable>
{
export abstract class UpdateManyLegalClientQuoteTableDTO {
id: string;
recipientId?: string;
kindService?: string;
Expand All @@ -19,4 +16,6 @@ export abstract class UpdateManyLegalClientQuoteTableDTO
volume?: number;
nf_value?: number;
icms_id?: string;
nf_serie?: string;
nf_number?: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { type AdressesType } from 'domain/entities/QuoteTables/AdressesType';
import { type IPhysicalCustomerQuoteTable } from 'domain/entities/QuoteTables/PhysicalCustomerQuoteTable/PhysicalCustomerQuoteTable';

export abstract class CreatePhysicalCustomerQuoteTableDTO
implements IPhysicalCustomerQuoteTable
{
export abstract class CreatePhysicalCustomerQuoteTableDTO {
kindService: string;
formPayment: string;
codQuote: string;
Expand All @@ -21,4 +18,6 @@ export abstract class CreatePhysicalCustomerQuoteTableDTO
created_by: string;
updated_by: string;
icms_id?: string;
nf_serie: string;
nf_number: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { type AdressesType } from 'domain/entities/QuoteTables/AdressesType';
import { type IPhysicalCustomerQuoteTable } from 'domain/entities/QuoteTables/PhysicalCustomerQuoteTable/PhysicalCustomerQuoteTable';

export abstract class UpdatePhysicalCustomerQuoteTableDTO
implements Partial<IPhysicalCustomerQuoteTable>
{
export abstract class UpdatePhysicalCustomerQuoteTableDTO {
recipientId?: string;
kindService?: string;
formPayment?: string;
Expand All @@ -19,4 +16,6 @@ export abstract class UpdatePhysicalCustomerQuoteTableDTO
nf_value?: number;
updated_by: string;
icms_id?: string;
nf_serie?: string;
nf_number?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export class LegalClientQuoteTableUseCases {
who_pays: data.who_pays,
created_by: data.created_by,
updated_by: data.updated_by,
nf_number: data.nf_number,
nf_serie: data.nf_serie,
digital_signature: generateRandomNumber(40),
});

return this.legalClientQuoteTableRepository.createLegalClientQuoteTable(
Expand Down Expand Up @@ -128,6 +131,9 @@ export class LegalClientQuoteTableUseCases {
who_pays: data.who_pays,
created_by: null,
updated_by: data.updated_by,
nf_number: data.nf_number,
nf_serie: data.nf_serie,
digital_signature: null,
});

return this.legalClientQuoteTableRepository.updateLegalClientQuoteTable(
Expand Down Expand Up @@ -160,6 +166,9 @@ export class LegalClientQuoteTableUseCases {
created_by: null,
updated_by: updateBy,
id: legalclientquotetable.id,
nf_number: legalclientquotetable.nf_number,
nf_serie: legalclientquotetable.nf_serie,
digital_signature: null,
});

return updateLegalClientQuoteTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export class PhysicalCustomerQuoteTableUseCases {
who_pays: data.who_pays,
created_by: data.created_by,
updated_by: data.updated_by,
nf_number: data.nf_number,
nf_serie: data.nf_serie,
digital_signature: generateRandomNumber(40),
});

return this.physicalCustomerQuoteTableRepository.createPhysicalCustomerQuoteTable(
Expand Down Expand Up @@ -127,6 +130,9 @@ export class PhysicalCustomerQuoteTableUseCases {
who_pays: data.who_pays,
created_by: null,
updated_by: data.updated_by,
nf_number: data.nf_number,
nf_serie: data.nf_serie,
digital_signature: null,
});

return this.physicalCustomerQuoteTableRepository.updatePhysicalCustomerQuoteTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ describe('CarrierCompany', () => {
senderId: '454654654',
typeMerchandise: '155',
updated_by: '45654654',
digital_signature: '54654654654',
nf_number: '65465465',
nf_serie: '54654654',
volume: 54.45,
who_pays: 'FOB',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ describe('CarrierCompany', () => {
updated_by: '45654654',
volume: 54.45,
who_pays: 'FOB',
digital_signature: '65465456',
nf_number: '564654654',
nf_serie: '+46654',
}),
rntrc: '46546',
senderLegalPerson: new LegalPerson({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ describe('User', () => {
updated_by: '45654654',
volume: 54.45,
who_pays: 'FOB',
digital_signature: '4654654',
nf_number: '65+65+65',
nf_serie: '464646',
});

expect(quote).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export interface ILegalClientQuoteTable {
created_by: string;
updated_by: string;
icms_id?: string;
nf_serie: string;
nf_number: string;
digital_signature: string;
}

export class LegalClientQuoteTable extends Entity {
Expand Down Expand Up @@ -237,7 +240,29 @@ export class LegalClientQuoteTable extends Entity {
set nf_value(nf_value: number) {
this.props.nf_value = nf_value;
}
get nf_serie(): string {
return this.props.nf_serie;
}

set nf_serie(nf_serie: string) {
this.props.nf_serie = nf_serie;
}

get nf_number(): string {
return this.props.nf_number;
}

set nf_number(nf_number: string) {
this.props.nf_number = nf_number;
}

get digital_signature(): string {
return this.props.digital_signature;
}

set digital_signature(digital_signature: string) {
this.props.digital_signature = digital_signature;
}
get updated_at(): Date {
return this.props.updated_at;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ describe('User', () => {
updated_by: '45654654',
volume: 54.45,
who_pays: 'FOB',
digital_signature: '4565465',
nf_number: '5464645',
nf_serie: '66767687',
});

expect(quote).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export interface IPhysicalCustomerQuoteTable {
created_by: string;
updated_by: string;
icms_id?: string;
nf_serie: string;
nf_number: string;
digital_signature: string;
}

export class PhysicalCustomerQuoteTable extends Entity {
Expand Down Expand Up @@ -240,6 +243,29 @@ export class PhysicalCustomerQuoteTable extends Entity {
this.props.nf_value = nf_value;
}

get nf_serie(): string {
return this.props.nf_serie;
}

set nf_serie(nf_serie: string) {
this.props.nf_serie = nf_serie;
}

get nf_number(): string {
return this.props.nf_number;
}

set nf_number(nf_number: string) {
this.props.nf_number = nf_number;
}

get digital_signature(): string {
return this.props.digital_signature;
}

set digital_signature(digital_signature: string) {
this.props.digital_signature = digital_signature;
}
get updated_at(): Date {
return this.props.updated_at;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export class PhysicalCustomerOrderPrismaService
async createPhysicalCustomerOrder(
physicalCustomerOrder: PhysicalCustomerOrder,
): Promise<PhysicalCustomerOrder> {
const icms = await this.prisma.physicalCustomerQuoteTable.findFirst({
select: { Icms: { select: { aliquot: true } } },
where: { id: physicalCustomerOrder.quote_table_id },
});
physicalCustomerOrder.icms_tax = icms.Icms.aliquot;
const physicalCustomerOrderPrisma =
await this.prisma.physicalCustomerOrder.create({
data: PhysicalCustomerOrderPrismaDTO.EntityToCreatePrisma(
Expand Down
Loading

0 comments on commit cff1f71

Please sign in to comment.