-
-
Save lipis/7564e99b6315a3940dbcb1a5c1a413a9 to your computer and use it in GitHub Desktop.
Prisma $extends
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const xprisma = prisma.$extends({ | |
result: { | |
statistic: { | |
salaryPercent: { | |
needs: { revenue: true, salary: true }, | |
compute(statistic) { | |
return statistic.revenue === 0 | |
? 0 | |
: Math.abs((statistic.salary / statistic.revenue) * 100); | |
}, | |
}, | |
expensePercent: { | |
needs: { revenue: true, expense: true }, | |
compute(statistic) { | |
return statistic.revenue === 0 | |
? 0 | |
: Math.abs((statistic.expense / statistic.revenue) * 100); | |
}, | |
}, | |
recurrentPercent: { | |
needs: { revenue: true, recurrent: true }, | |
compute(statistic) { | |
return statistic.revenue === 0 | |
? 0 | |
: Math.abs((statistic.recurrent / statistic.revenue) * 100); | |
}, | |
}, | |
vendorPercent: { | |
needs: { revenue: true, vendor: true }, | |
compute(statistic) { | |
return statistic.revenue === 0 | |
? 0 | |
: Math.abs((statistic.vendor / statistic.revenue) * 100); | |
}, | |
}, | |
reportPercent: { | |
needs: { revenue: true, report: true }, | |
compute(statistic) { | |
return statistic.revenue === 0 | |
? 0 | |
: Math.abs((statistic.report / statistic.revenue) * 100); | |
}, | |
}, | |
incomePercent: { | |
needs: { revenue: true, income: true }, | |
compute(statistic) { | |
return statistic.revenue === 0 | |
? 0 | |
: Math.abs((statistic.income / statistic.revenue) * 100); | |
}, | |
}, | |
sharePercent: { | |
needs: { revenue: true, share: true }, | |
compute(statistic) { | |
return statistic.revenue === 0 | |
? 0 | |
: Math.abs((statistic.share / statistic.revenue) * 100); | |
}, | |
}, | |
reservePercent: { | |
needs: { revenue: true, reserve: true }, | |
compute(statistic) { | |
return statistic.revenue === 0 | |
? 0 | |
: Math.abs((statistic.reserve / statistic.revenue) * 100); | |
}, | |
}, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment