feat: add settlement_type to SalesInvoice model and related DTOs

- Added settlement_type field to SalesInvoice model with ENUM values (CASH, CREDIT, MIXED).
- Updated SalesInvoice aggregate types, input types, and where filters to include settlement_type.
- Modified StatisticsService to calculate credit amounts based on settlement_type.
- Enhanced TspProviderOriginalSendPayloadDto to include settlement_type.
- Updated NamaProvider DTOs and utility functions to handle new settlement_type logic.
- Created migration to add settlement_type column to sales_invoices table and backfill existing records.
This commit is contained in:
2026-05-24 19:40:04 +03:30
parent b53b7d3ed3
commit ea6f1bfdd0
17 changed files with 340 additions and 268 deletions
+84 -242
View File
@@ -1,288 +1,130 @@
# GapCode Agent Instructions
# AGENTS.md
Operational guide for AI/coding agents working in `consumer_api`.
## Stack
- NestJS
- Prisma
- TypeScript
- pnpm
- RTK enabled
---
# ⚡ RTK LOW-TOKEN EXECUTION POLICY (MANDATORY)
# Core Rules
This repository uses **RTK (Rust Token Killer)**.
All shell interactions MUST prefer RTK wrappers to reduce token usage.
If an RTK equivalent exists, **never use the raw command**.
This repository can be large; uncontrolled shell output will quickly exhaust model context.
- Keep changes minimal.
- Do not touch unrelated files.
- Prefer existing patterns over new abstractions.
- Preserve API behavior unless requested otherwise.
- Prefer forward Prisma migrations.
- Never edit applied migrations in shared environments.
---
# ✅ COMMAND REWRITE RULES (STRICT)
# EXECUTION RULES
Always rewrite commands using RTK:
- Keep responses short.
- Do not narrate thoughts.
- Do not explain obvious steps.
- Do not create plans for simple tasks.
- Prefer implementation over exploration.
git status → rtk git status
git diff → rtk git diff
git log → rtk git log
ls → rtk ls
tree → rtk ls
cat <file> → rtk read <file>
grep <pattern> → rtk grep <pattern>
rg <pattern> → rtk grep <pattern>
find → rtk find
Avoid:
Never run:
- raw git commands for inspection
- raw cat
- raw grep
- raw ls
- raw tree
- “I think…”
- “Let me check…”
- “I should inspect…”
- “Im going to…”
---
# 📂 CODE NAVIGATION WORKFLOW (MANDATORY)
# RTK Rules
When working in this repository follow this order:
1️⃣ Discover structure
rtk ls
2️⃣ Search before opening files
rtk grep <symbol | class | function | DTO | service>
3️⃣ Read only the necessary files
rtk read <file>
4️⃣ For large files (>300 lines)
rtk read <file> -l aggressive
5️⃣ For quick understanding
rtk smart <file>
Never open many files blindly.
Never read entire modules without searching first.
---
# 🧠 DIFF INSPECTION RULES
For reviewing repository changes:
Always prefer RTK commands.
Use:
rtk git diff
- `rtk ls`
- `rtk grep`
- `rtk smart`
- `rtk read`
- `rtk git diff`
- `rtk git status`
For large diffs:
Avoid raw:
rtk git diff -l aggressive
Never run raw `git diff`.
- `cat`
- `grep`
- `rg`
- `git diff`
- recursive repository scans
---
# 📁 FORBIDDEN PATHS
# Reading Strategy
Never inspect or read these directories unless explicitly required:
1. `rtk grep`
2. `rtk smart`
3. `rtk read`
node_modules/
dist/
build/
coverage/
.prisma/
prisma/migrations/
Rules:
These folders produce extremely large outputs and waste tokens.
- Read only necessary files.
- Do not read sibling files unless needed.
- Do not reread unchanged files.
- Stop searching once target location is found.
- Edit quickly after locating target.
Avoid:
- opening entire modules
- multi-file chained reads
- large diff dumps
- exploratory scans
---
# 📄 FILE READING POLICY
# Forbidden Paths
Preferred:
Do not inspect unless required:
rtk read file.ts
Large file:
rtk read file.ts -l aggressive
Quick overview:
rtk smart file.ts
Never use `cat` for source code inspection.
- `node_modules/`
- `dist/`
- `coverage/`
- `.prisma/`
- `prisma/migrations/`
---
# 🔎 SEARCH POLICY
# Prisma Rules
Always search before opening files.
Use:
rtk grep <pattern>
Avoid raw recursive searches.
- Use transactions for multi-step writes.
- Prefer explicit `select/include`.
- Normalize `Decimal` values with `Number(...)`.
- Keep migrations forward-safe.
- Use:
- `pnpm prisma migrate dev --name <name>` for new local migrations
- `pnpm prisma migrate deploy` for applying existing migrations
---
# 🎯 TOKEN SAFETY RULES
# NestJS Rules
- Never scan the entire repository.
- Never dump full logs.
- Never output entire large files.
- Prefer targeted inspection.
- Keep layering:
- controller
- service
- prisma/shared service
Token preservation is mandatory for this project.
- Reuse shared services.
- Keep DTO validation strict.
- Avoid `any`.
---
## Scope
# Validation
- Applies to the whole repository.
- Stack: NestJS + Prisma + TypeScript.
Typecheck before handoff:
## Primary Goals
- Deliver minimal, safe, and focused changes.
- Preserve existing API behavior unless explicitly requested.
- Keep Prisma schema/data operations forward-safe.
## Project Conventions
- Keep module layering consistent: `controller -> service -> prisma/shared service`.
- Reuse shared services for cross-module business logic (for example, sales invoice create flow).
- Keep DTO validation at API boundaries; avoid unchecked `any` in new code.
- Keep response shaping aligned with existing `ResponseMapper` usage.
- Prefer explicit Prisma `select`/`include` to control payload shape.
## Sales Invoice / TSP Rules
- `originalSend`, `correctionSend`, and `revoke` flows should be consistent and auditable.
- For correction/revoke creation, prepare data from the related invoice when required.
- Persist attempt records with clear status transitions (`QUEUED` -> final status).
- Store request/response payloads for traceability.
- Avoid changing fiscal/tax status semantics without explicit approval.
## Prisma and Migration Safety
- Treat committed migrations as immutable history.
- Prefer forward migrations; avoid destructive resets unless explicitly requested.
- For data-affecting changes:
- use transactions,
- verify expected row scope,
- keep logic idempotent where possible.
## Editing Principles
- Do not modify unrelated files.
- Do not revert user changes unless asked.
- Keep functions cohesive; extract shared logic when duplication appears.
- Remove debug leftovers (`console.log`, dead code) before finishing unless explicitly needed.
## Validation Checklist (before handoff)
1. Read target module/service/DTO end-to-end before edits.
2. Apply minimal patch with consistent naming.
3. Run typecheck: `pnpm -s tsc --noEmit`.
4. If behavior changed, run targeted checks/tests where possible.
5. Summarize changed files and behavior impact clearly.
## Useful Commands
- Typecheck: `pnpm -s tsc --noEmit`
- Migration status: `pnpm prisma migrate status`
- Create migration: `pnpm prisma migrate dev --name <name>`
- Deploy migrations: `pnpm prisma migrate deploy`
## Communication Style
- Be concise and implementation-focused.
- Call out assumptions/risk before risky steps.
- Provide practical next actions after task completion.
## Do / Don't (Repo-Specific)
### Do
- Do derive correction/revoke invoice creation data from `relatedInvoice` when the flow requires historical consistency.
- Do keep TSP attempt lifecycle explicit (`QUEUED`, then update with provider result and timestamps).
- Do use shared invoice-creation service instead of duplicating create logic across modules.
- Do normalize numeric DB values (`Decimal`) with `Number(...)` before DTO/payload composition.
- Do keep Prisma queries tight with `select`/`include` only for fields you actually use.
### Don't
- Don't pass undefined/out-of-scope variables in TSP flows (common regressions: `invoice_id`, `attemptId`, `pos_id` mismatches).
- Don't leave placeholder query blocks (for example empty `select: {}`) in production code.
- Don't mix method semantics (`send` vs `originalSend`) across services without verifying signatures.
- Don't leave debug logs (`console.log`) in critical invoice/tax paths unless explicitly requested.
- Don't change invoice type semantics (`ORIGINAL`, `CORRECTION`, `REVOKE`) implicitly.
### Common Pitfalls To Recheck
- Incorrect relation field names (`tax_id` on wrong model, missing relation selects).
- Building payloads from the wrong invoice (must match the expected new/ref invoice in each flow).
- Creating attempts without persisting request payload and final response payload.
- Mismatch between DTO shapes and shared service input contracts.
## Thread Notes (May 2026)
- Shared sale-invoice creation was introduced and must be injected/exported correctly in consuming modules (example failure: `UnknownDependenciesException` for `SharedSaleInvoiceCreateService`).
- In `SalesInvoiceTspService.revoke`, prepare all creation/update data from `relatedInvoice` (no external `dataToUpdate` argument expected).
- Prisma client is generated to `src/generated/prisma` via:
- `provider = "prisma-client"`
- `output = "../../src/generated/prisma"`
- `moduleFormat = "cjs"`
- Docker/runtime must include generated Prisma artifacts and `@prisma/client` runtime; missing `@prisma/client/runtime/client` indicates build/copy/install mismatch.
- Seeder commands that use `tsx` require dev dependencies/runtime tools; if running in slim production container, use a dedicated seed target/container or run seed from build/dev image.
- `pnpm` invocation in containers should use executable form (`pnpm ...`), not `node /app/pnpm`.
- Added SQL/Prisma error normalization utility: `src/common/utils/prisma-error.util.ts`; prefer mapping duplicate/constraint DB errors to domain-friendly messages.
- Partner-module list endpoints were standardized toward `ResponseMapper.paginate` where pagination response contract is expected.
- For heavy license provisioning (100+), request path should not synchronously insert all licenses; queue/background + batching is required.
## Migration Drift Playbook (Prisma/MySQL)
- If Prisma reports `modified after applied`, never edit an already-applied migration in-place for shared environments; create a new forward migration instead.
- If migration history and DB drift mismatch:
1. Verify local migration folders are complete and ordered.
2. Check `_prisma_migrations` for missing/applied names.
3. Use `prisma migrate resolve` only to reconcile history state, then apply a forward fix migration.
- Duplicate FK error seen in this repo: `sales_invoices_ref_id_fkey` (MySQL 1826). Recheck migration SQL for repeated `ADD CONSTRAINT` statements before rerun.
- Drift that repeatedly showed in this project: missing FK/unique on `sale_invoice_tsp_attempts.invoice_id`. Validate both schema and migration SQL produce the same final state.
- `prisma migrate status` may show up-to-date while `migrate dev` still detects drift (shadow DB/application history issue); treat `migrate dev` output as source of truth for fixing local history.
## Redis Cache Conventions (May 2026)
- Use `RedisKeyMaker` in `src/common/utils/redis-key-maker.util.ts` for all cache keys and wildcard patterns; do not inline key strings in services.
- Keep invalidation domain-based (for example `src/modules/admin/guilds/cache/*`, `src/modules/admin/partners/cache/*`, `src/modules/pos/cache/*`) and avoid duplicating delete logic across modules.
- For list APIs that are expensive or frequently read, prefer read-through cache with TTL and invalidation on every related write path.
- For entity endpoints, use list + detail split:
- list key(s): invalidated broadly on writes,
- detail key(s): invalidated per entity id.
- Partner domain rules:
- Shared partner cache namespace is `partners:*` (not admin-prefixed) because writes occur in both `admin/partners` and `partners` modules.
- Use shared invalidation service `src/modules/partners/cache/partners-cache-invalidation.service.ts` from both admin and partner write paths.
- Invalidate `partners:list` and `partners:{id}:detail` on partner create/update/delete and license-affecting writes.
- Invalidate partner license caches (activated-licenses list, charge-transactions list/detail) via the shared invalidation service.
- POS goods rules:
- Cache key shape is BA + guild scoped (`pos:ba:{businessActivityId}:guild:{guildId}:goods:list`) because results combine guild-default and BA-owned goods.
- Invalidate POS goods cache by guild when admin guild goods/category/sku changes.
- Invalidate POS goods cache by business activity when consumer BA goods create/update/delete.
- Consumer/Partner hierarchy rules:
- Consumer profile cache key: `consumers:{consumerId}:info`.
- Partner-consumer profile cache key: `partners:{partnerId}:consumers:{consumerId}:info`.
- On partner-consumer single read, write both keys when practical to share warm cache across modules.
- On consumer info update or partner-consumer update, invalidate both consumer and partner-consumer profile keys.
- For business activities, invalidate both list and detail layers; child updates may invalidate parent single cache when parent aggregates depend on child state.
- Wildcard invalidation implementation:
- Use `RedisService.deleteByPattern` / `RedisService.deleteByPatterns` for all pattern deletes.
- Do not implement ad-hoc scan/delete loops inside domain services.
- Pattern deletion uses `SCAN` + pipelined `DEL`; multi-pattern deletes run in parallel.
```bash
pnpm -s tsc --noEmit
```
@@ -0,0 +1,10 @@
-- Add as nullable first to support existing rows, backfill, then enforce NOT NULL
ALTER TABLE `sales_invoices`
ADD COLUMN `settlement_type` ENUM('CASH', 'CREDIT', 'MIXED') NULL;
UPDATE `sales_invoices`
SET `settlement_type` = 'CASH'
WHERE `settlement_type` IS NULL;
ALTER TABLE `sales_invoices`
MODIFY `settlement_type` ENUM('CASH', 'CREDIT', 'MIXED') NOT NULL;
+6
View File
@@ -157,6 +157,12 @@ enum ConsumerType {
LEGAL
}
enum InvoiceSettlementType {
CASH
CREDIT
MIXED
}
enum TspProviderType {
NAMA
SUN
+8 -7
View File
@@ -1,11 +1,12 @@
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
tax_id String? @unique @db.VarChar(32)
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
@@ -15,7 +15,11 @@ import {
Min,
ValidateNested,
} from 'class-validator'
import type { CustomerIndividual, CustomerLegal } from 'generated/prisma/client'
import {
CustomerIndividual,
CustomerLegal,
InvoiceSettlementType,
} from 'generated/prisma/client'
import { CustomerType } from 'generated/prisma/enums'
export class SharedCreateSalesInvoiceItemDto {
@@ -165,6 +169,10 @@ export class SharedCreateSalesInvoiceDto {
)
invoice_date: Date
@ApiProperty({ required: true, enum: InvoiceSettlementType })
@IsEnum(InvoiceSettlementType)
settlement_type: InvoiceSettlementType
@ApiProperty({ required: true })
@IsObject()
@ValidateNested({ each: true })
@@ -382,7 +382,14 @@ export class SharedSaleInvoiceCreateService {
main_invoice_id,
ref_invoice_id,
} = params
const { customer_id, customer_type, customer, payments, ...invoiceData } = data
const {
customer_id,
customer_type,
customer,
payments,
settlement_type,
...invoiceData
} = data
if (
type !== TspProviderRequestType.ORIGINAL &&
@@ -398,6 +405,7 @@ export class SharedSaleInvoiceCreateService {
total_amount: data.total_amount,
code: this.generateInvoiceCode(businessId, complexId, posId, invoiceNumber),
type,
settlement_type,
items: {
createMany: {
data: data.items.map(item => ({
+34
View File
@@ -623,6 +623,13 @@ export type EnumTspProviderRequestTypeFilter<$PrismaModel = never> = {
not?: Prisma.NestedEnumTspProviderRequestTypeFilter<$PrismaModel> | $Enums.TspProviderRequestType
}
export type EnumInvoiceSettlementTypeFilter<$PrismaModel = never> = {
equals?: $Enums.InvoiceSettlementType | Prisma.EnumInvoiceSettlementTypeFieldRefInput<$PrismaModel>
in?: $Enums.InvoiceSettlementType[]
notIn?: $Enums.InvoiceSettlementType[]
not?: Prisma.NestedEnumInvoiceSettlementTypeFilter<$PrismaModel> | $Enums.InvoiceSettlementType
}
export type EnumTspProviderRequestTypeWithAggregatesFilter<$PrismaModel = never> = {
equals?: $Enums.TspProviderRequestType | Prisma.EnumTspProviderRequestTypeFieldRefInput<$PrismaModel>
in?: $Enums.TspProviderRequestType[]
@@ -633,6 +640,16 @@ export type EnumTspProviderRequestTypeWithAggregatesFilter<$PrismaModel = never>
_max?: Prisma.NestedEnumTspProviderRequestTypeFilter<$PrismaModel>
}
export type EnumInvoiceSettlementTypeWithAggregatesFilter<$PrismaModel = never> = {
equals?: $Enums.InvoiceSettlementType | Prisma.EnumInvoiceSettlementTypeFieldRefInput<$PrismaModel>
in?: $Enums.InvoiceSettlementType[]
notIn?: $Enums.InvoiceSettlementType[]
not?: Prisma.NestedEnumInvoiceSettlementTypeWithAggregatesFilter<$PrismaModel> | $Enums.InvoiceSettlementType
_count?: Prisma.NestedIntFilter<$PrismaModel>
_min?: Prisma.NestedEnumInvoiceSettlementTypeFilter<$PrismaModel>
_max?: Prisma.NestedEnumInvoiceSettlementTypeFilter<$PrismaModel>
}
export type JsonFilter<$PrismaModel = never> =
| Prisma.PatchUndefined<
Prisma.Either<Required<JsonFilterBase<$PrismaModel>>, Exclude<keyof Required<JsonFilterBase<$PrismaModel>>, 'path'>>,
@@ -1317,6 +1334,13 @@ export type NestedEnumTspProviderRequestTypeFilter<$PrismaModel = never> = {
not?: Prisma.NestedEnumTspProviderRequestTypeFilter<$PrismaModel> | $Enums.TspProviderRequestType
}
export type NestedEnumInvoiceSettlementTypeFilter<$PrismaModel = never> = {
equals?: $Enums.InvoiceSettlementType | Prisma.EnumInvoiceSettlementTypeFieldRefInput<$PrismaModel>
in?: $Enums.InvoiceSettlementType[]
notIn?: $Enums.InvoiceSettlementType[]
not?: Prisma.NestedEnumInvoiceSettlementTypeFilter<$PrismaModel> | $Enums.InvoiceSettlementType
}
export type NestedEnumTspProviderRequestTypeWithAggregatesFilter<$PrismaModel = never> = {
equals?: $Enums.TspProviderRequestType | Prisma.EnumTspProviderRequestTypeFieldRefInput<$PrismaModel>
in?: $Enums.TspProviderRequestType[]
@@ -1327,6 +1351,16 @@ export type NestedEnumTspProviderRequestTypeWithAggregatesFilter<$PrismaModel =
_max?: Prisma.NestedEnumTspProviderRequestTypeFilter<$PrismaModel>
}
export type NestedEnumInvoiceSettlementTypeWithAggregatesFilter<$PrismaModel = never> = {
equals?: $Enums.InvoiceSettlementType | Prisma.EnumInvoiceSettlementTypeFieldRefInput<$PrismaModel>
in?: $Enums.InvoiceSettlementType[]
notIn?: $Enums.InvoiceSettlementType[]
not?: Prisma.NestedEnumInvoiceSettlementTypeWithAggregatesFilter<$PrismaModel> | $Enums.InvoiceSettlementType
_count?: Prisma.NestedIntFilter<$PrismaModel>
_min?: Prisma.NestedEnumInvoiceSettlementTypeFilter<$PrismaModel>
_max?: Prisma.NestedEnumInvoiceSettlementTypeFilter<$PrismaModel>
}
export type NestedJsonFilter<$PrismaModel = never> =
| Prisma.PatchUndefined<
Prisma.Either<Required<NestedJsonFilterBase<$PrismaModel>>, Exclude<keyof Required<NestedJsonFilterBase<$PrismaModel>>, 'path'>>,
+9
View File
@@ -249,6 +249,15 @@ export const ConsumerType = {
export type ConsumerType = (typeof ConsumerType)[keyof typeof ConsumerType]
export const InvoiceSettlementType = {
CASH: 'CASH',
CREDIT: 'CREDIT',
MIXED: 'MIXED'
} as const
export type InvoiceSettlementType = (typeof InvoiceSettlementType)[keyof typeof InvoiceSettlementType]
export const TspProviderType = {
NAMA: 'NAMA',
SUN: 'SUN'
File diff suppressed because one or more lines are too long
@@ -4097,6 +4097,7 @@ export const SalesInvoiceScalarFieldEnum = {
invoice_number: 'invoice_number',
invoice_date: 'invoice_date',
type: 'type',
settlement_type: 'settlement_type',
tax_id: 'tax_id',
notes: 'notes',
unknown_customer: 'unknown_customer',
@@ -4931,6 +4932,13 @@ export type EnumTspProviderRequestTypeFieldRefInput<$PrismaModel> = FieldRefInpu
/**
* Reference to a field of type 'InvoiceSettlementType'
*/
export type EnumInvoiceSettlementTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'InvoiceSettlementType'>
/**
* Reference to a field of type 'TspProviderResponseStatus'
*/
@@ -622,6 +622,7 @@ export const SalesInvoiceScalarFieldEnum = {
invoice_number: 'invoice_number',
invoice_date: 'invoice_date',
type: 'type',
settlement_type: 'settlement_type',
tax_id: 'tax_id',
notes: 'notes',
unknown_customer: 'unknown_customer',
+70 -1
View File
@@ -43,6 +43,7 @@ export type SalesInvoiceMinAggregateOutputType = {
invoice_number: number | null
invoice_date: Date | null
type: $Enums.TspProviderRequestType | null
settlement_type: $Enums.InvoiceSettlementType | null
tax_id: string | null
notes: string | null
created_at: Date | null
@@ -61,6 +62,7 @@ export type SalesInvoiceMaxAggregateOutputType = {
invoice_number: number | null
invoice_date: Date | null
type: $Enums.TspProviderRequestType | null
settlement_type: $Enums.InvoiceSettlementType | null
tax_id: string | null
notes: string | null
created_at: Date | null
@@ -79,6 +81,7 @@ export type SalesInvoiceCountAggregateOutputType = {
invoice_number: number
invoice_date: number
type: number
settlement_type: number
tax_id: number
notes: number
unknown_customer: number
@@ -110,6 +113,7 @@ export type SalesInvoiceMinAggregateInputType = {
invoice_number?: true
invoice_date?: true
type?: true
settlement_type?: true
tax_id?: true
notes?: true
created_at?: true
@@ -128,6 +132,7 @@ export type SalesInvoiceMaxAggregateInputType = {
invoice_number?: true
invoice_date?: true
type?: true
settlement_type?: true
tax_id?: true
notes?: true
created_at?: true
@@ -146,6 +151,7 @@ export type SalesInvoiceCountAggregateInputType = {
invoice_number?: true
invoice_date?: true
type?: true
settlement_type?: true
tax_id?: true
notes?: true
unknown_customer?: true
@@ -252,6 +258,7 @@ export type SalesInvoiceGroupByOutputType = {
invoice_number: number
invoice_date: Date
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id: string | null
notes: string | null
unknown_customer: runtime.JsonValue | null
@@ -294,6 +301,7 @@ export type SalesInvoiceWhereInput = {
invoice_number?: Prisma.IntFilter<"SalesInvoice"> | number
invoice_date?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string
type?: Prisma.EnumTspProviderRequestTypeFilter<"SalesInvoice"> | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFilter<"SalesInvoice"> | $Enums.InvoiceSettlementType
tax_id?: Prisma.StringNullableFilter<"SalesInvoice"> | string | null
notes?: Prisma.StringNullableFilter<"SalesInvoice"> | string | null
unknown_customer?: Prisma.JsonNullableFilter<"SalesInvoice">
@@ -321,6 +329,7 @@ export type SalesInvoiceOrderByWithRelationInput = {
invoice_number?: Prisma.SortOrder
invoice_date?: Prisma.SortOrder
type?: Prisma.SortOrder
settlement_type?: Prisma.SortOrder
tax_id?: Prisma.SortOrderInput | Prisma.SortOrder
notes?: Prisma.SortOrderInput | Prisma.SortOrder
unknown_customer?: Prisma.SortOrderInput | Prisma.SortOrder
@@ -355,6 +364,7 @@ export type SalesInvoiceWhereUniqueInput = Prisma.AtLeast<{
invoice_number?: Prisma.IntFilter<"SalesInvoice"> | number
invoice_date?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string
type?: Prisma.EnumTspProviderRequestTypeFilter<"SalesInvoice"> | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFilter<"SalesInvoice"> | $Enums.InvoiceSettlementType
notes?: Prisma.StringNullableFilter<"SalesInvoice"> | string | null
unknown_customer?: Prisma.JsonNullableFilter<"SalesInvoice">
created_at?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string
@@ -380,6 +390,7 @@ export type SalesInvoiceOrderByWithAggregationInput = {
invoice_number?: Prisma.SortOrder
invoice_date?: Prisma.SortOrder
type?: Prisma.SortOrder
settlement_type?: Prisma.SortOrder
tax_id?: Prisma.SortOrderInput | Prisma.SortOrder
notes?: Prisma.SortOrderInput | Prisma.SortOrder
unknown_customer?: Prisma.SortOrderInput | Prisma.SortOrder
@@ -407,6 +418,7 @@ export type SalesInvoiceScalarWhereWithAggregatesInput = {
invoice_number?: Prisma.IntWithAggregatesFilter<"SalesInvoice"> | number
invoice_date?: Prisma.DateTimeWithAggregatesFilter<"SalesInvoice"> | Date | string
type?: Prisma.EnumTspProviderRequestTypeWithAggregatesFilter<"SalesInvoice"> | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeWithAggregatesFilter<"SalesInvoice"> | $Enums.InvoiceSettlementType
tax_id?: Prisma.StringNullableWithAggregatesFilter<"SalesInvoice"> | string | null
notes?: Prisma.StringNullableWithAggregatesFilter<"SalesInvoice"> | string | null
unknown_customer?: Prisma.JsonNullableWithAggregatesFilter<"SalesInvoice">
@@ -426,6 +438,7 @@ export type SalesInvoiceCreateInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -449,6 +462,7 @@ export type SalesInvoiceUncheckedCreateInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -472,6 +486,7 @@ export type SalesInvoiceUpdateInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -495,6 +510,7 @@ export type SalesInvoiceUncheckedUpdateInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -518,6 +534,7 @@ export type SalesInvoiceCreateManyInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -537,6 +554,7 @@ export type SalesInvoiceUpdateManyMutationInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -552,6 +570,7 @@ export type SalesInvoiceUncheckedUpdateManyInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -597,6 +616,7 @@ export type SalesInvoiceCountOrderByAggregateInput = {
invoice_number?: Prisma.SortOrder
invoice_date?: Prisma.SortOrder
type?: Prisma.SortOrder
settlement_type?: Prisma.SortOrder
tax_id?: Prisma.SortOrder
notes?: Prisma.SortOrder
unknown_customer?: Prisma.SortOrder
@@ -621,6 +641,7 @@ export type SalesInvoiceMaxOrderByAggregateInput = {
invoice_number?: Prisma.SortOrder
invoice_date?: Prisma.SortOrder
type?: Prisma.SortOrder
settlement_type?: Prisma.SortOrder
tax_id?: Prisma.SortOrder
notes?: Prisma.SortOrder
created_at?: Prisma.SortOrder
@@ -639,6 +660,7 @@ export type SalesInvoiceMinOrderByAggregateInput = {
invoice_number?: Prisma.SortOrder
invoice_date?: Prisma.SortOrder
type?: Prisma.SortOrder
settlement_type?: Prisma.SortOrder
tax_id?: Prisma.SortOrder
notes?: Prisma.SortOrder
created_at?: Prisma.SortOrder
@@ -808,6 +830,10 @@ export type EnumTspProviderRequestTypeFieldUpdateOperationsInput = {
set?: $Enums.TspProviderRequestType
}
export type EnumInvoiceSettlementTypeFieldUpdateOperationsInput = {
set?: $Enums.InvoiceSettlementType
}
export type SalesInvoiceUpdateOneWithoutReferenced_byNestedInput = {
create?: Prisma.XOR<Prisma.SalesInvoiceCreateWithoutReferenced_byInput, Prisma.SalesInvoiceUncheckedCreateWithoutReferenced_byInput>
connectOrCreate?: Prisma.SalesInvoiceCreateOrConnectWithoutReferenced_byInput
@@ -887,6 +913,7 @@ export type SalesInvoiceCreateWithoutConsumer_accountInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -909,6 +936,7 @@ export type SalesInvoiceUncheckedCreateWithoutConsumer_accountInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -960,6 +988,7 @@ export type SalesInvoiceScalarWhereInput = {
invoice_number?: Prisma.IntFilter<"SalesInvoice"> | number
invoice_date?: Prisma.DateTimeFilter<"SalesInvoice"> | Date | string
type?: Prisma.EnumTspProviderRequestTypeFilter<"SalesInvoice"> | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFilter<"SalesInvoice"> | $Enums.InvoiceSettlementType
tax_id?: Prisma.StringNullableFilter<"SalesInvoice"> | string | null
notes?: Prisma.StringNullableFilter<"SalesInvoice"> | string | null
unknown_customer?: Prisma.JsonNullableFilter<"SalesInvoice">
@@ -979,6 +1008,7 @@ export type SalesInvoiceCreateWithoutPosInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1001,6 +1031,7 @@ export type SalesInvoiceUncheckedCreateWithoutPosInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1049,6 +1080,7 @@ export type SalesInvoiceCreateWithoutCustomerInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1071,6 +1103,7 @@ export type SalesInvoiceUncheckedCreateWithoutCustomerInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1119,6 +1152,7 @@ export type SalesInvoiceCreateWithoutReferenced_byInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1141,6 +1175,7 @@ export type SalesInvoiceUncheckedCreateWithoutReferenced_byInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1168,6 +1203,7 @@ export type SalesInvoiceCreateWithoutReference_invoiceInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1190,6 +1226,7 @@ export type SalesInvoiceUncheckedCreateWithoutReference_invoiceInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1228,6 +1265,7 @@ export type SalesInvoiceUpdateWithoutReferenced_byInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1250,6 +1288,7 @@ export type SalesInvoiceUncheckedUpdateWithoutReferenced_byInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1283,6 +1322,7 @@ export type SalesInvoiceUpdateWithoutReference_invoiceInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1305,6 +1345,7 @@ export type SalesInvoiceUncheckedUpdateWithoutReference_invoiceInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1327,6 +1368,7 @@ export type SalesInvoiceCreateWithoutItemsInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1349,6 +1391,7 @@ export type SalesInvoiceUncheckedCreateWithoutItemsInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1387,6 +1430,7 @@ export type SalesInvoiceUpdateWithoutItemsInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1409,6 +1453,7 @@ export type SalesInvoiceUncheckedUpdateWithoutItemsInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1431,6 +1476,7 @@ export type SalesInvoiceCreateWithoutTsp_attemptsInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1453,6 +1499,7 @@ export type SalesInvoiceUncheckedCreateWithoutTsp_attemptsInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1491,6 +1538,7 @@ export type SalesInvoiceUpdateWithoutTsp_attemptsInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1513,6 +1561,7 @@ export type SalesInvoiceUncheckedUpdateWithoutTsp_attemptsInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1535,6 +1584,7 @@ export type SalesInvoiceCreateWithoutPaymentsInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1557,6 +1607,7 @@ export type SalesInvoiceUncheckedCreateWithoutPaymentsInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1595,6 +1646,7 @@ export type SalesInvoiceUpdateWithoutPaymentsInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1617,6 +1669,7 @@ export type SalesInvoiceUncheckedUpdateWithoutPaymentsInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1639,6 +1692,7 @@ export type SalesInvoiceCreateManyConsumer_accountInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1657,6 +1711,7 @@ export type SalesInvoiceUpdateWithoutConsumer_accountInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1679,6 +1734,7 @@ export type SalesInvoiceUncheckedUpdateWithoutConsumer_accountInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1701,6 +1757,7 @@ export type SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1719,6 +1776,7 @@ export type SalesInvoiceCreateManyPosInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1737,6 +1795,7 @@ export type SalesInvoiceUpdateWithoutPosInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1759,6 +1818,7 @@ export type SalesInvoiceUncheckedUpdateWithoutPosInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1781,6 +1841,7 @@ export type SalesInvoiceUncheckedUpdateManyWithoutPosInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1799,6 +1860,7 @@ export type SalesInvoiceCreateManyCustomerInput = {
invoice_number: number
invoice_date?: Date | string
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id?: string | null
notes?: string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1817,6 +1879,7 @@ export type SalesInvoiceUpdateWithoutCustomerInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1839,6 +1902,7 @@ export type SalesInvoiceUncheckedUpdateWithoutCustomerInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1861,6 +1925,7 @@ export type SalesInvoiceUncheckedUpdateManyWithoutCustomerInput = {
invoice_number?: Prisma.IntFieldUpdateOperationsInput | number
invoice_date?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
type?: Prisma.EnumTspProviderRequestTypeFieldUpdateOperationsInput | $Enums.TspProviderRequestType
settlement_type?: Prisma.EnumInvoiceSettlementTypeFieldUpdateOperationsInput | $Enums.InvoiceSettlementType
tax_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
unknown_customer?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue
@@ -1928,6 +1993,7 @@ export type SalesInvoiceSelect<ExtArgs extends runtime.Types.Extensions.Internal
invoice_number?: boolean
invoice_date?: boolean
type?: boolean
settlement_type?: boolean
tax_id?: boolean
notes?: boolean
unknown_customer?: boolean
@@ -1958,6 +2024,7 @@ export type SalesInvoiceSelectScalar = {
invoice_number?: boolean
invoice_date?: boolean
type?: boolean
settlement_type?: boolean
tax_id?: boolean
notes?: boolean
unknown_customer?: boolean
@@ -1970,7 +2037,7 @@ export type SalesInvoiceSelectScalar = {
pos_id?: boolean
}
export type SalesInvoiceOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "code" | "total_amount" | "invoice_number" | "invoice_date" | "type" | "tax_id" | "notes" | "unknown_customer" | "created_at" | "updated_at" | "main_id" | "ref_id" | "customer_id" | "consumer_account_id" | "pos_id", ExtArgs["result"]["salesInvoice"]>
export type SalesInvoiceOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "code" | "total_amount" | "invoice_number" | "invoice_date" | "type" | "settlement_type" | "tax_id" | "notes" | "unknown_customer" | "created_at" | "updated_at" | "main_id" | "ref_id" | "customer_id" | "consumer_account_id" | "pos_id", ExtArgs["result"]["salesInvoice"]>
export type SalesInvoiceInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
reference_invoice?: boolean | Prisma.SalesInvoice$reference_invoiceArgs<ExtArgs>
customer?: boolean | Prisma.SalesInvoice$customerArgs<ExtArgs>
@@ -2002,6 +2069,7 @@ export type $SalesInvoicePayload<ExtArgs extends runtime.Types.Extensions.Intern
invoice_number: number
invoice_date: Date
type: $Enums.TspProviderRequestType
settlement_type: $Enums.InvoiceSettlementType
tax_id: string | null
notes: string | null
unknown_customer: runtime.JsonValue | null
@@ -2395,6 +2463,7 @@ export interface SalesInvoiceFieldRefs {
readonly invoice_number: Prisma.FieldRef<"SalesInvoice", 'Int'>
readonly invoice_date: Prisma.FieldRef<"SalesInvoice", 'DateTime'>
readonly type: Prisma.FieldRef<"SalesInvoice", 'TspProviderRequestType'>
readonly settlement_type: Prisma.FieldRef<"SalesInvoice", 'InvoiceSettlementType'>
readonly tax_id: Prisma.FieldRef<"SalesInvoice", 'String'>
readonly notes: Prisma.FieldRef<"SalesInvoice", 'String'>
readonly unknown_customer: Prisma.FieldRef<"SalesInvoice", 'Json'>
@@ -23,6 +23,8 @@ export class StatisticsService {
pending_count: number | null
not_sended_amount_sum: number | null
not_sended_count: number | null
credit_amount_sum: number | null
credit_count: number | null
}>
>`
SELECT
@@ -35,19 +37,21 @@ export class StatisticsService {
SUM(CASE WHEN la.status = ${TspProviderResponseStatus.QUEUED} THEN si.total_amount ELSE 0 END) AS pending_amount_sum,
SUM(CASE WHEN la.status = ${TspProviderResponseStatus.QUEUED} THEN 1 ELSE 0 END) AS pending_count,
SUM(CASE WHEN la.status IS NULL THEN si.total_amount ELSE 0 END) AS not_sended_amount_sum,
SUM(CASE WHEN la.status IS NULL THEN 1 ELSE 0 END) AS not_sended_count
SUM(CASE WHEN la.status IS NULL THEN 1 ELSE 0 END) AS not_sended_count,
SUM(CASE WHEN si.settlement_type = 'CREDIT' THEN si.total_amount ELSE 0 END) AS credit_amount_sum,
SUM(CASE WHEN si.settlement_type = 'CREDIT' THEN 1 ELSE 0 END) AS credit_count
FROM sales_invoices si
INNER JOIN poses p ON p.id = si.pos_id
LEFT JOIN (
SELECT a1.invoice_id, a1.status
FROM sale_invoice_tsp_attempts a1
SELECT att.invoice_id, att.status
FROM sale_invoice_tsp_attempts att
INNER JOIN (
SELECT invoice_id, MAX(attempt_no) AS max_attempt_no
FROM sale_invoice_tsp_attempts
GROUP BY invoice_id
) latest
ON latest.invoice_id = a1.invoice_id
AND latest.max_attempt_no = a1.attempt_no
ON latest.invoice_id = att.invoice_id
AND latest.max_attempt_no = att.attempt_no
) la ON la.invoice_id = si.id
WHERE si.invoice_date >= ${seasonDate.start}
AND si.invoice_date <= ${seasonDate.end}
@@ -55,6 +59,11 @@ export class StatisticsService {
AND p.complex_id IN (
SELECT c.id FROM complexes c WHERE c.business_activity_id = ${businessId}
)
AND NOT EXISTS (
SELECT 1
FROM sales_invoices child
WHERE child.ref_id = si.id
)
`
return ResponseMapper.single({
@@ -83,6 +92,11 @@ export class StatisticsService {
total_tax: Number(0),
count: Number(item?.not_sended_count || 0),
},
credit: {
total_amount: Number(item?.credit_amount_sum || 0),
total_tax: Number(0),
count: Number(item?.credit_count || 0),
},
})
}
}
@@ -5,6 +5,7 @@ import {
} from '@/common/services/saleInvoices/sale-invoice-create.dto'
import {
CustomerType,
InvoiceSettlementType,
InvoiceTemplateType,
PaymentMethodType,
TspProviderRequestType,
@@ -208,6 +209,10 @@ export class TspProviderOriginalSendPayloadDto {
@ApiProperty({ required: true })
@IsString()
tsp_token: string
@ApiProperty({ required: true, enum: InvoiceSettlementType })
@IsEnum(InvoiceSettlementType)
settlement_type: InvoiceSettlementType
}
export class TspProviderSendItemResultDto {
@@ -288,6 +288,7 @@ export class SalesInvoiceTspService {
items: dataToUpdate.items,
total_amount: dataToUpdate.total_amount,
customer_id: relatedInvoice.customer_id || undefined,
settlement_type: relatedInvoice.settlement_type,
},
businessId,
complexId,
@@ -320,8 +321,7 @@ export class SalesInvoiceTspService {
)
if (result?.hasError) {
result.provider_request_payload =
result.provider_request_payload ||
JSON.parse(JSON.stringify(correctionPayload))
result.provider_request_payload || JSON.parse(JSON.stringify(correctionPayload))
result.sent_at = result.sent_at || new Date().toISOString()
result.received_at = result.received_at || new Date().toISOString()
}
@@ -472,6 +472,7 @@ export class SalesInvoiceTspService {
customer_type: relatedInvoice.customer?.type || CustomerType.UNKNOWN,
invoice_date: new Date(),
payments,
settlement_type: relatedInvoice.settlement_type,
items: relatedInvoice.items.map(item => ({
unit_price: Number(item.unit_price),
quantity: Number(item.quantity),
@@ -168,9 +168,17 @@ export class NamaProviderHeaderDto {
@IsString()
bid: string
@ApiProperty({ required: true, description: 'روش تسویه' })
@ApiProperty({ required: true, description: 'روش تسویه (۱.نقدی، ۲.نسیه، ۳.نقدی-نسیه)' })
@IsString()
setm: string
setm: '1' | '2' | '3'
@ApiProperty({ description: 'سهم پرداخت نقدی در صورتی که نقدی - نسیه باشد (۳)' })
@IsString()
cap: string
@ApiProperty({ description: 'سهم پرداخت نسیه در صورتی که نقدی - نسیه باشد (۳)' })
@IsString()
insp: string
}
export class NamaProviderRequestDto {
@@ -508,9 +516,17 @@ export class NamaProviderCorrectionHeaderDto {
@IsString()
bid: string
@ApiProperty({ required: true, description: 'روش تسویه' })
@ApiProperty({ required: true, description: 'روش تسویه (۱.نقدی، ۲.نسیه، ۳.نقدی-نسیه)' })
@IsString()
setm: string
setm: '1' | '2' | '3'
@ApiProperty({ description: 'سهم پرداخت نقدی در صورتی که نقدی - نسیه باشد (۳)' })
@IsString()
cap: string
@ApiProperty({ description: 'سهم پرداخت نسیه در صورتی که نقدی - نسیه باشد (۳)' })
@IsString()
insp: string
}
export class NamaProviderCorrectionRequestDto {
@@ -1,6 +1,7 @@
import { TspProviderCustomerType } from '@/common/enums/enums'
import {
CustomerType,
InvoiceSettlementType,
InvoiceTemplateType,
PaymentMethodType,
TspProviderRequestType,
@@ -54,7 +55,11 @@ export class NamaProviderUtils {
inno: payload.invoice_number.toString(),
tins: '',
indatim: payload.invoice_date.getTime() + '',
setm: '1',
...this.mapSettlementBased(
payload.settlement_type,
payload.payments,
payload.total_amount,
),
...this.mapCustomerInfo(payload.customer),
},
body: payload.items.map(item => ({
@@ -134,6 +139,41 @@ export class NamaProviderUtils {
}
}
private mapSettlementType(type: InvoiceSettlementType) {
switch (type) {
case InvoiceSettlementType.CASH:
return '1'
case InvoiceSettlementType.CREDIT:
return '2'
case InvoiceSettlementType.MIXED:
return '3'
}
}
private mapSettlementBased(
type: InvoiceSettlementType,
payments: PaymentInfoDto[],
totalAmount: number,
) {
switch (type) {
case InvoiceSettlementType.CASH:
return {
setm: '1',
}
case InvoiceSettlementType.CREDIT:
return {
setm: '2',
}
case InvoiceSettlementType.MIXED:
const totalPayed = payments.reduce((prev, curr) => (prev += curr.amount), 0)
return {
setm: '3',
cap: totalPayed.toString(),
insp: (totalAmount - totalPayed).toString(),
}
}
}
private mapInvoiceTemplate(template: InvoiceTemplateType) {
switch (template) {
case InvoiceTemplateType.SALE: