-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
121 lines (106 loc) · 2.95 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package main
import (
"add-entity-init/db"
"fmt"
"time"
)
func main() {
entity_id := 0
fmt.Print("Please input the new entity id:")
fmt.Scanf("%d", &entity_id)
if entity_id == 0 {
panic("entity_id can not be zero.")
}
entity := db.FindEntityById(int64(entity_id))
if entity == nil {
panic("entity is not exist.")
}
// assets
account := &db.AccountDao{
AccountType: "ASSET",
OpeningBalance: "0.00",
BaseOpeningBalance: "0.00",
AccountClass: 0,
AccountName: "Assets",
Created: time.Now(),
Updated: time.Now(),
CreatedTimeStamp: time.Now().UnixMilli(),
UpdatedTimeStamp: time.Now().UnixMilli(),
CreatedBy: 1,
UpdatedBy: 1,
Version: 1,
}
id := db.SaveAccount(*account)
financeAccount := &db.FinanceAccountDao{
ID: id,
AccountNumber: "1-0000",
SubAccountType: "Asset",
EntityID: int64(entity_id),
IsDetail: false,
Directory: "",
}
db.SaveFinanceAccout(*financeAccount)
// LIABILITY
account.ID = 0
account.AccountType = "LIABILITY"
account.AccountName = "Liabilities"
id = db.SaveAccount(*account)
financeAccount.ID = id
financeAccount.AccountNumber = "2-0000"
financeAccount.SubAccountType = "Liability"
db.SaveFinanceAccout(*financeAccount)
// EQUITY
account.ID = 0
account.AccountType = "EQUITY"
account.AccountName = "Equity"
id = db.SaveAccount(*account)
financeAccount.ID = id
financeAccount.AccountNumber = "3-0000"
financeAccount.SubAccountType = "Equity"
db.SaveFinanceAccout(*financeAccount)
// INCOME
account.ID = 0
account.AccountType = "INCOME"
account.AccountName = "Income"
id = db.SaveAccount(*account)
financeAccount.ID = id
financeAccount.AccountNumber = "4-0000"
financeAccount.SubAccountType = "Income"
db.SaveFinanceAccout(*financeAccount)
// COST_OF_SALES
account.ID = 0
account.AccountType = "COST_OF_SALES"
account.AccountName = "Cost of Sales"
id = db.SaveAccount(*account)
financeAccount.ID = id
financeAccount.AccountNumber = "5-0000"
financeAccount.SubAccountType = "Cost of Sales"
db.SaveFinanceAccout(*financeAccount)
// EXPENSE
account.ID = 0
account.AccountType = "EXPENSE"
account.AccountName = "Expenses"
id = db.SaveAccount(*account)
financeAccount.ID = id
financeAccount.AccountNumber = "6-0000"
financeAccount.SubAccountType = "Expense"
db.SaveFinanceAccout(*financeAccount)
// OTHER_INCOME
account.ID = 0
account.AccountType = "OTHER_INCOME"
account.AccountName = "Other Income"
id = db.SaveAccount(*account)
financeAccount.ID = id
financeAccount.AccountNumber = "8-0000"
financeAccount.SubAccountType = "Other Income"
db.SaveFinanceAccout(*financeAccount)
// OTHER_EXPENSE
account.ID = 0
account.AccountType = "OTHER_EXPENSE"
account.AccountName = "Other Expenses"
id = db.SaveAccount(*account)
financeAccount.ID = id
financeAccount.AccountNumber = "9-0000"
financeAccount.SubAccountType = "Other Expense"
db.SaveFinanceAccout(*financeAccount)
}