RecordINOUT.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <?php
  2. namespace App\Http\Livewire;
  3. use Livewire\Component;
  4. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  5. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  6. class RecordINOUT extends Component
  7. {
  8. //public $records_in, $records_out;
  9. public $total_in = 0;
  10. public $total_out = 0;
  11. public $datas = [];
  12. public $month;
  13. public $year;
  14. public $months_1 = [];
  15. public $year_1;
  16. public $months_2 = [];
  17. public $year_2;
  18. public $show_block_2;
  19. //public $borsellino_id = 0;
  20. public $columns = array();
  21. public $rows_in = array();
  22. public $rows_out = array();
  23. public $records_in = array();
  24. public $records_out = array();
  25. public $showData = true;
  26. public $hasFilter = false;
  27. public $total = 0;
  28. public $selectedFilter = '';
  29. public $causalsIn = array();
  30. public $causalsOut = array();
  31. public $payments = array();
  32. public $members = array();
  33. public $filterCausalsIn = null;
  34. public $filterCausalsOut = null;
  35. public $excludeCausals = array();
  36. public function mount()
  37. {
  38. if(\Auth::user()->level != env('LEVEL_ADMIN', 0))
  39. return redirect()->to('/dashboard');
  40. $borsellino = \App\Models\Causal::where('money', true)->first();
  41. if ($borsellino)
  42. $this->excludeCausals[] = $borsellino->id;
  43. //$this->borsellino_id = $borsellino->id;
  44. // Aggiungo
  45. $excludes = \App\Models\Causal::where('no_records', true)->get();
  46. foreach($excludes as $e)
  47. {
  48. $this->excludeCausals[] = $e->id;
  49. }
  50. $this->month = date("m");
  51. $this->year = date("Y");
  52. $this->year_1 = date("Y");
  53. $this->year_2 = date("Y");
  54. $this->show_block_2 = false;
  55. $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get(), 'IN', 0);
  56. $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->whereNotIn('id', $this->excludeCausals)->get(), 'OUT', 0);
  57. $this->getCausalsIn(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->get(), 0);
  58. $this->getCausalsOut(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->get(), 0);
  59. //$this->causalsIn = \App\Models\Causal::where('parent_id', null)->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get();
  60. //$this->causalsOut = \App\Models\Causal::where('parent_id', null)->where('type', 'OUT')->whereNotIn('id', $this->excludeCausals)->get();
  61. }
  62. public function getCausalsIn($records, $indentation)
  63. {
  64. foreach($records as $record)
  65. {
  66. $this->causalsIn[] = array('id' => $record->id, 'name' => $record->getTree(), 'text' => $record->getTree(), 'level' => $indentation);
  67. if(count($record->childs))
  68. $this->getCausalsIn($record->childs, $indentation + 1);
  69. }
  70. }
  71. public function getCausalsOut($records, $indentation)
  72. {
  73. foreach($records as $record)
  74. {
  75. $this->causalsOut[] = array('id' => $record->id, 'name' => $record->getTree(), 'text' => $record->getTree(), 'level' => $indentation);
  76. if(count($record->childs))
  77. $this->getCausalsOut($record->childs, $indentation + 1);
  78. }
  79. }
  80. public function getCausale($records, $type, $indentation)
  81. {
  82. foreach($records as $record)
  83. {
  84. $first_parent_id = null;
  85. if ($record->parent_id != null)
  86. {
  87. $first_parent_id = \App\Models\Causal::where('id', $record->parent_id)->first()->parent_id;
  88. }
  89. if ($type == 'IN')
  90. $this->rows_in[] = array('id' => $record->id, 'name' => $record->name, 'level' => $indentation, 'parent_id' => $record->parent_id, 'parent_name' => $this->getCausalName($record->parent_id), 'first_parent_id' => $first_parent_id, 'first_parent_name' => $this->getCausalName($first_parent_id));
  91. if ($type == 'OUT')
  92. $this->rows_out[] = array('id' => $record->id, 'name' => $record->name, 'level' => $indentation, 'parent_id' => $record->parent_id, 'parent_name' => $this->getCausalName($record->parent_id), 'first_parent_id' => $first_parent_id, 'first_parent_name' => $this->getCausalName($first_parent_id));
  93. if(count($record->childs))
  94. $this->getCausale($record->childs, $type, $indentation + 1);
  95. }
  96. }
  97. public function getCausalName($id)
  98. {
  99. if ($id > 0)
  100. return \App\Models\Causal::findOrFail($id)->name;
  101. else
  102. return "";
  103. }
  104. public function render()
  105. {
  106. return view('livewire.records_in_out');
  107. }
  108. public function hydrate()
  109. {
  110. $this->emit('load-select');
  111. }
  112. public function show($m, $y)
  113. //public function show($dt)
  114. {
  115. //list($m, $y) = explode("_", $dt);
  116. if ($m != "" && $y != "" && !in_array($m . "-" . $y, $this->datas))
  117. $this->datas[] = $m . "-" . $y;
  118. $this->columns = array();
  119. $this->records_in = [];
  120. $this->records_out = [];
  121. $exclude_from_records = \App\Models\Member::where('exclude_from_records', true)->pluck('id')->toArray();
  122. if (sizeof($this->datas) > 0)
  123. {
  124. foreach($this->datas as $filter)
  125. {
  126. // $filter = $m . "-" . $this->year;
  127. $this->columns[] = $filter;
  128. $f = $filter;
  129. if ($m == 'x')
  130. $f = str_replace("x-", "", $filter);
  131. print $filter;
  132. //$dt = $y . "-0" . $m;
  133. $records = \App\Models\Record::where('type', 'IN')
  134. ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
  135. ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
  136. ->where(function ($query) {
  137. $query->where('deleted', false)->orWhere('deleted', null);
  138. })
  139. ->where(function ($query) {
  140. $query->where('financial_movement', false)->orWhere('financial_movement', null);
  141. })
  142. ->whereNotIn('member_id', $exclude_from_records)
  143. /*->where(function ($query) use ($f, $dt) {
  144. $query->where('records.date', 'like', '%' . $dt . '%')->orWhere('records_rows.when', 'like', '%' . $f . '%');
  145. })*/
  146. ->where('records_rows.when', 'like', '%"' . $f . '"%')
  147. ->get();
  148. //$records = $records->orderBy('date', 'DESC')->get();
  149. foreach($records as $record)
  150. {
  151. $amount = $record->amount;
  152. $amount += getVatValue($amount, $record->vat_id);
  153. $when = sizeof(json_decode($record->when));
  154. if ($when > 1)
  155. {
  156. $amount = $amount / $when;
  157. $record->amount = $amount;
  158. }
  159. // Aggiungo/aggiorno i dati
  160. if (isset($this->records_in[$filter][$record->causal_id]))
  161. $this->records_in[$filter][$record->causal_id] += $amount;
  162. else
  163. $this->records_in[$filter][$record->causal_id] = $amount;
  164. // Aggiorno i dati del padre
  165. $this->updateParent("IN", $record->causal_id, $amount, $filter);
  166. }
  167. $records = \App\Models\Record::where('type', 'OUT')
  168. ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
  169. ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
  170. ->where(function ($query) {
  171. $query->where('deleted', false)->orWhere('deleted', null);
  172. })
  173. ->where(function ($query) {
  174. $query->where('financial_movement', false)->orWhere('financial_movement', null);
  175. })
  176. ->whereNotIn('member_id', $exclude_from_records)
  177. ->where('records_rows.when', 'like', '%"' . $f . '"%')->get();
  178. //$records = $records->orderBy('date', 'DESC')->get();
  179. foreach($records as $record)
  180. {
  181. $amount = $record->amount;
  182. $amount += getVatValue($amount, $record->vat_id);
  183. $when = sizeof(json_decode($record->when));
  184. if ($when > 1)
  185. {
  186. $amount = $amount / $when;
  187. $record->amount = $amount;
  188. }
  189. // Aggiungo/aggiorno i dati
  190. if (isset($this->records_out[$filter][$record->causal_id]))
  191. $this->records_out[$filter][$record->causal_id] += $amount;
  192. else
  193. $this->records_out[$filter][$record->causal_id] = $amount;
  194. $this->updateParent("OUT", $record->causal_id, $amount, $filter);
  195. }
  196. }
  197. }
  198. //$this->showData = true;
  199. $this->emit('load-table');
  200. }
  201. public function updateParent($type, $causal_id, $amount, $filter)
  202. {
  203. if ($type == "IN")
  204. {
  205. foreach($this->rows_in as $r)
  206. {
  207. if ($r["id"] == $causal_id)
  208. {
  209. if (isset($this->records_in[$filter][$r["parent_id"]]))
  210. $this->records_in[$filter][$r["parent_id"]] += $amount;
  211. else
  212. $this->records_in[$filter][$r["parent_id"]] = $amount;
  213. if ($r["parent_id"] > 0)
  214. $this->updateParent("IN", $r["parent_id"], $amount, $filter);
  215. }
  216. }
  217. }
  218. if ($type == "OUT")
  219. {
  220. foreach($this->rows_out as $r)
  221. {
  222. if ($r["id"] == $causal_id)
  223. {
  224. if (isset($this->records_out[$filter][$r["parent_id"]]))
  225. $this->records_out[$filter][$r["parent_id"]] += $amount;
  226. else
  227. $this->records_out[$filter][$r["parent_id"]] = $amount;
  228. if ($r["parent_id"] > 0)
  229. $this->updateParent("OUT", $r["parent_id"], $amount, $filter);
  230. }
  231. }
  232. }
  233. }
  234. public function updateParentYear($type, $causal_id, $amount, $filter, &$records_in, &$records_out)
  235. {
  236. if ($type == "IN")
  237. {
  238. foreach($this->rows_in as $r)
  239. {
  240. if ($r["id"] == $causal_id)
  241. {
  242. if (isset($records_in[$filter][$r["parent_id"]]))
  243. $records_in[$filter][$r["parent_id"]] += $amount;
  244. else
  245. $records_in[$filter][$r["parent_id"]] = $amount;
  246. if ($r["parent_id"] > 0)
  247. $this->updateParentYear("IN", $r["parent_id"], $amount, $filter, $records_in, $records_out);
  248. }
  249. }
  250. }
  251. if ($type == "OUT")
  252. {
  253. foreach($this->rows_out as $r)
  254. {
  255. if ($r["id"] == $causal_id)
  256. {
  257. if (isset($records_out[$filter][$r["parent_id"]]))
  258. $records_out[$filter][$r["parent_id"]] += $amount;
  259. else
  260. $records_out[$filter][$r["parent_id"]] = $amount;
  261. if ($r["parent_id"] > 0)
  262. $this->updateParentYear("OUT", $r["parent_id"], $amount, $filter, $records_in, $records_out);
  263. }
  264. }
  265. }
  266. }
  267. public function getCausal($causal)
  268. {
  269. $ret = '';
  270. if ($causal > 0)
  271. {
  272. $ret = \App\Models\Causal::findOrFail($causal)->getTree();
  273. }
  274. return $ret;
  275. }
  276. public function getMonth($str)
  277. {
  278. $ret = '';
  279. list($m, $y) = explode("-", $str);
  280. switch ($m) {
  281. case 'x':
  282. $ret = '';
  283. break;
  284. case '01':
  285. $ret = 'Gennaio ';
  286. break;
  287. case '02':
  288. $ret = 'Febbraio ';
  289. break;
  290. case '03':
  291. $ret = 'Marzo ';
  292. break;
  293. case '04':
  294. $ret = 'Aprile ';
  295. break;
  296. case '05':
  297. $ret = 'Maggio ';
  298. break;
  299. case '06':
  300. $ret = 'Giugno ';
  301. break;
  302. case '07':
  303. $ret = 'Luglio ';
  304. break;
  305. case '08':
  306. $ret = 'Agosto ';
  307. break;
  308. case '09':
  309. $ret = 'Settembre ';
  310. break;
  311. case '10':
  312. $ret = 'Ottobre ';
  313. break;
  314. case '11':
  315. $ret = 'Novembre ';
  316. break;
  317. case '12':
  318. $ret = 'Dicembre ';
  319. break;
  320. default:
  321. $ret = '';
  322. break;
  323. }
  324. $ret .= $y;
  325. return $ret;
  326. }
  327. public function clear()
  328. {
  329. $this->columns = [];
  330. $this->datas = [];
  331. $this->records_out = [];
  332. $this->records_in = [];
  333. $this->emit('load-select');
  334. $this->emit('reset-collapse');
  335. //$this->showData = false;
  336. }
  337. public function remove($idx)
  338. {
  339. unset($this->datas[$idx]);
  340. $this->show('', '');
  341. }
  342. public function export()
  343. {
  344. $rows_in = array();
  345. if ($this->filterCausalsIn != null && sizeof($this->filterCausalsIn) > 0)
  346. {
  347. foreach($this->rows_in as $r)
  348. {
  349. if (in_array($r["id"], $this->filterCausalsIn) || in_array($r["parent_id"], $this->filterCausalsIn) || in_array($r["first_parent_id"], $this->filterCausalsIn))
  350. {
  351. $rows_in[] = $r;
  352. }
  353. }
  354. }
  355. else
  356. {
  357. $rows_in = $this->rows_in;
  358. }
  359. $path = $this->generateExcel($this->columns, $rows_in, $this->records_in, $this->rows_out, $this->records_out);
  360. return response()->download($path)->deleteFileAfterSend();
  361. }
  362. public function exportYear($year)
  363. {
  364. $records_in = [];
  365. $records_out = [];
  366. $datas = [];
  367. if (env('FISCAL_YEAR_MONTH_FROM', 1) > 1)
  368. {
  369. for($m=env('FISCAL_YEAR_MONTH_FROM', 1);$m<=12;$m++)
  370. {
  371. $datas[] = $m . "-" . $year;
  372. }
  373. for($m=1;$m<=env('FISCAL_YEAR_MONTH_TO', 12);$m++)
  374. {
  375. $datas[] = $m . "-" . ($year + 1);
  376. }
  377. }
  378. else
  379. {
  380. for($m=1;$m<=12;$m++)
  381. {
  382. $datas[] = $m . "-" . $year;
  383. }
  384. }
  385. $exclude_from_records = \App\Models\Member::where('exclude_from_records', true)->pluck('id')->toArray();
  386. foreach($datas as $filter)
  387. {
  388. $columns[] = $filter;
  389. $records = \App\Models\Record::where('type', 'IN')
  390. ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
  391. ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
  392. ->where(function ($query) {
  393. $query->where('deleted', false)->orWhere('deleted', null);
  394. })
  395. ->where(function ($query) {
  396. $query->where('financial_movement', false)->orWhere('financial_movement', null);
  397. })
  398. ->whereNotIn('member_id', $exclude_from_records)
  399. ->where('records_rows.when', 'like', '%"' . $filter . '"%')->get();
  400. //$records = $records->orderBy('date', 'DESC')->get();
  401. foreach($records as $record)
  402. {
  403. $amount = $record->amount;
  404. $amount += getVatValue($amount, $record->vat_id);
  405. $when = sizeof(json_decode($record->when));
  406. if ($when > 1)
  407. {
  408. $amount = $amount / $when;
  409. $record->amount = $amount;
  410. }
  411. // Aggiungo/aggiorno i dati
  412. if (isset($records_in[$filter][$record->causal_id]))
  413. $records_in[$filter][$record->causal_id] += $amount;
  414. else
  415. $records_in[$filter][$record->causal_id] = $amount;
  416. // Aggiorno i dati del padre
  417. $this->updateParentYear("IN", $record->causal_id, $amount, $filter, $records_in, $records_out);
  418. }
  419. $records = \App\Models\Record::where('type', 'OUT')
  420. ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
  421. ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
  422. ->where(function ($query) {
  423. $query->where('deleted', false)->orWhere('deleted', null);
  424. })
  425. ->where(function ($query) {
  426. $query->where('financial_movement', false)->orWhere('financial_movement', null);
  427. })
  428. ->whereNotIn('member_id', $exclude_from_records)
  429. ->where('records_rows.when', 'like', '%"' . $filter . '"%')->get();
  430. //$records = $records->orderBy('date', 'DESC')->get();
  431. foreach($records as $record)
  432. {
  433. $amount = $record->amount;
  434. $when = sizeof(json_decode($record->when));
  435. if ($when > 1)
  436. {
  437. $amount = $amount / $when;
  438. $record->amount = $amount;
  439. }
  440. // Aggiungo/aggiorno i dati
  441. if (isset($records_out[$filter][$record->causal_id]))
  442. $records_out[$filter][$record->causal_id] += $amount;
  443. else
  444. $records_out[$filter][$record->causal_id] = $amount;
  445. $this->updateParentYear("OUT", $record->causal_id, $amount, $filter, $records_in, $records_out);
  446. }
  447. }
  448. $path = $this->generateExcel($columns, $this->rows_in, $records_in, $this->rows_out, $records_out);
  449. return response()->download($path)->deleteFileAfterSend();
  450. }
  451. public function generateExcel($columns, $rows_in, $records_in, $rows_out, $records_out)
  452. {
  453. $letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N');
  454. $spreadsheet = new Spreadsheet();
  455. $activeWorksheet = $spreadsheet->getActiveSheet();
  456. $activeWorksheet->setCellValue('A1', 'Entrate');
  457. foreach($columns as $idx => $column)
  458. {
  459. $activeWorksheet->setCellValue($letters[$idx + 1] . '1', $this->getMonth($column));
  460. }
  461. $activeWorksheet->getStyle('A1:N1')->getFont()->setBold(true);
  462. $activeWorksheet->getStyle('A1:N1')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('00ff00');
  463. $count = 2;
  464. $totals = [];
  465. foreach($rows_in as $in)
  466. {
  467. $activeWorksheet->setCellValue('A' . $count, str_repeat(" ", $in["level"]) . $in["name"]);
  468. foreach($columns as $idx => $column)
  469. {
  470. if(isset($records_in[$column][$in["id"]]))
  471. {
  472. $activeWorksheet->setCellValue($letters[$idx + 1] . $count, formatPrice($records_in[$column][$in["id"]]));
  473. if ($in["level"] == 0)
  474. {
  475. if (isset($totals[$idx]))
  476. $totals[$idx] += $records_in[$column][$in["id"]];
  477. else
  478. $totals[$idx] = $records_in[$column][$in["id"]];
  479. }
  480. }
  481. }
  482. if ($in["level"] == 0)
  483. {
  484. $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFont()->setBold(true);
  485. //$activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('b1ed5c');
  486. }
  487. $count += 1;
  488. }
  489. $activeWorksheet->setCellValue('A' . $count, 'Totale');
  490. foreach($totals as $idx => $total)
  491. {
  492. $activeWorksheet->setCellValue($letters[$idx + 1] . $count, formatPrice($total));
  493. $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFont()->setBold(true);
  494. $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('00ff00');
  495. }
  496. $count += 2;
  497. $activeWorksheet->setCellValue('A' . $count, "Uscite");
  498. foreach($columns as $idx => $column)
  499. {
  500. $activeWorksheet->setCellValue($letters[$idx + 1] . $count, $this->getMonth($column));
  501. }
  502. $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFont()->setBold(true);
  503. $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('ff0000');
  504. $count += 1;
  505. $totals = [];
  506. foreach($rows_out as $out)
  507. {
  508. $activeWorksheet->setCellValue('A' . $count, str_repeat(" ", $out["level"]) . $out["name"]);
  509. foreach($columns as $idx => $column)
  510. {
  511. if(isset($records_out[$column][$out["id"]]))
  512. {
  513. $activeWorksheet->setCellValue($letters[$idx + 1] . $count, formatPrice($records_out[$column][$out["id"]]));
  514. if ($out["level"] == 0)
  515. {
  516. if (isset($totals[$idx]))
  517. $totals[$idx] += $records_out[$column][$out["id"]];
  518. else
  519. $totals[$idx] = $records_out[$column][$out["id"]];
  520. }
  521. }
  522. }
  523. if ($out["level"] == 0)
  524. {
  525. $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFont()->setBold(true);
  526. //$activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('ed6d61');
  527. }
  528. $count += 1;
  529. }
  530. $activeWorksheet->setCellValue('A' . $count, 'Totale');
  531. foreach($totals as $idx => $total)
  532. {
  533. $activeWorksheet->setCellValue($letters[$idx + 1] . $count, formatPrice($total));
  534. $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFont()->setBold(true);
  535. $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('ff0000');
  536. }
  537. foreach($letters as $l)
  538. $activeWorksheet->getColumnDimension($l)->setWidth(20);
  539. $writer = new Xlsx($spreadsheet);
  540. $writer->save($path = storage_path('entrate_uscite_' . date("YmdHis") . '.xlsx'));
  541. return $path;
  542. }
  543. }