74 lines
1.8 KiB
SQL
74 lines
1.8 KiB
SQL
-- -- name: CreateShopTransaction :one
|
|
-- INSERT INTO shop_transactions (
|
|
-- amount,
|
|
-- branch_id,
|
|
-- company_id,
|
|
-- user_id,
|
|
-- type,
|
|
-- full_name,
|
|
-- phone_number,
|
|
-- payment_option,
|
|
-- bank_code,
|
|
-- beneficiary_name,
|
|
-- account_name,
|
|
-- account_number,
|
|
-- reference_number
|
|
-- )
|
|
-- VALUES (
|
|
-- $1,
|
|
-- $2,
|
|
-- $3,
|
|
-- $4,
|
|
-- $5,
|
|
-- $6,
|
|
-- $7,
|
|
-- $8,
|
|
-- $9,
|
|
-- $10,
|
|
-- $11,
|
|
-- $12,
|
|
-- $13
|
|
-- )
|
|
-- RETURNING *;
|
|
-- -- name: GetAllShopTransactions :many
|
|
-- SELECT *
|
|
-- FROM shop_transaction_detail
|
|
-- wHERE (
|
|
-- branch_id = sqlc.narg('branch_id')
|
|
-- OR sqlc.narg('branch_id') IS NULL
|
|
-- )
|
|
-- AND (
|
|
-- company_id = sqlc.narg('company_id')
|
|
-- OR sqlc.narg('company_id') IS NULL
|
|
-- )
|
|
-- AND (
|
|
-- user_id = sqlc.narg('user_id')
|
|
-- OR sqlc.narg('user_id') IS NULL
|
|
-- )
|
|
-- AND (
|
|
-- full_name ILIKE '%' || sqlc.narg('query') || '%'
|
|
-- OR phone_number ILIKE '%' || sqlc.narg('query') || '%'
|
|
-- OR sqlc.narg('query') IS NULL
|
|
-- )
|
|
-- AND (
|
|
-- created_at > sqlc.narg('created_before')
|
|
-- OR sqlc.narg('created_before') IS NULL
|
|
-- )
|
|
-- AND (
|
|
-- created_at < sqlc.narg('created_after')
|
|
-- OR sqlc.narg('created_after') IS NULL
|
|
-- );
|
|
-- -- name: GetShopTransactionByID :one
|
|
-- SELECT *
|
|
-- FROM shop_transaction_detail
|
|
-- WHERE id = $1;
|
|
-- -- name: GetShopTransactionByBranch :many
|
|
-- SELECT *
|
|
-- FROM shop_transaction_detail
|
|
-- WHERE branch_id = $1;
|
|
-- -- name: UpdateShopTransactionVerified :exec
|
|
-- UPDATE shop_transactions
|
|
-- SET verified = $2,
|
|
-- approved_by = $3,
|
|
-- updated_at = CURRENT_TIMESTAMP
|
|
-- WHERE id = $1; |