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

package db

import (
	"context"
	"database/sql"
)

const createConsignmentStatusTracker = `-- name: CreateConsignmentStatusTracker :one
INSERT INTO consignmentstatustracker (
     consignment_no,
     consignment_status,
     reasons,
     notes
 ) VALUES (
    $1, 
    $2,
    $3,
    $4
 ) RETURNING id, consignment_no, consignment_status, reasons, notes, created_at
`

type CreateConsignmentStatusTrackerParams struct {
	ConsignmentNo     string         `json:"consignment_no"`
	ConsignmentStatus string         `json:"consignment_status"`
	Reasons           sql.NullString `json:"reasons"`
	Notes             sql.NullString `json:"notes"`
}

func (q *Queries) CreateConsignmentStatusTracker(ctx context.Context, arg CreateConsignmentStatusTrackerParams) (Consignmentstatustracker, error) {
	row := q.db.QueryRowContext(ctx, createConsignmentStatusTracker,
		arg.ConsignmentNo,
		arg.ConsignmentStatus,
		arg.Reasons,
		arg.Notes,
	)
	var i Consignmentstatustracker
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.ConsignmentStatus,
		&i.Reasons,
		&i.Notes,
		&i.CreatedAt,
	)
	return i, err
}

const createDestructionNotice = `-- name: CreateDestructionNotice :one
INSERT INTO destructionnotice (
    consignment_no,
    instructions,
    notes,
    boarder_inspector,
    nppo_inspector,
    company_rep,
    user_id,
    exportcompany_id
 ) VALUES (
    $1, 
    $2,
    $3,
    $4, 
    $5, 
    $6, 
    $7, 
    $8
 ) RETURNING id, consignment_no, instructions, notes, user_id, boarder_inspector, nppo_inspector, company_rep, exportcompany_id, created_at, weight_rejected
`

type CreateDestructionNoticeParams struct {
	ConsignmentNo    string         `json:"consignment_no"`
	Instructions     sql.NullString `json:"instructions"`
	Notes            sql.NullString `json:"notes"`
	BoarderInspector int32          `json:"boarder_inspector"`
	NppoInspector    int32          `json:"nppo_inspector"`
	CompanyRep       int32          `json:"company_rep"`
	UserID           int32          `json:"user_id"`
	ExportcompanyID  int32          `json:"exportcompany_id"`
}

func (q *Queries) CreateDestructionNotice(ctx context.Context, arg CreateDestructionNoticeParams) (Destructionnotice, error) {
	row := q.db.QueryRowContext(ctx, createDestructionNotice,
		arg.ConsignmentNo,
		arg.Instructions,
		arg.Notes,
		arg.BoarderInspector,
		arg.NppoInspector,
		arg.CompanyRep,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Destructionnotice
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.Instructions,
		&i.Notes,
		&i.UserID,
		&i.BoarderInspector,
		&i.NppoInspector,
		&i.CompanyRep,
		&i.ExportcompanyID,
		&i.CreatedAt,
		&i.WeightRejected,
	)
	return i, err
}

const createInterceptionNotice = `-- name: CreateInterceptionNotice :one
INSERT INTO interceptionnotice (
    consignment_no,
    instructions,
    notes,
    user_id,
    exportcompany_id
 ) VALUES (
    $1, 
    $2,
    $3,
    $4, 
    $5
 ) RETURNING id, consignment_no, instructions, notes, user_id, exportcompany_id, created_at
`

type CreateInterceptionNoticeParams struct {
	ConsignmentNo   string         `json:"consignment_no"`
	Instructions    sql.NullString `json:"instructions"`
	Notes           sql.NullString `json:"notes"`
	UserID          int32          `json:"user_id"`
	ExportcompanyID int32          `json:"exportcompany_id"`
}

func (q *Queries) CreateInterceptionNotice(ctx context.Context, arg CreateInterceptionNoticeParams) (Interceptionnotice, error) {
	row := q.db.QueryRowContext(ctx, createInterceptionNotice,
		arg.ConsignmentNo,
		arg.Instructions,
		arg.Notes,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Interceptionnotice
	err := row.Scan(
		&i.ID,
		&i.ConsignmentNo,
		&i.Instructions,
		&i.Notes,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const createTrackStatus = `-- name: CreateTrackStatus :one
INSERT INTO trackstatus (
    instructions,
    comment,
    user_id,
    exportcompany_id
 ) VALUES (
    $1, 
    $2,
    $3,
    $4
 ) RETURNING id, instructions, comment, user_id, exportcompany_id, created_at
`

type CreateTrackStatusParams struct {
	Instructions    string         `json:"instructions"`
	Comment         sql.NullString `json:"comment"`
	UserID          int32          `json:"user_id"`
	ExportcompanyID int32          `json:"exportcompany_id"`
}

func (q *Queries) CreateTrackStatus(ctx context.Context, arg CreateTrackStatusParams) (Trackstatus, error) {
	row := q.db.QueryRowContext(ctx, createTrackStatus,
		arg.Instructions,
		arg.Comment,
		arg.UserID,
		arg.ExportcompanyID,
	)
	var i Trackstatus
	err := row.Scan(
		&i.ID,
		&i.Instructions,
		&i.Comment,
		&i.UserID,
		&i.ExportcompanyID,
		&i.CreatedAt,
	)
	return i, err
}

const fetchDestructionNotice = `-- name: FetchDestructionNotice :many
SELECT id, consignment_no, instructions, notes, user_id, boarder_inspector, nppo_inspector, company_rep, exportcompany_id, created_at, weight_rejected from destructionnotice 
WHERE consignment_no = $1
`

func (q *Queries) FetchDestructionNotice(ctx context.Context, consignmentNo string) ([]Destructionnotice, error) {
	rows, err := q.db.QueryContext(ctx, fetchDestructionNotice, consignmentNo)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []Destructionnotice{}
	for rows.Next() {
		var i Destructionnotice
		if err := rows.Scan(
			&i.ID,
			&i.ConsignmentNo,
			&i.Instructions,
			&i.Notes,
			&i.UserID,
			&i.BoarderInspector,
			&i.NppoInspector,
			&i.CompanyRep,
			&i.ExportcompanyID,
			&i.CreatedAt,
			&i.WeightRejected,
		); 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
}
