Add omset milestone scheduler with owner role and revenue tracking
This commit is contained in:
@@ -99,3 +99,14 @@ func (r *OrganizationRepositoryImpl) GetByEmail(ctx context.Context, email strin
|
||||
}
|
||||
return &org, nil
|
||||
}
|
||||
|
||||
// GetTotalOmset returns the total revenue from completed orders for an organization.
|
||||
func (r *OrganizationRepositoryImpl) GetTotalOmset(ctx context.Context, organizationID uuid.UUID) (float64, error) {
|
||||
var total float64
|
||||
err := r.db.WithContext(ctx).
|
||||
Table("orders").
|
||||
Where("organization_id = ? AND payment_status = ?", organizationID, "completed").
|
||||
Select("COALESCE(SUM(total_amount), 0)").
|
||||
Scan(&total).Error
|
||||
return total, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user