diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index d449b2d..87b1ef8 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -72,6 +72,8 @@ public class TasksFrame extends JFrame { setupDate(); + setupGuV(); + setupBinF(); setupSteuer(); @@ -1225,6 +1227,246 @@ public class TasksFrame extends JFrame { } + private void setupGuV() + { + JPanel jPanel = setupPanel("Gewinn und Verlust Rechnung"); + + JLabel l1 = new JLabel(); + l1.setVisible(true); + l1.setText("Aufwendungen"); + l1.setBounds(5,20,110,20); + l1.setFont(new java.awt.Font("Arial", Font.BOLD, 14)); + + JLabel l3 = new JLabel(); + l3.setVisible(true); + l3.setText("Wareneinkauf:"); + l3.setBounds(5,40,110,20); + + JLabel l4 = new JLabel(); + l4.setVisible(true); + l4.setText("Miete:"); + l4.setBounds(5,55,100,20); + + JLabel l5 = new JLabel(); + l5.setVisible(true); + l5.setText("Zinsen:"); + l5.setBounds(5,70,100,20); + + JLabel l6 = new JLabel(); + l6.setVisible(true); + l6.setText("Abschreibungen:"); + l6.setBounds(5,85,110,20); + + JLabel l7 = new JLabel(); + l7.setVisible(true); + l7.setText("Gehaelter:"); + l7.setBounds(5,100,100,20); + + JTextField t1 = new JTextField(); + t1.setBounds(110,42,70,15); + t1.setVisible(true); + + JTextField t2 = new JTextField(); + t2.setBounds(110,57,70,15); + t2.setVisible(true); + + JTextField t3 = new JTextField(); + t3.setBounds(110,72,70,15); + t3.setVisible(true); + + JTextField t4 = new JTextField(); + t4.setBounds(110,87,70,15); + t4.setVisible(true); + + JTextField t5 = new JTextField(); + t5.setBounds(110,102,70,15); + t5.setVisible(true); + + JLabel e1 = new JLabel(); + e1.setVisible(true); + e1.setText("€"); + e1.setBounds(180,40,20,20); + + JLabel e2 = new JLabel(); + e2.setVisible(true); + e2.setText("€"); + e2.setBounds(180,55,20,20); + + JLabel e3 = new JLabel(); + e3.setVisible(true); + e3.setText("€"); + e3.setBounds(180,70,20,20); + + JLabel e4 = new JLabel(); + e4.setVisible(true); + e4.setText("€"); + e4.setBounds(180,85,20,20); + + JLabel e5 = new JLabel(); + e5.setVisible(true); + e5.setText("€"); + e5.setBounds(180,100,20,20); + + JLabel l2 = new JLabel(); + l2.setVisible(true); + l2.setText("Ertraege"); + l2.setBounds(200,20,80,20); + l2.setFont(new java.awt.Font("Arial", Font.BOLD, 14)); + + JLabel l8 = new JLabel(); + l8.setVisible(true); + l8.setText("Umsatzerloese:"); + l8.setBounds(200,40,100,20); + + JLabel l9 = new JLabel(); + l9.setVisible(true); + l9.setText("Zinsertraege:"); + l9.setBounds(200,55,100,20); + + JLabel l10 = new JLabel(); + l10.setVisible(true); + l10.setText("Zuschuesse:"); + l10.setBounds(200,70,80,20); + + JTextField t6 = new JTextField(); + t6.setBounds(292,42,70,15); + t6.setVisible(true); + + JTextField t7 = new JTextField(); + t7.setBounds(292,57,70,15); + t7.setVisible(true); + + JTextField t8 = new JTextField(); + t8.setBounds(292,72,70,15); + t8.setVisible(true); + + JLabel e6 = new JLabel(); + e6.setVisible(true); + e6.setText("€"); + e6.setBounds(360,40,20,20); + + JLabel e7 = new JLabel(); + e7.setVisible(true); + e7.setText("€"); + e7.setBounds(360,55,20,20); + + JLabel e8 = new JLabel(); + e8.setVisible(true); + e8.setText("€"); + e8.setBounds(360,70,20,20); + + JButton jButton = new JButton(); + jButton.setVisible(true); + jButton.setText("Berechne GuV"); + jButton.setBounds(1,120,110,30); + + JLabel summe1 = new JLabel(); + summe1.setText("∑"); + summe1.setVisible(true); + summe1.setBounds(108,115,20,20); + + JLabel summe2 = new JLabel(); + summe2.setText("∑"); + summe2.setVisible(true); + summe2.setBounds(290,85,20,20); + + JLabel erg1 = new JLabel(); + erg1.setBounds(130,115,80,20); + erg1.setVisible(true); + + JLabel erg2 = new JLabel(); + erg2.setBounds(310,85,80,20); + erg2.setVisible(true); + + JLabel ausgabe = new JLabel(); + ausgabe.setVisible(true); + ausgabe.setBounds(250, 120,150,20); + + jButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String texta = t1.getText(); + String textb = t2.getText(); + String textc = t3.getText(); + String textd = t4.getText(); + String texte = t5.getText(); + String textf = t6.getText(); + String textg = t7.getText(); + String texth = t8.getText(); + + Integer val_a = Integer.valueOf(texta); + Integer val_b = Integer.valueOf(textb); + Integer val_c = Integer.valueOf(textc); + Integer val_d = Integer.valueOf(textd); + Integer val_e = Integer.valueOf(texte); + Integer val_f = Integer.valueOf(textf); + Integer val_g = Integer.valueOf(textg); + Integer val_h = Integer.valueOf(texth); + Integer res1 = setupAufwendungen(val_a, val_b, val_c, val_d, val_e); + Integer res2 = setupErtraege(val_f,val_g,val_h); + erg1.setText(String.valueOf(res1 +" €")); + erg2.setText(String.valueOf(res2 +"€")); + jPanel.add(erg1); + jPanel.add(erg2); + if(res1>res2) + { + ausgabe.setText("Verlust: " +(res1-res2) +"€"); + ausgabe.setForeground(Color.RED); + } else + { + ausgabe.setText("Gewinn: " + (res2-res1) +"€"); + ausgabe.setForeground(Color.GREEN); + } + } + }); + + jPanel.add(ausgabe); + jPanel.add(summe2); + jPanel.add(summe1); + jPanel.add(jButton); + jPanel.add(t1); + jPanel.add(t2); + jPanel.add(t3); + jPanel.add(t4); + jPanel.add(t5); + jPanel.add(t6); + jPanel.add(t7); + jPanel.add(t8); + jPanel.add(l1); + jPanel.add(l2); + jPanel.add(l3); + jPanel.add(l4); + jPanel.add(l5); + jPanel.add(l6); + jPanel.add(l7); + jPanel.add(l8); + jPanel.add(l9); + jPanel.add(l10); + jPanel.add(e1); + jPanel.add(e2); + jPanel.add(e3); + jPanel.add(e4); + jPanel.add(e5); + jPanel.add(e6); + jPanel.add(e7); + jPanel.add(e8); + } + + public int setupAufwendungen(int a, int b, int c, int d, int e) + { + int x = 0; + + x = a+b+c+d+e; + return x; + } + + public int setupErtraege(int a, int b, int c) + { + int x = 0; + x = a+b+c; + return x; + } + public void setupArea() { diff --git a/src/test/java/src/TasksFrameTest.java b/src/test/java/src/TasksFrameTest.java index beab9b5..605b757 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -80,7 +80,21 @@ class TasksFrameTest { assertEquals(40,x2); } + @Test + void aufwendungen() + { + TasksFrame tasksFrame = new TasksFrame(); + int x = tasksFrame.setupAufwendungen(20000,6000,10000,4000,100); + assertEquals(40100, x); + } + @Test + void ertraege() + { + TasksFrame tasksFrame = new TasksFrame(); + int x2 = tasksFrame.setupErtraege(80000,13000,4000); + assertEquals(97000, x2); + } @Test void setupPI() { TasksFrame tasksFrame = new TasksFrame();