Advertisement
Guest User

berechnung.qml

a guest
Nov 13th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 15.58 KB | Money | 0 0
  1. /*
  2.  * Copyright (C) 2022  Dirk Unverzagt
  3.  * Dieses Programm ist kostenlose Software: Sie können es weitergeben und/oder modifizieren
  4.   * Es unterliegt den Bedingungen der GNU General Public License, wie veröffentlicht von
  5.   * die Free Software Foundation; Fassung 3.
  6.   *
  7.   * mwst wird in der Hoffnung verteilt, dass es nützlich sein wird,
  8.   * jedoch OHNE JEGLICHE GEWÄHRLEISTUNG; sogar ohne die stillschweigende Garantie von
  9.   * MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK. Siehe die
  10.   * GNU General Public License für weitere Details.
  11.   *
  12.   * Sie sollten eine Kopie der GNU General Public License erhalten haben
  13.   * zusammen mit diesem Programm. Falls nicht, siehe <http://www.gnu.org/licenses/>.
  14.  *
  15.  * This program is free software: you can redistribute it and/or modify
  16.  * it under the terms of the GNU General Public License as published by
  17.  * the Free Software Foundation; version 3.
  18.  *
  19.  * mwst is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  * GNU General Public License for more details.
  23.  *
  24.  * You should have received a copy of the GNU General Public License
  25.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  26.  */
  27.  
  28. import QtQuick 2.7
  29. import Ubuntu.Components 1.3
  30. import QtQuick.Controls 2.2
  31. import QtQuick.Layouts 1.3
  32. import Qt.labs.settings 1.0
  33. import QtQuick.LocalStorage 2.0
  34.  
  35.  
  36.  
  37.  
  38.  
  39. MainView {
  40.     id: root2
  41.     objectName: 'mainView'
  42.     applicationName: 'mwst.dl8aax'
  43.     automaticOrientation: true
  44.  
  45.     width: units.gu(45)
  46.     height: units.gu(70)
  47.  
  48.  
  49.  
  50.     Item {
  51.             id : i
  52.  
  53.           function machmacombob(tv) {
  54.  
  55.                                      var satze = window.mw.split('\n' )
  56.                                      console.log(  i18n.tr( "satze 1 =" + satze[1] ))
  57.  
  58.                                     }
  59.  
  60.  
  61.           Component.onCompleted: {    
  62.                                
  63.                                    machmacombob()
  64.  
  65.                                  }
  66.         }
  67.  
  68.  
  69.     Page {
  70.           id:page_berechnung
  71.           anchors.fill: parent
  72.  
  73.       //   header: PageHeader {
  74.       //                       id: header
  75.       //                       title: i18n.tr('Mehrwertsteuer Rechner')
  76.       //                        }
  77.  
  78.  
  79.          Rectangle {
  80.                     id: rectangle
  81.                     x: units.gu(2)
  82.                     y: units.gu(2)
  83.                     width: units.gu(45)-units.gu(5)
  84.                     height: units.gu(75)/4
  85.                     color: "#ddd9d9"
  86.                     radius: 4
  87.                     border.color: "#be0cc4"
  88.                     border.width: units.gu(0.2)
  89.                     Text {
  90.                           id: btext
  91.                           x: units.gu(2.5) // 20 px Desktop 45 px Phone 25 px Tablet
  92.                           y: units.gu(3.25)
  93.                           height: units.gu(3)
  94.                           anchors.margins: units.gu(1)
  95.                           text: i18n.tr('Brutto ')
  96.                           font.pixelSize:  units.gu(2.5)
  97.                           color: "darkorange"
  98.                           }
  99.                     Text {
  100.                           id: ntext
  101.                           anchors.left : btext.left
  102.                           anchors.top  : btext.bottom
  103.                           anchors.topMargin: units.gu(1)
  104.                           height:  units.gu(3)
  105.                           text: i18n.tr("Neto ")
  106.                           font.pixelSize:  units.gu(2.5)
  107.                           color: "darkorange"
  108.                           }
  109.                     Text {
  110.                           id: mtext
  111.                           anchors.left : ntext.left
  112.                           anchors.top  : ntext.bottom
  113.                           anchors.topMargin: units.gu(1)
  114.                           height:  units.gu(3)
  115.                           text: i18n.tr("MwSt ")
  116.                           font.pixelSize:  units.gu(2.5)
  117.                           color: "darkorange"
  118.                           }
  119.                     }
  120.         Rectangle {
  121.                     id: rectangle2
  122.                     x: units.gu(2)
  123.                     y: units.gu(4)+rectangle.height
  124.                     width: units.gu(45)-units.gu(5)
  125.                     height: units.gu(75)/2
  126.                     color: "#ddd9d9"
  127.                     radius: 4
  128.                     border.color: "#be0cc4"
  129.                     border.width: units.gu(0.2)
  130.                       Text {
  131.                           id: nitext
  132.                           x:  units.gu(2)
  133.                           y:  units.gu(2)
  134.                         //  width: units.gu(20)
  135.                           height:  units.gu(3)
  136.                           text: i18n.tr("Der Betrag ist ")
  137.                           font.pixelSize: units.gu(2.5)
  138.                           color: "darkorange"
  139.                           }
  140.                     RadioButton {
  141.                                   id: radioButton
  142.                                 //  x: 126
  143.                                 //  y:  nitext.y - units.gu(2)
  144.                                   anchors.left : nitext.right
  145.                                 //  anchors.top  : nitext.top
  146.                                   anchors.verticalCenter: nitext.verticalCenter
  147.                                   text: i18n.tr("Brutto")
  148.                                   }
  149.  
  150.                   RadioButton {
  151.                                 id: radioButton1
  152.                               //  x: 210
  153.                               //  y: 14
  154.                                 anchors.left : radioButton.right
  155.                                 anchors.top  : radioButton.top
  156.                                 text: i18n.tr("Netto")
  157.                                 }
  158.                     Text {
  159.                           id: ni_text
  160.                         //  x: 20
  161.                         //  y: nitext.y+42
  162.                           anchors.left : nitext.left
  163.                           anchors.top  : nitext.bottom
  164.                           anchors.topMargin: units.gu(1.8)
  165.                           //width: 50
  166.                           height:  units.gu(2.5)
  167.                           text: i18n.tr("Betrag: ")
  168.                           font.pixelSize: units.gu(2.5)
  169.                           color: "darkorange"
  170.                           }
  171.  
  172.                                   TextField {
  173.                                             id: textInput_b
  174.                                             width: units.gu(10)
  175.                                           //  height:   units.gu(3)
  176.                                             anchors.left : ni_text.right
  177.                                             anchors.verticalCenter: ni_text.verticalCenter
  178.                                           //  anchors.topMargin: units.gu(3)
  179.                                             text: qsTr("")
  180.                                             font.pixelSize: units.gu(1.5 )
  181.                                             selectionColor: "#b8b8fe"
  182.                                             cursorVisible: true
  183.                                             focus: true
  184.  
  185.                                             }
  186.  
  187.  
  188.  
  189.                     Text {
  190.                           id: combotext
  191.                           x: 22
  192.                           y: nitext.y+80
  193.                         //  width: 100
  194.                           //height: 22
  195.                           anchors.left : ni_text.left
  196.                           anchors.top  : ni_text.bottom
  197.                           anchors.topMargin: units.gu(3)
  198.                           text: i18n.tr("Mehrwertsteuersatz ")
  199.                           font.pixelSize: units.gu(2.5)
  200.                           color: "darkorange"
  201.                           }
  202.                   ComboBox {
  203.                             id: comboBox
  204.                         //    x: rectangle2.width-22-comboBox.width
  205.                         //    y: rectangle2.width-22-comboBox.width
  206.                             width : units.gu(11)
  207.                             anchors.left : combotext.right
  208.                           //  anchors.top  : combotext.top
  209.                             anchors.verticalCenter: combotext.verticalCenter
  210.                             textRole: qsTr("")
  211.                             model: ["7 %","9.5 %", "10.7 %", "19 %"]
  212.                             }
  213.             /*      Rectangle {
  214.                                 id: rect
  215.                                 x: 22
  216.                                 y: comboBox.y+90
  217.                                 width: units.gu(13)
  218.                                 height: units.gu(4)
  219.                                 color: "orange"
  220.                                 radius: 10
  221.                                 border.color: "#be0cc4"
  222.                                 border.width: 1
  223.                                 Text {
  224.                                       id: buttontext
  225.                                       text: i18n.tr("Berechnen")
  226.                                       font.pixelSize: units.gu(2.5)
  227.                                       //x: parent.x + 4
  228.                                       anchors.centerIn:rect
  229.                                       //font.pointSize: FontUtils.sizeToPixels("medium")
  230.  
  231.                                       }
  232.                             MouseArea{
  233.                                            anchors.fill: parent
  234.                                            onEntered: {
  235.                                                         //var qrg = float
  236.                                                         var betrt = textInput_b.text.replace(',','.')
  237.                                                         var betr  = parseFloat ( betrt )
  238.                                                         var steu  = comboBox.currentText
  239.                                                         steu = steu.replace(' %','')
  240.                                                         var mwsts = parseFloat( steu)
  241.                                                         var n = 0.00
  242.                                                         var m = 0.00
  243.  
  244.                                                         if (radioButton.checked){
  245.  
  246.                                                           // Betrag ist Brutto also Netto berechnen
  247.  
  248.                                                           n = betr / (100 + mwsts ) * 100
  249.                                                           m = betr / (100 + mwsts ) * mwsts
  250.  
  251.                                                           ntext.text = i18n.tr("Netto  : " + Math.round(  n * 100)/100 + " €")
  252.                                                           btext.text = i18n.tr("Brutto : " + Math.round(  betrt * 100)/100 + " €")
  253.                                                           mtext.text = i18n.tr("MwSt   : " + Math.round(  m * 100)/100 + " €")
  254.                                                         }
  255.                                                         if (radioButton1.checked){
  256.                                                           // Betrag ist Netto also Brutto berechnen
  257.                                                          m = betr / 100 * mwsts
  258.                                                          n = betr + m
  259.                                                           console.log("m ="+m)
  260.                                                          ntext.text = i18n.tr("Netto  : " + Math.round( betr * 100)/100 + " €")
  261.                                                           btext.text = i18n.tr("Brutto : "+ Math.round( n * 100)/100 + " €")
  262.                                                           mtext.text = i18n.tr("MwSt   : "+ Math.round( m * 100)/100 + " €")
  263.  
  264.                                                         }
  265.  
  266.                                                       }
  267.  
  268.                                       }
  269.                               } */
  270.                     Item {
  271.                     anchors.centerIn:parent
  272.                           Action {
  273.                                   id: action1
  274.                                   text: "Bereken"
  275.                                   iconName: "compose"
  276.  
  277.                                   onTriggered: {
  278.  
  279.  
  280.                                                         }
  281.  
  282.                                                       }
  283.                                   }
  284.                           Button {
  285.                                   id : but
  286.                                   //anchors.horizontalCenter: rectangle2.center
  287.                                   anchors.top  : comboBox.bottom
  288.                                   anchors.topMargin: units.gu(3)
  289.                                   anchors.centerIn: parent
  290.                                 //  x : rectangle2.center - but / 2
  291.                                   text: i18n.tr("Bereken")
  292.                                   onClicked: {
  293.                                               console.log(  i18n.tr(' button clicked\n' + mw  ))
  294.                                               console.log(  i18n.tr( window.mw  ))
  295.                                                 //var qrg = float
  296.                                                         var betrt = textInput_b.text.replace(',','.')
  297.                                                         var betr  = parseFloat ( betrt )
  298.                                                         var steu  = comboBox.currentText
  299.                                                         steu = steu.replace(' %','')
  300.                                                         var mwsts = parseFloat( steu)
  301.                                                         var n = 0.00
  302.                                                         var m = 0.00
  303.  
  304.                                                         if (radioButton.checked){
  305.  
  306.                                                           // Betrag ist Brutto also Netto berechnen
  307.  
  308.                                                           n = betr / (100 + mwsts ) * 100
  309.                                                           m = betr / (100 + mwsts ) * mwsts
  310.  
  311.                                                           ntext.text = i18n.tr("Netto  : " + Math.round(  n * 100)/100 + " €")
  312.                                                           btext.text = i18n.tr("Brutto : " + Math.round(  betrt * 100)/100 + " €")
  313.                                                           mtext.text = i18n.tr("MwSt   : " + Math.round(  m * 100)/100 + " €")
  314.                                                         }
  315.                                                         if (radioButton1.checked){
  316.                                                           // Betrag ist Netto also Brutto berechnen
  317.                                                          m = betr / 100 * mwsts
  318.                                                          n = betr + m
  319.                                                           console.log("m ="+m)
  320.                                                          ntext.text = i18n.tr("Netto  : " + Math.round( betr * 100)/100 + " €")
  321.                                                           btext.text = i18n.tr("Brutto : "+ Math.round( n * 100)/100 + " €")
  322.                                                           mtext.text = i18n.tr("MwSt   : "+ Math.round( m * 100)/100 + " €")
  323.                                              }
  324.                                   color: UbuntuColors.warmGrey
  325.  
  326.                                   }
  327.                          }
  328.                     }//ende Rectangle
  329.  
  330.           }
  331. }
  332.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement