update migrations and create base migration. set discount and tax to sale invoices
This commit is contained in:
@@ -1,34 +1,28 @@
|
||||
model Customer {
|
||||
id String @id @default(ulid())
|
||||
is_favorite Boolean? @default(false)
|
||||
type CustomerType
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
individual CustomerIndividual?
|
||||
legal CustomerLegal?
|
||||
|
||||
id String @id @default(ulid())
|
||||
is_favorite Boolean? @default(false)
|
||||
type CustomerType
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
individual CustomerIndividual?
|
||||
legal CustomerLegal?
|
||||
sales_invoices SalesInvoice[]
|
||||
|
||||
@@map("customers")
|
||||
}
|
||||
|
||||
model CustomerIndividual {
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
national_id String @db.Char(10)
|
||||
mobile_number String @db.Char(15)
|
||||
|
||||
postal_code String @db.Char(10)
|
||||
economic_code String? @db.Char(10)
|
||||
|
||||
customer_id String @id
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
first_name String @db.VarChar(255)
|
||||
last_name String @db.VarChar(255)
|
||||
national_id String @db.Char(10)
|
||||
mobile_number String @db.Char(15)
|
||||
postal_code String @db.Char(10)
|
||||
economic_code String? @db.Char(10)
|
||||
customer_id String @id
|
||||
business_activity_id String
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: id)
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([business_activity_id, national_id])
|
||||
@@index([business_activity_id])
|
||||
@@ -36,16 +30,14 @@ model CustomerIndividual {
|
||||
}
|
||||
|
||||
model CustomerLegal {
|
||||
name String @db.VarChar(255)
|
||||
economic_code String @db.Char(10)
|
||||
registration_number String? @db.Char(20)
|
||||
postal_code String @db.Char(10)
|
||||
|
||||
customer_id String @id
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
name String @db.VarChar(255)
|
||||
economic_code String @db.Char(10)
|
||||
registration_number String? @db.Char(20)
|
||||
postal_code String @db.Char(10)
|
||||
customer_id String @id
|
||||
business_activity_id String
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: id)
|
||||
business_activity BusinessActivity @relation(fields: [business_activity_id], references: [id])
|
||||
customer Customer @relation(fields: [customer_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([business_activity_id, economic_code])
|
||||
@@index([business_activity_id])
|
||||
|
||||
@@ -9,16 +9,6 @@ enum PaymentMethodType {
|
||||
OTHER
|
||||
}
|
||||
|
||||
enum UnitType {
|
||||
COUNT
|
||||
GRAM
|
||||
KILOGRAM
|
||||
MILLILITER
|
||||
LITER
|
||||
METER
|
||||
HOUR
|
||||
}
|
||||
|
||||
enum GoodPricingModel {
|
||||
STANDARD
|
||||
GOLD
|
||||
@@ -50,18 +40,6 @@ enum BusinessRole {
|
||||
OPERATOR
|
||||
}
|
||||
|
||||
enum LicenseType {
|
||||
BASIC
|
||||
PRO
|
||||
ENTERPRISE
|
||||
}
|
||||
|
||||
enum LicenseStatus {
|
||||
ACTIVE
|
||||
EXPIRED
|
||||
SUSPENDED
|
||||
}
|
||||
|
||||
enum POSType {
|
||||
PSP
|
||||
MOBILE
|
||||
@@ -69,11 +47,6 @@ enum POSType {
|
||||
API
|
||||
}
|
||||
|
||||
enum UserType {
|
||||
LEGAL
|
||||
INDIVIDUAL
|
||||
}
|
||||
|
||||
enum AccountType {
|
||||
ADMIN
|
||||
PROVIDER
|
||||
@@ -81,17 +54,6 @@ enum AccountType {
|
||||
CONSUMER
|
||||
}
|
||||
|
||||
enum UserStatus {
|
||||
ACTIVE
|
||||
INACTIVE
|
||||
}
|
||||
|
||||
enum AccountRole {
|
||||
OWNER
|
||||
OPERATOR
|
||||
ACCOUNTANT
|
||||
}
|
||||
|
||||
enum AccountStatus {
|
||||
ACTIVE
|
||||
SUSPENDED
|
||||
@@ -114,11 +76,6 @@ enum ProviderRole {
|
||||
OPERATOR
|
||||
}
|
||||
|
||||
enum ProviderStatus {
|
||||
ACTIVE
|
||||
SUSPENDED
|
||||
}
|
||||
|
||||
enum ConsumerRole {
|
||||
OWNER
|
||||
MANAGER
|
||||
@@ -130,11 +87,6 @@ enum ConsumerStatus {
|
||||
SUSPENDED
|
||||
}
|
||||
|
||||
enum TokenType {
|
||||
ACCESS
|
||||
REFRESH
|
||||
}
|
||||
|
||||
enum ApplicationPlatform {
|
||||
ANDROID
|
||||
IOS
|
||||
@@ -146,12 +98,6 @@ enum ApplicationReleaseType {
|
||||
ALPHA
|
||||
}
|
||||
|
||||
enum ApplicationPublisher {
|
||||
DIRECT
|
||||
CAFE_BAZAR
|
||||
MAYKET
|
||||
}
|
||||
|
||||
enum ConsumerType {
|
||||
INDIVIDUAL
|
||||
LEGAL
|
||||
@@ -184,15 +130,6 @@ enum TspProviderRequestType {
|
||||
RETURN
|
||||
}
|
||||
|
||||
enum TspProviderCustomerType {
|
||||
Unknown
|
||||
Known
|
||||
}
|
||||
|
||||
enum SKUGuildType {
|
||||
GOLD
|
||||
}
|
||||
|
||||
enum InvoiceTemplateType {
|
||||
SALE
|
||||
FX_SALE
|
||||
|
||||
@@ -1,92 +1,86 @@
|
||||
model SalesInvoice {
|
||||
id String @id @default(uuid())
|
||||
code String @unique @db.VarChar(100)
|
||||
total_amount Decimal @db.Decimal(15, 2)
|
||||
invoice_number Int @db.Int()
|
||||
invoice_date DateTime @default(now()) @db.Timestamp(0)
|
||||
type TspProviderRequestType
|
||||
settlement_type InvoiceSettlementType
|
||||
tax_id String? @unique @db.VarChar(32)
|
||||
|
||||
notes String? @db.Text
|
||||
unknown_customer Json? @db.Json
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
|
||||
main_id String? @db.VarChar(50)
|
||||
ref_id String? @unique @db.VarChar(50)
|
||||
reference_invoice SalesInvoice? @relation("SalesInvoiceReference", fields: [ref_id], references: [id])
|
||||
|
||||
customer_id String?
|
||||
customer Customer? @relation(fields: [customer_id], references: [id])
|
||||
|
||||
id String @id @default(uuid())
|
||||
code String @unique @db.VarChar(100)
|
||||
total_amount Decimal @db.Decimal(15, 2)
|
||||
invoice_number Int
|
||||
invoice_date DateTime @default(now()) @db.Timestamp(0)
|
||||
type TspProviderRequestType
|
||||
tax_id String? @unique @db.VarChar(32)
|
||||
notes String? @db.Text
|
||||
unknown_customer Json?
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
main_id String? @db.VarChar(50)
|
||||
ref_id String? @unique @db.VarChar(50)
|
||||
customer_id String?
|
||||
consumer_account_id String
|
||||
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id])
|
||||
|
||||
pos_id String
|
||||
pos Pos @relation(fields: [pos_id], references: [id])
|
||||
|
||||
referenced_by SalesInvoice? @relation("SalesInvoiceReference")
|
||||
items SalesInvoiceItem[]
|
||||
payments SalesInvoicePayment[]
|
||||
tsp_attempts SaleInvoiceTspAttempts[]
|
||||
pos_id String
|
||||
settlement_type InvoiceSettlementType
|
||||
discount_amount Decimal? @db.Decimal(15, 2)
|
||||
tax_amount Decimal? @db.Decimal(15, 2)
|
||||
tsp_attempts SaleInvoiceTspAttempts[]
|
||||
items SalesInvoiceItem[]
|
||||
payments SalesInvoicePayment[]
|
||||
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id])
|
||||
customer Customer? @relation(fields: [customer_id], references: [id])
|
||||
pos Pos @relation(fields: [pos_id], references: [id])
|
||||
reference_invoice SalesInvoice? @relation("SalesInvoiceReference", fields: [ref_id], references: [id])
|
||||
referenced_by SalesInvoice? @relation("SalesInvoiceReference")
|
||||
|
||||
@@unique([invoice_number, pos_id])
|
||||
@@index([ref_id])
|
||||
@@index([tax_id])
|
||||
@@index([consumer_account_id], map: "sales_invoices_consumer_account_id_fkey")
|
||||
@@index([customer_id], map: "sales_invoices_customer_id_fkey")
|
||||
@@index([pos_id], map: "sales_invoices_pos_id_fkey")
|
||||
@@map("sales_invoices")
|
||||
}
|
||||
|
||||
model SalesInvoiceItem {
|
||||
id String @id @default(ulid())
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
measure_unit_text String @db.VarChar(50)
|
||||
measure_unit_code String @db.VarChar(50)
|
||||
sku_code String @db.VarChar(50)
|
||||
sku_vat Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
unit_price Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
total_amount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
discount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
notes String? @db.Text
|
||||
|
||||
payload Json?
|
||||
good_snapshot Json
|
||||
|
||||
invoice_id String
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
|
||||
good_id String
|
||||
good Good @relation(fields: [good_id], references: [id])
|
||||
|
||||
service_id String?
|
||||
service Service? @relation(fields: [service_id], references: [id])
|
||||
id String @id @default(ulid())
|
||||
quantity Decimal @db.Decimal(10, 0)
|
||||
measure_unit_text String @db.VarChar(50)
|
||||
measure_unit_code String @db.VarChar(50)
|
||||
sku_code String @db.VarChar(50)
|
||||
sku_vat Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
unit_price Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
total_amount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
discount Decimal @default(0.00) @db.Decimal(15, 2)
|
||||
notes String? @db.Text
|
||||
payload Json?
|
||||
good_snapshot Json
|
||||
invoice_id String
|
||||
good_id String
|
||||
service_id String?
|
||||
discount_amount Decimal? @db.Decimal(15, 2)
|
||||
tax_amount Decimal? @db.Decimal(15, 2)
|
||||
good Good @relation(fields: [good_id], references: [id])
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
service Service? @relation(fields: [service_id], references: [id])
|
||||
|
||||
@@index([invoice_id, good_id])
|
||||
@@index([good_id], map: "sales_invoice_items_good_id_fkey")
|
||||
@@index([service_id], map: "sales_invoice_items_service_id_fkey")
|
||||
@@map("sales_invoice_items")
|
||||
}
|
||||
|
||||
model SaleInvoiceTspAttempts {
|
||||
id String @id @default(ulid())
|
||||
|
||||
attempt_no Int
|
||||
status TspProviderResponseStatus
|
||||
|
||||
raw_request_payload Json
|
||||
id String @id @default(ulid())
|
||||
attempt_no Int
|
||||
status TspProviderResponseStatus
|
||||
message String @db.Text
|
||||
sent_at DateTime? @db.Timestamp(0)
|
||||
received_at DateTime? @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
invoice_id String
|
||||
provider_request_payload Json
|
||||
provider_response Json?
|
||||
message String @db.Text
|
||||
error_message String? @db.Text
|
||||
validation_errors Json?
|
||||
raw_request_payload Json
|
||||
error_message String? @db.Text
|
||||
fiscal_warnings Json?
|
||||
|
||||
sent_at DateTime? @db.Timestamp(0)
|
||||
received_at DateTime? @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
invoice_id String
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id], onDelete: Cascade)
|
||||
provider_response Json?
|
||||
validation_errors Json?
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([invoice_id, attempt_no])
|
||||
@@index([status])
|
||||
@@ -95,35 +89,30 @@ model SaleInvoiceTspAttempts {
|
||||
}
|
||||
|
||||
model SalesInvoicePayment {
|
||||
id String @id @default(ulid())
|
||||
amount Decimal @db.Decimal(15, 2)
|
||||
id String @id @default(ulid())
|
||||
amount Decimal @db.Decimal(15, 2)
|
||||
payment_method PaymentMethodType
|
||||
paid_at DateTime @db.Timestamp(0)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
invoice_id String
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
|
||||
terminal_info SalesInvoicePaymentTerminalInfo?
|
||||
paid_at DateTime @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
invoice_id String
|
||||
terminal_info SalesInvoicePaymentTerminalInfo?
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
|
||||
@@index([invoice_id])
|
||||
@@map("sales_invoice_payments")
|
||||
}
|
||||
|
||||
model SalesInvoicePaymentTerminalInfo {
|
||||
id String @id @default(ulid())
|
||||
id String @id @default(ulid())
|
||||
terminal_id String
|
||||
stan String
|
||||
rrn String
|
||||
transaction_date_time DateTime
|
||||
customer_card_no String?
|
||||
description String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
payment_id String @unique
|
||||
payment SalesInvoicePayment @relation(fields: [payment_id], references: [id])
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
payment_id String @unique
|
||||
payment SalesInvoicePayment @relation(fields: [payment_id], references: [id])
|
||||
|
||||
@@unique([terminal_id, stan, rrn, payment_id])
|
||||
@@map("sales_invoice_payment_terminal_info")
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
model Service {
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(255)
|
||||
description String? @db.Text
|
||||
sku String @unique() @db.VarChar(100)
|
||||
local_sku String? @unique() @db.VarChar(100)
|
||||
barcode String? @unique() @db.VarChar(100)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
category_id String?
|
||||
base_sale_price Decimal @default(0.00) @db.Decimal(15, 0)
|
||||
account_id String
|
||||
complex_id String
|
||||
|
||||
category ServiceCategory? @relation(fields: [category_id], references: [id])
|
||||
id String @id @default(ulid())
|
||||
name String @db.VarChar(255)
|
||||
description String? @db.Text
|
||||
sku String @unique @db.VarChar(100)
|
||||
local_sku String? @unique @db.VarChar(100)
|
||||
barcode String? @unique @db.VarChar(100)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
category_id String?
|
||||
base_sale_price Decimal @default(0) @db.Decimal(15, 0)
|
||||
account_id String
|
||||
complex_id String
|
||||
sales_invoice_items SalesInvoiceItem[]
|
||||
category ServiceCategory? @relation(fields: [category_id], references: [id])
|
||||
|
||||
@@index([category_id])
|
||||
@@map("services")
|
||||
@@ -30,8 +29,7 @@ model ServiceCategory {
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt @db.Timestamp(0)
|
||||
deleted_at DateTime? @db.Timestamp(0)
|
||||
|
||||
services Service[]
|
||||
services Service[]
|
||||
|
||||
@@map("service_categories")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user