update switch providers and nama provider. fix original send
This commit is contained in:
@@ -0,0 +1,257 @@
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { Type } from 'class-transformer'
|
||||
import {
|
||||
IsArray,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Min,
|
||||
ValidateNested,
|
||||
} from 'class-validator'
|
||||
|
||||
export enum NamaProviderResponseStatus {
|
||||
POSTED = 'POSTED',
|
||||
PENDING = 'PENDING',
|
||||
IN_PROGRESS = 'IN_PROGRESS',
|
||||
SUCCESS = 'SUCCESS',
|
||||
VALIDATION_ERROR = 'VALIDATION_ERROR',
|
||||
FAILED = 'FAILED',
|
||||
}
|
||||
|
||||
export class NamaProviderPaymentInfoDto {
|
||||
@ApiProperty({ required: true, description: 'روش پرداخت با توجه به PaymentMethodType' })
|
||||
@IsNumber()
|
||||
pmt: number
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'مبلغ پرداختی. در صورتی که روش تسویه نسیه باشد برابر با ۰ است',
|
||||
})
|
||||
@IsNumber({ allowInfinity: false, allowNaN: false })
|
||||
@Min(0)
|
||||
pv: number
|
||||
|
||||
@ApiProperty({ required: false, description: 'شمارهی پیگیری' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
trn?: string
|
||||
|
||||
@ApiProperty({ required: false, description: 'شمارهی کارت پرداخت کنندهی صورتحساب' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
pcn?: string
|
||||
|
||||
@ApiProperty({ required: false, description: 'تاریخ و زمان پرداخت صورتحساب unix' })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
pdt?: string
|
||||
}
|
||||
|
||||
export class NamaProviderCommonHeaderDto {
|
||||
@ApiProperty({ required: true, description: 'الگوی صورتحساب' })
|
||||
@IsString()
|
||||
inp: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'نوع صورتحساب' })
|
||||
@IsString()
|
||||
inty: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'سریال صورتحساب داخلی حافظه مالیاتی' })
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
// @ApiProperty({ required: true })
|
||||
// @IsString()
|
||||
// tins: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'تاریخ و زمان صدور صورتحساب به صورت timestamp',
|
||||
})
|
||||
@IsString()
|
||||
indatim: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'نام مشتری' })
|
||||
@IsString()
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
required: false,
|
||||
description:
|
||||
'نوع شخصیت خریدار (در صورتیکه خریدار نوع ۲ باشه باید ۱ یا ۲ گذاشته بشه)',
|
||||
})
|
||||
@IsString()
|
||||
tob: string
|
||||
|
||||
@ApiProperty({ description: 'آدرس' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
address?: string
|
||||
|
||||
@ApiProperty({ description: 'شماره موبایل' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
mobile?: string
|
||||
|
||||
@ApiProperty({
|
||||
description: `شماره ملی / شناسه ملی / شناسه مشارکت مدنی / کد فراگیر خریدار`,
|
||||
})
|
||||
@IsString()
|
||||
bid: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'روش تسویه (۱.نقدی، ۲.نسیه، ۳.نقدی-نسیه)' })
|
||||
@IsString()
|
||||
setm: '1' | '2' | '3'
|
||||
|
||||
@ApiProperty({ description: 'سهم پرداخت نقدی در صورتی که نقدی - نسیه باشد (۳)' })
|
||||
@IsString()
|
||||
cap: string
|
||||
|
||||
@ApiProperty({ description: 'سهم پرداخت نسیه در صورتی که نقدی - نسیه باشد (۳)' })
|
||||
@IsString()
|
||||
insp: string
|
||||
}
|
||||
|
||||
export class NamaProviderCommonBodyDto {
|
||||
@ApiProperty({ required: true, description: 'شناسه کالا / خدمت' })
|
||||
@IsString()
|
||||
sstid: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: `نرخ مالیات بر ارزش افزوده`,
|
||||
})
|
||||
@IsString()
|
||||
vra: string
|
||||
|
||||
// @ApiProperty()
|
||||
// @IsString()
|
||||
// sstt: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'مبلغ واحد',
|
||||
})
|
||||
@IsString()
|
||||
fee: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'مبلغ تخفیف',
|
||||
})
|
||||
@IsString()
|
||||
dis: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'واحد اندازه گیری',
|
||||
})
|
||||
@IsString()
|
||||
mu: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'تعداد / مقدار',
|
||||
})
|
||||
@IsString()
|
||||
am: string
|
||||
|
||||
@ApiProperty({
|
||||
description: ' اجرت ساخت (طلا)',
|
||||
})
|
||||
@IsString()
|
||||
consfee: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'حق العمل',
|
||||
})
|
||||
@IsString()
|
||||
bros: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'سود فروشنده',
|
||||
})
|
||||
@IsString()
|
||||
spro: string
|
||||
}
|
||||
|
||||
export class NamaProviderApiErrorItemDto {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
message: string
|
||||
}
|
||||
|
||||
export class NamaProviderTSPValidationErrorsDto {
|
||||
@ApiProperty({ type: [NamaProviderApiErrorItemDto], required: false })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderApiErrorItemDto)
|
||||
error?: NamaProviderApiErrorItemDto[]
|
||||
|
||||
@ApiProperty({ type: [NamaProviderApiErrorItemDto], required: false })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderApiErrorItemDto)
|
||||
warning?: NamaProviderApiErrorItemDto[]
|
||||
}
|
||||
|
||||
export class NamaProviderValidationErrorDto {
|
||||
@IsString()
|
||||
key: string
|
||||
|
||||
@IsString()
|
||||
errorKeyPosition: string
|
||||
|
||||
@IsString()
|
||||
message: string
|
||||
|
||||
@IsNumber()
|
||||
errorKeyIndex: number
|
||||
}
|
||||
|
||||
export class NamaProviderResponseDto {
|
||||
@ApiProperty({ description: 'شناسه پیگیری فاکتور' })
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
message: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
status: NamaProviderResponseStatus
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
reference_number: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
tax_id?: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
error_message: string
|
||||
|
||||
@ApiProperty({ type: [NamaProviderValidationErrorDto] })
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
validation_error: NamaProviderValidationErrorDto[]
|
||||
|
||||
@ApiProperty({ type: [NamaProviderTSPValidationErrorsDto], required: false })
|
||||
@IsOptional()
|
||||
tax_api_response?: NamaProviderTSPValidationErrorsDto[]
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { Type } from 'class-transformer'
|
||||
import { IsArray, IsString, Length, ValidateNested } from 'class-validator'
|
||||
import {
|
||||
NamaProviderCommonBodyDto,
|
||||
NamaProviderCommonHeaderDto,
|
||||
NamaProviderPaymentInfoDto,
|
||||
NamaProviderResponseDto,
|
||||
} from './common.dto'
|
||||
|
||||
export class NamaProviderCorrectionHeaderDto extends NamaProviderCommonHeaderDto {
|
||||
@ApiProperty({ required: true, description: 'موضوع صورتحساب (2- اصلاحی)' })
|
||||
@IsString()
|
||||
ins: '2'
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'شناسه مالیاتی صورتحساب مرجع',
|
||||
minLength: 22,
|
||||
maxLength: 22,
|
||||
})
|
||||
@IsString()
|
||||
@Length(22, 22)
|
||||
irtaxid: string
|
||||
}
|
||||
|
||||
export class NamaProviderCorrectionBodyItemDto extends NamaProviderCommonBodyDto {}
|
||||
|
||||
export class NamaProviderCorrectionRequestDto {
|
||||
@ApiProperty({ type: [NamaProviderCorrectionBodyItemDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderCorrectionBodyItemDto)
|
||||
body: NamaProviderCorrectionBodyItemDto[]
|
||||
|
||||
@ApiProperty({ type: [NamaProviderPaymentInfoDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderPaymentInfoDto)
|
||||
payment: NamaProviderPaymentInfoDto[]
|
||||
|
||||
@ApiProperty({ type: NamaProviderCorrectionHeaderDto })
|
||||
@ValidateNested()
|
||||
@Type(() => NamaProviderCorrectionHeaderDto)
|
||||
header: NamaProviderCorrectionHeaderDto
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
economic_code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
fiscal_id: string
|
||||
}
|
||||
|
||||
export class NamaProviderCorrectionResponseDto extends NamaProviderResponseDto {}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { ApiProperty, OmitType } from '@nestjs/swagger'
|
||||
import { IsString } from 'class-validator'
|
||||
import { NamaProviderResponseDto } from './common.dto'
|
||||
|
||||
export class NamaProviderGetResponseDto extends OmitType(NamaProviderResponseDto, [
|
||||
'tax_id',
|
||||
]) {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
tax_id: string
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export * from './common.dto'
|
||||
export * from './correction.dto'
|
||||
export * from './get.dto'
|
||||
export * from './original.dto'
|
||||
export * from './revoke.dto'
|
||||
@@ -0,0 +1,50 @@
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { Type } from 'class-transformer'
|
||||
import { IsArray, IsString, ValidateNested } from 'class-validator'
|
||||
import {
|
||||
NamaProviderCommonBodyDto,
|
||||
NamaProviderCommonHeaderDto,
|
||||
NamaProviderPaymentInfoDto,
|
||||
NamaProviderResponseDto,
|
||||
} from './common.dto'
|
||||
|
||||
export class NamaProviderOriginalHeaderDto extends NamaProviderCommonHeaderDto {
|
||||
@ApiProperty({ required: true, description: 'موضوع صورتحساب (1- اصلی)' })
|
||||
@IsString()
|
||||
ins: '1'
|
||||
}
|
||||
|
||||
export class NamaProviderOriginalBodyItemDto extends NamaProviderCommonBodyDto {}
|
||||
|
||||
export class NamaProviderOriginalRequestDto {
|
||||
@ApiProperty({ type: [NamaProviderOriginalBodyItemDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderOriginalBodyItemDto)
|
||||
body: NamaProviderOriginalBodyItemDto[]
|
||||
|
||||
@ApiProperty({ type: [NamaProviderPaymentInfoDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderPaymentInfoDto)
|
||||
payment: NamaProviderPaymentInfoDto[]
|
||||
|
||||
@ApiProperty({ type: NamaProviderOriginalHeaderDto })
|
||||
@ValidateNested()
|
||||
@Type(() => NamaProviderOriginalHeaderDto)
|
||||
header: NamaProviderOriginalHeaderDto
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
economic_code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
fiscal_id: string
|
||||
}
|
||||
|
||||
export class NamaProviderOriginalResponseDto extends NamaProviderResponseDto {}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { ApiProperty, OmitType } from '@nestjs/swagger'
|
||||
import { Type } from 'class-transformer'
|
||||
import { IsString, ValidateNested } from 'class-validator'
|
||||
import { NamaProviderResponseDto } from './common.dto'
|
||||
|
||||
export class NamaProviderRevokeHeaderDto {
|
||||
@ApiProperty({ required: true, description: 'موضوع صورتحساب (3- ابطالی)' })
|
||||
@IsString()
|
||||
ins: '3'
|
||||
|
||||
@ApiProperty({ required: true, description: 'سریال صورتحساب داخلی حافظه مالیاتی' })
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'تاریخ و زمان صدور صورتحساب به صورت timestamp',
|
||||
})
|
||||
@IsString()
|
||||
indatim: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'آخرین شماره مالیاتی دریافت شده مربوط به فاکتور',
|
||||
})
|
||||
@IsString()
|
||||
irtaxid: string
|
||||
}
|
||||
export class NamaProviderRevokeRequestDto {
|
||||
@ApiProperty({ type: NamaProviderRevokeHeaderDto })
|
||||
@ValidateNested()
|
||||
@Type(() => NamaProviderRevokeHeaderDto)
|
||||
header: NamaProviderRevokeHeaderDto
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
economic_code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
fiscal_id: string
|
||||
}
|
||||
|
||||
export class NamaProviderRevokeResponseDto extends OmitType(NamaProviderResponseDto, [
|
||||
'tax_id',
|
||||
]) {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
tax_id: string
|
||||
}
|
||||
@@ -7,23 +7,25 @@ import { HttpClientUtil } from '@/common/utils/http-client.util'
|
||||
import { TspProviderResponseStatus } from '@/generated/prisma/enums'
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import {
|
||||
IProviderSwitchAdapter,
|
||||
TspProviderBulkSendResultDto,
|
||||
TspProviderCorrectionSendPayloadDto,
|
||||
TspProviderCorrectionSendResponseDto,
|
||||
TspProviderGetResultDto,
|
||||
TspProviderOriginalSendItemResultDto,
|
||||
TspProviderOriginalSendPayloadDto,
|
||||
TspProviderRevokePayloadDto,
|
||||
TspProviderRevokeResponseDto,
|
||||
TspProviderSendItemResultDto,
|
||||
} from '../../dto'
|
||||
import {
|
||||
IProviderSwitchAdapter,
|
||||
TspProviderBulkSendResultDto,
|
||||
} from '../../dto/provider-switch.dto'
|
||||
import {
|
||||
NamaProviderGetResponseDto,
|
||||
NamaProviderOriginalResponseDto,
|
||||
NamaProviderResponseStatus,
|
||||
NamaProviderRevokeRequestDto,
|
||||
NamaProviderRevokeResponseDto,
|
||||
NamaProviderSendItemResponseDto,
|
||||
} from './nama-provider.dto'
|
||||
} from './dto'
|
||||
import { NamaProviderUtils } from './nama-provider.util'
|
||||
|
||||
@Injectable()
|
||||
@@ -77,8 +79,8 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
|
||||
async originalSend(
|
||||
payload: TspProviderOriginalSendPayloadDto,
|
||||
): Promise<TspProviderSendItemResultDto> {
|
||||
const mappedRequest = this.namaProviderUtils.mapToNamaRequestDto(payload)
|
||||
): Promise<TspProviderOriginalSendItemResultDto> {
|
||||
const mappedRequest = this.namaProviderUtils.mapToNamaOriginalRequestDto(payload)
|
||||
try {
|
||||
const response = await this.httpClient.request(
|
||||
this.buildSendUrl(),
|
||||
@@ -86,20 +88,23 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mappedRequest),
|
||||
},
|
||||
this.createRequestInterceptors(payload.tsp_token),
|
||||
this.createRequestInterceptors(payload.token),
|
||||
)
|
||||
const providerResponse: NamaProviderSendItemResponseDto = await response.json()
|
||||
this.logger.debug('NAMA provider response', providerResponse)
|
||||
const providerResponse: NamaProviderOriginalResponseDto = await response.json()
|
||||
this.logger.debug('NAMA provider response', response)
|
||||
this.logger.debug('NAMA provider providerResponse', providerResponse)
|
||||
|
||||
const result: TspProviderSendItemResultDto = {
|
||||
invoice_id: payload.invoice_id,
|
||||
const result: TspProviderOriginalSendItemResultDto = {
|
||||
invoice_id: payload.id,
|
||||
provider_request_payload: JSON.parse(JSON.stringify(mappedRequest)),
|
||||
hasError: !response.ok,
|
||||
message: providerResponse.message,
|
||||
provider_response_payload: JSON.parse(JSON.stringify(providerResponse)),
|
||||
received_at: providerResponse.tsp_update_time,
|
||||
sent_at: new Date().toISOString(),
|
||||
received_at: new Date().toISOString(),
|
||||
provider_response: JSON.parse(JSON.stringify(providerResponse)),
|
||||
tax_id: providerResponse.tax_id,
|
||||
error_message: providerResponse.error_message,
|
||||
fiscal_warnings: providerResponse.tax_api_response,
|
||||
validation_errors: providerResponse.validation_error,
|
||||
status: this.namaProviderUtils.mapResponseStatus(
|
||||
providerResponse.status as NamaProviderResponseStatus,
|
||||
),
|
||||
@@ -108,24 +113,22 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
return result
|
||||
} catch (err) {
|
||||
this.logger.error('NAMA send failed', err)
|
||||
const failure: TspProviderSendItemResultDto = {
|
||||
invoice_id: payload.invoice_id,
|
||||
const failure: TspProviderOriginalSendItemResultDto = {
|
||||
invoice_id: payload.id,
|
||||
provider_request_payload: JSON.parse(JSON.stringify(mappedRequest)),
|
||||
hasError: true,
|
||||
message: (err as Error).message,
|
||||
sent_at: new Date().toISOString(),
|
||||
received_at: new Date().toISOString(),
|
||||
tax_id: null,
|
||||
status: TspProviderResponseStatus.NOT_SEND,
|
||||
status: TspProviderResponseStatus.SEND_FAILURE,
|
||||
}
|
||||
throw failure
|
||||
return failure
|
||||
}
|
||||
}
|
||||
|
||||
async correctionSend(
|
||||
payload: TspProviderCorrectionSendPayloadDto,
|
||||
): Promise<TspProviderCorrectionSendResponseDto> {
|
||||
const mappedRequest = this.namaProviderUtils.mapToNamaRequestDto(payload)
|
||||
const mappedRequest = this.namaProviderUtils.mapToNamaOriginalRequestDto(payload)
|
||||
|
||||
try {
|
||||
const response = await this.httpClient.request(
|
||||
@@ -134,19 +137,18 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(mappedRequest),
|
||||
},
|
||||
this.createRequestInterceptors(payload.tsp_token),
|
||||
this.createRequestInterceptors(payload.token),
|
||||
)
|
||||
const providerResponse: NamaProviderSendItemResponseDto = await response.json()
|
||||
const providerResponse: NamaProviderOriginalResponseDto = await response.json()
|
||||
this.logger.debug('NAMA provider response', providerResponse)
|
||||
|
||||
const result: TspProviderSendItemResultDto = {
|
||||
invoice_id: payload.invoice_id,
|
||||
const result: TspProviderOriginalSendItemResultDto = {
|
||||
invoice_id: payload.id,
|
||||
provider_request_payload: JSON.parse(JSON.stringify(mappedRequest)),
|
||||
hasError: !response.ok,
|
||||
message: providerResponse.message,
|
||||
sent_at: new Date().toISOString(),
|
||||
provider_response_payload: JSON.parse(JSON.stringify(providerResponse)),
|
||||
received_at: providerResponse.tsp_update_time,
|
||||
provider_response: JSON.parse(JSON.stringify(providerResponse)),
|
||||
received_at: new Date().toISOString(),
|
||||
tax_id: providerResponse.tax_id,
|
||||
status: this.namaProviderUtils.mapResponseStatus(
|
||||
providerResponse.status as NamaProviderResponseStatus,
|
||||
@@ -156,12 +158,11 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
return result
|
||||
} catch (err) {
|
||||
this.logger.error('NAMA send failed', err)
|
||||
const failure: TspProviderSendItemResultDto = {
|
||||
invoice_id: payload.invoice_id,
|
||||
const failure: TspProviderOriginalSendItemResultDto = {
|
||||
invoice_id: payload.id,
|
||||
provider_request_payload: JSON.parse(JSON.stringify(mappedRequest)),
|
||||
hasError: true,
|
||||
message: (err as Error).message,
|
||||
sent_at: new Date().toISOString(),
|
||||
received_at: new Date().toISOString(),
|
||||
tax_id: null,
|
||||
status: TspProviderResponseStatus.NOT_SEND,
|
||||
@@ -177,7 +178,7 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
for (const payload of payloads) {
|
||||
const itemResults = await this.originalSend(payload)
|
||||
result.push({
|
||||
invoice_id: payload.invoice_id,
|
||||
invoice_id: payload.id,
|
||||
items: [itemResults],
|
||||
})
|
||||
}
|
||||
@@ -201,7 +202,7 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
message: providerResponse.message,
|
||||
provider_response_payload: providerResponse,
|
||||
sent_at: new Date().toISOString(),
|
||||
received_at: providerResponse.tsp_update_time || new Date().toISOString(),
|
||||
received_at: new Date().toISOString(),
|
||||
tax_id: providerResponse.tax_id,
|
||||
status: this.namaProviderUtils.mapResponseStatus(
|
||||
providerResponse.status as NamaProviderResponseStatus,
|
||||
@@ -228,7 +229,7 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
payload: TspProviderRevokePayloadDto,
|
||||
): Promise<TspProviderRevokeResponseDto> {
|
||||
const mappedRequest: NamaProviderRevokeRequestDto =
|
||||
this.namaProviderUtils.mapRevokeToNamaRequestDto(payload)
|
||||
this.namaProviderUtils.mapToNamaRevokeRequestDto(payload)
|
||||
|
||||
this.logger.debug('NAMA provider response', mappedRequest)
|
||||
|
||||
@@ -251,7 +252,7 @@ export class NamaProviderSwitchAdapter implements IProviderSwitchAdapter {
|
||||
message: providerResponse.message,
|
||||
sent_at: new Date().toISOString(),
|
||||
provider_response_payload: providerResponse,
|
||||
received_at: providerResponse.tsp_update_time,
|
||||
received_at: new Date().toISOString(),
|
||||
tax_id: providerResponse.tax_id,
|
||||
status: this.namaProviderUtils.mapResponseStatus(
|
||||
providerResponse.status as NamaProviderResponseStatus,
|
||||
|
||||
@@ -1,561 +0,0 @@
|
||||
import { TspProviderResponseStatus } from '@/generated/prisma/enums'
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { Type } from 'class-transformer'
|
||||
import {
|
||||
IsArray,
|
||||
IsEnum,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Min,
|
||||
ValidateNested,
|
||||
} from 'class-validator'
|
||||
|
||||
export enum NamaProviderResponseStatus {
|
||||
POSTED = 'SUCCESS',
|
||||
PENDING = 'PENDING',
|
||||
IN_PROGRESS = 'IN_PROGRESS',
|
||||
SUCCESS = 'SUCCESS',
|
||||
FAILED = 'FAILED',
|
||||
}
|
||||
|
||||
export class NamaProviderPaymentInfoDto {
|
||||
@ApiProperty({ required: true, description: 'روش پرداخت' })
|
||||
@IsNumber()
|
||||
pmt: number
|
||||
|
||||
@ApiProperty({ required: true, description: 'مبلغ پرداختی' })
|
||||
@IsNumber()
|
||||
@Min(10_000)
|
||||
pv: number
|
||||
|
||||
@ApiProperty({ required: false, description: 'شمارهی پیگیری' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
trn?: string
|
||||
|
||||
@ApiProperty({ required: false, description: 'شمارهی کارت پرداخت کنندهی صورتحساب' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
pcn?: string
|
||||
|
||||
@ApiProperty({ required: false, description: 'تاریخ و زمان پرداخت صورتحساب unix' })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
pdt?: string
|
||||
}
|
||||
|
||||
export class NamaProviderBodyItemDto {
|
||||
@ApiProperty({ required: true, description: 'شناسه کالا / خدمت' })
|
||||
@IsString()
|
||||
sstid: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: `نرخ مالیات بر ارزش افزوده`,
|
||||
})
|
||||
@IsString()
|
||||
vra: string
|
||||
|
||||
// @ApiProperty()
|
||||
// @IsString()
|
||||
// sstt: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'مبلغ واحد',
|
||||
})
|
||||
@IsString()
|
||||
fee: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'مبلغ تخفیف',
|
||||
})
|
||||
@IsString()
|
||||
dis: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'واحد اندازه گیری',
|
||||
})
|
||||
@IsString()
|
||||
mu: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'تعداد / مقدار',
|
||||
})
|
||||
@IsString()
|
||||
am: string
|
||||
|
||||
@ApiProperty({
|
||||
description: ' اجرت ساخت (طلا)',
|
||||
})
|
||||
@IsString()
|
||||
consfee: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'حق العمل',
|
||||
})
|
||||
@IsString()
|
||||
bros: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'سود فروشنده',
|
||||
})
|
||||
@IsString()
|
||||
spro: string
|
||||
}
|
||||
|
||||
export class NamaProviderHeaderDto {
|
||||
@ApiProperty({ required: true, description: 'موضوع صورتحساب' })
|
||||
@IsString()
|
||||
ins: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'الگوی صورتحساب' })
|
||||
@IsString()
|
||||
inp: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'نوع صورتحساب' })
|
||||
@IsString()
|
||||
inty: string
|
||||
|
||||
// @ApiProperty({required: true})
|
||||
// @IsString()
|
||||
// unique_tax_code: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'سریال صورتحساب داخلی حافظه مالیاتی' })
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
// @ApiProperty({ required: true })
|
||||
// @IsString()
|
||||
// tins: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'تاریخ و زمان صدور صورتحساب به صورت timestamp',
|
||||
})
|
||||
@IsString()
|
||||
indatim: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'نام مشتری' })
|
||||
@IsString()
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
required: false,
|
||||
description:
|
||||
'نوع شخصیت خریدار (در صورتیکه خریدار نوع ۲ باشه باید ۱ یا ۲ گذاشته بشه)',
|
||||
})
|
||||
@IsString()
|
||||
tob: string
|
||||
|
||||
@ApiProperty({ description: 'آدرس' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
address?: string
|
||||
|
||||
@ApiProperty({ description: 'شماره موبایل' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
mobile?: string
|
||||
|
||||
@ApiProperty({
|
||||
description: `شماره ملی / شناسه ملی / شناسه مشارکت مدنی / کد فراگیر خریدار`,
|
||||
})
|
||||
@IsString()
|
||||
bid: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'روش تسویه (۱.نقدی، ۲.نسیه، ۳.نقدی-نسیه)' })
|
||||
@IsString()
|
||||
setm: '1' | '2' | '3'
|
||||
|
||||
@ApiProperty({ description: 'سهم پرداخت نقدی در صورتی که نقدی - نسیه باشد (۳)' })
|
||||
@IsString()
|
||||
cap: string
|
||||
|
||||
@ApiProperty({ description: 'سهم پرداخت نسیه در صورتی که نقدی - نسیه باشد (۳)' })
|
||||
@IsString()
|
||||
insp: string
|
||||
}
|
||||
|
||||
export class NamaProviderRequestDto {
|
||||
@ApiProperty({ type: [NamaProviderBodyItemDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderBodyItemDto)
|
||||
body: NamaProviderBodyItemDto[]
|
||||
|
||||
@ApiProperty({ type: [NamaProviderPaymentInfoDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderPaymentInfoDto)
|
||||
payment: NamaProviderPaymentInfoDto[]
|
||||
|
||||
@ApiProperty({ type: NamaProviderHeaderDto })
|
||||
@ValidateNested()
|
||||
@Type(() => NamaProviderHeaderDto)
|
||||
header: NamaProviderHeaderDto
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
economic_code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
fiscal_id: string
|
||||
}
|
||||
|
||||
export class NamaProviderApiErrorItemDto {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
message: string
|
||||
}
|
||||
|
||||
export class NamaProviderApiErrorResponseDto {
|
||||
@ApiProperty({ type: [NamaProviderApiErrorItemDto], required: false })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderApiErrorItemDto)
|
||||
error?: NamaProviderApiErrorItemDto
|
||||
}
|
||||
|
||||
export class NamaProviderSendItemResponseDto {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
message: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
status: NamaProviderResponseStatus
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
tax_id: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
reference_number: string
|
||||
|
||||
@ApiProperty({ type: () => NamaProviderApiErrorResponseDto, required: false })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => NamaProviderApiErrorResponseDto)
|
||||
tax_api_response?: NamaProviderApiErrorResponseDto
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
tsp_update_time: string
|
||||
}
|
||||
|
||||
export class NamaProviderGetResponseDto {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
message: string
|
||||
|
||||
@ApiProperty({ enum: TspProviderResponseStatus })
|
||||
@IsEnum(TspProviderResponseStatus)
|
||||
status: TspProviderResponseStatus
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
tax_id: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
reference_number: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
tsp_update_time: string
|
||||
}
|
||||
|
||||
export class NamaProviderRevokeHeaderDto {
|
||||
@ApiProperty({ required: true, description: 'موضوع صورتحساب' })
|
||||
@IsString()
|
||||
ins: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'سریال صورتحساب داخلی حافظه مالیاتی' })
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'تاریخ و زمان صدور صورتحساب به صورت timestamp',
|
||||
})
|
||||
@IsString()
|
||||
indatim: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'آخرین شماره مالیاتی دریافت شده مربوط به فاکتور',
|
||||
})
|
||||
@IsString()
|
||||
irtaxid: string
|
||||
}
|
||||
export class NamaProviderRevokeRequestDto {
|
||||
// @ApiProperty({ type: [NamaProviderBodyItemDto] })
|
||||
// @IsArray()
|
||||
// @ValidateNested({ each: true })
|
||||
// @Type(() => NamaProviderBodyItemDto)
|
||||
// body: NamaProviderBodyItemDto[]
|
||||
|
||||
// @ApiProperty({ type: [NamaProviderPaymentInfoDto] })
|
||||
// @IsArray()
|
||||
// @ValidateNested({ each: true })
|
||||
// @Type(() => NamaProviderPaymentInfoDto)
|
||||
// payment: NamaProviderPaymentInfoDto[]
|
||||
// @ApiProperty({ type: Object, required: true })
|
||||
// @IsObject()
|
||||
// body: {}
|
||||
|
||||
@ApiProperty({ type: NamaProviderRevokeHeaderDto })
|
||||
@ValidateNested()
|
||||
@Type(() => NamaProviderRevokeHeaderDto)
|
||||
header: NamaProviderRevokeHeaderDto
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
economic_code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
fiscal_id: string
|
||||
}
|
||||
|
||||
export class NamaProviderRevokeResponseDto {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
message: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
status: NamaProviderResponseStatus
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
tax_id: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
reference_number: string
|
||||
|
||||
@ApiProperty({ type: () => NamaProviderApiErrorResponseDto, required: false })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => NamaProviderApiErrorResponseDto)
|
||||
tax_api_response?: NamaProviderApiErrorResponseDto
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
tsp_update_time: string
|
||||
}
|
||||
|
||||
/////////////// Correction DTOs ///////////////
|
||||
export class NamaProviderCorrectionBodyItemDto {
|
||||
@ApiProperty({ required: true, description: 'شناسه کالا / خدمت' })
|
||||
@IsString()
|
||||
sstid: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: `نرخ مالیات بر ارزش افزوده`,
|
||||
})
|
||||
@IsString()
|
||||
vra: string
|
||||
|
||||
// @ApiProperty()
|
||||
// @IsString()
|
||||
// sstt: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'مبلغ واحد',
|
||||
})
|
||||
@IsString()
|
||||
fee: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'مبلغ تخفیف',
|
||||
})
|
||||
@IsString()
|
||||
dis: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'واحد اندازه گیری',
|
||||
})
|
||||
@IsString()
|
||||
mu: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'تعداد / مقدار',
|
||||
})
|
||||
@IsString()
|
||||
am: string
|
||||
|
||||
@ApiProperty({
|
||||
description: ' اجرت ساخت (طلا)',
|
||||
})
|
||||
@IsString()
|
||||
consfee: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'حق العمل',
|
||||
})
|
||||
@IsString()
|
||||
bros: string
|
||||
|
||||
@ApiProperty({
|
||||
description: 'سود فروشنده',
|
||||
})
|
||||
@IsString()
|
||||
spro: string
|
||||
}
|
||||
|
||||
export class NamaProviderCorrectionHeaderDto {
|
||||
@ApiProperty({ required: true, description: 'موضوع صورتحساب' })
|
||||
@IsString()
|
||||
ins: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'الگوی صورتحساب' })
|
||||
@IsString()
|
||||
inp: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'نوع صورتحساب' })
|
||||
@IsString()
|
||||
inty: string
|
||||
|
||||
// @ApiProperty({required: true})
|
||||
// @IsString()
|
||||
// unique_tax_code: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'سریال صورتحساب داخلی حافظه مالیاتی' })
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
// @ApiProperty({ required: true })
|
||||
// @IsString()
|
||||
// tins: string
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: 'تاریخ و زمان صدور صورتحساب به صورت timestamp',
|
||||
})
|
||||
@IsString()
|
||||
indatim: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'نام مشتری' })
|
||||
@IsString()
|
||||
name: string
|
||||
|
||||
@ApiProperty({
|
||||
required: false,
|
||||
description:
|
||||
'نوع شخصیت خریدار (در صورتیکه خریدار نوع ۲ باشه باید ۱ یا ۲ گذاشته بشه)',
|
||||
})
|
||||
@IsString()
|
||||
tob: string
|
||||
|
||||
@ApiProperty({ description: 'آدرس' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
address?: string
|
||||
|
||||
@ApiProperty({ description: 'شماره موبایل' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
mobile?: string
|
||||
|
||||
@ApiProperty({
|
||||
description: `شماره ملی / شناسه ملی / شناسه مشارکت مدنی / کد فراگیر خریدار`,
|
||||
})
|
||||
@IsString()
|
||||
bid: string
|
||||
|
||||
@ApiProperty({ required: true, description: 'روش تسویه (۱.نقدی، ۲.نسیه، ۳.نقدی-نسیه)' })
|
||||
@IsString()
|
||||
setm: '1' | '2' | '3'
|
||||
|
||||
@ApiProperty({ description: 'سهم پرداخت نقدی در صورتی که نقدی - نسیه باشد (۳)' })
|
||||
@IsString()
|
||||
cap: string
|
||||
|
||||
@ApiProperty({ description: 'سهم پرداخت نسیه در صورتی که نقدی - نسیه باشد (۳)' })
|
||||
@IsString()
|
||||
insp: string
|
||||
}
|
||||
|
||||
export class NamaProviderCorrectionRequestDto {
|
||||
@ApiProperty({ type: [NamaProviderCorrectionBodyItemDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderCorrectionBodyItemDto)
|
||||
body: NamaProviderCorrectionBodyItemDto[]
|
||||
|
||||
@ApiProperty({ type: [NamaProviderPaymentInfoDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaProviderPaymentInfoDto)
|
||||
payment: NamaProviderPaymentInfoDto[]
|
||||
|
||||
@ApiProperty({ type: NamaProviderCorrectionHeaderDto })
|
||||
@ValidateNested()
|
||||
@Type(() => NamaProviderCorrectionHeaderDto)
|
||||
header: NamaProviderCorrectionHeaderDto
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
economic_code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
fiscal_id: string
|
||||
}
|
||||
@@ -13,45 +13,45 @@ import {
|
||||
TspProviderCorrectionSendPayloadDto,
|
||||
TspProviderOriginalSendPayloadDto,
|
||||
TspProviderRevokePayloadDto,
|
||||
} from '../../dto/provider-switch.dto'
|
||||
} from '../../dto'
|
||||
import {
|
||||
NamaProviderCorrectionRequestDto,
|
||||
NamaProviderOriginalRequestDto,
|
||||
NamaProviderPaymentInfoDto,
|
||||
NamaProviderRequestDto,
|
||||
NamaProviderResponseStatus,
|
||||
NamaProviderRevokeRequestDto,
|
||||
} from './nama-provider.dto'
|
||||
} from './dto'
|
||||
|
||||
export class NamaProviderUtils {
|
||||
mapResponseStatus(status: NamaProviderResponseStatus): TspProviderResponseStatus {
|
||||
console.log('NAMA status', status)
|
||||
|
||||
switch (status.toUpperCase()) {
|
||||
case NamaProviderResponseStatus.SUCCESS:
|
||||
case NamaProviderResponseStatus.POSTED:
|
||||
return TspProviderResponseStatus.FISCAL_QUEUED
|
||||
case NamaProviderResponseStatus.SUCCESS:
|
||||
return TspProviderResponseStatus.SUCCESS
|
||||
case NamaProviderResponseStatus.PENDING:
|
||||
case NamaProviderResponseStatus.IN_PROGRESS:
|
||||
return TspProviderResponseStatus.QUEUED
|
||||
case NamaProviderResponseStatus.FAILED:
|
||||
return TspProviderResponseStatus.FAILURE
|
||||
case NamaProviderResponseStatus.PENDING:
|
||||
case NamaProviderResponseStatus.IN_PROGRESS:
|
||||
default:
|
||||
return TspProviderResponseStatus.QUEUED
|
||||
}
|
||||
}
|
||||
|
||||
mapToNamaRequestDto(
|
||||
mapToNamaOriginalRequestDto(
|
||||
payload: TspProviderOriginalSendPayloadDto,
|
||||
): NamaProviderRequestDto {
|
||||
): NamaProviderOriginalRequestDto {
|
||||
return {
|
||||
uuid: payload.invoice_id,
|
||||
uuid: payload.id,
|
||||
economic_code: payload.economic_code,
|
||||
fiscal_id: payload.fiscal_id,
|
||||
payment: this.mapPayments(payload.payments),
|
||||
header: {
|
||||
ins: this.mapTspProviderRequestType(payload.type),
|
||||
inp: this.mapInvoiceTemplate(payload.invoice_template),
|
||||
inty: this.mapTspProviderCustomerType(payload.customer_type),
|
||||
ins: '1',
|
||||
inp: this.mapInvoiceTemplate(payload.template),
|
||||
inty: this.mapTspProviderCustomerType(payload.customer?.type),
|
||||
inno: payload.invoice_number.toString(),
|
||||
tins: '',
|
||||
indatim: payload.invoice_date.getTime() + '',
|
||||
@@ -81,14 +81,14 @@ export class NamaProviderUtils {
|
||||
payload: TspProviderCorrectionSendPayloadDto,
|
||||
): NamaProviderCorrectionRequestDto {
|
||||
return {
|
||||
uuid: payload.invoice_id,
|
||||
uuid: payload.id,
|
||||
economic_code: payload.economic_code,
|
||||
fiscal_id: payload.fiscal_id,
|
||||
payment: this.mapPayments(payload.payments),
|
||||
header: {
|
||||
ins: this.mapTspProviderRequestType(TspProviderRequestType.CORRECTION),
|
||||
inp: this.mapInvoiceTemplate(payload.invoice_template),
|
||||
inty: this.mapTspProviderCustomerType(payload.customer_type),
|
||||
ins: this.mapRequestType(TspProviderRequestType.CORRECTION),
|
||||
inp: this.mapInvoiceTemplate(payload.template),
|
||||
inty: this.mapTspProviderCustomerType(payload.customer?.type),
|
||||
inno: payload.invoice_number.toString(),
|
||||
tins: '',
|
||||
indatim: payload.invoice_date.getTime() + '',
|
||||
@@ -110,7 +110,7 @@ export class NamaProviderUtils {
|
||||
}
|
||||
}
|
||||
|
||||
mapRevokeToNamaRequestDto(
|
||||
mapToNamaRevokeRequestDto(
|
||||
payload: TspProviderRevokePayloadDto,
|
||||
): NamaProviderRevokeRequestDto {
|
||||
return {
|
||||
@@ -119,14 +119,14 @@ export class NamaProviderUtils {
|
||||
fiscal_id: payload.fiscal_id,
|
||||
header: {
|
||||
inno: payload.invoice_number.toString(),
|
||||
ins: this.mapTspProviderRequestType(TspProviderRequestType.REVOKE),
|
||||
ins: '3',
|
||||
irtaxid: payload.last_tax_id,
|
||||
indatim: new Date().getTime() + '',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
private mapTspProviderRequestType(type: TspProviderRequestType) {
|
||||
private mapRequestType(type: TspProviderRequestType) {
|
||||
switch (type) {
|
||||
case TspProviderRequestType.ORIGINAL:
|
||||
return '1'
|
||||
@@ -206,9 +206,9 @@ export class NamaProviderUtils {
|
||||
case TspProviderCustomerType.KNOWN:
|
||||
return '1'
|
||||
case TspProviderCustomerType.UNKNOWN:
|
||||
return '2'
|
||||
default:
|
||||
return '3'
|
||||
return '2'
|
||||
// return '3'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,8 +267,8 @@ export class NamaProviderUtils {
|
||||
return payments.map(payment => ({
|
||||
pmt: this.mapPaymentMethod(payment.payment_method),
|
||||
pv: payment.amount,
|
||||
trn: payment.tracking_code,
|
||||
pcn: payment.card_number,
|
||||
trn: payment.terminal_info.tracking_code,
|
||||
pcn: payment.terminal_info.card_number,
|
||||
pdt: payment.paid_at ? String(payment.paid_at.getTime()) : undefined,
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user