Skip to content

Commit 5800be7

Browse files
committed
feat: add tables related to payroll
1 parent 9c91bb9 commit 5800be7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3678
-30
lines changed

.air.toml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
root = "."
2+
testdata_dir = "testdata"
3+
tmp_dir = "tmp"
4+
5+
[build]
6+
args_bin = []
7+
bin = "./tmp/main"
8+
cmd = "go build -o ./tmp/main ./cmd/server/main.go"
9+
delay = 3000
10+
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
11+
exclude_file = []
12+
exclude_regex = ["_test.go"]
13+
exclude_unchanged = false
14+
follow_symlink = false
15+
full_bin = ""
16+
include_dir = []
17+
include_ext = ["go", "tpl", "tmpl", "html"]
18+
kill_delay = "0s"
19+
log = "build-errors.log"
20+
send_interrupt = false
21+
stop_on_error = true
22+
23+
[color]
24+
app = ""
25+
build = "yellow"
26+
main = "magenta"
27+
runner = "green"
28+
watcher = "cyan"
29+
30+
[log]
31+
time = false
32+
33+
[misc]
34+
clean_on_exit = false
35+
36+
[screen]
37+
clear_on_rebuild = false

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ build
1717

1818
# dependencies
1919
vendor
20+
tmp

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ build:
5151
dev:
5252
go run ./cmd/server/main.go
5353

54+
air:
55+
air -c .air.toml
56+
5457
cronjob:
5558
go run ./cmd/cronjob/main.go
5659

@@ -100,3 +103,7 @@ gen-swagger:
100103

