Update Api
This commit is contained in:
parent
40705fbf3b
commit
dc8aafbbc1
159
database.txt
Normal file
159
database.txt
Normal file
@ -0,0 +1,159 @@
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username VARCHAR(100) UNIQUE NOT NULL,
|
||||
password_hash TEXT NOT NULL,
|
||||
role VARCHAR(50) NOT NULL, -- contoh: 'admin', 'sales', 'warehouse'
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
updated_at TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE master_product_category (
|
||||
id SERIAL PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(100),
|
||||
description TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE master_collection (
|
||||
id SERIAL PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(100),
|
||||
description TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE master_colour (
|
||||
id SERIAL PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(100),
|
||||
hex VARCHAR(7),
|
||||
);
|
||||
|
||||
CREATE TABLE master_size (
|
||||
id SERIAL PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(100),
|
||||
description TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE master_warehouse (
|
||||
id SERIAL PRIMARY KEY,
|
||||
kode VARCHAR(50),
|
||||
name VARCHAR(100),
|
||||
type VARCHAR(50),
|
||||
address TEXT,
|
||||
stackholder VARCHAR(100),
|
||||
number VARCHAR(50),
|
||||
description TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE master_product (
|
||||
id SERIAL PRIMARY KEY,
|
||||
category_id INT REFERENCES master_product_category(id),
|
||||
collection_id INT REFERENCES master_collection(id),
|
||||
colour_id INT REFERENCES master_colour(id),
|
||||
size_id INT REFERENCES master_size(id),
|
||||
sku VARCHAR(50),
|
||||
name VARCHAR(100),
|
||||
description TEXT,
|
||||
price float,
|
||||
hpp float,
|
||||
unit_of_measure VARCHAR(50),
|
||||
is_raw_material BOOLEAN,
|
||||
is_finished_good BOOLEAN
|
||||
);
|
||||
|
||||
CREATE TABLE stock_movement (
|
||||
id SERIAL PRIMARY KEY,
|
||||
product_id INT REFERENCES master_product(id),
|
||||
origin_warehouse_id INT REFERENCES master_warehouse(id),
|
||||
stock_type VARCHAR(50),
|
||||
destination_warehouse_id INT REFERENCES master_warehouse(id),
|
||||
date DATE,
|
||||
note TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE master_product_componen (
|
||||
id SERIAL PRIMARY KEY,
|
||||
product_id INT REFERENCES master_product(id),
|
||||
componen_id INT REFERENCES master_product(id),
|
||||
quantity NUMERIC,
|
||||
unit VARCHAR(10),
|
||||
note TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE production_order (
|
||||
id SERIAL PRIMARY KEY,
|
||||
product_id INT REFERENCES master_product(id),
|
||||
production_id INT REFERENCES master_warehouse(id),
|
||||
target_quantity NUMERIC,
|
||||
status VARCHAR(50),
|
||||
start_date DATE,
|
||||
end_date DATE,
|
||||
note TEXT
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE customer (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
address TEXT,
|
||||
phone VARCHAR(20),
|
||||
email VARCHAR(100)
|
||||
);
|
||||
|
||||
CREATE TABLE sales_order (
|
||||
id SERIAL PRIMARY KEY,
|
||||
customer_id INT REFERENCES customer(id),
|
||||
order_date DATE,
|
||||
status VARCHAR(50),
|
||||
total_amount NUMERIC,
|
||||
note TEXT,
|
||||
payment_terms VARCHAR(100),
|
||||
due_date DATE,
|
||||
is_dp BOOLEAN,
|
||||
dp_ammount NUMERIC,
|
||||
dp_paid BOOLEAN
|
||||
);
|
||||
|
||||
CREATE TABLE sales_order_item (
|
||||
id SERIAL PRIMARY KEY,
|
||||
sales_order_id INT REFERENCES sales_order(id),
|
||||
product_id INT REFERENCES master_product(id),
|
||||
quantity NUMERIC,
|
||||
unit_price NUMERIC,
|
||||
discount NUMERIC,
|
||||
sub_total NUMERIC
|
||||
);
|
||||
|
||||
CREATE TABLE invoice (
|
||||
id SERIAL PRIMARY KEY,
|
||||
sales_order_id INT REFERENCES sales_order(id),
|
||||
invoice_number VARCHAR(100),
|
||||
invoice_date DATE,
|
||||
due_date DATE,
|
||||
status VARCHAR(50),
|
||||
total_amount NUMERIC,
|
||||
is_dp_invoice BOOLEAN,
|
||||
is_full_invoice BOOLEAN,
|
||||
parent_invoice_id INT
|
||||
);
|
||||
|
||||
CREATE TABLE invoice_line (
|
||||
id SERIAL PRIMARY KEY,
|
||||
invoice_id INT REFERENCES invoice(id),
|
||||
product_id INT REFERENCES master_product(id),
|
||||
quantity NUMERIC,
|
||||
unit_price NUMERIC,
|
||||
discount NUMERIC,
|
||||
sub_total NUMERIC
|
||||
);
|
||||
|
||||
CREATE TABLE payment (
|
||||
id SERIAL PRIMARY KEY,
|
||||
invoice_id INT REFERENCES invoice(id),
|
||||
payment_date DATE,
|
||||
amount NUMERIC,
|
||||
payment_method VARCHAR(100),
|
||||
reference_number VARCHAR(100),
|
||||
notes TEXT
|
||||
);
|
||||
@ -1,10 +1,14 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Collection struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Code string `gorm:"not null;unique" json:"code"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
@ -4,8 +4,9 @@ import "time"
|
||||
|
||||
type Colour struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Code string `json:"code"` // contoh: HEX (#000000) atau RGB
|
||||
Hex string `json:"hex"` // Hexadecimal color code
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
@ -16,10 +16,12 @@ type Product struct {
|
||||
SizeID uint `json:"size_id"`
|
||||
Size Size `gorm:"foreignKey:SizeID" json:"size"`
|
||||
|
||||
SKU string `gorm:"not null;unique" json:"sku"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Description string `json:"description"`
|
||||
UnitOfMeasure string `json:"unit_of_measure"`
|
||||
SKU string `gorm:"not null;unique" json:"sku"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Description string `json:"description"`
|
||||
Price float64 `gorm:"not null" json:"price"`
|
||||
Hpp float64 `gorm:"not null" json:"hpp"`
|
||||
UnitOfMeasure string `json:"unit_of_measure"`
|
||||
|
||||
IsRawMaterial bool `json:"is_raw_material"`
|
||||
IsFinishedGood bool `json:"is_finished_good"`
|
||||
|
||||
@ -3,8 +3,10 @@ package models
|
||||
import "time"
|
||||
|
||||
type ProductCategory struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Code string `gorm:"not null;unique" json:"code"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@ type ProductComponent struct {
|
||||
Component Product `gorm:"foreignKey:ComponenID" json:"component"`
|
||||
|
||||
Quantity float64 `json:"quantity"`
|
||||
Unit string `json:"unit"` // Satuan dari komponen
|
||||
Note string `json:"note,omitempty"`
|
||||
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
|
||||
@ -4,8 +4,9 @@ import "time"
|
||||
|
||||
type Size struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"not null" json:"name"` // contoh: S, M, L, XL
|
||||
Description string `json:"description"` // opsional, seperti "Small", "Large"
|
||||
Code string `gorm:"not null;unique" json:"code"` // contoh: S, M, L, XL
|
||||
Name string `gorm:"not null" json:"name"` // contoh: S, M, L, XL
|
||||
Description string `json:"description"` // opsional, seperti "Small", "Large"
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ type Warehouse struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Kode string `gorm:"not null;unique" json:"kode"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Type string `gorm:"not null" json:"type"`
|
||||
Address string `json:"address"`
|
||||
Stackholder string `json:"stackholder"`
|
||||
Number string `json:"number"`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user