some update
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user