101104
ci: init
102105
@PROJECT_PATH=$(shell pwd) go test -cover ./... -count=1 -p=1
106+
107+
WD := $(shell pwd)
108+
lint:
109+
docker run -t --rm -v $(WD):/app -w /app golangci/golangci-lint:v1.52.2 golangci-lint run -v

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/Boostport/mjml-go v0.9.0
88
github.com/Rhymond/go-money v1.0.9
99
github.com/SebastiaanKlippert/go-wkhtmltopdf v1.7.1
10+
github.com/antchfx/htmlquery v1.3.0
1011
github.com/bwmarrin/discordgo v0.27.0
1112
github.com/dstotijn/go-notion v0.9.0
1213
github.com/gin-contrib/cors v1.4.0
@@ -21,7 +22,6 @@ require (
2122
github.com/jackc/pgtype v1.12.0
2223
github.com/jinzhu/now v1.1.5
2324
github.com/joho/godotenv v1.4.0
24-
github.com/k0kubun/pp/v3 v3.2.0
2525
github.com/lib/pq v1.10.6
2626
github.com/matoous/go-nanoid v1.5.0
2727
github.com/patrickmn/go-cache v2.1.0+incompatible
@@ -53,7 +53,6 @@ require (
5353
github.com/PuerkitoBio/purell v1.1.1 // indirect
5454
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
5555
github.com/andybalholm/brotli v1.0.4 // indirect
56-
github.com/antchfx/htmlquery v1.3.0 // indirect
5756
github.com/antchfx/xpath v1.2.3 // indirect
5857
github.com/armon/go-metrics v0.3.10 // indirect
5958
github.com/armon/go-radix v1.0.0 // indirect
@@ -105,6 +104,7 @@ require (
105104
github.com/jinzhu/inflection v1.0.0 // indirect
106105
github.com/josharian/intern v1.0.0 // indirect
107106
github.com/json-iterator/go v1.1.12 // indirect
107+
github.com/k0kubun/pp v3.0.1+incompatible // indirect
108108
github.com/leodido/go-urn v1.2.1 // indirect
109109
github.com/magiconair/properties v1.8.6 // indirect
110110
github.com/mailru/easyjson v0.7.6 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
386386
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
387387
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
388388
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
389-
github.com/k0kubun/pp/v3 v3.2.0 h1:h33hNTZ9nVFNP3u2Fsgz8JXiF5JINoZfFq4SvKJwNcs=
390-
github.com/k0kubun/pp/v3 v3.2.0/go.mod h1:ODtJQbQcIRfAD3N+theGCV1m/CBxweERz2dapdz1EwA=
389+
github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40=
390+
github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=
391391
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
392392
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
393393
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
2+
-- +migrate Up
3+
CREATE TABLE IF NOT EXISTS "base_salaries" (
4+
"id" uuid PRIMARY KEY DEFAULT (uuid()),
5+
"employee_id" uuid,
6+
"contract_amount" int8 NOT NULL DEFAULT 0,
7+
"company_account_amount" int8 NOT NULL DEFAULT 0,
8+
"personal_account_amount" int8 NOT NULL DEFAULT 0,
9+
"insurance_amount" int8 NOT NULL DEFAULT 0,
10+
"currency_id" uuid,
11+
"effective_date" date,
12+
"created_at" timestamptz(6) DEFAULT now(),
13+
"deleted_at" timestamptz(6),
14+
"is_active" bool DEFAULT true,
15+
"batch" int4,
16+
"type" text COLLATE "pg_catalog"."default",
17+
"category" text COLLATE "pg_catalog"."default"
18+
)
19+
;
20+
ALTER TABLE "base_salaries" ADD CONSTRAINT "base_salaries_currency_id_fkey" FOREIGN KEY ("currency_id") REFERENCES "currencies" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
21+
ALTER TABLE "base_salaries" ADD CONSTRAINT "base_salaries_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
22+
23+
CREATE TABLE IF NOT EXISTS "accounting_transactions" (
24+
"id" uuid PRIMARY KEY DEFAULT (uuid()),
25+
"created_at" timestamptz(6) DEFAULT now(),
26+
"deleted_at" timestamptz(6),
27+
"date" timestamptz(6) DEFAULT now(),
28+
"name" text COLLATE "pg_catalog"."default",
29+
"amount" float8,
30+
"currency_id" uuid NOT NULL,
31+
"conversion_amount" int8,
32+
"organization" text COLLATE "pg_catalog"."default",
33+
"metadata" json,
34+
"category" text COLLATE "pg_catalog"."default",
35+
"currency" text COLLATE "pg_catalog"."default",
36+
"conversion_rate" float4,
37+
"type" text COLLATE "pg_catalog"."default"
38+
)
39+
;
40+
ALTER TABLE "accounting_transactions" ADD CONSTRAINT "transaction_info_unique" UNIQUE ("name", "date");
41+
ALTER TABLE "accounting_transactions" DROP CONSTRAINT IF EXISTS "accounting_transactions_currency_id_fkey";
42+
ALTER TABLE "accounting_transactions" ADD CONSTRAINT "accounting_transactions_currency_id_fkey" FOREIGN KEY ("currency_id") REFERENCES "currencies" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;
43+
44+
CREATE TABLE IF NOT EXISTS "accounting_categories" (
45+
"id" uuid PRIMARY KEY DEFAULT (uuid()),
46+
"created_at" timestamptz(6) DEFAULT now(),
47+
"updated_at" TIMESTAMPTZ(6) DEFAULT NOW(),
48+
"deleted_at" timestamptz(6),
49+
"name" text COLLATE "pg_catalog"."default",
50+
"type" text COLLATE "pg_catalog"."default"
51+
);
52+
53+
CREATE TABLE IF NOT EXISTS "employee_commissions" (
54+
"id" UUID PRIMARY KEY DEFAULT (uuid()),
55+
"created_at" TIMESTAMPTZ(6) DEFAULT NOW(),
56+
"updated_at" TIMESTAMPTZ(6) DEFAULT NOW(),
57+
"deleted_at" TIMESTAMPTZ(6),
58+
"invoice_id" UUID NOT NULL,
59+
"employee_id" UUID,
60+
"amount" INT4,
61+
"project" TEXT COLLATE "pg_catalog"."default",
62+
"conversion_rate" DECIMAL DEFAULT 0,
63+
"is_paid" BOOL DEFAULT FALSE,
64+
"formula" TEXT COLLATE "pg_catalog"."default",
65+
"note" TEXT COLLATE "pg_catalog"."default",
66+
"paid_at" TIMESTAMPTZ(6)
67+
);
68+
ALTER TABLE "employee_commissions" ADD CONSTRAINT "employee_commissions_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
69+
70+
CREATE TABLE IF NOT EXISTS "employee_bonuses" (
71+
"id" uuid PRIMARY KEY DEFAULT (uuid()),
72+
"employee_id" uuid NOT NULL,
73+
"amount" int8,
74+
"is_active" bool DEFAULT true,
75+
"name" text COLLATE "pg_catalog"."default",
76+
"created_at" timestamp(6) DEFAULT now()
77+
)
78+
;
79+
ALTER TABLE "employee_bonuses" ADD CONSTRAINT "employee_bonuses_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
80+
81+
CREATE TABLE IF NOT EXISTS "payrolls" (
82+
"id" uuid PRIMARY KEY DEFAULT (uuid()),
83+
"employee_id" uuid NOT NULL,
84+
"total" int8 NOT NULL DEFAULT 0,
85+
"month" int4,
86+
"year" int4,
87+
"commission_amount" int8 NOT NULL DEFAULT 0,
88+
"commission_explain" json,
89+
"employee_rank_snapshot" json,
90+
"total_explain" json,
91+
"project_bonus_amount" int8 NOT NULL DEFAULT 0,
92+
"due_date" date,
93+
"project_bonus_explain" json,
94+
"is_paid" bool DEFAULT false,
95+
"conversion_amount" int8 NOT NULL DEFAULT 0,
96+
"base_salary_amount" int8 NOT NULL DEFAULT 0,
97+
"contract_amount" int8
98+
);
99+
ALTER TABLE
100+
"payrolls"
101+
ADD
102+
CONSTRAINT "payrolls_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
103+
104+
CREATE TABLE IF NOT EXISTS "project_commission_configs" (
105+
"id" UUID PRIMARY KEY DEFAULT (uuid()),
106+
"deleted_at" TIMESTAMP(6),
107+
"created_at" TIMESTAMP(6) DEFAULT (NOW()),
108+
"updated_at" TIMESTAMP(6) DEFAULT (NOW()),
109+
"project_id" UUID,
110+
"position" project_head_positions,
111+
"commission_rate" DECIMAL
112+
);
113+
114+
ALTER TABLE
115+
"project_commission_configs"
116+
ADD
117+
CONSTRAINT "project_commission_configs_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects" ("id");
118+
119+
-- +migrate Down

0 commit comments

Comments
 (0)