Add omset milestone scheduler with owner role and revenue tracking

This commit is contained in:
2026-05-13 09:48:17 +07:00
parent 015292e830
commit d38a770ec5
4 changed files with 206 additions and 5 deletions
@@ -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
}