38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"git.nochill.in/nochill/naice_pos/util"
|
|
"github.com/google/uuid"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func createRandomStockLog(t *testing.T) {
|
|
product, _ := createRandomProduct(t)
|
|
user := createRandomUser(t)
|
|
|
|
arg := CreateStockLogsParams{
|
|
ProductID: product.ID,
|
|
MerchantID: product.MerchantID,
|
|
CreatedBy: user.ID,
|
|
TransactionID: uuid.NullUUID{Valid: true, UUID: uuid.New()},
|
|
TransactionActionType: "Stock_log",
|
|
TransactionDescription: fmt.Sprintf("Penyesuaian stok %s", util.RandomTransactionCode("P", user.IndexID)),
|
|
SellingPrice: util.RandomFloat(10000, 99999),
|
|
PurchasePrice: util.RandomFloat(5000, 50000),
|
|
Quantity: util.RandomFloat(1, 100),
|
|
Type: util.STOCK_LOG_IN,
|
|
}
|
|
|
|
stockLog, err := testQueries.CreateStockLogs(context.Background(), arg)
|
|
require.NoError(t, err)
|
|
require.NotEmpty(t, stockLog)
|
|
}
|
|
|
|
func TestCreateStockLog(t *testing.T) {
|
|
createRandomStockLog(t)
|
|
}
|