feat: billing fixes

This commit is contained in:
=
2025-10-20 18:58:22 +05:30
parent 03e4918362
commit 8afc391e97
22 changed files with 103 additions and 52 deletions
+21 -1
View File
@@ -705,6 +705,25 @@ export const orgDALFactory = (db: TDbClient) => {
}
};
const findRootOrgDetails = async (orgId: string): Promise<TOrganizations | undefined> => {
try {
const org = await db
.replicaNode()(TableName.Organization)
.select(selectAllTableCols(TableName.Organization))
.where(
"id",
db(TableName.Organization)
.select(db.raw(`CASE WHEN "rootOrgId" IS NULL THEN id ELSE "rootOrgId" END`))
.where("id", orgId)
)
.first();
return org;
} catch (error) {
throw new DatabaseError({ error, name: "FindRootOrgDetails" });
}
};
return withTransaction(db, {
...orgOrm,
findOrgByProjectId,
@@ -728,6 +747,7 @@ export const orgDALFactory = (db: TDbClient) => {
deleteMembershipById,
deleteMembershipsById,
updateMembership,
findIdentityOrganization
findIdentityOrganization,
findRootOrgDetails
});
};