feat: enhance business activities and sale invoices handling with new query constants and pagination support
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { BusinessActivitySelect } from '@/generated/prisma/models'
|
||||
|
||||
export const summarySelect: BusinessActivitySelect = {
|
||||
id: true,
|
||||
name: true,
|
||||
economic_code: true,
|
||||
created_at: true,
|
||||
fiscal_id: true,
|
||||
invoice_number_sequence: true,
|
||||
partner_token: true,
|
||||
guild: {
|
||||
select: {
|
||||
id: true,
|
||||
code: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
license_activation: {
|
||||
select: {
|
||||
id: true,
|
||||
starts_at: true,
|
||||
expires_at: true,
|
||||
license: {
|
||||
select: {
|
||||
activation: {
|
||||
select: {
|
||||
_count: {
|
||||
select: {
|
||||
account_allocations: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export const select: BusinessActivitySelect = {
|
||||
...summarySelect,
|
||||
}
|
||||
|
||||
export const mappedData = (businessActivity: any) => {
|
||||
const { license_activation, ...rest } = businessActivity
|
||||
const { license, ...license_activation_rest } = license_activation
|
||||
const { _count } = license.activation
|
||||
|
||||
return {
|
||||
...rest,
|
||||
license_info: {
|
||||
...license_activation_rest,
|
||||
accounts_limit: _count.account_allocations,
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user