-
Notifications
You must be signed in to change notification settings - Fork 1
/
dashboard.sql.go
43 lines (37 loc) · 1.21 KB
/
dashboard.sql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.24.0
// source: dashboard.sql
package database
import (
"context"
"github.com/google/uuid"
)
const getInvoiceCounts = `-- name: GetInvoiceCounts :one
SELECT
SUM(CASE WHEN payment_status = 'paid' THEN 1 ELSE 0 END)::text AS paid_count,
SUM(CASE WHEN payment_status = 'unpaid' THEN 1 ELSE 0 END)::text AS unpaid_count,
SUM(CASE WHEN payment_status = 'partial_paid' THEN 1 ELSE 0 END)::text AS partial_paid_count,
SUM(CASE WHEN payment_status = 'overdue' THEN 1 ELSE 0 END)::text AS overdue_count
FROM
invoice
WHERE
business_id = $1
`
type GetInvoiceCountsRow struct {
PaidCount string `db:"paid_count" json:"paid_count"`
UnpaidCount string `db:"unpaid_count" json:"unpaid_count"`
PartialPaidCount string `db:"partial_paid_count" json:"partial_paid_count"`
OverdueCount string `db:"overdue_count" json:"overdue_count"`
}
func (q *Queries) GetInvoiceCounts(ctx context.Context, businessID uuid.UUID) (GetInvoiceCountsRow, error) {
row := q.db.QueryRow(ctx, getInvoiceCounts, businessID)
var i GetInvoiceCountsRow
err := row.Scan(
&i.PaidCount,
&i.UnpaidCount,
&i.PartialPaidCount,
&i.OverdueCount,
)
return i, err
}