feat: update activation expiration handling and enhance payload structure in transaction services
This commit is contained in:
@@ -24,9 +24,10 @@ export const summarySelect: BusinessActivitySelect = {
|
|||||||
select: {
|
select: {
|
||||||
activation: {
|
activation: {
|
||||||
select: {
|
select: {
|
||||||
_count: {
|
account_allocations: {
|
||||||
select: {
|
select: {
|
||||||
account_allocations: true,
|
id: true,
|
||||||
|
account_id: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -44,13 +45,18 @@ export const select: BusinessActivitySelect = {
|
|||||||
export const mappedData = (businessActivity: any) => {
|
export const mappedData = (businessActivity: any) => {
|
||||||
const { license_activation, ...rest } = businessActivity
|
const { license_activation, ...rest } = businessActivity
|
||||||
const { license, ...license_activation_rest } = license_activation
|
const { license, ...license_activation_rest } = license_activation
|
||||||
const { _count } = license.activation
|
const { account_allocations } = license.activation
|
||||||
|
|
||||||
|
console.log('license_activation', license_activation)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
license_info: {
|
license_info: {
|
||||||
...license_activation_rest,
|
...license_activation_rest,
|
||||||
accounts_limit: _count.account_allocations,
|
accounts_limit: account_allocations.length,
|
||||||
|
allocated_account_count: account_allocations.filter(
|
||||||
|
allocation => allocation.account_id,
|
||||||
|
).length,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -105,7 +105,9 @@ export class PartnerAccountChargeTransactionService {
|
|||||||
try {
|
try {
|
||||||
createdTransaction = await tx.partnerAccountQuotaChargeTransaction.create({
|
createdTransaction = await tx.partnerAccountQuotaChargeTransaction.create({
|
||||||
data: {
|
data: {
|
||||||
activation_expires_at: data.activated_expires_at,
|
activation_expires_at: data.activated_expires_at
|
||||||
|
? new Date(data.activated_expires_at).toISOString()
|
||||||
|
: new Date().toISOString(),
|
||||||
tracking_code: generateTrackingCode('AQC', this.TRACKING_CODE_LENGTH),
|
tracking_code: generateTrackingCode('AQC', this.TRACKING_CODE_LENGTH),
|
||||||
purchased_count: data.quantity,
|
purchased_count: data.quantity,
|
||||||
partner: { connect: { id: partner_id } },
|
partner: { connect: { id: partner_id } },
|
||||||
|
|||||||
+3
-1
@@ -121,7 +121,9 @@ export class PartnerLicenseChargeTransactionService {
|
|||||||
try {
|
try {
|
||||||
createdTransaction = await tx.licenseChargeTransaction.create({
|
createdTransaction = await tx.licenseChargeTransaction.create({
|
||||||
data: {
|
data: {
|
||||||
activation_expires_at: data.activated_expires_at,
|
activation_expires_at: data.activated_expires_at
|
||||||
|
? new Date(data.activated_expires_at).toISOString()
|
||||||
|
: new Date().toISOString(),
|
||||||
tracking_code: generateTrackingCode('LIC', this.TRACKING_CODE_LENGTH),
|
tracking_code: generateTrackingCode('LIC', this.TRACKING_CODE_LENGTH),
|
||||||
purchased_count: data.quantity,
|
purchased_count: data.quantity,
|
||||||
partner: { connect: { id: partner_id } },
|
partner: { connect: { id: partner_id } },
|
||||||
|
|||||||
@@ -419,6 +419,9 @@ export async function buildOriginalPayload(
|
|||||||
select: {
|
select: {
|
||||||
stan: true,
|
stan: true,
|
||||||
rrn: true,
|
rrn: true,
|
||||||
|
transaction_date_time: true,
|
||||||
|
customer_card_no: true,
|
||||||
|
terminal_id: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -465,7 +468,9 @@ export async function buildOriginalPayload(
|
|||||||
payment_method: payment.payment_method,
|
payment_method: payment.payment_method,
|
||||||
paid_at: payment.paid_at,
|
paid_at: payment.paid_at,
|
||||||
terminal_info: {
|
terminal_info: {
|
||||||
card_number: payment.terminal_info ? payment.terminal_info.stan : undefined,
|
card_number: payment.terminal_info?.customer_card_no
|
||||||
|
? payment.terminal_info.customer_card_no
|
||||||
|
: undefined,
|
||||||
tracking_code: payment.terminal_info ? payment.terminal_info.rrn : undefined,
|
tracking_code: payment.terminal_info ? payment.terminal_info.rrn : undefined,
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
|
|||||||
Reference in New Issue
Block a user