some update

This commit is contained in:
2026-05-30 19:05:56 +03:30
parent 7ae027633b
commit c11166b365
6 changed files with 49 additions and 39 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ export default {
SUN: 'سان',
},
TspProviderResponseStatus: {
[TspProviderResponseStatus.SUCCESS]: 'موفق',
[TspProviderResponseStatus.SUCCESS]: 'تایید شده',
[TspProviderResponseStatus.FAILURE]: 'ناموفق',
[TspProviderResponseStatus.NOT_SEND]: 'ارسال نشده',
[TspProviderResponseStatus.QUEUED]: 'در صف ارسال',
@@ -95,7 +95,7 @@ export class ResponseMappingInterceptor implements NestInterceptor {
meta = {
totalRecords: total,
totalPages: Math.max(1, Math.ceil(total / perPage)),
page,
page: parseInt(page),
perPage,
}
break
@@ -188,7 +188,7 @@ export class ResponseMappingInterceptor implements NestInterceptor {
meta = {
totalRecords: total,
totalPages: Math.max(1, Math.ceil(total / perPage)),
page,
page: parseInt(page),
perPage,
}
}
@@ -47,8 +47,8 @@ export class SalesInvoicesFilterDto {
@ApiPropertyOptional()
@IsOptional()
@IsString()
code?: string
@IsNumber()
invoice_number?: number
@ApiPropertyOptional()
@IsOptional()
@@ -163,10 +163,8 @@ export class SalesInvoicesService {
},
}
if (query.code?.trim()) {
where.code = {
contains: query.code.trim(),
}
if (query.invoice_number) {
where.invoice_number = parseInt(query.invoice_number + '')
}
if (query.invoice_date_from || query.invoice_date_to) {
@@ -287,17 +287,17 @@ export async function buildCorrectionPayload(
customer:
invoice.customer && invoice.customer.type !== 'UNKNOWN'
? {
type: invoice.customer.type,
legal_info: invoice.customer.legal ?? undefined,
individual_info: invoice.customer.individual ?? undefined,
}
type: invoice.customer.type,
legal_info: invoice.customer.legal ?? undefined,
individual_info: invoice.customer.individual ?? undefined,
}
: {
type: 'UNKNOWN',
unknown_info: {
name: unknown_customer?.name || '',
economic_code: unknown_customer?.economic_code || '',
type: 'UNKNOWN',
unknown_info: {
name: unknown_customer?.name || '',
economic_code: unknown_customer?.economic_code || '',
},
},
},
}
}
@@ -420,7 +420,16 @@ export async function buildOriginalPayload(
throw new NotFoundException('فاکتور مورد نظر یافت نشد.')
}
const { pos, id, invoice_number, invoice_date, total_amount, discount_amount, tax_amount, settlement_type } = invoice
const {
pos,
id,
invoice_number,
invoice_date,
total_amount,
discount_amount,
tax_amount,
settlement_type,
} = invoice
const { business_activity: ba } = pos.complex
const unknown_customer = (invoice.unknown_customer || {}) as Record<string, string>
@@ -453,17 +462,17 @@ export async function buildOriginalPayload(
customer:
invoice.customer && invoice.customer.type !== 'UNKNOWN'
? {
type: invoice.customer.type,
legal_info: invoice.customer.legal ?? undefined,
individual_info: invoice.customer.individual ?? undefined,
}
type: invoice.customer.type,
legal_info: invoice.customer.legal ?? undefined,
individual_info: invoice.customer.individual ?? undefined,
}
: {
type: 'UNKNOWN',
unknown_info: {
name: unknown_customer?.name || '',
economic_code: unknown_customer?.economic_code || '',
type: 'UNKNOWN',
unknown_info: {
name: unknown_customer?.name || '',
economic_code: unknown_customer?.economic_code || '',
},
},
},
items: invoice.items.map(item => ({
invoice_item_id: item.id,
quantity: Number(item.quantity),
@@ -478,9 +487,7 @@ export async function buildOriginalPayload(
good_id: item.good_id,
service_id: item.service_id,
good_snapshot: item.good_snapshot,
gold_type_payload: isGoldTypePayload(item.payload)
? item.payload
: undefined
gold_type_payload: isGoldTypePayload(item.payload) ? item.payload : undefined,
})),
}
}
@@ -512,7 +519,6 @@ export async function onResult(
provider_request_payload: result['provider_request_payload']
? JSON.parse(JSON.stringify(result['provider_request_payload']))
: undefined,
provider_response: JSON.parse(JSON.stringify(result.provider_response)),
status: result.status,
received_at: result.received_at || new Date().toISOString(),
message: resultMessage
@@ -525,12 +531,19 @@ export async function onResult(
tax_id: result['tax_id'] ? result['tax_id'] : undefined,
},
},
error_message: result.error_message || undefined,
}
if (result.hasError) {
attemptUpdatedData.error_message = result.error_message
if (result.provider_response) {
attemptUpdatedData.provider_response = JSON.parse(
JSON.stringify(result.provider_response),
)
}
if (result.validation_errors) {
attemptUpdatedData.validation_errors = JSON.parse(
JSON.stringify(result.validation_errors),
)
}
if (result.fiscal_warnings) {
attemptUpdatedData.fiscal_warnings = JSON.parse(
JSON.stringify(result.fiscal_warnings),
)
@@ -562,7 +575,6 @@ export async function onResult(
}
}
function isGoldTypePayload(value: unknown): value is goldTypePayload {
return typeof value === 'object' && value !== null && !Array.isArray(value);
return typeof value === 'object' && value !== null && !Array.isArray(value)
}