1 | unit ModuleFinance;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, ModularSystem, ModuleBase, WebPage;
|
---|
7 |
|
---|
8 | type
|
---|
9 |
|
---|
10 | { TModuleUser }
|
---|
11 |
|
---|
12 | TModuleFinance = class(TModule)
|
---|
13 | private
|
---|
14 | WebPageFinance: TWebPage;
|
---|
15 | public
|
---|
16 | ModuleBase: TModuleBase;
|
---|
17 | constructor Create(Owner: TComponent); override;
|
---|
18 | procedure Start; override;
|
---|
19 | procedure Stop; override;
|
---|
20 | procedure Install; override;
|
---|
21 | procedure Uninstall; override;
|
---|
22 | end;
|
---|
23 |
|
---|
24 |
|
---|
25 | implementation
|
---|
26 |
|
---|
27 | uses
|
---|
28 | Core, PageFinance, SqlDatabase;
|
---|
29 |
|
---|
30 | { TModuleFinance }
|
---|
31 |
|
---|
32 | constructor TModuleFinance.Create(Owner: TComponent);
|
---|
33 | begin
|
---|
34 | inherited;
|
---|
35 | Identification := 'Finance';
|
---|
36 | Title := 'Accounting management';
|
---|
37 | Version := '1.0';
|
---|
38 | License := 'GNU/LGPL v3';
|
---|
39 | Author := 'Chronosoft';
|
---|
40 | Dependencies.Add('Base');
|
---|
41 | end;
|
---|
42 |
|
---|
43 | procedure TModuleFinance.Start;
|
---|
44 | begin
|
---|
45 | BeforeStart;
|
---|
46 | ModuleBase := TModuleBase(Manager.FindModuleByName('Base'));
|
---|
47 | WebPageFinance := TWebPageFinance.Create(nil);
|
---|
48 | ModuleBase.Pages.RegisterPage(WebPageFinance, 'finance');
|
---|
49 | //RegisterPage(TUserControlPage, UserControlPage, '');
|
---|
50 | AfterStart;
|
---|
51 | end;
|
---|
52 |
|
---|
53 | procedure TModuleFinance.Stop;
|
---|
54 | begin
|
---|
55 | BeforeStop;
|
---|
56 | ModuleBase.Pages.UnregisterPage(WebPageFinance);
|
---|
57 | FreeAndNil(WebPageFinance);
|
---|
58 | ModuleBase := nil;
|
---|
59 | AfterStop;
|
---|
60 | end;
|
---|
61 |
|
---|
62 | procedure TModuleFinance.Install;
|
---|
63 | var
|
---|
64 | DbRows: TDbRows;
|
---|
65 | begin
|
---|
66 | try
|
---|
67 | DbRows := TDbRows.Create;
|
---|
68 |
|
---|
69 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
70 | 'CREATE TABLE IF NOT EXISTS `FinanceTariff` (' +
|
---|
71 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
72 | ' `Name` varchar(32) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
73 | ' `Group` int(11) NOT NULL DEFAULT "0",' +
|
---|
74 | ' `SpeedMin` int(11) NOT NULL DEFAULT "0",' +
|
---|
75 | ' `SpeedMax` int(11) NOT NULL DEFAULT "0",' +
|
---|
76 | ' `UploadAsymmetry` int(11) NOT NULL DEFAULT "1",' +
|
---|
77 | ' `Price` int(11) NOT NULL DEFAULT "0",' +
|
---|
78 | ' `MemberCount` int(11) NOT NULL DEFAULT "0",' +
|
---|
79 | ' `ReplaceId` int(11) DEFAULT NULL,' +
|
---|
80 | ' `Public` int(11) NOT NULL DEFAULT "1",' +
|
---|
81 | ' PRIMARY KEY (`Id`),' +
|
---|
82 | ' KEY `ReplaceId` (`ReplaceId`),' +
|
---|
83 | ' KEY `Public` (`Public`)' +
|
---|
84 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
85 |
|
---|
86 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
87 | 'CREATE TABLE IF NOT EXISTS `FinanceYear` (' +
|
---|
88 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
89 | ' `Year` int(11) NOT NULL,' +
|
---|
90 | ' `DateStart` date NOT NULL,' +
|
---|
91 | ' `DateEnd` date NOT NULL,' +
|
---|
92 | ' PRIMARY KEY (`Id`)' +
|
---|
93 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
94 |
|
---|
95 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
96 | 'CREATE TABLE IF NOT EXISTS `DocumentLine` (' +
|
---|
97 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
98 | ' `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
99 | ' `Shortcut` varchar(16) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
100 | ' PRIMARY KEY (`Id`),' +
|
---|
101 | ' UNIQUE KEY `Shortcut` (`Shortcut`)' +
|
---|
102 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1; ');
|
---|
103 |
|
---|
104 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
105 | 'CREATE TABLE IF NOT EXISTS `DocumentLineSequence` (' +
|
---|
106 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
107 | ' `DocumentLine` int(11) NOT NULL,' +
|
---|
108 | ' `FinanceYear` int(11) NOT NULL,' +
|
---|
109 | ' `NextNumber` int(11) NOT NULL,' +
|
---|
110 | ' `YearPrefix` int(11) NOT NULL,' +
|
---|
111 | ' PRIMARY KEY (`Id`),' +
|
---|
112 | ' KEY `DocumentLine` (`DocumentLine`),' +
|
---|
113 | ' KEY `FinanceYear` (`FinanceYear`)' +
|
---|
114 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
115 |
|
---|
116 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
117 | 'CREATE TABLE IF NOT EXISTS `FinanceBankAccount` (' +
|
---|
118 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
119 | ' `TimeCreate` date NOT NULL,' +
|
---|
120 | ' `Number` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
121 | ' `Comment` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
122 | ' PRIMARY KEY (`Id`)' +
|
---|
123 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1; ');
|
---|
124 |
|
---|
125 | Core.Core.CommonDatabase.Query(DbRows,
|
---|
126 | 'CREATE TABLE IF NOT EXISTS `FinanceBillingPeriod` (' +
|
---|
127 | ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
|
---|
128 | ' `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
|
---|
129 | ' `MonthCount` int(11) NOT NULL,' +
|
---|
130 | ' PRIMARY KEY (`Id`)' +
|
---|
131 | ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
|
---|
132 |
|
---|
133 | finally
|
---|
134 | DbRows.Free;
|
---|
135 | end;
|
---|
136 | inherited;
|
---|
137 | end;
|
---|
138 |
|
---|
139 | procedure TModuleFinance.Uninstall;
|
---|
140 | var
|
---|
141 | DbRows: TDbRows;
|
---|
142 | begin
|
---|
143 | inherited;
|
---|
144 | try
|
---|
145 | DbRows := TDbRows.Create;
|
---|
146 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `FinanceBillingPeriod`');
|
---|
147 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `FinanceBankAccount`');
|
---|
148 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `DocumentLine`');
|
---|
149 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `DocumentLineSequence`');
|
---|
150 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `FinanceTariff`');
|
---|
151 | Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `FinanceYear`');
|
---|
152 | finally
|
---|
153 | DbRows.Free;
|
---|
154 | end;
|
---|
155 | end;
|
---|
156 |
|
---|
157 | end.
|
---|
158 |
|
---|