1/*************************************************************************** 2 * SPDX-FileCopyrightText: 2021 S. MANKOWSKI stephane@mankowski.fr 3 * SPDX-FileCopyrightText: 2021 G. DE BURE support@mankowski.fr 4 * SPDX-License-Identifier: GPL-3.0-or-later 5 ***************************************************************************/ 6import QtQuick 2.0 7import QtQuick.Layouts 1.0 8import QtQuick.Controls 1.0 9 10GridLayout { 11 property var pixel_size: report==null ? 0 : report.point_size 12 13 id: widget 14 columns: 2 15 16 property double maxValue: Math.max(incomes1Bar.value, expenditures1Bar.value, incomes2Bar.value, expenditures2Bar.value) 17 property double totrigger: 1.0 18 19 Connections { 20 target: report 21 function onChanged() { 22 totrigger = 2.0; 23 totrigger = 1.0; 24 } 25 } 26 27 Label{ 28 id: label1 29 text: period1Widget.text 30 font.bold: true 31 font.pixelSize: pixel_size 32 Layout.columnSpan: 2 33 } 34 35 Label{ 36 text: qsTr("Incomes:") 37 font.pixelSize: pixel_size 38 } 39 40 SKGValue { 41 font.pixelSize: pixel_size 42 id: incomes1Bar 43 max: parent.maxValue 44 value: totrigger*(report==null ? 0 : report.getIncomeVsExpenditure(suboperationsWidget.checked, groupedWidget.checked, transferWidget.checked, trackerWidget.checked, period1Widget.whereClause, period2Widget.whereClause)[1][3]) 45 text: document.formatPrimaryMoney(value) 46 horizontalAlignment: Text.AlignHCenter 47 backgroundColor: '#' + color_positivetext 48 url: "skg://skrooge_operation_plugin/" + (suboperationsWidget.checked ? "SKGOPERATION_CONSOLIDATED_DEFAULT_PARAMETERS/" :"") + "?operationTable=" + 49 (suboperationsWidget.checked ? "v_suboperation_consolidated": "v_operation_display") + "&title_icon=view-bank-account-savings¤tPage=-1&title=" + 50 qsTr("Incomes of %1").arg(label1.text) + 51 "&operationWhereClause=" + period1Widget.whereClause + " AND t_TYPEACCOUNT<>'L' AND t_TYPEEXPENSE='+'" + 52 (groupedWidget.checked ? "" : " AND i_group_id=0") + (transferWidget.checked ? "" : " AND t_TRANSFER='N'") + (trackerWidget.checked ? "" : (suboperationsWidget.checked ? " AND t_REALREFUND=''" : " AND t_REFUND=''")); 53 } 54 55 Label{ 56 text: qsTr("Expenditures:") 57 font.pixelSize: pixel_size 58 } 59 60 SKGValue { 61 font.pixelSize: pixel_size 62 id: expenditures1Bar 63 max: parent.maxValue 64 value: totrigger*(report==null ? 0 : report.getIncomeVsExpenditure(suboperationsWidget.checked, groupedWidget.checked, transferWidget.checked, trackerWidget.checked, period1Widget.whereClause, period2Widget.whereClause)[2][3]) 65 text: document.formatPrimaryMoney(value) 66 horizontalAlignment: Text.AlignHCenter 67 backgroundColor: '#' + color_negativetext 68 url: "skg://skrooge_operation_plugin/" + (suboperationsWidget.checked ? "SKGOPERATION_CONSOLIDATED_DEFAULT_PARAMETERS/" :"") + "?operationTable=" + 69 (suboperationsWidget.checked ? "v_suboperation_consolidated": "v_operation_display") + "&title_icon=view-bank-account-savings¤tPage=-1&title=" + 70 qsTr("Expenses of %1").arg(label1.text) + 71 "&operationWhereClause=" + period1Widget.whereClause + " AND t_TYPEACCOUNT<>'L' AND t_TYPEEXPENSE='-'" + 72 (groupedWidget.checked ? "" : " AND i_group_id=0") + (transferWidget.checked ? "" : " AND t_TRANSFER='N'") + (trackerWidget.checked ? "" : (suboperationsWidget.checked ? " AND t_REALREFUND=''" : " AND t_REFUND=''")); 73 } 74 75 Label{ 76 text: qsTr("Savings:") 77 font.pixelSize: pixel_size 78 } 79 80 SKGValue { 81 font.pixelSize: pixel_size 82 id: savings1Bar 83 max: parent.maxValue 84 value: Math.abs(incomes1Bar.value - expenditures1Bar.value) 85 text: document.formatPrimaryMoney(incomes1Bar.value - expenditures1Bar.value) 86 horizontalAlignment: Text.AlignHCenter 87 backgroundColor: '#' + (incomes1Bar.value - expenditures1Bar.value <0 ? color_negativetext : color_positivetext) 88 url: "skg://skrooge_operation_plugin/" + (suboperationsWidget.checked ? "SKGOPERATION_CONSOLIDATED_DEFAULT_PARAMETERS/" :"") + "?operationTable=" + 89 (suboperationsWidget.checked ? "v_suboperation_consolidated": "v_operation_display") + "&title_icon=view-bank-account-savings¤tPage=-1&title=" + 90 qsTr("Savings of %1").arg(label1.text) + 91 "&operationWhereClause=" + period1Widget.whereClause + " AND t_TYPEACCOUNT<>'L'" + 92 (groupedWidget.checked ? "" : " AND i_group_id=0") + (transferWidget.checked ? "" : " AND t_TRANSFER='N'") + (trackerWidget.checked ? "" : (suboperationsWidget.checked ? " AND t_REALREFUND=''" : " AND t_REFUND=''")); 93 } 94 95 96 Label{ 97 id: label2 98 text: period2Widget.text 99 font.bold: true 100 font.pixelSize: pixel_size 101 Layout.columnSpan: 2 102 } 103 104 Label{ 105 text: qsTr("Incomes:") 106 font.pixelSize: pixel_size 107 } 108 109 SKGValue { 110 font.pixelSize: pixel_size 111 id: incomes2Bar 112 max: parent.maxValue 113 value: totrigger*(report==null ? 0 : report.getIncomeVsExpenditure(suboperationsWidget.checked, groupedWidget.checked, transferWidget.checked, trackerWidget.checked, period1Widget.whereClause, period2Widget.whereClause)[1][2]) 114 text: document.formatPrimaryMoney(value) 115 horizontalAlignment: Text.AlignHCenter 116 backgroundColor: '#' + color_positivetext 117 url: "skg://skrooge_operation_plugin/" + (suboperationsWidget.checked ? "SKGOPERATION_CONSOLIDATED_DEFAULT_PARAMETERS/" :"") + "?operationTable=" + 118 (suboperationsWidget.checked ? "v_suboperation_consolidated": "v_operation_display") + "&title_icon=view-bank-account-savings¤tPage=-1&title=" + 119 qsTr("Incomes of %1").arg(label2.text) + 120 "&operationWhereClause=" + period2Widget.whereClause + " AND t_TYPEACCOUNT<>'L' AND t_TYPEEXPENSE='+'" + 121 (groupedWidget.checked ? "" : " AND i_group_id=0") + (transferWidget.checked ? "" : " AND t_TRANSFER='N'") + (trackerWidget.checked ? "" : (suboperationsWidget.checked ? " AND t_REALREFUND=''" : " AND t_REFUND=''")); 122 } 123 124 Label{ 125 text: qsTr("Expenditures:") 126 font.pixelSize: pixel_size 127 } 128 129 SKGValue { 130 font.pixelSize: pixel_size 131 id: expenditures2Bar 132 max: parent.maxValue 133 value: totrigger*(report==null ? 0 : report.getIncomeVsExpenditure(suboperationsWidget.checked, groupedWidget.checked, transferWidget.checked, trackerWidget.checked, period1Widget.whereClause, period2Widget.whereClause)[2][2]) 134 text: document.formatPrimaryMoney(value) 135 horizontalAlignment: Text.AlignHCenter 136 backgroundColor: '#' + color_negativetext 137 url: "skg://skrooge_operation_plugin/" + (suboperationsWidget.checked ? "SKGOPERATION_CONSOLIDATED_DEFAULT_PARAMETERS/" :"") + "?operationTable=" + 138 (suboperationsWidget.checked ? "v_suboperation_consolidated": "v_operation_display") + "&title_icon=view-bank-account-savings¤tPage=-1&title=" + 139 qsTr("Expenses of %1").arg(label2.text) + 140 "&operationWhereClause=" + period2Widget.whereClause + " AND t_TYPEACCOUNT<>'L' AND t_TYPEEXPENSE='-'" + 141 (groupedWidget.checked ? "" : " AND i_group_id=0") + (transferWidget.checked ? "" : " AND t_TRANSFER='N'") + (trackerWidget.checked ? "" : (suboperationsWidget.checked ? " AND t_REALREFUND=''" : " AND t_REFUND=''")); 142 } 143 144 Label{ 145 text: qsTr("Savings:") 146 font.pixelSize: pixel_size 147 } 148 149 SKGValue { 150 id: savings2Bar 151 max: parent.maxValue 152 value: Math.abs(incomes2Bar.value - expenditures2Bar.value) 153 text: document.formatPrimaryMoney(incomes2Bar.value - expenditures2Bar.value) 154 horizontalAlignment: Text.AlignHCenter 155 backgroundColor: '#' + (incomes2Bar.value - expenditures2Bar.value <0 ? color_negativetext : color_positivetext) 156 url: "skg://skrooge_operation_plugin/" + (suboperationsWidget.checked ? "SKGOPERATION_CONSOLIDATED_DEFAULT_PARAMETERS/" :"") + "?operationTable=" + 157 (suboperationsWidget.checked ? "v_suboperation_consolidated": "v_operation_display") + "&title_icon=view-bank-account-savings¤tPage=-1&title=" + 158 qsTr("Savings of %1").arg(label2.text) + 159 "&operationWhereClause=" + period2Widget.whereClause + " AND t_TYPEACCOUNT<>'L'" + 160 (groupedWidget.checked ? "" : " AND i_group_id=0") + (transferWidget.checked ? "" : " AND t_TRANSFER='N'") + (trackerWidget.checked ? "" : (suboperationsWidget.checked ? " AND t_REALREFUND=''" : " AND t_REFUND=''")); 161 } 162 163} 164