2023-03-05 23:35:41 +07:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// sqlc v1.17.2
|
|
|
|
// source: purchase_order_detail.sql
|
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
const createPurchaseOrderDetail = `-- name: CreatePurchaseOrderDetail :one
|
|
|
|
INSERT INTO purchase_order_detail (
|
|
|
|
purchase_order_id,
|
|
|
|
merchant_id,
|
|
|
|
product_id,
|
|
|
|
quantity,
|
|
|
|
sub_total,
|
|
|
|
product_price
|
|
|
|
) VALUES (
|
|
|
|
$1, $2, $3, $4, $5, $6
|
|
|
|
)
|
|
|
|
RETURNING id, index_id, code, merchant_id, purchase_order_id, product_id, quantity, sub_total, product_price, created_at, updated_at
|
|
|
|
`
|
|
|
|
|
|
|
|
type CreatePurchaseOrderDetailParams struct {
|
|
|
|
PurchaseOrderID uuid.UUID `json:"purchase_order_id"`
|
|
|
|
MerchantID uuid.UUID `json:"merchant_id"`
|
|
|
|
ProductID uuid.UUID `json:"product_id"`
|
|
|
|
Quantity float64 `json:"quantity"`
|
|
|
|
SubTotal float64 `json:"sub_total"`
|
|
|
|
ProductPrice float64 `json:"product_price"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) CreatePurchaseOrderDetail(ctx context.Context, arg CreatePurchaseOrderDetailParams) (PurchaseOrderDetail, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, createPurchaseOrderDetail,
|
|
|
|
arg.PurchaseOrderID,
|
|
|
|
arg.MerchantID,
|
|
|
|
arg.ProductID,
|
|
|
|
arg.Quantity,
|
|
|
|
arg.SubTotal,
|
|
|
|
arg.ProductPrice,
|
|
|
|
)
|
|
|
|
var i PurchaseOrderDetail
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.IndexID,
|
|
|
|
&i.Code,
|
|
|
|
&i.MerchantID,
|
|
|
|
&i.PurchaseOrderID,
|
|
|
|
&i.ProductID,
|
|
|
|
&i.Quantity,
|
|
|
|
&i.SubTotal,
|
|
|
|
&i.ProductPrice,
|
|
|
|
&i.CreatedAt,
|
|
|
|
&i.UpdatedAt,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
2023-03-16 16:55:45 +07:00
|
|
|
|
|
|
|
const getPurchaseOrderDetailsByPuchaseOrderId = `-- name: GetPurchaseOrderDetailsByPuchaseOrderId :one
|
|
|
|
SELECT id, index_id, code, merchant_id, purchase_order_id, product_id, quantity, sub_total, product_price, created_at, updated_at
|
|
|
|
FROM purchase_order_detail
|
|
|
|
WHERE purchase_order_id = $1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetPurchaseOrderDetailsByPuchaseOrderId(ctx context.Context, purchaseOrderID uuid.UUID) (PurchaseOrderDetail, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getPurchaseOrderDetailsByPuchaseOrderId, purchaseOrderID)
|
|
|
|
var i PurchaseOrderDetail
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.IndexID,
|
|
|
|
&i.Code,
|
|
|
|
&i.MerchantID,
|
|
|
|
&i.PurchaseOrderID,
|
|
|
|
&i.ProductID,
|
|
|
|
&i.Quantity,
|
|
|
|
&i.SubTotal,
|
|
|
|
&i.ProductPrice,
|
|
|
|
&i.CreatedAt,
|
|
|
|
&i.UpdatedAt,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|