// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.28.0
// source: exportcompany.sql

package db

import (
	"context"
	"database/sql"
	"time"
)

const allExporters = `-- name: AllExporters :many
SELECT id, expname, expregno, exprexno, expaddress1, expdistrict_id, expsubcounty_id, expvillage_id, expparish_id, registrationstatus, validitydate, expcompanyphone, expemail, created_at, logo FROM exportcompanies
`

func (q *Queries) AllExporters(ctx context.Context) ([]Exportcompany, error) {
	rows, err := q.db.QueryContext(ctx, allExporters)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Exportcompany{}
	for rows.Next() {
		var i Exportcompany
		if err := rows.Scan(
			&i.ID,
			&i.Expname,
			&i.Expregno,
			&i.Exprexno,
			&i.Expaddress1,
			&i.ExpdistrictID,
			&i.ExpsubcountyID,
			&i.ExpvillageID,
			&i.ExpparishID,
			&i.Registrationstatus,
			&i.Validitydate,
			&i.Expcompanyphone,
			&i.Expemail,
			&i.CreatedAt,
			&i.Logo,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const countCompletedQcp1s = `-- name: CountCompletedQcp1s :one
SELECT COUNT(id) from qcp1
where exportcompany_id = $1
AND status='Passed'
`

func (q *Queries) CountCompletedQcp1s(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countCompletedQcp1s, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countCompletedQcp2s = `-- name: CountCompletedQcp2s :one
SELECT COUNT(id) from qcp2
where exportcompany_id = $1
AND   status ='Passed'
`

func (q *Queries) CountCompletedQcp2s(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countCompletedQcp2s, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countCompletedQcp3s = `-- name: CountCompletedQcp3s :one
SELECT COUNT(id) from qcp3
where exportcompany_id = $1
AND status='FitForExport'
`

func (q *Queries) CountCompletedQcp3s(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countCompletedQcp3s, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countConsignmentForms = `-- name: CountConsignmentForms :one
SELECT COUNT(id) from plannedconsignments
where plannedconsignments.exportcompany_id = $1
`

func (q *Queries) CountConsignmentForms(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countConsignmentForms, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countExporterClients = `-- name: CountExporterClients :one
SELECT COUNT(id) from clients
where clients.exportcompany_id = $1
`

func (q *Queries) CountExporterClients(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countExporterClients, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countExporterFarmers = `-- name: CountExporterFarmers :one
SELECT COUNT(id) from farmer_exporter
where farmer_exporter.exportcompany_id = $1
`

func (q *Queries) CountExporterFarmers(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countExporterFarmers, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countExporterFarmersWithStatus = `-- name: CountExporterFarmersWithStatus :one
SELECT COUNT(farmers.id) FROM farmers
INNER JOIN farmer_exporter on farmer_exporter.farmer_id = farmers.id
WHERE farmer_exporter.exportcompany_id = $1
AND   farmers.status = $2
`

type CountExporterFarmersWithStatusParams struct {
	ExportcompanyID int32  `json:"exportcompany_id"`
	Status          string `json:"status"`
}

func (q *Queries) CountExporterFarmersWithStatus(ctx context.Context, arg CountExporterFarmersWithStatusParams) (int64, error) {
	row := q.db.QueryRowContext(ctx, countExporterFarmersWithStatus, arg.ExportcompanyID, arg.Status)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countExporterManagers = `-- name: CountExporterManagers :one
SELECT COUNT(users.id) from user_exporter
JOIN users on users.id = user_exporter.exportcompany_id
WHERE user_exporter.exportcompany_id = $1
AND   users.user_type = 'EXPORTER' OR users.user_type= 'MANAGER'
`

func (q *Queries) CountExporterManagers(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countExporterManagers, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countExporterPackinglists = `-- name: CountExporterPackinglists :one
SELECT COUNT(id) from packinglist
where exportcompany_id = $1
AND  status= 'Submitted'
`

func (q *Queries) CountExporterPackinglists(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countExporterPackinglists, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countExporterReceptionForms = `-- name: CountExporterReceptionForms :one
SELECT COUNT(id) from receptionform
where exportcompany_id = $1
AND  status= 'Submitted'
`

func (q *Queries) CountExporterReceptionForms(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countExporterReceptionForms, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countManagers = `-- name: CountManagers :one
SELECT COUNT(id) from users
where users.user_type = 'MANAGER'
`

func (q *Queries) CountManagers(ctx context.Context) (int64, error) {
	row := q.db.QueryRowContext(ctx, countManagers)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countOrders = `-- name: CountOrders :one
SELECT COUNT(id) from orders
where orders.exportcompany_id = $1
`

func (q *Queries) CountOrders(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countOrders, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countQualityControllers = `-- name: CountQualityControllers :one
SELECT COUNT(user_exporter.user_id) from user_exporter
JOIN   users on users.id = user_exporter.user_id
WHERE  user_exporter.exportcompany_id=$1
AND    users.user_type = 'QUALITY-CONTROLLER'
`

func (q *Queries) CountQualityControllers(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countQualityControllers, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const countReceptionForms = `-- name: CountReceptionForms :one
SELECT COUNT(id) from receptionform
where receptionform.exportcompany_id = $1
`

func (q *Queries) CountReceptionForms(ctx context.Context, exportcompanyID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, countReceptionForms, exportcompanyID)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const createExportCompany = `-- name: CreateExportCompany :one
INSERT INTO exportcompanies (
    expname,
    expregno,
    expaddress1,
    expdistrict_id,
    expvillage_id,
    expparish_id,
    expsubcounty_id,
    expcompanyphone,
    expemail,
    registrationstatus,
    validitydate
 ) VALUES (
    $1, $2, $3, $4, $5, $6, $7, $8, $9,$10,$11
 ) RETURNING id, expname, expregno, exprexno, expaddress1, expdistrict_id, expsubcounty_id, expvillage_id, expparish_id, registrationstatus, validitydate, expcompanyphone, expemail, created_at, logo
`

type CreateExportCompanyParams struct {
	Expname            string    `json:"expname"`
	Expregno           string    `json:"expregno"`
	Expaddress1        string    `json:"expaddress1"`
	ExpdistrictID      int32     `json:"expdistrict_id"`
	ExpvillageID       int32     `json:"expvillage_id"`
	ExpparishID        int32     `json:"expparish_id"`
	ExpsubcountyID     int32     `json:"expsubcounty_id"`
	Expcompanyphone    string    `json:"expcompanyphone"`
	Expemail           string    `json:"expemail"`
	Registrationstatus string    `json:"registrationstatus"`
	Validitydate       time.Time `json:"validitydate"`
}

func (q *Queries) CreateExportCompany(ctx context.Context, arg CreateExportCompanyParams) (Exportcompany, error) {
	row := q.db.QueryRowContext(ctx, createExportCompany,
		arg.Expname,
		arg.Expregno,
		arg.Expaddress1,
		arg.ExpdistrictID,
		arg.ExpvillageID,
		arg.ExpparishID,
		arg.ExpsubcountyID,
		arg.Expcompanyphone,
		arg.Expemail,
		arg.Registrationstatus,
		arg.Validitydate,
	)
	var i Exportcompany
	err := row.Scan(
		&i.ID,
		&i.Expname,
		&i.Expregno,
		&i.Exprexno,
		&i.Expaddress1,
		&i.ExpdistrictID,
		&i.ExpsubcountyID,
		&i.ExpvillageID,
		&i.ExpparishID,
		&i.Registrationstatus,
		&i.Validitydate,
		&i.Expcompanyphone,
		&i.Expemail,
		&i.CreatedAt,
		&i.Logo,
	)
	return i, err
}

const deactivateExportCompany = `-- name: DeactivateExportCompany :one
UPDATE exportcompanies
  set
    registrationstatus = $2
WHERE id = $1
RETURNING id, expname, expregno, exprexno, expaddress1, expdistrict_id, expsubcounty_id, expvillage_id, expparish_id, registrationstatus, validitydate, expcompanyphone, expemail, created_at, logo
`

type DeactivateExportCompanyParams struct {
	ID                 int64  `json:"id"`
	Registrationstatus string `json:"registrationstatus"`
}

func (q *Queries) DeactivateExportCompany(ctx context.Context, arg DeactivateExportCompanyParams) (Exportcompany, error) {
	row := q.db.QueryRowContext(ctx, deactivateExportCompany, arg.ID, arg.Registrationstatus)
	var i Exportcompany
	err := row.Scan(
		&i.ID,
		&i.Expname,
		&i.Expregno,
		&i.Exprexno,
		&i.Expaddress1,
		&i.ExpdistrictID,
		&i.ExpsubcountyID,
		&i.ExpvillageID,
		&i.ExpparishID,
		&i.Registrationstatus,
		&i.Validitydate,
		&i.Expcompanyphone,
		&i.Expemail,
		&i.CreatedAt,
		&i.Logo,
	)
	return i, err
}

const deleteExportCompany = `-- name: DeleteExportCompany :exec
DELETE FROM exportcompanies WHERE id= $1
`

func (q *Queries) DeleteExportCompany(ctx context.Context, id int64) error {
	_, err := q.db.ExecContext(ctx, deleteExportCompany, id)
	return err
}

const detachQcFromExporter = `-- name: DetachQcFromExporter :exec
DELETE from user_exporter
where exportcompany_id = $1
AND   user_id  = $2
RETURNING id, user_id, exportcompany_id, created_at
`

type DetachQcFromExporterParams struct {
	ExportcompanyID int32 `json:"exportcompany_id"`
	UserID          int32 `json:"user_id"`
}

func (q *Queries) DetachQcFromExporter(ctx context.Context, arg DetachQcFromExporterParams) error {
	_, err := q.db.ExecContext(ctx, detachQcFromExporter, arg.ExportcompanyID, arg.UserID)
	return err
}

const exportCompaniesPastExpiry = `-- name: ExportCompaniesPastExpiry :many
SELECT id, expname, expregno, exprexno, expaddress1, expdistrict_id, expsubcounty_id, expvillage_id, expparish_id, registrationstatus, validitydate, expcompanyphone, expemail, created_at, logo from exportcompanies where
validitydate < $1
`

func (q *Queries) ExportCompaniesPastExpiry(ctx context.Context, validitydate time.Time) ([]Exportcompany, error) {
	rows, err := q.db.QueryContext(ctx, exportCompaniesPastExpiry, validitydate)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Exportcompany{}
	for rows.Next() {
		var i Exportcompany
		if err := rows.Scan(
			&i.ID,
			&i.Expname,
			&i.Expregno,
			&i.Exprexno,
			&i.Expaddress1,
			&i.ExpdistrictID,
			&i.ExpsubcountyID,
			&i.ExpvillageID,
			&i.ExpparishID,
			&i.Registrationstatus,
			&i.Validitydate,
			&i.Expcompanyphone,
			&i.Expemail,
			&i.CreatedAt,
			&i.Logo,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const fetchCompanyLogo = `-- name: FetchCompanyLogo :one
Select logo from exportcompanies
where id = $1 LIMIT 1
`

func (q *Queries) FetchCompanyLogo(ctx context.Context, id int64) (sql.NullString, error) {
	row := q.db.QueryRowContext(ctx, fetchCompanyLogo, id)
	var logo sql.NullString
	err := row.Scan(&logo)
	return logo, err
}

const getExportCompany = `-- name: GetExportCompany :one
SELECT exportcompanies.id,exportcompanies.expname,exportcompanies.expregno,exportcompanies.logo,
exportcompanies.expaddress1,exportcompanies.expdistrict_id,exportcompanies.expvillage_id,
exportcompanies.expparish_id,exportcompanies.expcompanyphone,exportcompanies.expemail,
exportcompanies.expsubcounty_id,exportcompanies.registrationstatus,exportcompanies.validitydate,packhouses.phname,
packhouses.phregno,packhouses.id packhouse_id,packhouses.contactname,packhouses.contactphone,packhouses.contactemail,
packhouses.streetaddress,packhouses.district_id,packhouses.long,packhouses.lat,packhouses.expirydate,packhouses.regstatus FROM exportcompanies
LEFT JOIN packhouse_exporter on packhouse_exporter.exportcompany_id = exportcompanies.id
LEFT JOIN packhouses         on packhouses.id   = packhouse_exporter.packhouse_id
WHERE exportcompanies.id = $1
`

type GetExportCompanyRow struct {
	ID                 int64           `json:"id"`
	Expname            string          `json:"expname"`
	Expregno           string          `json:"expregno"`
	Logo               sql.NullString  `json:"logo"`
	Expaddress1        string          `json:"expaddress1"`
	ExpdistrictID      int32           `json:"expdistrict_id"`
	ExpvillageID       int32           `json:"expvillage_id"`
	ExpparishID        int32           `json:"expparish_id"`
	Expcompanyphone    string          `json:"expcompanyphone"`
	Expemail           string          `json:"expemail"`
	ExpsubcountyID     int32           `json:"expsubcounty_id"`
	Registrationstatus string          `json:"registrationstatus"`
	Validitydate       time.Time       `json:"validitydate"`
	Phname             sql.NullString  `json:"phname"`
	Phregno            sql.NullString  `json:"phregno"`
	PackhouseID        sql.NullInt64   `json:"packhouse_id"`
	Contactname        sql.NullString  `json:"contactname"`
	Contactphone       sql.NullString  `json:"contactphone"`
	Contactemail       sql.NullString  `json:"contactemail"`
	Streetaddress      sql.NullString  `json:"streetaddress"`
	DistrictID         sql.NullInt32   `json:"district_id"`
	Long               sql.NullFloat64 `json:"long"`
	Lat                sql.NullFloat64 `json:"lat"`
	Expirydate         sql.NullTime    `json:"expirydate"`
	Regstatus          sql.NullString  `json:"regstatus"`
}

func (q *Queries) GetExportCompany(ctx context.Context, id int64) (GetExportCompanyRow, error) {
	row := q.db.QueryRowContext(ctx, getExportCompany, id)
	var i GetExportCompanyRow
	err := row.Scan(
		&i.ID,
		&i.Expname,
		&i.Expregno,
		&i.Logo,
		&i.Expaddress1,
		&i.ExpdistrictID,
		&i.ExpvillageID,
		&i.ExpparishID,
		&i.Expcompanyphone,
		&i.Expemail,
		&i.ExpsubcountyID,
		&i.Registrationstatus,
		&i.Validitydate,
		&i.Phname,
		&i.Phregno,
		&i.PackhouseID,
		&i.Contactname,
		&i.Contactphone,
		&i.Contactemail,
		&i.Streetaddress,
		&i.DistrictID,
		&i.Long,
		&i.Lat,
		&i.Expirydate,
		&i.Regstatus,
	)
	return i, err
}

const getExporterCompanyID = `-- name: GetExporterCompanyID :one
SELECT id FROM exportcompanies
WHERE expname = $1
`

func (q *Queries) GetExporterCompanyID(ctx context.Context, expname string) (int64, error) {
	row := q.db.QueryRowContext(ctx, getExporterCompanyID, expname)
	var id int64
	err := row.Scan(&id)
	return id, err
}

const listExportCompanies = `-- name: ListExportCompanies :many
SELECT id, expname, expregno, exprexno, expaddress1, expdistrict_id, expsubcounty_id, expvillage_id, expparish_id, registrationstatus, validitydate, expcompanyphone, expemail, created_at, logo FROM exportcompanies
ORDER BY id LIMIT $1
OFFSET $2
`

type ListExportCompaniesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

func (q *Queries) ListExportCompanies(ctx context.Context, arg ListExportCompaniesParams) ([]Exportcompany, error) {
	rows, err := q.db.QueryContext(ctx, listExportCompanies, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Exportcompany{}
	for rows.Next() {
		var i Exportcompany
		if err := rows.Scan(
			&i.ID,
			&i.Expname,
			&i.Expregno,
			&i.Exprexno,
			&i.Expaddress1,
			&i.ExpdistrictID,
			&i.ExpsubcountyID,
			&i.ExpvillageID,
			&i.ExpparishID,
			&i.Registrationstatus,
			&i.Validitydate,
			&i.Expcompanyphone,
			&i.Expemail,
			&i.CreatedAt,
			&i.Logo,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const searchCompanyName = `-- name: SearchCompanyName :many
SELECT id, expname, expregno, exprexno, expaddress1, expdistrict_id, expsubcounty_id, expvillage_id, expparish_id, registrationstatus, validitydate, expcompanyphone, expemail, created_at, logo
FROM  exportcompanies
WHERE LOWER(expname) LIKE '%' || LOWER($1) || '%'
`

func (q *Queries) SearchCompanyName(ctx context.Context, lower string) ([]Exportcompany, error) {
	rows, err := q.db.QueryContext(ctx, searchCompanyName, lower)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Exportcompany{}
	for rows.Next() {
		var i Exportcompany
		if err := rows.Scan(
			&i.ID,
			&i.Expname,
			&i.Expregno,
			&i.Exprexno,
			&i.Expaddress1,
			&i.ExpdistrictID,
			&i.ExpsubcountyID,
			&i.ExpvillageID,
			&i.ExpparishID,
			&i.Registrationstatus,
			&i.Validitydate,
			&i.Expcompanyphone,
			&i.Expemail,
			&i.CreatedAt,
			&i.Logo,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const totalBorderInspectors = `-- name: TotalBorderInspectors :one
SELECT COUNT(id) from users
where user_type = 'PACKHOUSE-INSPECTOR'
`

func (q *Queries) TotalBorderInspectors(ctx context.Context) (int64, error) {
	row := q.db.QueryRowContext(ctx, totalBorderInspectors)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const totalExportCompanies = `-- name: TotalExportCompanies :one
SELECT COUNT(id) from exportcompanies
`

func (q *Queries) TotalExportCompanies(ctx context.Context) (int64, error) {
	row := q.db.QueryRowContext(ctx, totalExportCompanies)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const totalPackhouseInspectors = `-- name: TotalPackhouseInspectors :one
SELECT COUNT(id) from users
where user_type = 'PACKHOUSE-INSPECTOR'
`

func (q *Queries) TotalPackhouseInspectors(ctx context.Context) (int64, error) {
	row := q.db.QueryRowContext(ctx, totalPackhouseInspectors)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const totalQualityControllers = `-- name: TotalQualityControllers :one
SELECT COUNT(id) from users
where user_type = 'QUALITY-CONTROLLER'
`

func (q *Queries) TotalQualityControllers(ctx context.Context) (int64, error) {
	row := q.db.QueryRowContext(ctx, totalQualityControllers)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const totalZonalInspectors = `-- name: TotalZonalInspectors :one
SELECT COUNT(id) from users
where user_type = 'PACKHOUSE-INSPECTOR'
`

func (q *Queries) TotalZonalInspectors(ctx context.Context) (int64, error) {
	row := q.db.QueryRowContext(ctx, totalZonalInspectors)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const updateExportCompany = `-- name: UpdateExportCompany :one
UPDATE exportcompanies
  set
    expname= $2,
    expregno = $3,
    expaddress1 = $4,
    expdistrict_id = $5,
    expvillage_id = $6,
    expparish_id = $7,
    expcompanyphone = $8,
    expemail = $9,
    registrationstatus = $10,
    validitydate = $11
WHERE id = $1
RETURNING id, expname, expregno, exprexno, expaddress1, expdistrict_id, expsubcounty_id, expvillage_id, expparish_id, registrationstatus, validitydate, expcompanyphone, expemail, created_at, logo
`

type UpdateExportCompanyParams struct {
	ID                 int64     `json:"id"`
	Expname            string    `json:"expname"`
	Expregno           string    `json:"expregno"`
	Expaddress1        string    `json:"expaddress1"`
	ExpdistrictID      int32     `json:"expdistrict_id"`
	ExpvillageID       int32     `json:"expvillage_id"`
	ExpparishID        int32     `json:"expparish_id"`
	Expcompanyphone    string    `json:"expcompanyphone"`
	Expemail           string    `json:"expemail"`
	Registrationstatus string    `json:"registrationstatus"`
	Validitydate       time.Time `json:"validitydate"`
}

func (q *Queries) UpdateExportCompany(ctx context.Context, arg UpdateExportCompanyParams) (Exportcompany, error) {
	row := q.db.QueryRowContext(ctx, updateExportCompany,
		arg.ID,
		arg.Expname,
		arg.Expregno,
		arg.Expaddress1,
		arg.ExpdistrictID,
		arg.ExpvillageID,
		arg.ExpparishID,
		arg.Expcompanyphone,
		arg.Expemail,
		arg.Registrationstatus,
		arg.Validitydate,
	)
	var i Exportcompany
	err := row.Scan(
		&i.ID,
		&i.Expname,
		&i.Expregno,
		&i.Exprexno,
		&i.Expaddress1,
		&i.ExpdistrictID,
		&i.ExpsubcountyID,
		&i.ExpvillageID,
		&i.ExpparishID,
		&i.Registrationstatus,
		&i.Validitydate,
		&i.Expcompanyphone,
		&i.Expemail,
		&i.CreatedAt,
		&i.Logo,
	)
	return i, err
}

const uploadCompanyLogo = `-- name: UploadCompanyLogo :one
UPDATE exportcompanies
  set
    logo = $2
WHERE id = $1
RETURNING id, expname, expregno, exprexno, expaddress1, expdistrict_id, expsubcounty_id, expvillage_id, expparish_id, registrationstatus, validitydate, expcompanyphone, expemail, created_at, logo
`

type UploadCompanyLogoParams struct {
	ID   int64          `json:"id"`
	Logo sql.NullString `json:"logo"`
}

func (q *Queries) UploadCompanyLogo(ctx context.Context, arg UploadCompanyLogoParams) (Exportcompany, error) {
	row := q.db.QueryRowContext(ctx, uploadCompanyLogo, arg.ID, arg.Logo)
	var i Exportcompany
	err := row.Scan(
		&i.ID,
		&i.Expname,
		&i.Expregno,
		&i.Exprexno,
		&i.Expaddress1,
		&i.ExpdistrictID,
		&i.ExpsubcountyID,
		&i.ExpvillageID,
		&i.ExpparishID,
		&i.Registrationstatus,
		&i.Validitydate,
		&i.Expcompanyphone,
		&i.Expemail,
		&i.CreatedAt,
		&i.Logo,
	)
	return i, err
}
