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

package db

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

const createQcp5 = `-- name: CreateQcp5 :one
INSERT INTO qcp5 (
    packinglist_id,
    status,
    user_id,
    exportcompany_id
 ) VALUES (
     $1,
     $2,
     $3,
     $4
    )
RETURNING id, packinglist_id, user_id, status, exportcompany_id, created_at
`

type CreateQcp5Params struct {
	PackinglistID   int32  `json:"packinglist_id"`
	Status          string `json:"status"`
	UserID          int32  `json:"user_id"`
	ExportcompanyID int32  `json:"exportcompany_id"`
}

func (q *Queries) CreateQcp5(ctx context.Context, arg CreateQcp5Params) (Qcp5, error) {
	row := q.db.QueryRowContext(ctx, createQcp5,
		arg.PackinglistID,
		arg.Status,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Qcp5
	err := row.Scan(
		&i.ID,
		&i.PackinglistID,
		&i.UserID,
		&i.Status,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createQcp5Attributes = `-- name: CreateQcp5Attributes :one
INSERT INTO qcp5_attributes (
    qcp5_id,
    qualityattributes_id,
    qcp5_product_id,
    user_id,
    exportcompany_id
 ) VALUES (
     $1,
     $2,
     $3,
     $4,
     $5
    )
RETURNING id, qcp5_id, qcp5_product_id, qualityattributes_id, user_id, exportcompany_id, created_at
`

type CreateQcp5AttributesParams struct {
	Qcp5ID              int32 `json:"qcp5_id"`
	QualityattributesID int32 `json:"qualityattributes_id"`
	Qcp5ProductID       int32 `json:"qcp5_product_id"`
	UserID              int32 `json:"user_id"`
	ExportcompanyID     int32 `json:"exportcompany_id"`
}

func (q *Queries) CreateQcp5Attributes(ctx context.Context, arg CreateQcp5AttributesParams) (Qcp5Attribute, error) {
	row := q.db.QueryRowContext(ctx, createQcp5Attributes,
		arg.Qcp5ID,
		arg.QualityattributesID,
		arg.Qcp5ProductID,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Qcp5Attribute
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.Qcp5ProductID,
		&i.QualityattributesID,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createQcp5OtherQualityAttributes = `-- name: CreateQcp5OtherQualityAttributes :one
INSERT INTO qcp5_other_attributes(
     qcp5_id,
     qcp5_other_id,
     qualityattributes_id,
     other ,
     user_id,
     exportcompany_id
) VALUES (
    $1,
    $2,
    $3,
    $4,
    $5,
    $6
)
RETURNING id, qcp5_id, qcp5_other_id, other, qualityattributes_id, user_id, exportcompany_id, created_at
`

type CreateQcp5OtherQualityAttributesParams struct {
	Qcp5ID              int32  `json:"qcp5_id"`
	Qcp5OtherID         int32  `json:"qcp5_other_id"`
	QualityattributesID int32  `json:"qualityattributes_id"`
	Other               string `json:"other"`
	UserID              int32  `json:"user_id"`
	ExportcompanyID     int32  `json:"exportcompany_id"`
}

func (q *Queries) CreateQcp5OtherQualityAttributes(ctx context.Context, arg CreateQcp5OtherQualityAttributesParams) (Qcp5OtherAttribute, error) {
	row := q.db.QueryRowContext(ctx, createQcp5OtherQualityAttributes,
		arg.Qcp5ID,
		arg.Qcp5OtherID,
		arg.QualityattributesID,
		arg.Other,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Qcp5OtherAttribute
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.Qcp5OtherID,
		&i.Other,
		&i.QualityattributesID,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createQcp5OtherRecommendations = `-- name: CreateQcp5OtherRecommendations :one
INSERT INTO qcp5_otherrecommendations (
    qcp5_id,
    qcp5_others_id,
    status,
    reason,
    weight_rejected,
    weight_passed,
    user_id,
    exportcompany_id
 ) VALUES (
     $1,
     $2,
     $3,
     $4,
     $5,
     $6,
     $7,
     $8
    )
RETURNING id, qcp5_id, qcp5_others_id, status, reason, weight_rejected, weight_passed, user_id, exportcompany_id, created_at
`

type CreateQcp5OtherRecommendationsParams struct {
	Qcp5ID          int32          `json:"qcp5_id"`
	Qcp5OthersID    int32          `json:"qcp5_others_id"`
	Status          string         `json:"status"`
	Reason          sql.NullString `json:"reason"`
	WeightRejected  float64        `json:"weight_rejected"`
	WeightPassed    float64        `json:"weight_passed"`
	UserID          int32          `json:"user_id"`
	ExportcompanyID int32          `json:"exportcompany_id"`
}

func (q *Queries) CreateQcp5OtherRecommendations(ctx context.Context, arg CreateQcp5OtherRecommendationsParams) (Qcp5Otherrecommendation, error) {
	row := q.db.QueryRowContext(ctx, createQcp5OtherRecommendations,
		arg.Qcp5ID,
		arg.Qcp5OthersID,
		arg.Status,
		arg.Reason,
		arg.WeightRejected,
		arg.WeightPassed,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Qcp5Otherrecommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.Qcp5OthersID,
		&i.Status,
		&i.Reason,
		&i.WeightRejected,
		&i.WeightPassed,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createQcp5Others = `-- name: CreateQcp5Others :one
INSERT INTO qcp5_others (
    qcp5_id,
    packinglist_id,
    product_name,
    noofboxes,
    sampledboxes,
    boxweight,
    productnetweight,
    totalproductnetweight,
    totalproductgrossweight,
    status,
    user_id,
    exportcompany_id
 ) VALUES (
     $1,
     $2,
     $3,
     $4,
     $5,
     $6,
     $7,
     $8,
     $9,
     $10,
     $11,
     $12
    )
RETURNING id, qcp5_id, packinglist_id, product_name, noofboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, status, user_id, exportcompany_id, created_at
`

type CreateQcp5OthersParams struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	PackinglistID           int32           `json:"packinglist_id"`
	ProductName             string          `json:"product_name"`
	Noofboxes               int32           `json:"noofboxes"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Status                  string          `json:"status"`
	UserID                  int32           `json:"user_id"`
	ExportcompanyID         int32           `json:"exportcompany_id"`
}

func (q *Queries) CreateQcp5Others(ctx context.Context, arg CreateQcp5OthersParams) (Qcp5Other, error) {
	row := q.db.QueryRowContext(ctx, createQcp5Others,
		arg.Qcp5ID,
		arg.PackinglistID,
		arg.ProductName,
		arg.Noofboxes,
		arg.Sampledboxes,
		arg.Boxweight,
		arg.Productnetweight,
		arg.Totalproductnetweight,
		arg.Totalproductgrossweight,
		arg.Status,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Qcp5Other
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.PackinglistID,
		&i.ProductName,
		&i.Noofboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.Status,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createQcp5Products = `-- name: CreateQcp5Products :one
INSERT INTO qcp5_products (
    qcp5_id,
    traceability_code,
    product_id,
	totalboxes,
    boxweight,
    productnetweight,
    totalproductnetweight,
    totalproductgrossweight,
    sampledboxes,
    status
 ) VALUES (
     $1,
     $2,
     $3,
     $4,
     $5,
     $6,
     $7,
     $8,
     $9,
     $10
    )
RETURNING id, qcp5_id, traceability_code, status, product_id, totalboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, created_at
`

type CreateQcp5ProductsParams struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	TraceabilityCode        string          `json:"traceability_code"`
	ProductID               int32           `json:"product_id"`
	Totalboxes              int32           `json:"totalboxes"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	Status                  string          `json:"status"`
}

func (q *Queries) CreateQcp5Products(ctx context.Context, arg CreateQcp5ProductsParams) (Qcp5Product, error) {
	row := q.db.QueryRowContext(ctx, createQcp5Products,
		arg.Qcp5ID,
		arg.TraceabilityCode,
		arg.ProductID,
		arg.Totalboxes,
		arg.Boxweight,
		arg.Productnetweight,
		arg.Totalproductnetweight,
		arg.Totalproductgrossweight,
		arg.Sampledboxes,
		arg.Status,
	)
	var i Qcp5Product
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.TraceabilityCode,
		&i.Status,
		&i.ProductID,
		&i.Totalboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.CreatedAt,
	)
	return i, err
}

const createQcp5Recommendations = `-- name: CreateQcp5Recommendations :one
INSERT INTO qcp5_recommendations (
    qcp5_id,
    qcp5_product_id,
    status,
    reason,
    weight_rejected,
    weight_passed,
    user_id,
    exportcompany_id
 ) VALUES (
     $1,
     $2,
     $3,
     $4,
     $5,
     $6,
     $7,
     $8
    )
RETURNING id, qcp5_id, qcp5_product_id, status, reason, weight_rejected, weight_passed, user_id, exportcompany_id, created_at
`

type CreateQcp5RecommendationsParams struct {
	Qcp5ID          int32          `json:"qcp5_id"`
	Qcp5ProductID   int32          `json:"qcp5_product_id"`
	Status          string         `json:"status"`
	Reason          sql.NullString `json:"reason"`
	WeightRejected  float64        `json:"weight_rejected"`
	WeightPassed    float64        `json:"weight_passed"`
	UserID          int32          `json:"user_id"`
	ExportcompanyID int32          `json:"exportcompany_id"`
}

func (q *Queries) CreateQcp5Recommendations(ctx context.Context, arg CreateQcp5RecommendationsParams) (Qcp5Recommendation, error) {
	row := q.db.QueryRowContext(ctx, createQcp5Recommendations,
		arg.Qcp5ID,
		arg.Qcp5ProductID,
		arg.Status,
		arg.Reason,
		arg.WeightRejected,
		arg.WeightPassed,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Qcp5Recommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.Qcp5ProductID,
		&i.Status,
		&i.Reason,
		&i.WeightRejected,
		&i.WeightPassed,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const getBorderInspectorID = `-- name: GetBorderInspectorID :one
SELECT user_id FROM qcp5_recommendations
WHERE qcp5_id = $1 LIMIT 1
`

func (q *Queries) GetBorderInspectorID(ctx context.Context, qcp5ID int32) (int32, error) {
	row := q.db.QueryRowContext(ctx, getBorderInspectorID, qcp5ID)
	var user_id int32
	err := row.Scan(&user_id)
	return user_id, err
}

const getConsignmentNoByQcp5ID = `-- name: GetConsignmentNoByQcp5ID :one
SELECT orders.consignment_no, qcp5.id as qcp5_id from qcp5
LEFT JOIN packinglist  on packinglist.id   = qcp5.packinglist_id
LEFT JOIN orders       on orders.id        = packinglist.order_id
WHERE qcp5.id = $1
`

type GetConsignmentNoByQcp5IDRow struct {
	ConsignmentNo sql.NullString `json:"consignment_no"`
	Qcp5ID        int64          `json:"qcp5_id"`
}

func (q *Queries) GetConsignmentNoByQcp5ID(ctx context.Context, id int64) (GetConsignmentNoByQcp5IDRow, error) {
	row := q.db.QueryRowContext(ctx, getConsignmentNoByQcp5ID, id)
	var i GetConsignmentNoByQcp5IDRow
	err := row.Scan(&i.ConsignmentNo, &i.Qcp5ID)
	return i, err
}

const getPackingListIDFromQcp5 = `-- name: GetPackingListIDFromQcp5 :one
SELECT id,user_id,exportcompany_id FROM qcp5
WHERE  packinglist_id= $1 LIMIT 1
`

type GetPackingListIDFromQcp5Row struct {
	ID              int64 `json:"id"`
	UserID          int32 `json:"user_id"`
	ExportcompanyID int32 `json:"exportcompany_id"`
}

func (q *Queries) GetPackingListIDFromQcp5(ctx context.Context, packinglistID int32) (GetPackingListIDFromQcp5Row, error) {
	row := q.db.QueryRowContext(ctx, getPackingListIDFromQcp5, packinglistID)
	var i GetPackingListIDFromQcp5Row
	err := row.Scan(&i.ID, &i.UserID, &i.ExportcompanyID)
	return i, err
}

const getQcp5 = `-- name: GetQcp5 :one
SELECT id, packinglist_id, user_id, status, exportcompany_id, created_at FROM qcp5
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetQcp5(ctx context.Context, id int64) (Qcp5, error) {
	row := q.db.QueryRowContext(ctx, getQcp5, id)
	var i Qcp5
	err := row.Scan(
		&i.ID,
		&i.PackinglistID,
		&i.UserID,
		&i.Status,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const getQcp5Attributes = `-- name: GetQcp5Attributes :many
SELECT  qcp5_attributes.qcp5_id,qcp5_attributes.qualityattributes_id,
qcp5_attributes.qcp5_product_id,qcp5_attributes.user_id,qualityattributes.description,
qcp5_attributes.exportcompany_id, crops.cropname FROM qcp5_attributes
JOIN qualityattributes on qualityattributes.id = qcp5_attributes.qualityattributes_id
JOIN crops             on crops.id             = qcp5_attributes.qcp5_product_id
WHERE qcp5_id = $1
`

type GetQcp5AttributesRow struct {
	Qcp5ID              int32  `json:"qcp5_id"`
	QualityattributesID int32  `json:"qualityattributes_id"`
	Qcp5ProductID       int32  `json:"qcp5_product_id"`
	UserID              int32  `json:"user_id"`
	Description         string `json:"description"`
	ExportcompanyID     int32  `json:"exportcompany_id"`
	Cropname            string `json:"cropname"`
}

func (q *Queries) GetQcp5Attributes(ctx context.Context, qcp5ID int32) ([]GetQcp5AttributesRow, error) {
	rows, err := q.db.QueryContext(ctx, getQcp5Attributes, qcp5ID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GetQcp5AttributesRow{}
	for rows.Next() {
		var i GetQcp5AttributesRow
		if err := rows.Scan(
			&i.Qcp5ID,
			&i.QualityattributesID,
			&i.Qcp5ProductID,
			&i.UserID,
			&i.Description,
			&i.ExportcompanyID,
			&i.Cropname,
		); 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 getQcp5DetailsRes = `-- name: GetQcp5DetailsRes :one
SELECT qcp5.packinglist_id,qcp5.user_id,qcp5.status,qcp5.created_at,orders.consignment_no,qcp5.exportcompany_id FROM qcp5
JOIN   packinglist on packinglist.id = qcp5.packinglist_id
JOIN   orders      on orders.id      = packinglist.order_id
WHERE qcp5.id = $1 LIMIT 1
`

type GetQcp5DetailsResRow struct {
	PackinglistID   int32          `json:"packinglist_id"`
	UserID          int32          `json:"user_id"`
	Status          string         `json:"status"`
	CreatedAt       time.Time      `json:"created_at"`
	ConsignmentNo   sql.NullString `json:"consignment_no"`
	ExportcompanyID int32          `json:"exportcompany_id"`
}

func (q *Queries) GetQcp5DetailsRes(ctx context.Context, id int64) (GetQcp5DetailsResRow, error) {
	row := q.db.QueryRowContext(ctx, getQcp5DetailsRes, id)
	var i GetQcp5DetailsResRow
	err := row.Scan(
		&i.PackinglistID,
		&i.UserID,
		&i.Status,
		&i.CreatedAt,
		&i.ConsignmentNo,
		&i.ExportcompanyID,
	)
	return i, err
}

const getQcp5OtherAttributes = `-- name: GetQcp5OtherAttributes :many
SELECT id, qcp5_id, qcp5_other_id, other, qualityattributes_id, user_id, exportcompany_id, created_at FROM qcp5_other_attributes
WHERE qcp5_id = $1
`

func (q *Queries) GetQcp5OtherAttributes(ctx context.Context, qcp5ID int32) ([]Qcp5OtherAttribute, error) {
	rows, err := q.db.QueryContext(ctx, getQcp5OtherAttributes, qcp5ID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5OtherAttribute{}
	for rows.Next() {
		var i Qcp5OtherAttribute
		if err := rows.Scan(
			&i.ID,
			&i.Qcp5ID,
			&i.Qcp5OtherID,
			&i.Other,
			&i.QualityattributesID,
			&i.UserID,
			&i.ExportcompanyID,
			&i.CreatedAt,
		); 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 getQcp5OtherProductRecommendations = `-- name: GetQcp5OtherProductRecommendations :one
SELECT id, qcp5_id, qcp5_others_id, status, reason, weight_rejected, weight_passed, user_id, exportcompany_id, created_at FROM qcp5_otherrecommendations
WHERE qcp5_others_id = $1 LIMIT 1
`

func (q *Queries) GetQcp5OtherProductRecommendations(ctx context.Context, qcp5OthersID int32) (Qcp5Otherrecommendation, error) {
	row := q.db.QueryRowContext(ctx, getQcp5OtherProductRecommendations, qcp5OthersID)
	var i Qcp5Otherrecommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.Qcp5OthersID,
		&i.Status,
		&i.Reason,
		&i.WeightRejected,
		&i.WeightPassed,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const getQcp5OtherRecommendations = `-- name: GetQcp5OtherRecommendations :one
SELECT id, qcp5_id, qcp5_others_id, status, reason, weight_rejected, weight_passed, user_id, exportcompany_id, created_at FROM qcp5_otherrecommendations
WHERE qcp5_id = $1 LIMIT 1
`

func (q *Queries) GetQcp5OtherRecommendations(ctx context.Context, qcp5ID int32) (Qcp5Otherrecommendation, error) {
	row := q.db.QueryRowContext(ctx, getQcp5OtherRecommendations, qcp5ID)
	var i Qcp5Otherrecommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.Qcp5OthersID,
		&i.Status,
		&i.Reason,
		&i.WeightRejected,
		&i.WeightPassed,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const getQcp5Others = `-- name: GetQcp5Others :one
SELECT id, qcp5_id, packinglist_id, product_name, noofboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, status, user_id, exportcompany_id, created_at FROM qcp5_others
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetQcp5Others(ctx context.Context, id int64) (Qcp5Other, error) {
	row := q.db.QueryRowContext(ctx, getQcp5Others, id)
	var i Qcp5Other
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.PackinglistID,
		&i.ProductName,
		&i.Noofboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.Status,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const getQcp5OthersByID = `-- name: GetQcp5OthersByID :many
SELECT id, qcp5_id, packinglist_id, product_name, noofboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, status, user_id, exportcompany_id, created_at FROM qcp5_others
WHERE qcp5_id = $1
`

func (q *Queries) GetQcp5OthersByID(ctx context.Context, qcp5ID int32) ([]Qcp5Other, error) {
	rows, err := q.db.QueryContext(ctx, getQcp5OthersByID, qcp5ID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5Other{}
	for rows.Next() {
		var i Qcp5Other
		if err := rows.Scan(
			&i.ID,
			&i.Qcp5ID,
			&i.PackinglistID,
			&i.ProductName,
			&i.Noofboxes,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.Sampledboxes,
			&i.Status,
			&i.UserID,
			&i.ExportcompanyID,
			&i.CreatedAt,
		); 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 getQcp5ProductRecommendations = `-- name: GetQcp5ProductRecommendations :one
SELECT id, qcp5_id, qcp5_product_id, status, reason, weight_rejected, weight_passed, user_id, exportcompany_id, created_at FROM qcp5_recommendations
WHERE qcp5_product_id = $1
`

func (q *Queries) GetQcp5ProductRecommendations(ctx context.Context, qcp5ProductID int32) (Qcp5Recommendation, error) {
	row := q.db.QueryRowContext(ctx, getQcp5ProductRecommendations, qcp5ProductID)
	var i Qcp5Recommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.Qcp5ProductID,
		&i.Status,
		&i.Reason,
		&i.WeightRejected,
		&i.WeightPassed,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const getQcp5ProductsByID = `-- name: GetQcp5ProductsByID :many
SELECT qcp5_products.id,qcp5_products.status,qcp5_id,qcp5_products.traceability_code,
qcp5_products.totalboxes,qcp5_products.product_id,crops.cropname product_name,
qcp5_products.boxweight,qcp5_products.productnetweight,qcp5_products.totalproductnetweight,
qcp5_products.totalproductgrossweight,qcp5_products.sampledboxes,clients.companyname,exportcompanies.expname,
qcp5_products.created_at,orders.consignment_no
FROM qcp5_products
JOIN crops           on crops.id = qcp5_products.product_id
JOIN qcp5            on qcp5.id  = qcp5_products.qcp5_id
JOIN packinglist     on packinglist.id = qcp5.packinglist_id
JOIN orders          on orders.id      = packinglist.order_id
JOIN clients         on clients.id     = orders.client_id
JOIN exportcompanies on exportcompanies.id = qcp5.exportcompany_id
WHERE qcp5_id = $1
`

type GetQcp5ProductsByIDRow struct {
	ID                      int64           `json:"id"`
	Status                  string          `json:"status"`
	Qcp5ID                  int32           `json:"qcp5_id"`
	TraceabilityCode        string          `json:"traceability_code"`
	Totalboxes              int32           `json:"totalboxes"`
	ProductID               int32           `json:"product_id"`
	ProductName             string          `json:"product_name"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	Companyname             string          `json:"companyname"`
	Expname                 string          `json:"expname"`
	CreatedAt               time.Time       `json:"created_at"`
	ConsignmentNo           sql.NullString  `json:"consignment_no"`
}

func (q *Queries) GetQcp5ProductsByID(ctx context.Context, qcp5ID int32) ([]GetQcp5ProductsByIDRow, error) {
	rows, err := q.db.QueryContext(ctx, getQcp5ProductsByID, qcp5ID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GetQcp5ProductsByIDRow{}
	for rows.Next() {
		var i GetQcp5ProductsByIDRow
		if err := rows.Scan(
			&i.ID,
			&i.Status,
			&i.Qcp5ID,
			&i.TraceabilityCode,
			&i.Totalboxes,
			&i.ProductID,
			&i.ProductName,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.Sampledboxes,
			&i.Companyname,
			&i.Expname,
			&i.CreatedAt,
			&i.ConsignmentNo,
		); 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 getQcp5Recommendations = `-- name: GetQcp5Recommendations :many
SELECT id, qcp5_id, qcp5_product_id, status, reason, weight_rejected, weight_passed, user_id, exportcompany_id, created_at FROM qcp5_recommendations
WHERE qcp5_id = $1
`

func (q *Queries) GetQcp5Recommendations(ctx context.Context, qcp5ID int32) ([]Qcp5Recommendation, error) {
	rows, err := q.db.QueryContext(ctx, getQcp5Recommendations, qcp5ID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5Recommendation{}
	for rows.Next() {
		var i Qcp5Recommendation
		if err := rows.Scan(
			&i.ID,
			&i.Qcp5ID,
			&i.Qcp5ProductID,
			&i.Status,
			&i.Reason,
			&i.WeightRejected,
			&i.WeightPassed,
			&i.UserID,
			&i.ExportcompanyID,
			&i.CreatedAt,
		); 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 getQcp5SingleRecommendations = `-- name: GetQcp5SingleRecommendations :one
SELECT id, qcp5_id, qcp5_product_id, status, reason, weight_rejected, weight_passed, user_id, exportcompany_id, created_at FROM qcp5_recommendations
WHERE qcp5_id = $1
AND   qcp5_product_id = $2
`

type GetQcp5SingleRecommendationsParams struct {
	Qcp5ID        int32 `json:"qcp5_id"`
	Qcp5ProductID int32 `json:"qcp5_product_id"`
}

func (q *Queries) GetQcp5SingleRecommendations(ctx context.Context, arg GetQcp5SingleRecommendationsParams) (Qcp5Recommendation, error) {
	row := q.db.QueryRowContext(ctx, getQcp5SingleRecommendations, arg.Qcp5ID, arg.Qcp5ProductID)
	var i Qcp5Recommendation
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.Qcp5ProductID,
		&i.Status,
		&i.Reason,
		&i.WeightRejected,
		&i.WeightPassed,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const globalQcp5ProductsReport = `-- name: GlobalQcp5ProductsReport :many
SELECT qcp5_products.qcp5_id,qcp5_products.traceability_code,
qcp5_products.product_id,qcp5_products.totalboxes,qcp5_products.boxweight,qcp5_products.productnetweight,
qcp5_products.totalproductnetweight,qcp5_products.totalproductgrossweight,crops.cropname,qcp5_products.sampledboxes,
qcp5_products.status,
qcp5.packinglist_id,qcp5.id as qcp5_id,
qcp5.status,qcp5.user_id,qcp5.exportcompany_id,receptionform.traceability_code,orders.id as order_id,
exportcompanies.expname,qcp5.user_id,users.fullname,clients.companyname,countries.countryname,
qcp5_recommendations.status,qcp5_recommendations.weight_passed,qcp5_recommendations.weight_rejected,
farmers.fmname,farmers.fmcode,qcp5.status,qcp5.created_at,orders.consignment_no FROM qcp5_products
LEFT JOIN  qcp5 on qcp5.id = qcp5_products.qcp5_id
LEFT JOIN  qcp5_recommendations on qcp5_recommendations.qcp5_product_id = qcp5_products.id
LEFT JOIN  packinglist  on packinglist.id    = qcp5.packinglist_id
LEFT JOIN  orders       on orders.id              = packinglist.order_id
LEFT JOIN  clients      on clients.id              = orders.client_id
LEFT JOIN  countries     on countries.id           = clients.country_id
LEFT JOIN  receptionform on receptionform.order_id = orders.id
LEFT JOIN  farmers on farmers.id = receptionform.supplier_id
LEFT JOIN  crops on crops.id = qcp5_products.product_id
LEFT JOIN  exportcompanies on exportcompanies.id = qcp5.exportcompany_id
LEFT JOIN  users on  users.id = qcp5.user_id
LIMIT $1 OFFSET $2
`

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

type GlobalQcp5ProductsReportRow struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	TraceabilityCode        string          `json:"traceability_code"`
	ProductID               int32           `json:"product_id"`
	Totalboxes              int32           `json:"totalboxes"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Cropname                sql.NullString  `json:"cropname"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	Status                  string          `json:"status"`
	PackinglistID           sql.NullInt32   `json:"packinglist_id"`
	Qcp5ID_2                sql.NullInt64   `json:"qcp5_id_2"`
	Status_2                sql.NullString  `json:"status_2"`
	UserID                  sql.NullInt32   `json:"user_id"`
	ExportcompanyID         sql.NullInt32   `json:"exportcompany_id"`
	TraceabilityCode_2      sql.NullString  `json:"traceability_code_2"`
	OrderID                 sql.NullInt64   `json:"order_id"`
	Expname                 sql.NullString  `json:"expname"`
	UserID_2                sql.NullInt32   `json:"user_id_2"`
	Fullname                sql.NullString  `json:"fullname"`
	Companyname             sql.NullString  `json:"companyname"`
	Countryname             sql.NullString  `json:"countryname"`
	Status_3                sql.NullString  `json:"status_3"`
	WeightPassed            sql.NullFloat64 `json:"weight_passed"`
	WeightRejected          sql.NullFloat64 `json:"weight_rejected"`
	Fmname                  sql.NullString  `json:"fmname"`
	Fmcode                  sql.NullString  `json:"fmcode"`
	Status_4                sql.NullString  `json:"status_4"`
	CreatedAt               sql.NullTime    `json:"created_at"`
	ConsignmentNo           sql.NullString  `json:"consignment_no"`
}

func (q *Queries) GlobalQcp5ProductsReport(ctx context.Context, arg GlobalQcp5ProductsReportParams) ([]GlobalQcp5ProductsReportRow, error) {
	rows, err := q.db.QueryContext(ctx, globalQcp5ProductsReport, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GlobalQcp5ProductsReportRow{}
	for rows.Next() {
		var i GlobalQcp5ProductsReportRow
		if err := rows.Scan(
			&i.Qcp5ID,
			&i.TraceabilityCode,
			&i.ProductID,
			&i.Totalboxes,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.Cropname,
			&i.Sampledboxes,
			&i.Status,
			&i.PackinglistID,
			&i.Qcp5ID_2,
			&i.Status_2,
			&i.UserID,
			&i.ExportcompanyID,
			&i.TraceabilityCode_2,
			&i.OrderID,
			&i.Expname,
			&i.UserID_2,
			&i.Fullname,
			&i.Companyname,
			&i.Countryname,
			&i.Status_3,
			&i.WeightPassed,
			&i.WeightRejected,
			&i.Fmname,
			&i.Fmcode,
			&i.Status_4,
			&i.CreatedAt,
			&i.ConsignmentNo,
		); 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 globalQcp5ProductsReportFilterDate = `-- name: GlobalQcp5ProductsReportFilterDate :many
SELECT qcp5_products.qcp5_id,qcp5_products.traceability_code,
qcp5_products.product_id,qcp5_products.totalboxes,qcp5_products.boxweight,qcp5_products.productnetweight,
qcp5_products.totalproductnetweight,qcp5_products.totalproductgrossweight,crops.cropname,qcp5_products.sampledboxes,
qcp5_products.status,
qcp5.packinglist_id,qcp5.id as qcp5_id,
qcp5.status,qcp5.user_id,qcp5.exportcompany_id,receptionform.traceability_code,orders.id as order_id,
exportcompanies.expname,qcp5.user_id,users.fullname,clients.companyname,countries.countryname,
qcp5_recommendations.status,qcp5_recommendations.weight_passed,qcp5_recommendations.weight_rejected,
farmers.fmname,farmers.fmcode,qcp5.status,qcp5.created_at,orders.consignment_no FROM qcp5_products
LEFT JOIN  qcp5 on qcp5.id = qcp5_products.qcp5_id
LEFT JOIN  qcp5_recommendations on qcp5_recommendations.qcp5_product_id = qcp5_products.id
LEFT JOIN  packinglist  on packinglist.id    = qcp5.packinglist_id
LEFT JOIN  orders       on orders.id              = packinglist.order_id
LEFT JOIN  clients      on clients.id              = orders.client_id
LEFT JOIN  countries     on countries.id           = clients.country_id
LEFT JOIN  receptionform on receptionform.order_id = orders.id
LEFT JOIN  farmers on farmers.id = receptionform.supplier_id
LEFT JOIN  crops on crops.id = qcp5_products.product_id
LEFT JOIN  exportcompanies on exportcompanies.id = qcp5.exportcompany_id
LEFT JOIN  users on  users.id = qcp5.user_id
WHERE   qcp5_products.created_at
BETWEEN TO_TIMESTAMP($1, 'YYYY-MM-DD HH24:MI:SS')
AND     TO_TIMESTAMP($2, 'YYYY-MM-DD HH24:MI:SS')
LIMIT   $3 OFFSET $4
`

type GlobalQcp5ProductsReportFilterDateParams struct {
	ToTimestamp   string `json:"to_timestamp"`
	ToTimestamp_2 string `json:"to_timestamp_2"`
	Limit         int32  `json:"limit"`
	Offset        int32  `json:"offset"`
}

type GlobalQcp5ProductsReportFilterDateRow struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	TraceabilityCode        string          `json:"traceability_code"`
	ProductID               int32           `json:"product_id"`
	Totalboxes              int32           `json:"totalboxes"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Cropname                sql.NullString  `json:"cropname"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	Status                  string          `json:"status"`
	PackinglistID           sql.NullInt32   `json:"packinglist_id"`
	Qcp5ID_2                sql.NullInt64   `json:"qcp5_id_2"`
	Status_2                sql.NullString  `json:"status_2"`
	UserID                  sql.NullInt32   `json:"user_id"`
	ExportcompanyID         sql.NullInt32   `json:"exportcompany_id"`
	TraceabilityCode_2      sql.NullString  `json:"traceability_code_2"`
	OrderID                 sql.NullInt64   `json:"order_id"`
	Expname                 sql.NullString  `json:"expname"`
	UserID_2                sql.NullInt32   `json:"user_id_2"`
	Fullname                sql.NullString  `json:"fullname"`
	Companyname             sql.NullString  `json:"companyname"`
	Countryname             sql.NullString  `json:"countryname"`
	Status_3                sql.NullString  `json:"status_3"`
	WeightPassed            sql.NullFloat64 `json:"weight_passed"`
	WeightRejected          sql.NullFloat64 `json:"weight_rejected"`
	Fmname                  sql.NullString  `json:"fmname"`
	Fmcode                  sql.NullString  `json:"fmcode"`
	Status_4                sql.NullString  `json:"status_4"`
	CreatedAt               sql.NullTime    `json:"created_at"`
	ConsignmentNo           sql.NullString  `json:"consignment_no"`
}

func (q *Queries) GlobalQcp5ProductsReportFilterDate(ctx context.Context, arg GlobalQcp5ProductsReportFilterDateParams) ([]GlobalQcp5ProductsReportFilterDateRow, error) {
	rows, err := q.db.QueryContext(ctx, globalQcp5ProductsReportFilterDate,
		arg.ToTimestamp,
		arg.ToTimestamp_2,
		arg.Limit,
		arg.Offset,
	)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GlobalQcp5ProductsReportFilterDateRow{}
	for rows.Next() {
		var i GlobalQcp5ProductsReportFilterDateRow
		if err := rows.Scan(
			&i.Qcp5ID,
			&i.TraceabilityCode,
			&i.ProductID,
			&i.Totalboxes,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.Cropname,
			&i.Sampledboxes,
			&i.Status,
			&i.PackinglistID,
			&i.Qcp5ID_2,
			&i.Status_2,
			&i.UserID,
			&i.ExportcompanyID,
			&i.TraceabilityCode_2,
			&i.OrderID,
			&i.Expname,
			&i.UserID_2,
			&i.Fullname,
			&i.Companyname,
			&i.Countryname,
			&i.Status_3,
			&i.WeightPassed,
			&i.WeightRejected,
			&i.Fmname,
			&i.Fmcode,
			&i.Status_4,
			&i.CreatedAt,
			&i.ConsignmentNo,
		); 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 globalQcp5ProductsReportFilterDateStatus = `-- name: GlobalQcp5ProductsReportFilterDateStatus :many
SELECT qcp5_products.qcp5_id,qcp5_products.traceability_code,
qcp5_products.product_id,qcp5_products.totalboxes,qcp5_products.boxweight,qcp5_products.productnetweight,
qcp5_products.totalproductnetweight,qcp5_products.totalproductgrossweight,crops.cropname,qcp5_products.sampledboxes,
qcp5_products.status,
qcp5.packinglist_id,qcp5.id as qcp5_id,
qcp5.status,qcp5.user_id,qcp5.exportcompany_id,receptionform.traceability_code,orders.id as order_id,
exportcompanies.expname,qcp5.user_id,users.fullname,clients.companyname,countries.countryname,
qcp5_recommendations.status,qcp5_recommendations.weight_passed,qcp5_recommendations.weight_rejected,
farmers.fmname,farmers.fmcode,qcp5.status,qcp5.created_at,orders.consignment_no FROM qcp5_products
LEFT JOIN  qcp5 on qcp5.id = qcp5_products.qcp5_id
LEFT JOIN  qcp5_recommendations on qcp5_recommendations.qcp5_product_id = qcp5_products.id
LEFT JOIN  packinglist  on packinglist.id    = qcp5.packinglist_id
LEFT JOIN  orders       on orders.id              = packinglist.order_id
LEFT JOIN  clients      on clients.id              = orders.client_id
LEFT JOIN  countries     on countries.id           = clients.country_id
LEFT JOIN  receptionform on receptionform.order_id = orders.id
LEFT JOIN  farmers on farmers.id = receptionform.supplier_id
LEFT JOIN  crops on crops.id = qcp5_products.product_id
LEFT JOIN  exportcompanies on exportcompanies.id = qcp5.exportcompany_id
LEFT JOIN  users on  users.id = qcp5.user_id
WHERE   qcp5_products.created_at
BETWEEN TO_TIMESTAMP($1, 'YYYY-MM-DD HH24:MI:SS')
AND     TO_TIMESTAMP($2, 'YYYY-MM-DD HH24:MI:SS')
AND     qcp5_products.status = $3
LIMIT   $4 OFFSET $5
`

type GlobalQcp5ProductsReportFilterDateStatusParams struct {
	ToTimestamp   string `json:"to_timestamp"`
	ToTimestamp_2 string `json:"to_timestamp_2"`
	Status        string `json:"status"`
	Limit         int32  `json:"limit"`
	Offset        int32  `json:"offset"`
}

type GlobalQcp5ProductsReportFilterDateStatusRow struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	TraceabilityCode        string          `json:"traceability_code"`
	ProductID               int32           `json:"product_id"`
	Totalboxes              int32           `json:"totalboxes"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Cropname                sql.NullString  `json:"cropname"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	Status                  string          `json:"status"`
	PackinglistID           sql.NullInt32   `json:"packinglist_id"`
	Qcp5ID_2                sql.NullInt64   `json:"qcp5_id_2"`
	Status_2                sql.NullString  `json:"status_2"`
	UserID                  sql.NullInt32   `json:"user_id"`
	ExportcompanyID         sql.NullInt32   `json:"exportcompany_id"`
	TraceabilityCode_2      sql.NullString  `json:"traceability_code_2"`
	OrderID                 sql.NullInt64   `json:"order_id"`
	Expname                 sql.NullString  `json:"expname"`
	UserID_2                sql.NullInt32   `json:"user_id_2"`
	Fullname                sql.NullString  `json:"fullname"`
	Companyname             sql.NullString  `json:"companyname"`
	Countryname             sql.NullString  `json:"countryname"`
	Status_3                sql.NullString  `json:"status_3"`
	WeightPassed            sql.NullFloat64 `json:"weight_passed"`
	WeightRejected          sql.NullFloat64 `json:"weight_rejected"`
	Fmname                  sql.NullString  `json:"fmname"`
	Fmcode                  sql.NullString  `json:"fmcode"`
	Status_4                sql.NullString  `json:"status_4"`
	CreatedAt               sql.NullTime    `json:"created_at"`
	ConsignmentNo           sql.NullString  `json:"consignment_no"`
}

func (q *Queries) GlobalQcp5ProductsReportFilterDateStatus(ctx context.Context, arg GlobalQcp5ProductsReportFilterDateStatusParams) ([]GlobalQcp5ProductsReportFilterDateStatusRow, error) {
	rows, err := q.db.QueryContext(ctx, globalQcp5ProductsReportFilterDateStatus,
		arg.ToTimestamp,
		arg.ToTimestamp_2,
		arg.Status,
		arg.Limit,
		arg.Offset,
	)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GlobalQcp5ProductsReportFilterDateStatusRow{}
	for rows.Next() {
		var i GlobalQcp5ProductsReportFilterDateStatusRow
		if err := rows.Scan(
			&i.Qcp5ID,
			&i.TraceabilityCode,
			&i.ProductID,
			&i.Totalboxes,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.Cropname,
			&i.Sampledboxes,
			&i.Status,
			&i.PackinglistID,
			&i.Qcp5ID_2,
			&i.Status_2,
			&i.UserID,
			&i.ExportcompanyID,
			&i.TraceabilityCode_2,
			&i.OrderID,
			&i.Expname,
			&i.UserID_2,
			&i.Fullname,
			&i.Companyname,
			&i.Countryname,
			&i.Status_3,
			&i.WeightPassed,
			&i.WeightRejected,
			&i.Fmname,
			&i.Fmcode,
			&i.Status_4,
			&i.CreatedAt,
			&i.ConsignmentNo,
		); 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 globalQcp5ProductsReportFilterStatus = `-- name: GlobalQcp5ProductsReportFilterStatus :many
SELECT qcp5_products.qcp5_id,qcp5_products.traceability_code,
qcp5_products.product_id,qcp5_products.totalboxes,qcp5_products.boxweight,qcp5_products.productnetweight,
qcp5_products.totalproductnetweight,qcp5_products.totalproductgrossweight,crops.cropname,qcp5_products.sampledboxes,
qcp5_products.status,
qcp5.packinglist_id,qcp5.id as qcp5_id,
qcp5.status,qcp5.user_id,qcp5.exportcompany_id,receptionform.traceability_code,orders.id as order_id,
exportcompanies.expname,qcp5.user_id,users.fullname,clients.companyname,countries.countryname,
qcp5_recommendations.status,qcp5_recommendations.weight_passed,qcp5_recommendations.weight_rejected,
farmers.fmname,farmers.fmcode,qcp5.status,qcp5.created_at,orders.consignment_no FROM qcp5_products
LEFT JOIN  qcp5 on qcp5.id = qcp5_products.qcp5_id
LEFT JOIN  qcp5_recommendations on qcp5_recommendations.qcp5_product_id = qcp5_products.id
LEFT JOIN  packinglist  on packinglist.id    = qcp5.packinglist_id
LEFT JOIN  orders       on orders.id              = packinglist.order_id
LEFT JOIN  clients      on clients.id              = orders.client_id
LEFT JOIN  countries     on countries.id           = clients.country_id
LEFT JOIN  receptionform on receptionform.order_id = orders.id
LEFT JOIN  farmers on farmers.id = receptionform.supplier_id
LEFT JOIN  crops on crops.id = qcp5_products.product_id
LEFT JOIN  exportcompanies on exportcompanies.id = qcp5.exportcompany_id
LEFT JOIN  users on  users.id = qcp5.user_id
WHERE   qcp5_products.status = $1
LIMIT   $2 OFFSET $3
`

type GlobalQcp5ProductsReportFilterStatusParams struct {
	Status string `json:"status"`
	Limit  int32  `json:"limit"`
	Offset int32  `json:"offset"`
}

type GlobalQcp5ProductsReportFilterStatusRow struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	TraceabilityCode        string          `json:"traceability_code"`
	ProductID               int32           `json:"product_id"`
	Totalboxes              int32           `json:"totalboxes"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Cropname                sql.NullString  `json:"cropname"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	Status                  string          `json:"status"`
	PackinglistID           sql.NullInt32   `json:"packinglist_id"`
	Qcp5ID_2                sql.NullInt64   `json:"qcp5_id_2"`
	Status_2                sql.NullString  `json:"status_2"`
	UserID                  sql.NullInt32   `json:"user_id"`
	ExportcompanyID         sql.NullInt32   `json:"exportcompany_id"`
	TraceabilityCode_2      sql.NullString  `json:"traceability_code_2"`
	OrderID                 sql.NullInt64   `json:"order_id"`
	Expname                 sql.NullString  `json:"expname"`
	UserID_2                sql.NullInt32   `json:"user_id_2"`
	Fullname                sql.NullString  `json:"fullname"`
	Companyname             sql.NullString  `json:"companyname"`
	Countryname             sql.NullString  `json:"countryname"`
	Status_3                sql.NullString  `json:"status_3"`
	WeightPassed            sql.NullFloat64 `json:"weight_passed"`
	WeightRejected          sql.NullFloat64 `json:"weight_rejected"`
	Fmname                  sql.NullString  `json:"fmname"`
	Fmcode                  sql.NullString  `json:"fmcode"`
	Status_4                sql.NullString  `json:"status_4"`
	CreatedAt               sql.NullTime    `json:"created_at"`
	ConsignmentNo           sql.NullString  `json:"consignment_no"`
}

func (q *Queries) GlobalQcp5ProductsReportFilterStatus(ctx context.Context, arg GlobalQcp5ProductsReportFilterStatusParams) ([]GlobalQcp5ProductsReportFilterStatusRow, error) {
	rows, err := q.db.QueryContext(ctx, globalQcp5ProductsReportFilterStatus, arg.Status, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []GlobalQcp5ProductsReportFilterStatusRow{}
	for rows.Next() {
		var i GlobalQcp5ProductsReportFilterStatusRow
		if err := rows.Scan(
			&i.Qcp5ID,
			&i.TraceabilityCode,
			&i.ProductID,
			&i.Totalboxes,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.Cropname,
			&i.Sampledboxes,
			&i.Status,
			&i.PackinglistID,
			&i.Qcp5ID_2,
			&i.Status_2,
			&i.UserID,
			&i.ExportcompanyID,
			&i.TraceabilityCode_2,
			&i.OrderID,
			&i.Expname,
			&i.UserID_2,
			&i.Fullname,
			&i.Companyname,
			&i.Countryname,
			&i.Status_3,
			&i.WeightPassed,
			&i.WeightRejected,
			&i.Fmname,
			&i.Fmcode,
			&i.Status_4,
			&i.CreatedAt,
			&i.ConsignmentNo,
		); 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 listAllCompaniesQcp5Ds = `-- name: ListAllCompaniesQcp5Ds :many
SELECT qcp5.packinglist_id,qcp5.id as qcp5_id,
qcp5.status,qcp5.user_id,qcp5.created_at,
qcp5.exportcompany_id, users.fullname,exportcompanies.expname FROM qcp5
JOIN exportcompanies on exportcompanies.id = qcp5.exportcompany_id
JOIN users           on users.id           = qcp5.user_id
Where qcp5.status = $1
`

type ListAllCompaniesQcp5DsRow struct {
	PackinglistID   int32     `json:"packinglist_id"`
	Qcp5ID          int64     `json:"qcp5_id"`
	Status          string    `json:"status"`
	UserID          int32     `json:"user_id"`
	CreatedAt       time.Time `json:"created_at"`
	ExportcompanyID int32     `json:"exportcompany_id"`
	Fullname        string    `json:"fullname"`
	Expname         string    `json:"expname"`
}

func (q *Queries) ListAllCompaniesQcp5Ds(ctx context.Context, status string) ([]ListAllCompaniesQcp5DsRow, error) {
	rows, err := q.db.QueryContext(ctx, listAllCompaniesQcp5Ds, status)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListAllCompaniesQcp5DsRow{}
	for rows.Next() {
		var i ListAllCompaniesQcp5DsRow
		if err := rows.Scan(
			&i.PackinglistID,
			&i.Qcp5ID,
			&i.Status,
			&i.UserID,
			&i.CreatedAt,
			&i.ExportcompanyID,
			&i.Fullname,
			&i.Expname,
		); 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 listAllCompaniesQcp5WFs = `-- name: ListAllCompaniesQcp5WFs :many
SELECT qcp5.packinglist_id,qcp5.id as qcp5_id,
qcp5.status,qcp5.user_id,qcp5.created_at,
qcp5.exportcompany_id, users.fullname,exportcompanies.expname FROM qcp5
JOIN exportcompanies on exportcompanies.id = qcp5.exportcompany_id
JOIN users           on users.id           = qcp5.user_id
Where qcp5.status = $1 LIMIT $2 OFFSET $3
`

type ListAllCompaniesQcp5WFsParams struct {
	Status string `json:"status"`
	Limit  int32  `json:"limit"`
	Offset int32  `json:"offset"`
}

type ListAllCompaniesQcp5WFsRow struct {
	PackinglistID   int32     `json:"packinglist_id"`
	Qcp5ID          int64     `json:"qcp5_id"`
	Status          string    `json:"status"`
	UserID          int32     `json:"user_id"`
	CreatedAt       time.Time `json:"created_at"`
	ExportcompanyID int32     `json:"exportcompany_id"`
	Fullname        string    `json:"fullname"`
	Expname         string    `json:"expname"`
}

func (q *Queries) ListAllCompaniesQcp5WFs(ctx context.Context, arg ListAllCompaniesQcp5WFsParams) ([]ListAllCompaniesQcp5WFsRow, error) {
	rows, err := q.db.QueryContext(ctx, listAllCompaniesQcp5WFs, arg.Status, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListAllCompaniesQcp5WFsRow{}
	for rows.Next() {
		var i ListAllCompaniesQcp5WFsRow
		if err := rows.Scan(
			&i.PackinglistID,
			&i.Qcp5ID,
			&i.Status,
			&i.UserID,
			&i.CreatedAt,
			&i.ExportcompanyID,
			&i.Fullname,
			&i.Expname,
		); 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 listAllCompaniesQcp5s = `-- name: ListAllCompaniesQcp5s :many
SELECT qcp5.packinglist_id,qcp5.id as qcp5_id,
qcp5.status,qcp5.user_id,qcp5.created_at,
qcp5.exportcompany_id, users.fullname,exportcompanies.expname FROM qcp5
JOIN exportcompanies on exportcompanies.id = qcp5.exportcompany_id
JOIN users           on users.id           = qcp5.user_id
Where qcp5.status = $1 AND qcp5.created_at
BETWEEN TO_TIMESTAMP($2, 'YYYY-MM-DD HH24:MI:SS')
AND     TO_TIMESTAMP($3, 'YYYY-MM-DD HH24:MI:SS')
LIMIT   $4 OFFSET $5
`

type ListAllCompaniesQcp5sParams struct {
	Status        string `json:"status"`
	ToTimestamp   string `json:"to_timestamp"`
	ToTimestamp_2 string `json:"to_timestamp_2"`
	Limit         int32  `json:"limit"`
	Offset        int32  `json:"offset"`
}

type ListAllCompaniesQcp5sRow struct {
	PackinglistID   int32     `json:"packinglist_id"`
	Qcp5ID          int64     `json:"qcp5_id"`
	Status          string    `json:"status"`
	UserID          int32     `json:"user_id"`
	CreatedAt       time.Time `json:"created_at"`
	ExportcompanyID int32     `json:"exportcompany_id"`
	Fullname        string    `json:"fullname"`
	Expname         string    `json:"expname"`
}

func (q *Queries) ListAllCompaniesQcp5s(ctx context.Context, arg ListAllCompaniesQcp5sParams) ([]ListAllCompaniesQcp5sRow, error) {
	rows, err := q.db.QueryContext(ctx, listAllCompaniesQcp5s,
		arg.Status,
		arg.ToTimestamp,
		arg.ToTimestamp_2,
		arg.Limit,
		arg.Offset,
	)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListAllCompaniesQcp5sRow{}
	for rows.Next() {
		var i ListAllCompaniesQcp5sRow
		if err := rows.Scan(
			&i.PackinglistID,
			&i.Qcp5ID,
			&i.Status,
			&i.UserID,
			&i.CreatedAt,
			&i.ExportcompanyID,
			&i.Fullname,
			&i.Expname,
		); 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 listPendingQcp5s = `-- name: ListPendingQcp5s :many
SELECT crops.cropname,receptionform.order_id,
qcp5.user_id,users.fullname,qcp5.created_at,qcp5.status,
orders.consignment_no,qcp5.id qcp5_id,receptionform.traceability_code from qcp5
LEFT JOIN receptionform on receptionform.id = qcp3.reception_id
LEFT JOIN orders  on orders.id  = receptionform.order_id
LEFT JOIN crops   on crops.id   = receptionform.crop_id
LEFT JOIN users   on users.id   = qcp5.user_id
WHERE qcp5.exportcompany_id     = $3  AND qcp5.status = $4
LIMIT $1 OFFSET $2
`

type ListPendingQcp5sParams struct {
	Limit           int32  `json:"limit"`
	Offset          int32  `json:"offset"`
	ExportcompanyID int32  `json:"exportcompany_id"`
	Status          string `json:"status"`
}

type ListPendingQcp5sRow struct {
	Cropname         sql.NullString `json:"cropname"`
	OrderID          sql.NullInt32  `json:"order_id"`
	UserID           int32          `json:"user_id"`
	Fullname         sql.NullString `json:"fullname"`
	CreatedAt        time.Time      `json:"created_at"`
	Status           string         `json:"status"`
	ConsignmentNo    sql.NullString `json:"consignment_no"`
	Qcp5ID           int64          `json:"qcp5_id"`
	TraceabilityCode sql.NullString `json:"traceability_code"`
}

func (q *Queries) ListPendingQcp5s(ctx context.Context, arg ListPendingQcp5sParams) ([]ListPendingQcp5sRow, error) {
	rows, err := q.db.QueryContext(ctx, listPendingQcp5s,
		arg.Limit,
		arg.Offset,
		arg.ExportcompanyID,
		arg.Status,
	)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ListPendingQcp5sRow{}
	for rows.Next() {
		var i ListPendingQcp5sRow
		if err := rows.Scan(
			&i.Cropname,
			&i.OrderID,
			&i.UserID,
			&i.Fullname,
			&i.CreatedAt,
			&i.Status,
			&i.ConsignmentNo,
			&i.Qcp5ID,
			&i.TraceabilityCode,
		); 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 listQcp5s = `-- name: ListQcp5s :many
SELECT id, packinglist_id, user_id, status, exportcompany_id, created_at FROM qcp5
ORDER BY id LIMIT $1
OFFSET $2
`

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

func (q *Queries) ListQcp5s(ctx context.Context, arg ListQcp5sParams) ([]Qcp5, error) {
	rows, err := q.db.QueryContext(ctx, listQcp5s, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5{}
	for rows.Next() {
		var i Qcp5
		if err := rows.Scan(
			&i.ID,
			&i.PackinglistID,
			&i.UserID,
			&i.Status,
			&i.ExportcompanyID,
			&i.CreatedAt,
		); 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 qcp5AttributesContent = `-- name: Qcp5AttributesContent :many
Select qcp5_attributes.qcp5_id,qualityattributes.description from qcp5_attributes
JOIN   qualityattributes on qualityattributes.id = qcp5_attributes.qualityattributes_id
WHERE  qcp5_id = $1
AND    qcp5_attributes.qcp5_product_id = $2
`

type Qcp5AttributesContentParams struct {
	Qcp5ID        int32 `json:"qcp5_id"`
	Qcp5ProductID int32 `json:"qcp5_product_id"`
}

type Qcp5AttributesContentRow struct {
	Qcp5ID      int32  `json:"qcp5_id"`
	Description string `json:"description"`
}

func (q *Queries) Qcp5AttributesContent(ctx context.Context, arg Qcp5AttributesContentParams) ([]Qcp5AttributesContentRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5AttributesContent, arg.Qcp5ID, arg.Qcp5ProductID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5AttributesContentRow{}
	for rows.Next() {
		var i Qcp5AttributesContentRow
		if err := rows.Scan(&i.Qcp5ID, &i.Description); 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 qcp5ContentPerOrder = `-- name: Qcp5ContentPerOrder :many
Select clients.companyname,countries.countryname,exportcompanies.expname,exportcompanies.expregno, packhouses.phname, orders.consignment_no,
orders.status,orders.created_at,orders.id,orders.consignment_no as consignment__no from qcp5
JOIN  packinglist        on packinglist.id       = qcp5.packinglist_id
JOIN  orders             on orders.id            = packinglist.order_id
JOIN  exportcompanies    on exportcompanies.id   = orders.exportcompany_id
JOIN  clients            on clients.id           = orders.client_id
JOIN  countries          on countries.id         = clients.country_id
JOIN  packhouse_exporter on packhouse_exporter.exportcompany_id = exportcompanies.id
JOIN  packhouses         on packhouse_exporter.packhouse_id     = packhouses.id
WHERE qcp5.id = $1
`

type Qcp5ContentPerOrderRow struct {
	Companyname     string         `json:"companyname"`
	Countryname     string         `json:"countryname"`
	Expname         string         `json:"expname"`
	Expregno        string         `json:"expregno"`
	Phname          string         `json:"phname"`
	ConsignmentNo   sql.NullString `json:"consignment_no"`
	Status          string         `json:"status"`
	CreatedAt       time.Time      `json:"created_at"`
	ID              int64          `json:"id"`
	ConsignmentNo_2 sql.NullString `json:"consignment__no_2"`
}

func (q *Queries) Qcp5ContentPerOrder(ctx context.Context, id int64) ([]Qcp5ContentPerOrderRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5ContentPerOrder, id)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5ContentPerOrderRow{}
	for rows.Next() {
		var i Qcp5ContentPerOrderRow
		if err := rows.Scan(
			&i.Companyname,
			&i.Countryname,
			&i.Expname,
			&i.Expregno,
			&i.Phname,
			&i.ConsignmentNo,
			&i.Status,
			&i.CreatedAt,
			&i.ID,
			&i.ConsignmentNo_2,
		); 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 qcp5OtherAttributesContent = `-- name: Qcp5OtherAttributesContent :many
Select qualityattributes.description, qcp5_others.product_name from qcp5_other_attributes
JOIN   qualityattributes  on qualityattributes.id = qcp5_other_attributes.qualityattributes_id
JOIN   qcp5_others        on qcp5_others.id       = qcp5_other_attributes.qcp5_other_id
JOIN   users              on users.id             = qcp5_other_attributes.user_id
WHERE  qcp5_other_attributes.qcp5_id = $1
AND    qcp5_others.product_name = $2
`

type Qcp5OtherAttributesContentParams struct {
	Qcp5ID      int32  `json:"qcp5_id"`
	ProductName string `json:"product_name"`
}

type Qcp5OtherAttributesContentRow struct {
	Description string `json:"description"`
	ProductName string `json:"product_name"`
}

func (q *Queries) Qcp5OtherAttributesContent(ctx context.Context, arg Qcp5OtherAttributesContentParams) ([]Qcp5OtherAttributesContentRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5OtherAttributesContent, arg.Qcp5ID, arg.ProductName)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5OtherAttributesContentRow{}
	for rows.Next() {
		var i Qcp5OtherAttributesContentRow
		if err := rows.Scan(&i.Description, &i.ProductName); 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 qcp5OthersContentPerOrder = `-- name: Qcp5OthersContentPerOrder :many
select qcp5_others.qcp5_id,qcp5_others.noofboxes,qcp5_others.product_name,
qcp5_others.boxweight,qcp5_others.productnetweight,qcp5_others.totalproductnetweight,
qcp5_others.totalproductgrossweight,qcp5_others.status,qcp5_others.sampledboxes,
qcp5_others.created_at from qcp5_others
WHERE qcp5_others.qcp5_id = $1
`

type Qcp5OthersContentPerOrderRow struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	Noofboxes               int32           `json:"noofboxes"`
	ProductName             string          `json:"product_name"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Status                  string          `json:"status"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	CreatedAt               time.Time       `json:"created_at"`
}

func (q *Queries) Qcp5OthersContentPerOrder(ctx context.Context, qcp5ID int32) ([]Qcp5OthersContentPerOrderRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5OthersContentPerOrder, qcp5ID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5OthersContentPerOrderRow{}
	for rows.Next() {
		var i Qcp5OthersContentPerOrderRow
		if err := rows.Scan(
			&i.Qcp5ID,
			&i.Noofboxes,
			&i.ProductName,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.Status,
			&i.Sampledboxes,
			&i.CreatedAt,
		); 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 qcp5OthersCount = `-- name: Qcp5OthersCount :one
SELECT COUNT(id) AS id_count
FROM   qcp5_others
WHERE  qcp5_id = $1
`

func (q *Queries) Qcp5OthersCount(ctx context.Context, qcp5ID int32) (int64, error) {
	row := q.db.QueryRowContext(ctx, qcp5OthersCount, qcp5ID)
	var id_count int64
	err := row.Scan(&id_count)
	return id_count, err
}

const qcp5OthersPerConsignment = `-- name: Qcp5OthersPerConsignment :many
SELECT  qcp5_others.qcp5_id,qcp5_others.packinglist_id,qcp5_others.product_name,qcp5_others.noofboxes,
qcp5_others.sampledboxes,qcp5_others.boxweight,qcp5_others.productnetweight,
qcp5_others.totalproductnetweight,qcp5_others.totalproductgrossweight,qcp5_others.status,
qcp5_others.user_id,qcp5_others.exportcompany_id from qcp5_others
LEFT JOIN qcp5          on qcp5_others.qcp5_id   = qcp5.id
LEFT JOIN users         on users.id              = qcp5.user_id
LEFT JOIN packinglist   on packinglist.id        = qcp5.packinglist_id
LEFT JOIN orders        on orders.id             = packinglist.order_id
WHERE  orders.consignment_no = $1
GROUP BY qcp5_others.qcp5_id,qcp5.id,orders.id
`

type Qcp5OthersPerConsignmentRow struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	PackinglistID           int32           `json:"packinglist_id"`
	ProductName             string          `json:"product_name"`
	Noofboxes               int32           `json:"noofboxes"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Status                  string          `json:"status"`
	UserID                  int32           `json:"user_id"`
	ExportcompanyID         int32           `json:"exportcompany_id"`
}

func (q *Queries) Qcp5OthersPerConsignment(ctx context.Context, consignmentNo sql.NullString) ([]Qcp5OthersPerConsignmentRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5OthersPerConsignment, consignmentNo)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5OthersPerConsignmentRow{}
	for rows.Next() {
		var i Qcp5OthersPerConsignmentRow
		if err := rows.Scan(
			&i.Qcp5ID,
			&i.PackinglistID,
			&i.ProductName,
			&i.Noofboxes,
			&i.Sampledboxes,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.Status,
			&i.UserID,
			&i.ExportcompanyID,
		); 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 qcp5PerConsignment = `-- name: Qcp5PerConsignment :many
SELECT orders.id order_id,qcp5.id qcp5ID,qcp5.packinglist_id,
qcp5_products.traceability_code traceability_code,
qcp5_products.id row_id,qcp5_products.product_id product_id,
qcp5_products.totalboxes total_boxes,crops.cropname qcp5_product_name,
qcp5_products.status qcp5_product_status,
qcp5_products.boxweight boxweight,qcp5_products.totalproductnetweight totalproductnetweight,
qcp5_products.totalproductgrossweight totalproductgrossweight,
qcp5_products.sampledboxes sampled_boxes,
qcp5_products.productnetweight productnetweight from qcp5
LEFT JOIN qcp5_products on qcp5_products.qcp5_id = qcp5.id
LEFT JOIN crops         on crops.id   = qcp5_products.product_id
LEFT JOIN users         on users.id   = qcp5.user_id
LEFT JOIN packinglist   on packinglist.id = qcp5.packinglist_id
LEFT JOIN orders        on orders.id      = packinglist.order_id
WHERE  orders.consignment_no = $1
GROUP BY qcp5.id,orders.id, qcp5_products.id,crops.cropname
`

type Qcp5PerConsignmentRow struct {
	OrderID                 sql.NullInt64   `json:"order_id"`
	Qcp5id                  int64           `json:"qcp5id"`
	PackinglistID           int32           `json:"packinglist_id"`
	TraceabilityCode        sql.NullString  `json:"traceability_code"`
	RowID                   sql.NullInt64   `json:"row_id"`
	ProductID               sql.NullInt32   `json:"product_id"`
	TotalBoxes              sql.NullInt32   `json:"total_boxes"`
	Qcp5ProductName         sql.NullString  `json:"qcp5_product_name"`
	Qcp5ProductStatus       sql.NullString  `json:"qcp5_product_status"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	SampledBoxes            sql.NullInt32   `json:"sampled_boxes"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
}

func (q *Queries) Qcp5PerConsignment(ctx context.Context, consignmentNo sql.NullString) ([]Qcp5PerConsignmentRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5PerConsignment, consignmentNo)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5PerConsignmentRow{}
	for rows.Next() {
		var i Qcp5PerConsignmentRow
		if err := rows.Scan(
			&i.OrderID,
			&i.Qcp5id,
			&i.PackinglistID,
			&i.TraceabilityCode,
			&i.RowID,
			&i.ProductID,
			&i.TotalBoxes,
			&i.Qcp5ProductName,
			&i.Qcp5ProductStatus,
			&i.Boxweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.SampledBoxes,
			&i.Productnetweight,
		); 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 qcp5ProductsContentPerOrder = `-- name: Qcp5ProductsContentPerOrder :many
select qcp5_products.qcp5_id,qcp5_products.totalboxes,
qcp5_products.boxweight,qcp5_products.productnetweight,
crops.cropname,crops.id,crops.variant,
crops.crophscode,qcp5_products.totalproductnetweight,
qcp5_products.traceability_code,
qcp5_products.totalproductgrossweight,qcp5_products.status,
qcp5_products.sampledboxes,qcp5_products.created_at,
qcp5_products.id as product_row_id,
qcp5_products.product_id from qcp5_products
JOIN crops on crops.id = qcp5_products.product_id
JOIN qcp5  on qcp5.id  = qcp5_products.qcp5_id
WHERE qcp5.id = $1
`

type Qcp5ProductsContentPerOrderRow struct {
	Qcp5ID                  int32           `json:"qcp5_id"`
	Totalboxes              int32           `json:"totalboxes"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
	Cropname                string          `json:"cropname"`
	ID                      int64           `json:"id"`
	Variant                 string          `json:"variant"`
	Crophscode              string          `json:"crophscode"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	TraceabilityCode        string          `json:"traceability_code"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	Status                  string          `json:"status"`
	Sampledboxes            sql.NullInt32   `json:"sampledboxes"`
	CreatedAt               time.Time       `json:"created_at"`
	ProductRowID            int64           `json:"product_row_id"`
	ProductID               int32           `json:"product_id"`
}

func (q *Queries) Qcp5ProductsContentPerOrder(ctx context.Context, id int64) ([]Qcp5ProductsContentPerOrderRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5ProductsContentPerOrder, id)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5ProductsContentPerOrderRow{}
	for rows.Next() {
		var i Qcp5ProductsContentPerOrderRow
		if err := rows.Scan(
			&i.Qcp5ID,
			&i.Totalboxes,
			&i.Boxweight,
			&i.Productnetweight,
			&i.Cropname,
			&i.ID,
			&i.Variant,
			&i.Crophscode,
			&i.Totalproductnetweight,
			&i.TraceabilityCode,
			&i.Totalproductgrossweight,
			&i.Status,
			&i.Sampledboxes,
			&i.CreatedAt,
			&i.ProductRowID,
			&i.ProductID,
		); 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 qcp5ProductsExactRow = `-- name: Qcp5ProductsExactRow :one
SELECT id, qcp5_id, traceability_code, status, product_id, totalboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, created_at FROM  qcp5_products
WHERE qcp5_id           = $1
AND   traceability_code = $2
AND   product_id        = $3
AND   boxweight         = $4
`

type Qcp5ProductsExactRowParams struct {
	Qcp5ID           int32           `json:"qcp5_id"`
	TraceabilityCode string          `json:"traceability_code"`
	ProductID        int32           `json:"product_id"`
	Boxweight        sql.NullFloat64 `json:"boxweight"`
}

func (q *Queries) Qcp5ProductsExactRow(ctx context.Context, arg Qcp5ProductsExactRowParams) (Qcp5Product, error) {
	row := q.db.QueryRowContext(ctx, qcp5ProductsExactRow,
		arg.Qcp5ID,
		arg.TraceabilityCode,
		arg.ProductID,
		arg.Boxweight,
	)
	var i Qcp5Product
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.TraceabilityCode,
		&i.Status,
		&i.ProductID,
		&i.Totalboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.CreatedAt,
	)
	return i, err
}

const qcp5listOtherPerConsignment = `-- name: Qcp5listOtherPerConsignment :many
SELECT orders.id qcp5orderid,qcp5_others.product_name other_product_name,qcp5_others.status qcp5_others_status,orders.id as qcp5_order_ids, qcp5_others.boxweight others_boxweight,
qcp5_others.productnetweight others_product_netweight,qcp5_others.totalproductnetweight others_total_productweight,qcp5_others.totalproductgrossweight others_total_productgrossweight,
qcp5.id qcp5ID,qcp5_others.noofboxes other_box_numbers,qcp5_others.sampledboxes other_sampled_boxes,qcp5_others.id row_other_id,
qcp5.packinglist_id from qcp5
LEFT JOIN qcp5_others   on qcp5_others.qcp5_id   = qcp5.id
LEFT JOIN packinglist   on packinglist.id        = qcp5.packinglist_id
LEFT JOIN orders        on orders.id             = packinglist.order_id
LEFT JOIN users         on users.id              = qcp5.user_id
WHERE qcp5.status = $2
AND   orders.consignment_no = $1
GROUP BY qcp5_others.id,qcp5.id,orders.id
`

type Qcp5listOtherPerConsignmentParams struct {
	ConsignmentNo sql.NullString `json:"consignment_no"`
	Status        string         `json:"status"`
}

type Qcp5listOtherPerConsignmentRow struct {
	Qcp5orderid                   sql.NullInt64   `json:"qcp5orderid"`
	OtherProductName              sql.NullString  `json:"other_product_name"`
	Qcp5OthersStatus              sql.NullString  `json:"qcp5_others_status"`
	Qcp5OrderIds                  sql.NullInt64   `json:"qcp5_order_ids"`
	OthersBoxweight               sql.NullFloat64 `json:"others_boxweight"`
	OthersProductNetweight        sql.NullFloat64 `json:"others_product_netweight"`
	OthersTotalProductweight      sql.NullFloat64 `json:"others_total_productweight"`
	OthersTotalProductgrossweight sql.NullFloat64 `json:"others_total_productgrossweight"`
	Qcp5id                        int64           `json:"qcp5id"`
	OtherBoxNumbers               sql.NullInt32   `json:"other_box_numbers"`
	OtherSampledBoxes             sql.NullInt32   `json:"other_sampled_boxes"`
	RowOtherID                    sql.NullInt64   `json:"row_other_id"`
	PackinglistID                 int32           `json:"packinglist_id"`
}

func (q *Queries) Qcp5listOtherPerConsignment(ctx context.Context, arg Qcp5listOtherPerConsignmentParams) ([]Qcp5listOtherPerConsignmentRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5listOtherPerConsignment, arg.ConsignmentNo, arg.Status)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5listOtherPerConsignmentRow{}
	for rows.Next() {
		var i Qcp5listOtherPerConsignmentRow
		if err := rows.Scan(
			&i.Qcp5orderid,
			&i.OtherProductName,
			&i.Qcp5OthersStatus,
			&i.Qcp5OrderIds,
			&i.OthersBoxweight,
			&i.OthersProductNetweight,
			&i.OthersTotalProductweight,
			&i.OthersTotalProductgrossweight,
			&i.Qcp5id,
			&i.OtherBoxNumbers,
			&i.OtherSampledBoxes,
			&i.RowOtherID,
			&i.PackinglistID,
		); 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 qcp5listPerConsignment = `-- name: Qcp5listPerConsignment :many
SELECT  orders.id order_id,qcp5.id qcp5ID,qcp5.packinglist_id,qcp5_products.traceability_code traceability_code,qcp5_products.id row_id,qcp5_products.product_id product_id,
qcp5_products.totalboxes total_boxes,crops.cropname qcp5_product_name,qcp5_products.status qcp5_product_status,
qcp5_products.boxweight boxweight,qcp5_products.totalproductnetweight totalproductnetweight,
qcp5_products.totalproductgrossweight totalproductgrossweight,
qcp5_products.sampledboxes sampled_boxes,qcp5_products.productnetweight productnetweight from qcp5
LEFT JOIN qcp5_products on qcp5_products.qcp5_id = qcp5.id
LEFT JOIN crops         on crops.id   = qcp5_products.product_id
LEFT JOIN users         on users.id   = qcp5.user_id
LEFT JOIN packinglist   on packinglist.id = qcp5.packinglist_id
LEFT JOIN orders        on orders.id      = packinglist.order_id
WHERE    qcp5.status = $2
AND      orders.consignment_no = $1
GROUP BY qcp5.id,orders.id, qcp5_products.id,crops.cropname
`

type Qcp5listPerConsignmentParams struct {
	ConsignmentNo sql.NullString `json:"consignment_no"`
	Status        string         `json:"status"`
}

type Qcp5listPerConsignmentRow struct {
	OrderID                 sql.NullInt64   `json:"order_id"`
	Qcp5id                  int64           `json:"qcp5id"`
	PackinglistID           int32           `json:"packinglist_id"`
	TraceabilityCode        sql.NullString  `json:"traceability_code"`
	RowID                   sql.NullInt64   `json:"row_id"`
	ProductID               sql.NullInt32   `json:"product_id"`
	TotalBoxes              sql.NullInt32   `json:"total_boxes"`
	Qcp5ProductName         sql.NullString  `json:"qcp5_product_name"`
	Qcp5ProductStatus       sql.NullString  `json:"qcp5_product_status"`
	Boxweight               sql.NullFloat64 `json:"boxweight"`
	Totalproductnetweight   sql.NullFloat64 `json:"totalproductnetweight"`
	Totalproductgrossweight sql.NullFloat64 `json:"totalproductgrossweight"`
	SampledBoxes            sql.NullInt32   `json:"sampled_boxes"`
	Productnetweight        sql.NullFloat64 `json:"productnetweight"`
}

func (q *Queries) Qcp5listPerConsignment(ctx context.Context, arg Qcp5listPerConsignmentParams) ([]Qcp5listPerConsignmentRow, error) {
	rows, err := q.db.QueryContext(ctx, qcp5listPerConsignment, arg.ConsignmentNo, arg.Status)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Qcp5listPerConsignmentRow{}
	for rows.Next() {
		var i Qcp5listPerConsignmentRow
		if err := rows.Scan(
			&i.OrderID,
			&i.Qcp5id,
			&i.PackinglistID,
			&i.TraceabilityCode,
			&i.RowID,
			&i.ProductID,
			&i.TotalBoxes,
			&i.Qcp5ProductName,
			&i.Qcp5ProductStatus,
			&i.Boxweight,
			&i.Totalproductnetweight,
			&i.Totalproductgrossweight,
			&i.SampledBoxes,
			&i.Productnetweight,
		); 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 updateQcp5 = `-- name: UpdateQcp5 :one
UPDATE qcp5
  set
    status  = $2
WHERE id = $1
RETURNING id, packinglist_id, user_id, status, exportcompany_id, created_at
`

type UpdateQcp5Params struct {
	ID     int64  `json:"id"`
	Status string `json:"status"`
}

func (q *Queries) UpdateQcp5(ctx context.Context, arg UpdateQcp5Params) (Qcp5, error) {
	row := q.db.QueryRowContext(ctx, updateQcp5, arg.ID, arg.Status)
	var i Qcp5
	err := row.Scan(
		&i.ID,
		&i.PackinglistID,
		&i.UserID,
		&i.Status,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const updateQcp5OtherProductsStatusRows = `-- name: UpdateQcp5OtherProductsStatusRows :one
Update qcp5_others
    SET
    status   = $5
    WHERE qcp5_id  = $1
    AND   packinglist_id = $2
    AND   product_name = $3
    AND   boxweight = $4
RETURNING id, qcp5_id, packinglist_id, product_name, noofboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, status, user_id, exportcompany_id, created_at
`

type UpdateQcp5OtherProductsStatusRowsParams struct {
	Qcp5ID        int32           `json:"qcp5_id"`
	PackinglistID int32           `json:"packinglist_id"`
	ProductName   string          `json:"product_name"`
	Boxweight     sql.NullFloat64 `json:"boxweight"`
	Status        string          `json:"status"`
}

func (q *Queries) UpdateQcp5OtherProductsStatusRows(ctx context.Context, arg UpdateQcp5OtherProductsStatusRowsParams) (Qcp5Other, error) {
	row := q.db.QueryRowContext(ctx, updateQcp5OtherProductsStatusRows,
		arg.Qcp5ID,
		arg.PackinglistID,
		arg.ProductName,
		arg.Boxweight,
		arg.Status,
	)
	var i Qcp5Other
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.PackinglistID,
		&i.ProductName,
		&i.Noofboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.Status,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const updateQcp5OtherStatus = `-- name: UpdateQcp5OtherStatus :one
UPDATE qcp5_others
  set
    status = $2
WHERE id = $1
RETURNING id, qcp5_id, packinglist_id, product_name, noofboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, status, user_id, exportcompany_id, created_at
`

type UpdateQcp5OtherStatusParams struct {
	ID     int64  `json:"id"`
	Status string `json:"status"`
}

func (q *Queries) UpdateQcp5OtherStatus(ctx context.Context, arg UpdateQcp5OtherStatusParams) (Qcp5Other, error) {
	row := q.db.QueryRowContext(ctx, updateQcp5OtherStatus, arg.ID, arg.Status)
	var i Qcp5Other
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.PackinglistID,
		&i.ProductName,
		&i.Noofboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.Status,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const updateQcp5Others = `-- name: UpdateQcp5Others :one
UPDATE qcp5_others
  set
    qcp5_id = $2,
    product_name = $3,
    noofboxes = $4
WHERE id = $1
RETURNING id, qcp5_id, packinglist_id, product_name, noofboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, status, user_id, exportcompany_id, created_at
`

type UpdateQcp5OthersParams struct {
	ID          int64  `json:"id"`
	Qcp5ID      int32  `json:"qcp5_id"`
	ProductName string `json:"product_name"`
	Noofboxes   int32  `json:"noofboxes"`
}

func (q *Queries) UpdateQcp5Others(ctx context.Context, arg UpdateQcp5OthersParams) (Qcp5Other, error) {
	row := q.db.QueryRowContext(ctx, updateQcp5Others,
		arg.ID,
		arg.Qcp5ID,
		arg.ProductName,
		arg.Noofboxes,
	)
	var i Qcp5Other
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.PackinglistID,
		&i.ProductName,
		&i.Noofboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.Status,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const updateQcp5OthersSampled = `-- name: UpdateQcp5OthersSampled :one
UPDATE qcp5_others
  set
    sampledboxes = $2
WHERE id = $1
RETURNING id, qcp5_id, packinglist_id, product_name, noofboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, status, user_id, exportcompany_id, created_at
`

type UpdateQcp5OthersSampledParams struct {
	ID           int64         `json:"id"`
	Sampledboxes sql.NullInt32 `json:"sampledboxes"`
}

func (q *Queries) UpdateQcp5OthersSampled(ctx context.Context, arg UpdateQcp5OthersSampledParams) (Qcp5Other, error) {
	row := q.db.QueryRowContext(ctx, updateQcp5OthersSampled, arg.ID, arg.Sampledboxes)
	var i Qcp5Other
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.PackinglistID,
		&i.ProductName,
		&i.Noofboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.Status,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const updateQcp5Products = `-- name: UpdateQcp5Products :one
UPDATE qcp5_products
  set
    status  = $2
WHERE id = $1
RETURNING id, qcp5_id, traceability_code, status, product_id, totalboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, created_at
`

type UpdateQcp5ProductsParams struct {
	ID     int64  `json:"id"`
	Status string `json:"status"`
}

func (q *Queries) UpdateQcp5Products(ctx context.Context, arg UpdateQcp5ProductsParams) (Qcp5Product, error) {
	row := q.db.QueryRowContext(ctx, updateQcp5Products, arg.ID, arg.Status)
	var i Qcp5Product
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.TraceabilityCode,
		&i.Status,
		&i.ProductID,
		&i.Totalboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.CreatedAt,
	)
	return i, err
}

const updateQcp5ProductsStatusRows = `-- name: UpdateQcp5ProductsStatusRows :one
Update qcp5_products
    SET
    status   = $5
    WHERE qcp5_id  = $1
    AND   traceability_code = $2
    AND   product_id = $3
    AND   boxweight = $4
RETURNING id, qcp5_id, traceability_code, status, product_id, totalboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, created_at
`

type UpdateQcp5ProductsStatusRowsParams struct {
	Qcp5ID           int32           `json:"qcp5_id"`
	TraceabilityCode string          `json:"traceability_code"`
	ProductID        int32           `json:"product_id"`
	Boxweight        sql.NullFloat64 `json:"boxweight"`
	Status           string          `json:"status"`
}

func (q *Queries) UpdateQcp5ProductsStatusRows(ctx context.Context, arg UpdateQcp5ProductsStatusRowsParams) (Qcp5Product, error) {
	row := q.db.QueryRowContext(ctx, updateQcp5ProductsStatusRows,
		arg.Qcp5ID,
		arg.TraceabilityCode,
		arg.ProductID,
		arg.Boxweight,
		arg.Status,
	)
	var i Qcp5Product
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.TraceabilityCode,
		&i.Status,
		&i.ProductID,
		&i.Totalboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.CreatedAt,
	)
	return i, err
}

const updateQcp5Sampled = `-- name: UpdateQcp5Sampled :one
UPDATE qcp5_products
  set
    sampledboxes = $2
WHERE id = $1
RETURNING id, qcp5_id, traceability_code, status, product_id, totalboxes, boxweight, productnetweight, totalproductnetweight, totalproductgrossweight, sampledboxes, created_at
`

type UpdateQcp5SampledParams struct {
	ID           int64         `json:"id"`
	Sampledboxes sql.NullInt32 `json:"sampledboxes"`
}

func (q *Queries) UpdateQcp5Sampled(ctx context.Context, arg UpdateQcp5SampledParams) (Qcp5Product, error) {
	row := q.db.QueryRowContext(ctx, updateQcp5Sampled, arg.ID, arg.Sampledboxes)
	var i Qcp5Product
	err := row.Scan(
		&i.ID,
		&i.Qcp5ID,
		&i.TraceabilityCode,
		&i.Status,
		&i.ProductID,
		&i.Totalboxes,
		&i.Boxweight,
		&i.Productnetweight,
		&i.Totalproductnetweight,
		&i.Totalproductgrossweight,
		&i.Sampledboxes,
		&i.CreatedAt,
	)
	return i, err
}
