This commit is contained in:
phaichayon
2026-06-25 16:26:14 +07:00
parent 69279fc341
commit 5a83040077
11 changed files with 547 additions and 64 deletions

View File

@@ -47,6 +47,17 @@ type ProjectPartyTableAvailability = {
let projectPartyTableAvailability: ProjectPartyTableAvailability | null = null;
const outcomeOpportunitySelect = {
id: crmOpportunities.id,
customerId: crmOpportunities.customerId,
branchId: crmOpportunities.branchId,
productType: crmOpportunities.productType,
assignedToUserId: crmOpportunities.assignedToUserId,
poAmount: crmOpportunities.poAmount,
closedWonAt: crmOpportunities.closedWonAt,
closedLostAt: crmOpportunities.closedLostAt
} as const;
function splitFilterValue(value?: string) {
return value
?.split(',')
@@ -412,7 +423,7 @@ async function getOutcomeRevenueRecords(
): Promise<OutcomeRevenueRecord[]> {
const whereFilters = buildOutcomeRevenueFilters(organizationId, stage, filters);
const where = whereFilters.length === 1 ? whereFilters[0] : and(...whereFilters);
const opportunities = await db.select().from(crmOpportunities).where(where);
const opportunities = await db.select(outcomeOpportunitySelect).from(crmOpportunities).where(where);
if (!opportunities.length) {
return [];
@@ -556,4 +567,3 @@ export async function getWinRate(
return Math.round((wonRows.length / denominator) * 10000) / 100;
}