1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/FinanceModels.php');
|
---|
4 | include_once(dirname(__FILE__).'/Bill.php');
|
---|
5 | include_once(dirname(__FILE__).'/Manage.php');
|
---|
6 | include_once(dirname(__FILE__).'/UserState.php');
|
---|
7 | include_once(dirname(__FILE__).'/Import.php');
|
---|
8 | include_once(dirname(__FILE__).'/Trade.php');
|
---|
9 |
|
---|
10 | class ModuleFinance extends Module
|
---|
11 | {
|
---|
12 | public Finance $Finance;
|
---|
13 | public Bill $Bill;
|
---|
14 |
|
---|
15 | function __construct(System $System)
|
---|
16 | {
|
---|
17 | parent::__construct($System);
|
---|
18 | $this->Name = 'Finance';
|
---|
19 | $this->Version = '1.0';
|
---|
20 | $this->Creator = 'Chronos';
|
---|
21 | $this->License = 'GNU/GPLv3';
|
---|
22 | $this->Description = 'Base module for finance management';
|
---|
23 | $this->Dependencies = array(ModuleFile::GetName(), ModuleEmailQueue::GetName(), ModuleSubject::GetName(),
|
---|
24 | ModuleDocument::GetName());
|
---|
25 | $this->Models = array(FinanceBillingPeriod::GetClassName(), FinanceVatType::GetClassName(), FinanceVat::GetClassName(),
|
---|
26 | FinanceGroup::GetClassName(), FinanceOperationGroup::GetClassName(), FinanceOperation::GetClassName(),
|
---|
27 | FinanceInvoiceGroup::GetClassName(), FinanceInvoice::GetClassName(), FinanceInvoiceItem::GetClassName(),
|
---|
28 | Company::GetClassName(), FinanceTreasury::GetClassName(), FinanceTreasuryCheck::GetClassName(),
|
---|
29 | Currency::GetClassName(), FinanceBank::GetClassName(), FinanceBankAccount::GetClassName(), FinanceCharge::GetClassName(),
|
---|
30 | FinanceInvoiceOperationRel::GetClassName());
|
---|
31 |
|
---|
32 | $this->Bill = new Bill($this->System);
|
---|
33 | $this->Finance = new Finance($this->System);
|
---|
34 | }
|
---|
35 |
|
---|
36 | function DoStart(): void
|
---|
37 | {
|
---|
38 | $this->Finance->MainSubject = $this->System->Config['Finance']['MainSubjectId'];
|
---|
39 | $this->Finance->DirectoryId = $this->System->Config['Finance']['DirectoryId'];
|
---|
40 |
|
---|
41 | $this->System->RegisterPage(['finance', 'sprava'], 'PageFinanceManage');
|
---|
42 | $this->System->RegisterPage(['finance', 'platby'], 'PageFinanceUserState');
|
---|
43 | $this->System->RegisterPage(['finance', 'import'], 'PageFinanceImportPayment');
|
---|
44 | $this->System->RegisterPage(['finance', 'zivnost'], 'PageFinanceTaxFiling');
|
---|
45 |
|
---|
46 | $this->System->FormManager->RegisterClass('FinanceOperation', array(
|
---|
47 | 'Title' => 'Finanční operace',
|
---|
48 | 'Table' => 'FinanceOperation',
|
---|
49 | 'DefaultSortColumn' => 'Time',
|
---|
50 | 'DefaultSortOrder' => 1,
|
---|
51 | 'Items' => array(
|
---|
52 | 'Group' => array('Type' => 'TFinanceOperationGroup', 'Caption' => 'Skupina', 'Default' => ''),
|
---|
53 | 'BillCode' => array('Type' => 'TDocumentLineCode', 'Caption' => 'Označení', 'Default' => '', 'ReadOnly' => true),
|
---|
54 | 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),
|
---|
55 | 'Time' => array('Type' => 'Date', 'Caption' => 'Čas realizace', 'Default' => ''),
|
---|
56 | 'Cash' => array('Type' => 'Boolean', 'Caption' => 'Hotově', 'Default' => ''),
|
---|
57 | 'Taxable' => array('Type' => 'Boolean', 'Caption' => 'Zdanitelné', 'Default' => ''),
|
---|
58 | 'Value' => array('Type' => 'Integer', 'Caption' => 'Částka absolutní', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true),
|
---|
59 | 'ValueUser' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'),
|
---|
60 | 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true),
|
---|
61 | 'Text' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
|
---|
62 | 'Network' => array('Type' => 'Boolean', 'Caption' => 'Týkající sítě', 'Default' => ''),
|
---|
63 | 'BankAccount' => array('Type' => 'TFinanceBankAccount', 'Caption' => 'Účet', 'Default' => '', 'Null' => true),
|
---|
64 | 'Treasury' => array('Type' => 'TFinanceTreasury', 'Caption' => 'Pokladna', 'Default' => '', 'Null' => true),
|
---|
65 | 'Generate' => array('Type' => 'Boolean', 'Caption' => 'Generovat', 'Default' => ''),
|
---|
66 | 'Balance' => array('Type' => 'Integer', 'Caption' => 'Zůstatek', 'Default' => '',
|
---|
67 | 'ReadOnly' => true, 'SQL' => '(SELECT SUM(`FinanceOperation2`.`Value`) FROM `FinanceOperation` AS `FinanceOperation2` WHERE `FinanceOperation2`.`Time`<`Time`)'),
|
---|
68 | 'InvoiceRel' => array('Type' => 'TFinanceInvoiceOperationRelListOperation', 'Caption' => 'Zaplacené faktury', 'Default' => ''),
|
---|
69 | 'InvoiceRelCount' => array('Type' => 'Integer', 'Caption' => 'Faktur',
|
---|
70 | 'ReadOnly' => true, 'SQL' => '(SELECT COUNT(`FinanceInvoiceOperationRel`.`Id`) FROM `FinanceInvoiceOperationRel` '.
|
---|
71 | 'WHERE `FinanceInvoiceOperationRel`.`Operation`=#Id)'),
|
---|
72 | ),
|
---|
73 | 'BeforeInsert' => array($this, 'BeforeInsertFinanceOperation'),
|
---|
74 | 'AfterInsert' => array($this, 'AfterInsertFinanceOperation'),
|
---|
75 | 'BeforeModify' => array($this, 'BeforeModifyFinanceOperation'),
|
---|
76 | 'AfterModify' => array($this, 'BeforeModifyFinanceOperation'),
|
---|
77 | 'ItemActions' => array(
|
---|
78 | array('Caption' => 'Přegenerovat doklad', 'URL' => '/finance/sprava/?Operation=RegenerateOperation&i=#RowId'),
|
---|
79 | ),
|
---|
80 | ));
|
---|
81 |
|
---|
82 | $this->System->FormManager->RegisterClass('FinanceTreasuryIn', $this->System->FormManager->Classes['FinanceOperation']);
|
---|
83 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Title'] = 'Pokladní příjmy';
|
---|
84 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Group']['Default'] = OPERATION_GROUP_TREASURY_IN;
|
---|
85 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Group']['Hidden'] = true;
|
---|
86 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Group']['Filter'] = true;
|
---|
87 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Default'] = 1;
|
---|
88 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Hidden'] = true;
|
---|
89 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Filter'] = false;
|
---|
90 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['BankAccount']['Hidden'] = true;
|
---|
91 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Value']['Hidden'] = true;
|
---|
92 |
|
---|
93 | $this->System->FormManager->RegisterClass('FinanceTreasuryOut', $this->System->FormManager->Classes['FinanceOperation']);
|
---|
94 | $this->System->FormManager->Classes['FinanceTreasuryOut']['Title'] = 'Pokladní výdeje';
|
---|
95 | $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Group']['Default'] = OPERATION_GROUP_TREASURY_OUT;
|
---|
96 | $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Group']['Hidden'] = true;
|
---|
97 | $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Group']['Filter'] = true;
|
---|
98 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Default'] = 1;
|
---|
99 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Hidden'] = true;
|
---|
100 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Filter'] = false;
|
---|
101 | $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['BankAccount']['Hidden'] = true;
|
---|
102 | $this->System->FormManager->Classes['FinanceTreasuryOut']['Items']['Value']['Hidden'] = true;
|
---|
103 |
|
---|
104 | $this->System->FormManager->RegisterClass('FinanceAccountIn', $this->System->FormManager->Classes['FinanceOperation']);
|
---|
105 | $this->System->FormManager->Classes['FinanceAccountIn']['Title'] = 'Příjmy na účet';
|
---|
106 | $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Group']['Default'] = OPERATION_GROUP_ACCOUNT_IN;
|
---|
107 | $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Group']['Hidden'] = true;
|
---|
108 | $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Group']['Filter'] = true;
|
---|
109 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Default'] = 0;
|
---|
110 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Hidden'] = true;
|
---|
111 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Filter'] = false;
|
---|
112 | $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Treasury']['Hidden'] = true;
|
---|
113 | $this->System->FormManager->Classes['FinanceAccountIn']['Items']['Value']['Hidden'] = true;
|
---|
114 |
|
---|
115 | $this->System->FormManager->RegisterClass('FinanceAccountOut', $this->System->FormManager->Classes['FinanceOperation']);
|
---|
116 | $this->System->FormManager->Classes['FinanceAccountOut']['Title'] = 'Výdeje z účtu';
|
---|
117 | $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Group']['Default'] = OPERATION_GROUP_ACCOUNT_OUT;
|
---|
118 | $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Group']['Hidden'] = true;
|
---|
119 | $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Group']['Filter'] = true;
|
---|
120 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Default'] = 0;
|
---|
121 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Hidden'] = true;
|
---|
122 | $this->System->FormManager->Classes['FinanceTreasuryIn']['Items']['Cash']['Filter'] = false;
|
---|
123 | $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Treasury']['Hidden'] = true;
|
---|
124 | $this->System->FormManager->Classes['FinanceAccountOut']['Items']['Value']['Hidden'] = true;
|
---|
125 |
|
---|
126 | $this->System->FormManager->RegisterClass('FinanceOperationGroup', array(
|
---|
127 | 'Title' => 'Skupina finančních operací',
|
---|
128 | 'Table' => 'FinanceOperationGroup',
|
---|
129 | 'Items' => array(
|
---|
130 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'),
|
---|
131 | 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => '0'),
|
---|
132 | 'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'),
|
---|
133 | 'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'),
|
---|
134 | 'Items' => array('Type' => 'TFinanceOperationListGroup', 'Caption' => 'Operace', 'Default' => ''),
|
---|
135 | ),
|
---|
136 | ));
|
---|
137 | $this->System->FormManager->RegisterClass('FinanceBillingPeriod', array(
|
---|
138 | 'Title' => 'Platební období',
|
---|
139 | 'Table' => 'FinanceBillingPeriod',
|
---|
140 | 'Items' => array(
|
---|
141 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'),
|
---|
142 | 'MonthCount' => array('Type' => 'Integer', 'Caption' => 'Počet měsíců', 'Default' => '0'),
|
---|
143 | 'Customers' => array('Type' => 'TCustomerBillingPeriod', 'Caption' => 'Zákazníci')
|
---|
144 | ),
|
---|
145 | ));
|
---|
146 | $this->System->FormManager->RegisterFormType('TFinanceOperationGroup', array(
|
---|
147 | 'Type' => 'Reference',
|
---|
148 | 'Table' => 'FinanceOperationGroup',
|
---|
149 | 'Id' => 'Id',
|
---|
150 | 'Name' => 'Name',
|
---|
151 | 'Filter' => '1',
|
---|
152 | ));
|
---|
153 | $this->System->FormManager->RegisterFormType('TFinanceValueSign', array(
|
---|
154 | 'Type' => 'Enumeration',
|
---|
155 | 'States' => array(-1 => 'Mínus', 1 => 'Plus'),
|
---|
156 | ));
|
---|
157 | $this->System->FormManager->RegisterFormType('TFinanceDirection', array(
|
---|
158 | 'Type' => 'Enumeration',
|
---|
159 | 'States' => array(0 => 'Příjem', 1 => 'Výdej'),
|
---|
160 | ));
|
---|
161 | $this->System->FormManager->RegisterClass('FinanceInvoice', array(
|
---|
162 | 'Title' => 'Faktury',
|
---|
163 | 'Table' => 'FinanceInvoice',
|
---|
164 | 'DefaultSortColumn' => 'Time',
|
---|
165 | 'DefaultSortOrder' => 1,
|
---|
166 | 'Items' => array(
|
---|
167 | 'Group' => array('Type' => 'TFinanceInvoiceGroup', 'Caption' => 'Skupina', 'Default' => ''),
|
---|
168 | 'BillCode' => array('Type' => 'TDocumentLineCode', 'Caption' => 'Označení', 'Default' => '', 'ReadOnly' => true),
|
---|
169 | 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),
|
---|
170 | 'Time' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
|
---|
171 | 'TimeDue' => array('Type' => 'Date', 'Caption' => 'Čas splatnosti', 'Default' => ''),
|
---|
172 | 'TimePayment' => array('Type' => 'Date', 'Caption' => 'Čas zaplacení', 'Default' => '', 'Null' => true),
|
---|
173 | 'Value' => array('Type' => 'Integer', 'Caption' => 'Částka absolutní', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true),
|
---|
174 | 'ValueUser' => array('Type' => 'Integer', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
175 | 'SQL' => 'SELECT ROUND(SUM(`Price`*`Quantity`), '.$this->System->Config['Finance']['Rounding'].') FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=#Id'),
|
---|
176 | 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true),
|
---|
177 | 'Generate' => array('Type' => 'Boolean', 'Caption' => 'Generovat', 'Default' => ''),
|
---|
178 | 'PeriodFrom' => array('Type' => 'Date', 'Caption' => 'Období od', 'Default' => '', 'Null' => true),
|
---|
179 | 'PeriodTo' => array('Type' => 'Date', 'Caption' => 'Období do', 'Default' => '', 'Null' => true),
|
---|
180 | 'Cash' => array('Type' => 'Boolean', 'Caption' => 'Platit hotově', 'Default' => ''),
|
---|
181 | 'VisibleToUser' => array('Type' => 'Boolean', 'Caption' => 'Viditelné uživatelům', 'Default' => '1'),
|
---|
182 | 'Items' => array('Type' => 'TFinanceInvoiceItemListInvoice', 'Caption' => 'Položky', 'Default' => ''),
|
---|
183 | 'StornoBy' => array('Type' => 'TFinanceInvoiceStornoListBy', 'Caption' => 'Původní doklady', 'Default' => ''),
|
---|
184 | 'StornoOf' => array('Type' => 'TFinanceInvoiceStornoListOf', 'Caption' => 'Storno doklady', 'Default' => ''),
|
---|
185 | 'OperationRel' => array('Type' => 'TFinanceInvoiceOperationRelListInvoice', 'Caption' => 'Platba', 'Default' => ''),
|
---|
186 | 'OperationRelCount' => array('Type' => 'Integer', 'Caption' => 'Plateb',
|
---|
187 | 'ReadOnly' => true, 'SQL' => '(SELECT COUNT(`FinanceInvoiceOperationRel`.`Id`) FROM `FinanceInvoiceOperationRel` '.
|
---|
188 | 'WHERE `FinanceInvoiceOperationRel`.`Invoice`=#Id)'),
|
---|
189 | ),
|
---|
190 | 'BeforeInsert' => array($this, 'BeforeInsertFinanceInvoice'),
|
---|
191 | 'AfterInsert' => array($this, 'AfterInsertFinanceInvoice'),
|
---|
192 | 'BeforeModify' => array($this, 'BeforeModifyFinanceInvoice'),
|
---|
193 | 'AfterModify' => array($this, 'BeforeModifyFinanceInvoice'),
|
---|
194 | 'ItemActions' => array(
|
---|
195 | array('Caption' => 'Přegenerovat doklad', 'URL' => '/finance/sprava/?Operation=RegenerateInvoice&i=#RowId'),
|
---|
196 | ),
|
---|
197 | ));
|
---|
198 | $this->System->FormManager->RegisterClass('FinanceInvoiceIn', $this->System->FormManager->Classes['FinanceInvoice']);
|
---|
199 | $this->System->FormManager->Classes['FinanceInvoiceIn']['Title'] = 'Přijaté faktury';
|
---|
200 | $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Group']['Default'] = INVOICE_GROUP_IN;
|
---|
201 | $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Group']['Hidden'] = true;
|
---|
202 | $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Group']['Filter'] = true;
|
---|
203 | $this->System->FormManager->Classes['FinanceInvoiceIn']['Items']['Value']['Hidden'] = true;
|
---|
204 |
|
---|
205 | $this->System->FormManager->RegisterClass('FinanceInvoiceOut', $this->System->FormManager->Classes['FinanceInvoice']);
|
---|
206 | $this->System->FormManager->Classes['FinanceInvoiceOut']['Title'] = 'Vydané faktury';
|
---|
207 | $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Group']['Default'] = INVOICE_GROUP_OUT;
|
---|
208 | $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Group']['Hidden'] = true;
|
---|
209 | $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Group']['Filter'] = true;
|
---|
210 | $this->System->FormManager->Classes['FinanceInvoiceOut']['Items']['Value']['Hidden'] = true;
|
---|
211 |
|
---|
212 | $this->System->FormManager->RegisterClass('FinanceInvoiceGroup', array(
|
---|
213 | 'Title' => 'Skupina faktur',
|
---|
214 | 'Table' => 'FinanceInvoiceGroup',
|
---|
215 | 'Items' => array(
|
---|
216 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'),
|
---|
217 | 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => '0'),
|
---|
218 | 'ValueSign' => array('Type' => 'TFinanceValueSign', 'Caption' => 'Znaménko hodnoty', 'Default' => '0'),
|
---|
219 | 'Direction' => array('Type' => 'TFinanceDirection', 'Caption' => 'Směr', 'Default' => '0'),
|
---|
220 | 'Items' => array('Type' => 'TFinanceInvoiceListGroup', 'Caption' => 'Faktury', 'Default' => ''),
|
---|
221 | ),
|
---|
222 | ));
|
---|
223 |
|
---|
224 | $this->System->FormManager->RegisterClass('FinanceInvoiceStorno', array(
|
---|
225 | 'Title' => 'Storno faktur',
|
---|
226 | 'Table' => 'FinanceInvoiceStorno',
|
---|
227 | 'Items' => array(
|
---|
228 | 'StornoBy' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Storno doklad', 'Default' => ''),
|
---|
229 | 'StornoOf' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Původní doklad', 'Default' => ''),
|
---|
230 | ),
|
---|
231 | ));
|
---|
232 | $this->System->FormManager->RegisterFormType('TFinanceInvoiceGroup', array(
|
---|
233 | 'Type' => 'Reference',
|
---|
234 | 'Table' => 'FinanceInvoiceGroup',
|
---|
235 | 'Id' => 'Id',
|
---|
236 | 'Name' => 'Name',
|
---|
237 | 'Filter' => '1',
|
---|
238 | ));
|
---|
239 |
|
---|
240 | $this->System->FormManager->RegisterClass('Company', array(
|
---|
241 | 'Title' => 'Firma',
|
---|
242 | 'Table' => 'Company',
|
---|
243 | 'Items' => array(
|
---|
244 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'),
|
---|
245 | 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => '0'),
|
---|
246 | ),
|
---|
247 | ));
|
---|
248 | $this->System->FormManager->RegisterClass('FinanceInvoiceItem', array(
|
---|
249 | 'Title' => 'Položka faktury',
|
---|
250 | 'Table' => 'FinanceInvoiceItem',
|
---|
251 | 'Items' => array(
|
---|
252 | 'FinanceInvoice' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Faktura', 'Default' => '0'),
|
---|
253 | 'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => 'Položka'),
|
---|
254 | 'Price' => array('Type' => 'Float', 'Caption' => 'Částka', 'Default' => '0', 'Suffix' => 'Kč'),
|
---|
255 | 'Quantity' => array('Type' => 'Float', 'Caption' => 'Množství', 'Default' => '1'),
|
---|
256 | 'VAT' => array('Type' => 'Integer', 'Caption' => 'Daň', 'Default' => '21', 'Suffix' => '%'),
|
---|
257 | 'Total' => array('Type' => 'Integer', 'Caption' => 'Celkem', 'Default' => '', 'Suffix' => 'Kč',
|
---|
258 | 'ReadOnly' => true, 'SQL' => 'ROUND(`Price` * `Quantity`, '.$this->System->Config['Finance']['Rounding'].')'),
|
---|
259 | ),
|
---|
260 | 'AfterInsert' => array($this, 'AfterInsertFinanceInvoiceItem'),
|
---|
261 | 'AfterModify' => array($this, 'AfterModifyFinanceInvoiceItem'),
|
---|
262 | 'AfterDelete' => array($this, 'AfterModifyFinanceInvoiceItem'),
|
---|
263 | ));
|
---|
264 | $this->System->FormManager->RegisterClass('FinanceTreasury', array(
|
---|
265 | 'Title' => 'Pokladny',
|
---|
266 | 'Table' => 'FinanceTreasury',
|
---|
267 | 'DefaultSortColumn' => 'Name',
|
---|
268 | 'Items' => array(
|
---|
269 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
---|
270 | 'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
|
---|
271 | 'State' => array('Type' => 'Float', 'Caption' => 'Stav', 'Default' => '',
|
---|
272 | 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => 'IFNULL(ROUND((SELECT SUM(`FinanceOperation`.`Value`) FROM `FinanceOperation` '.
|
---|
273 | 'WHERE `FinanceOperation`.`Treasury`=#Id), '.$this->System->Config['Finance']['Rounding'].'), 0)'),
|
---|
274 | 'Operations' => array('Type' => 'TFinanceOperationListTreasury', 'Caption' => 'Operace', 'Default' => ''),
|
---|
275 | 'Check' => array('Type' => 'TFinanceTreasuryCheckListTreasury', 'Caption' => 'Kontrola', 'Default' => ''),
|
---|
276 | ),
|
---|
277 | ));
|
---|
278 | $this->System->FormManager->RegisterClass('FinanceTreasuryCheck', array(
|
---|
279 | 'Title' => 'Kontrola pokladen',
|
---|
280 | 'Table' => 'FinanceTreasuryCheck',
|
---|
281 | 'DefaultSortColumn' => 'Time',
|
---|
282 | 'DefaultSortOrder' => 1,
|
---|
283 | 'Items' => array(
|
---|
284 | 'Treasury' => array('Type' => 'TFinanceTreasury', 'Caption' => 'Pokladna', 'Default' => ''),
|
---|
285 | 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
|
---|
286 | 'Value1' => array('Type' => 'Integer', 'Caption' => 'Hodnota 1', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
287 | 'Value2' => array('Type' => 'Integer', 'Caption' => 'Hodnota 2', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
288 | 'Value5' => array('Type' => 'Integer', 'Caption' => 'Hodnota 5', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
289 | 'Value10' => array('Type' => 'Integer', 'Caption' => 'Hodnota 10', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
290 | 'Value20' => array('Type' => 'Integer', 'Caption' => 'Hodnota 20', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
291 | 'Value50' => array('Type' => 'Integer', 'Caption' => 'Hodnota 50', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
292 | 'Value100' => array('Type' => 'Integer', 'Caption' => 'Hodnota 100', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
293 | 'Value200' => array('Type' => 'Integer', 'Caption' => 'Hodnota 200', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
294 | 'Value500' => array('Type' => 'Integer', 'Caption' => 'Hodnota 500', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
295 | 'Value1000' => array('Type' => 'Integer', 'Caption' => 'Hodnota 1000', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
296 | 'Value2000' => array('Type' => 'Integer', 'Caption' => 'Hodnota 2000', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
297 | 'Value5000' => array('Type' => 'Integer', 'Caption' => 'Hodnota 5000', 'Default' => '0', 'Suffix' => 'ks'),
|
---|
298 | 'Sum' => array('Type' => 'Integer', 'Caption' => 'Součet', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
299 | 'SQL' => '(`Value1` * 1 + `Value2` * 2 + `Value5` * 5 + `Value10` * 10 + '.
|
---|
300 | '`Value20` * 20 + `Value50` * 50 + `Value100` * 100 + `Value200` * 200 + '.
|
---|
301 | '`Value500` * 500 + `Value1000` * 1000 + `Value2000` * 2000 + `Value5000` * 5000)'),
|
---|
302 | 'Missing' => array('Type' => 'Integer', 'Caption' => 'Chybí', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
303 | 'SQL' => '(`Value1` * 1 + `Value2` * 2 + `Value5` * 5 + `Value10` * 10 + '.
|
---|
304 | '`Value20` * 20 + `Value50` * 50 + `Value100` * 100 + `Value200` * 200 + '.
|
---|
305 | '`Value500` * 500 + `Value1000` * 1000 + `Value2000` * 2000 + `Value5000` * 5000) - '.
|
---|
306 | '(SELECT (T2.`Value1` * 1 + T2.`Value2` * 2 + T2.`Value5` * 5 + T2.`Value10` * 10 + '.
|
---|
307 | 'T2.`Value20` * 20 + T2.`Value50` * 50 + T2.`Value100` * 100 + T2.`Value200` * 200 + '.
|
---|
308 | 'T2.`Value500` * 500 + T2.`Value1000` * 1000 + T2.`Value2000` * 2000 + T2.`Value5000` * 5000) + '.
|
---|
309 | '(SELECT SUM(T3.Value) FROM FinanceOperation AS T3 WHERE (T3.Time < TX.Time) AND (T3.Time > T2.Time) AND (T3.Treasury=TX.Treasury))'.
|
---|
310 | ' FROM FinanceTreasuryCheck AS T2 WHERE (T2.Time < TX.Time) ORDER BY T2.Time DESC LIMIT 1)'),
|
---|
311 | ),
|
---|
312 | ));
|
---|
313 | $this->System->FormManager->RegisterFormType('TCustomerBillingPeriod', array(
|
---|
314 | 'Type' => 'ManyToOne',
|
---|
315 | 'Table' => 'Member',
|
---|
316 | 'Id' => 'Id',
|
---|
317 | 'Ref' => 'BillingPeriod',
|
---|
318 | 'Filter' => '1',
|
---|
319 | ));
|
---|
320 | $this->System->FormManager->RegisterFormType('TFinanceTreasuryCheckListTreasury', array(
|
---|
321 | 'Type' => 'ManyToOne',
|
---|
322 | 'Table' => 'FinanceTreasuryCheck',
|
---|
323 | 'Id' => 'Id',
|
---|
324 | 'Ref' => 'Treasury',
|
---|
325 | 'Filter' => '1',
|
---|
326 | ));
|
---|
327 | $this->System->FormManager->RegisterFormType('TFinanceTreasury', array(
|
---|
328 | 'Type' => 'Reference',
|
---|
329 | 'Table' => 'FinanceTreasury',
|
---|
330 | 'Id' => 'Id',
|
---|
331 | 'Name' => 'Name',
|
---|
332 | 'Filter' => '1',
|
---|
333 | ));
|
---|
334 | $this->System->FormManager->RegisterClass('FinanceBankAccount', array(
|
---|
335 | 'Title' => 'Účty',
|
---|
336 | 'Table' => 'FinanceBankAccount',
|
---|
337 | 'DefaultSortColumn' => 'Comment',
|
---|
338 | 'Items' => array(
|
---|
339 | 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Vlastník', 'Default' => ''),
|
---|
340 | 'Comment' => array('Type' => 'String', 'Caption' => 'Komentář', 'Default' => ''),
|
---|
341 | 'Number' => array('Type' => 'String', 'Caption' => 'Číslo', 'Default' => ''),
|
---|
342 | 'Bank' => array('Type' => 'TFinanceBank', 'Caption' => 'Banka', 'Default' => ''),
|
---|
343 | 'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
|
---|
344 | 'TimeEnd' => array('Type' => 'Date', 'Caption' => 'Čas zrušení', 'Default' => '', 'Null' => true),
|
---|
345 | 'Currency' => array('Type' => 'TCurrency', 'Caption' => 'Měna', 'Default' => ''),
|
---|
346 | 'LoginName' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno / token', 'Default' => '', 'NotInList' => true),
|
---|
347 | 'LoginPassword' => array('Type' => 'String', 'Caption' => 'Přihlašovací heslo', 'Default' => '', 'NotInList' => true),
|
---|
348 | 'Operations' => array('Type' => 'TFinanceOperationListAccount', 'Caption' => 'Operace', 'Default' => ''),
|
---|
349 | 'Use' => array('Type' => 'Boolean', 'Caption' => 'Používat', 'Default' => '0'),
|
---|
350 | 'LastImportDate' => array('Type' => 'Date', 'Caption' => 'Datum posledního importu', 'Default' => ''),
|
---|
351 | 'LastImportId' => array('Type' => 'String', 'Caption' => 'Id posledního importu', 'Default' => ''),
|
---|
352 | 'State' => array('Type' => 'Float', 'Caption' => 'Stav', 'Default' => '',
|
---|
353 | 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value`) FROM `FinanceOperation` '.
|
---|
354 | 'WHERE `FinanceOperation`.`BankAccount`=#Id)'),
|
---|
355 | 'AutoImport' => array('Type' => 'Boolean', 'Caption' => 'Automaticky stahovat z banky', 'Default' => ''),
|
---|
356 | ),
|
---|
357 | 'ItemActions' => array(
|
---|
358 | array('Caption' => 'Import plateb z banky', 'URL' => '/finance/import-api/?i=#RowId'),
|
---|
359 | array('Caption' => 'Import plateb ze souboru', 'URL' => '/finance/import-soubor/?i=#RowId'),
|
---|
360 | ),
|
---|
361 | ));
|
---|
362 | $this->System->FormManager->RegisterClass('FinanceBankAccountReport', array(
|
---|
363 | 'Title' => 'Roční výkaz operací',
|
---|
364 | 'Table' => 'FinanceBankAccountReport',
|
---|
365 | 'SQL' => 'SELECT Id, DateEnd, DateStart FROM FinanceYear',
|
---|
366 | 'DefaultSortColumn' => 'Id',
|
---|
367 | 'Items' => array(
|
---|
368 | 'Id' => array('Type' => 'TFinanceYear', 'Caption' => 'Rok', 'Default' => '',
|
---|
369 | 'ReadOnly' => true),
|
---|
370 | //'Account' => array('Type' => 'TFinanceBankAccount', 'Caption' => 'Bankovní účet', 'Default' => '',
|
---|
371 | // 'ReadOnly' => true),
|
---|
372 | 'StartBalance' => array('Type' => 'Integer', 'Caption' => 'Starý zůstatek', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
373 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
374 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
375 | 'WHERE (`FinanceOperation`.`Time` <= `DateStart`) AND (`FinanceOperation`.`BankAccount` = 2))'),
|
---|
376 | 'EndBalance' => array('Type' => 'Integer', 'Caption' => 'Nový zůstatek', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
377 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
378 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
379 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) AND (`FinanceOperation`.`BankAccount` = 2))'),
|
---|
380 | 'Change' => array('Type' => 'Integer', 'Caption' => 'Změna', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
381 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
382 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
383 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
384 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`BankAccount` = 2))'),
|
---|
385 | ),
|
---|
386 | //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),
|
---|
387 | ));
|
---|
388 | $this->System->FormManager->RegisterFormType('TFinanceBankAccount', array(
|
---|
389 | 'Type' => 'Reference',
|
---|
390 | 'Table' => 'FinanceBankAccount',
|
---|
391 | 'Id' => 'Id',
|
---|
392 | 'Name' => 'Comment',
|
---|
393 | 'Filter' => '1',
|
---|
394 | ));
|
---|
395 | $this->System->FormManager->RegisterClass('FinanceBank', array(
|
---|
396 | 'Title' => 'Banky',
|
---|
397 | 'Table' => 'FinanceBank',
|
---|
398 | 'Items' => array(
|
---|
399 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
---|
400 | 'Code' => array('Type' => 'String', 'Caption' => 'Český kód', 'Default' => ''),
|
---|
401 | 'BIC' => array('Type' => 'String', 'Caption' => 'Kód BIC', 'Default' => ''),
|
---|
402 | 'Country' => array('Type' => 'TCountry', 'Caption' => 'Země', 'Default' => ''),
|
---|
403 | ),
|
---|
404 | ));
|
---|
405 | $this->System->FormManager->RegisterFormType('TFinanceBank', array(
|
---|
406 | 'Type' => 'Reference',
|
---|
407 | 'Table' => 'FinanceBank',
|
---|
408 | 'Id' => 'Id',
|
---|
409 | 'Name' => 'CONCAT(Name, " (", Code, ")")',
|
---|
410 | 'Filter' => '1',
|
---|
411 | ));
|
---|
412 | $this->System->FormManager->RegisterClass('Currency', array(
|
---|
413 | 'Title' => 'Měny',
|
---|
414 | 'Table' => 'Currency',
|
---|
415 | 'Items' => array(
|
---|
416 | 'Code' => array('Type' => 'String', 'Caption' => 'Kód', 'Default' => ''),
|
---|
417 | 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
|
---|
418 | 'Symbol' => array('Type' => 'String', 'Caption' => 'Symbol', 'Default' => ''),
|
---|
419 | ),
|
---|
420 | ));
|
---|
421 | $this->System->FormManager->RegisterClass('FinanceCharge', array(
|
---|
422 | 'Title' => 'Parametry účtování',
|
---|
423 | 'Table' => 'FinanceCharge',
|
---|
424 | 'Items' => array(
|
---|
425 | 'Internet' => array('Type' => 'Integer', 'Caption' => 'Platba Internetu', 'Default' => '0', 'Suffix' => 'Kč'),
|
---|
426 | 'InternetSpeed' => array('Type' => 'Integer', 'Caption' => 'Rychlost Internetu', 'Default' => '0', 'Suffix' => 'Mbit/s'),
|
---|
427 | 'InternetSpeedReserve' => array('Type' => 'Integer', 'Caption' => 'Rezerva rychlosti', 'Default' => '0', 'Suffix' => 'Mbit/s'),
|
---|
428 | 'AdministrationPerUser' => array('Type' => 'Integer', 'Caption' => 'Správa za uživatele', 'Default' => '0', 'Suffix' => 'Kč'),
|
---|
429 | 'kWh' => array('Type' => 'Integer', 'Caption' => 'Cena kWh', 'Default' => '0', 'Suffix' => 'Kč'),
|
---|
430 | 'BaseSpeedElement' => array('Type' => 'Integer', 'Caption' => 'Základní díl rychlosti', 'Default' => '0', 'Suffix' => 'Mbit/s'),
|
---|
431 | 'BaseTariffPrice' => array('Type' => 'Integer', 'Caption' => 'Základní cena tarifu', 'Default' => '0', 'Suffix' => 'Kč'),
|
---|
432 | 'TopTariffPrice' => array('Type' => 'Integer', 'Caption' => 'Nejvyšší cena tarifu', 'Default' => '0', 'Suffix' => 'Kč'),
|
---|
433 | 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
434 | 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true, 'NotInList' => true),
|
---|
435 | 'ChangeReplaceId' => array('Type' => 'TFinanceCharge', 'Caption' => 'Změna - položka', 'Default' => '0', 'Null' => true, 'NotInList' => true),
|
---|
436 | ),
|
---|
437 | ));
|
---|
438 | $this->System->FormManager->RegisterClass('FinanceVAT', array(
|
---|
439 | 'Title' => 'Sazby DPH',
|
---|
440 | 'Table' => 'FinanceVAT',
|
---|
441 | 'Items' => array(
|
---|
442 | 'Type' => array('Type' => 'TFinanceVATType', 'Caption' => 'Typ', 'Default' => ''),
|
---|
443 | 'ValidFrom' => array('Type' => 'Date', 'Caption' => 'Platnost od', 'Default' => ''),
|
---|
444 | 'ValidTo' => array('Type' => 'Date', 'Caption' => 'Platnost do', 'Default' => '', 'Null' => true),
|
---|
445 | 'Value' => array('Type' => 'Integer', 'Caption' => 'Hodnota', 'Default' => '', 'Suffix' => '%'),
|
---|
446 | ),
|
---|
447 | ));
|
---|
448 | $this->System->FormManager->RegisterClass('FinanceVATType', array(
|
---|
449 | 'Title' => 'Sazby DPH',
|
---|
450 | 'Table' => 'FinanceVATType',
|
---|
451 | 'Items' => array(
|
---|
452 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
---|
453 | ),
|
---|
454 | ));
|
---|
455 | $this->System->FormManager->RegisterFormType('TFinanceVAT', array(
|
---|
456 | 'Type' => 'Reference',
|
---|
457 | 'Table' => 'FinanceVAT',
|
---|
458 | 'Id' => 'Id',
|
---|
459 | 'Name' => 'Name',
|
---|
460 | 'Filter' => '1',
|
---|
461 | ));
|
---|
462 | $this->System->FormManager->RegisterFormType('TFinanceVATType', array(
|
---|
463 | 'Type' => 'Reference',
|
---|
464 | 'Table' => 'FinanceVATType',
|
---|
465 | 'Id' => 'Id',
|
---|
466 | 'Name' => 'Name',
|
---|
467 | 'Filter' => '1',
|
---|
468 | ));
|
---|
469 | $this->System->FormManager->RegisterFormType('TBankAccount', array(
|
---|
470 | 'Type' => 'Reference',
|
---|
471 | 'Table' => 'FinanceBankAccount',
|
---|
472 | 'Id' => 'Id',
|
---|
473 | 'Name' => 'CONCAT(`Comment`, " (", `Number`, "/", '.
|
---|
474 | '(SELECT `FinanceBank`.`Code` FROM `FinanceBank` WHERE `FinanceBank`.`Id`=`FinanceBankAccount`.`Bank`), ")")',
|
---|
475 | 'Filter' => '1',
|
---|
476 | ));
|
---|
477 | $this->System->FormManager->RegisterClass('FinanceYearReport', array(
|
---|
478 | 'Title' => 'Roční výkaz',
|
---|
479 | 'Table' => 'FinanceYearReport',
|
---|
480 | 'SQL' => 'SELECT Id, DateEnd, DateStart FROM FinanceYear',
|
---|
481 | 'DefaultSortColumn' => 'Id',
|
---|
482 | 'DefaultSortOrder' => 1,
|
---|
483 | 'Items' => array(
|
---|
484 | 'Id' => array('Type' => 'TFinanceYear', 'Caption' => 'Rok', 'Default' => '',
|
---|
485 | 'ReadOnly' => true),
|
---|
486 | 'Income' => array('Type' => 'Integer', 'Caption' => 'Evidenční příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
487 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
488 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
489 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
490 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
|
---|
491 | 'Spending' => array('Type' => 'Integer', 'Caption' => 'Evidenční výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
492 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
493 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
494 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
495 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
|
---|
496 | 'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Evidenční zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
497 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
498 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
499 | 'AND (`FinanceOperation`.`Time` >= `DateStart`))'),
|
---|
500 | 'RealIncome' => array('Type' => 'Integer', 'Caption' => 'Skutečné příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
501 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
502 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
503 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) AND (`FinanceOperation`.`Subject` != '.$this->Finance->MainSubject.')'.
|
---|
504 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
|
---|
505 | 'RealSpending' => array('Type' => 'Integer', 'Caption' => 'Skutečné výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
506 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
507 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
508 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) AND (`FinanceOperation`.`Subject` != '.$this->Finance->MainSubject.')'.
|
---|
509 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
|
---|
510 | 'RealOperationBalance' => array('Type' => 'Integer', 'Caption' => 'Skutečný zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
511 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
512 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) AND (`FinanceOperation`.`Subject` != '.$this->Finance->MainSubject.')'.
|
---|
513 | 'AND (`FinanceOperation`.`Time` >= `DateStart`))'),
|
---|
514 | 'TaxIncome' => array('Type' => 'Integer', 'Caption' => 'Daňové příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
515 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
516 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
517 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
518 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
|
---|
519 | 'TaxSpending' => array('Type' => 'Integer', 'Caption' => 'Daňové výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
520 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
521 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
522 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
523 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
|
---|
524 | 'TaxBase' => array('Type' => 'Integer', 'Caption' => 'Základ daně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
525 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
526 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
527 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1))'),
|
---|
528 | 'Claims' => array('Type' => 'Integer', 'Caption' => 'Pohledávky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
529 | 'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
|
---|
530 | 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
|
---|
531 | 'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
|
---|
532 | 'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = 1))'),
|
---|
533 | 'Liabilities' => array('Type' => 'Integer', 'Caption' => 'Závazky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
534 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
|
---|
535 | 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
|
---|
536 | 'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
|
---|
537 | 'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = -1))'),
|
---|
538 | 'InvoiceBalance' => array('Type' => 'Integer', 'Caption' => 'Fakturační rozdíl', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
539 | 'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
|
---|
540 | 'AND (`FinanceInvoice`.`Time` >= `DateStart`))'),
|
---|
541 | 'IncomeList' => array('Type' => 'TIncomeList', 'Caption' => 'Příjmy', 'Default' => '0'),
|
---|
542 | 'SpendingList' => array('Type' => 'TSpendingList', 'Caption' => 'Výdaje', 'Default' => '0'),
|
---|
543 | 'TaxIncomeList' => array('Type' => 'TTaxIncomeList', 'Caption' => 'Daňové příjmy', 'Default' => '0'),
|
---|
544 | 'TaxSpendingList' => array('Type' => 'TTaxSpendingList', 'Caption' => 'Daňové výdaje', 'Default' => '0'),
|
---|
545 | 'ClaimsList' => array('Type' => 'TClaimsList', 'Caption' => 'Pohledávky', 'Default' => '0'),
|
---|
546 | 'LiabilitiesList' => array('Type' => 'TLiabilitiesList', 'Caption' => 'Závazky', 'Default' => '0'),
|
---|
547 | ),
|
---|
548 | //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),
|
---|
549 | ));
|
---|
550 | $this->System->FormManager->RegisterClass('FinanceMonthReport', array(
|
---|
551 | 'Title' => 'Měsíční výkaz',
|
---|
552 | 'Table' => 'FinanceMonthReport',
|
---|
553 | 'SQL' => 'SELECT 0 AS `Id`, m1 AS `DateStart`, LAST_DAY(m1) AS `DateEnd` FROM '.
|
---|
554 | '(SELECT ((SELECT MIN(`DateStart`) FROM `FinanceYear`) - INTERVAL DAYOFMONTH((SELECT MIN(`DateStart`) FROM `FinanceYear`)) - 1 DAY) '.
|
---|
555 | '+ INTERVAL m MONTH AS m1 FROM ('.
|
---|
556 | 'SELECT @rownum := @rownum + 1 AS m FROM '.
|
---|
557 | '(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,'.
|
---|
558 | '(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2,'.
|
---|
559 | '(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t3,'.
|
---|
560 | '(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t4,'.
|
---|
561 | '(SELECT @rownum := -1) t0'.
|
---|
562 | ') d1'.
|
---|
563 | ') d2 '.
|
---|
564 | 'WHERE m1 <= (SELECT MAX(`DateEnd`) FROM `FinanceYear`)',
|
---|
565 | 'DefaultSortColumn' => 'DateStart',
|
---|
566 | 'DefaultSortOrder' => 1,
|
---|
567 | 'Items' => array(
|
---|
568 | 'DateStart' => array('Type' => 'Date', 'Caption' => 'Měsíc', 'Default' => '', 'ReadOnly' => true),
|
---|
569 | 'Income' => array('Type' => 'Integer', 'Caption' => 'Evidenční příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
570 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
571 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
572 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
573 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
|
---|
574 | 'Spending' => array('Type' => 'Integer', 'Caption' => 'Evidenční výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
575 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
576 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
577 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
578 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
|
---|
579 | 'OperationBalance' => array('Type' => 'Integer', 'Caption' => 'Evidenční zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
580 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
581 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
582 | 'AND (`FinanceOperation`.`Time` >= `DateStart`))'),
|
---|
583 | 'RealIncome' => array('Type' => 'Integer', 'Caption' => 'Skutečné příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
584 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
585 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
586 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) AND (`FinanceOperation`.`Subject` != '.$this->Finance->MainSubject.')'.
|
---|
587 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
|
---|
588 | 'RealSpending' => array('Type' => 'Integer', 'Caption' => 'Skutečné výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
589 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
590 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
591 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) AND (`FinanceOperation`.`Subject` != '.$this->Finance->MainSubject.')'.
|
---|
592 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
|
---|
593 | 'RealOperationBalance' => array('Type' => 'Integer', 'Caption' => 'Skutečný zisk', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
594 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
595 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) AND (`FinanceOperation`.`Subject` != '.$this->Finance->MainSubject.')'.
|
---|
596 | 'AND (`FinanceOperation`.`Time` >= `DateStart`))'),
|
---|
597 | 'TaxIncome' => array('Type' => 'Integer', 'Caption' => 'Daňové příjmy', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
598 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
599 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
600 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
601 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = 1))'),
|
---|
602 | 'TaxSpending' => array('Type' => 'Integer', 'Caption' => 'Daňové výdaje', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
603 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
604 | 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id`=`FinanceOperation`.`Group` '.
|
---|
605 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
606 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1) AND (`FinanceOperationGroup`.`ValueSign` = -1))'),
|
---|
607 | 'TaxBase' => array('Type' => 'Integer', 'Caption' => 'Základ daně', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
608 | 'SQL' => '(SELECT ROUND(SUM(`FinanceOperation`.`Value`)) FROM `FinanceOperation` '.
|
---|
609 | 'WHERE (`FinanceOperation`.`Time` <= `DateEnd`) '.
|
---|
610 | 'AND (`FinanceOperation`.`Time` >= `DateStart`) AND (`FinanceOperation`.`Taxable` = 1))'),
|
---|
611 | 'Claims' => array('Type' => 'Integer', 'Caption' => 'Pohledávky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
612 | 'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
|
---|
613 | 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
|
---|
614 | 'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
|
---|
615 | 'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = 1))'),
|
---|
616 | 'Liabilities' => array('Type' => 'Integer', 'Caption' => 'Závazky', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
617 | 'SQL' => '(SELECT -ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` '.
|
---|
618 | 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group` '.
|
---|
619 | 'WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
|
---|
620 | 'AND (`FinanceInvoice`.`Time` >= `DateStart`) AND (`FinanceInvoiceGroup`.`ValueSign` = -1))'),
|
---|
621 | 'InvoiceBalance' => array('Type' => 'Integer', 'Caption' => 'Fakturační rozdíl', 'Default' => '0', 'Suffix' => 'Kč', 'ReadOnly' => true,
|
---|
622 | 'SQL' => '(SELECT ROUND(SUM(`FinanceInvoice`.`Value`)) FROM `FinanceInvoice` WHERE (`FinanceInvoice`.`Time` <= `DateEnd`) '.
|
---|
623 | 'AND (`FinanceInvoice`.`Time` >= `DateStart`))'),
|
---|
624 | 'IncomeList' => array('Type' => 'TIncomeList', 'Caption' => 'Příjmy', 'Default' => '0'),
|
---|
625 | 'SpendingList' => array('Type' => 'TSpendingList', 'Caption' => 'Výdaje', 'Default' => '0'),
|
---|
626 | 'TaxIncomeList' => array('Type' => 'TTaxIncomeList', 'Caption' => 'Daňové příjmy', 'Default' => '0'),
|
---|
627 | 'TaxSpendingList' => array('Type' => 'TTaxSpendingList', 'Caption' => 'Daňové výdaje', 'Default' => '0'),
|
---|
628 | 'ClaimsList' => array('Type' => 'TClaimsList', 'Caption' => 'Pohledávky', 'Default' => '0'),
|
---|
629 | 'LiabilitiesList' => array('Type' => 'TLiabilitiesList', 'Caption' => 'Závazky', 'Default' => '0'),
|
---|
630 | ),
|
---|
631 | //'AfterInsert' => array($this, 'AfterInsertFinanceYear'),
|
---|
632 | ));
|
---|
633 | $this->System->FormManager->RegisterFormType('TClaimsList', array(
|
---|
634 | 'Type' => 'ManyToOne',
|
---|
635 | 'Table' => 'FinanceInvoice',
|
---|
636 | 'Id' => 'Id',
|
---|
637 | 'Ref' => '',
|
---|
638 | 'Filter' => '(`TX`.`Time` <= (SELECT `FinanceYear`.`DateEnd` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
639 | 'AND (`TX`.`Time` >= (SELECT `FinanceYear`.`DateStart` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
640 | 'AND (SIGN(`TX`.`Value`) > 0)',
|
---|
641 | ));
|
---|
642 | $this->System->FormManager->RegisterFormType('TLiabilitiesList', array(
|
---|
643 | 'Type' => 'ManyToOne',
|
---|
644 | 'Table' => 'FinanceInvoice',
|
---|
645 | 'Id' => 'Id',
|
---|
646 | 'Ref' => '',
|
---|
647 | 'Filter' => '(`TX`.`Time` <= (SELECT `FinanceYear`.`DateEnd` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
648 | 'AND (`TX`.`Time` >= (SELECT `FinanceYear`.`DateStart` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
649 | 'AND (SIGN(`TX`.`Value`) < 0)',
|
---|
650 | ));
|
---|
651 | $this->System->FormManager->RegisterFormType('TSpendingList', array(
|
---|
652 | 'Type' => 'ManyToOne',
|
---|
653 | 'Table' => 'FinanceOperation',
|
---|
654 | 'Id' => 'Id',
|
---|
655 | 'Ref' => '',
|
---|
656 | 'Filter' => '(`TX`.`Time` <= (SELECT `FinanceYear`.`DateEnd` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
657 | 'AND (`TX`.`Time` >= (SELECT `FinanceYear`.`DateStart` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
658 | 'AND (SIGN(`TX`.`Value`) < 0)',
|
---|
659 | ));
|
---|
660 | $this->System->FormManager->RegisterFormType('TIncomeList', array(
|
---|
661 | 'Type' => 'ManyToOne',
|
---|
662 | 'Table' => 'FinanceOperation',
|
---|
663 | 'Id' => 'Id',
|
---|
664 | 'Ref' => '',
|
---|
665 | 'Filter' => '(`TX`.`Time` <= (SELECT `FinanceYear`.`DateEnd` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
666 | 'AND (`TX`.`Time` >= (SELECT `FinanceYear`.`DateStart` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
667 | 'AND (SIGN(`TX`.`Value`) > 0)',
|
---|
668 | ));
|
---|
669 | $this->System->FormManager->RegisterFormType('TTaxSpendingList', array(
|
---|
670 | 'Type' => 'ManyToOne',
|
---|
671 | 'Table' => 'FinanceOperation',
|
---|
672 | 'Id' => 'Id',
|
---|
673 | 'Ref' => '',
|
---|
674 | 'Filter' => '(`TX`.`Time` <= (SELECT `FinanceYear`.`DateEnd` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
675 | 'AND (`TX`.`Time` >= (SELECT `FinanceYear`.`DateStart` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
676 | 'AND (SIGN(`TX`.`Value`) < 0) AND (`TX`.`Taxable` = 1)',
|
---|
677 | ));
|
---|
678 | $this->System->FormManager->RegisterFormType('TTaxIncomeList', array(
|
---|
679 | 'Type' => 'ManyToOne',
|
---|
680 | 'Table' => 'FinanceOperation',
|
---|
681 | 'Id' => 'Id',
|
---|
682 | 'Ref' => '',
|
---|
683 | 'Filter' => '(`TX`.`Time` <= (SELECT `FinanceYear`.`DateEnd` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
684 | 'AND (`TX`.`Time` >= (SELECT `FinanceYear`.`DateStart` FROM `FinanceYear` WHERE `FinanceYear`.`Id`=#Id)) '.
|
---|
685 | 'AND (SIGN(`TX`.`Value`) > 0) AND (`TX`.`Taxable` = 1)',
|
---|
686 | ));
|
---|
687 | $this->System->FormManager->RegisterClass('FinanceInvoiceOperationRel', array(
|
---|
688 | 'Title' => 'Zaplacení faktůr',
|
---|
689 | 'Table' => 'FinanceInvoiceOperationRel',
|
---|
690 | 'Items' => array(
|
---|
691 | 'Invoice' => array('Type' => 'TFinanceInvoice', 'Caption' => 'Faktura', 'Default' => ''),
|
---|
692 | 'Operation' => array('Type' => 'TFinanceOperation', 'Caption' => 'Platba', 'Default' => ''),
|
---|
693 | ),
|
---|
694 | ));
|
---|
695 |
|
---|
696 | ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Finance', array($this, 'ShowDashboardItem'));
|
---|
697 | }
|
---|
698 |
|
---|
699 | function ShowDashboardItem(): string
|
---|
700 | {
|
---|
701 | $DbResult = $this->Database->select('FinanceOperation', 'ROUND(SUM(`Value`))', '1');
|
---|
702 | $DbRow = $DbResult->fetch_row();
|
---|
703 | $Output = 'Stav placení: '.$DbRow['0'].' Kč<br/>';
|
---|
704 | return $Output;
|
---|
705 | }
|
---|
706 |
|
---|
707 | function BeforeInsertFinanceOperation(Form $Form): array
|
---|
708 | {
|
---|
709 | if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
|
---|
710 | else $Year = date("Y", $Form->Values['ValidFrom']);
|
---|
711 | $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
|
---|
712 | $Form->Values['BillCode'] = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
|
---|
713 | return $Form->Values;
|
---|
714 | }
|
---|
715 |
|
---|
716 | function AfterInsertFinanceOperation(Form $Form, string $Id): array
|
---|
717 | {
|
---|
718 | $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
|
---|
719 | $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
|
---|
720 | ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
|
---|
721 | return $Form->Values;
|
---|
722 | }
|
---|
723 |
|
---|
724 | function BeforeModifyFinanceOperation(Form $Form, string $Id): array
|
---|
725 | {
|
---|
726 | $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
|
---|
727 | $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
|
---|
728 | ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
|
---|
729 | return $Form->Values;
|
---|
730 | }
|
---|
731 |
|
---|
732 | function BeforeInsertFinanceInvoice(Form $Form): array
|
---|
733 | {
|
---|
734 | // Get new DocumentLineCode by selected invoice Group
|
---|
735 | if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
|
---|
736 | else $Year = date("Y", $Form->Values['ValidFrom']);
|
---|
737 | $Group = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
|
---|
738 | $Form->Values['BillCode'] = ModuleDocument::Cast($this->System->GetModule('Document'))->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
|
---|
739 | return $Form->Values;
|
---|
740 | }
|
---|
741 |
|
---|
742 | function AfterInsertFinanceInvoice(Form $Form, string $Id): array
|
---|
743 | {
|
---|
744 | $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
|
---|
745 | $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL']));
|
---|
746 | $DbRow = $DbResult->fetch_row();
|
---|
747 | $Sum = $DbRow[0];
|
---|
748 |
|
---|
749 | $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
|
---|
750 | ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
|
---|
751 | return $Form->Values;
|
---|
752 | }
|
---|
753 |
|
---|
754 | function BeforeModifyFinanceInvoice(Form $Form, string $Id): array
|
---|
755 | {
|
---|
756 | $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
|
---|
757 | $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL']));
|
---|
758 | $DbRow = $DbResult->fetch_row();
|
---|
759 | $Sum = $DbRow[0];
|
---|
760 | $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
|
---|
761 | ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
|
---|
762 | return $Form->Values;
|
---|
763 | }
|
---|
764 |
|
---|
765 | function AfterInsertFinanceInvoiceItem(Form $Form, string $Id): array
|
---|
766 | {
|
---|
767 | $ParentForm = new Form($this->System->FormManager);
|
---|
768 | $ParentForm->SetClass('FinanceInvoice');
|
---|
769 | $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']);
|
---|
770 | $this->AfterInsertFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']);
|
---|
771 | return $Form->Values;
|
---|
772 | }
|
---|
773 |
|
---|
774 | function AfterModifyFinanceInvoiceItem(Form $Form, string $Id): array
|
---|
775 | {
|
---|
776 | $ParentForm = new Form($this->System->FormManager);
|
---|
777 | $ParentForm->SetClass('FinanceInvoice');
|
---|
778 | $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']);
|
---|
779 | $this->BeforeModifyFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']);
|
---|
780 | return $Form->Values;
|
---|
781 | }
|
---|
782 |
|
---|
783 | static function Cast(Module $Module): ModuleFinance
|
---|
784 | {
|
---|
785 | if ($Module instanceof ModuleFinance)
|
---|
786 | {
|
---|
787 | return $Module;
|
---|
788 | }
|
---|
789 | throw new Exception('Expected ModuleFinance type but '.gettype($Module));
|
---|
790 | }
|
---|
791 | }
|
---|