equal
deleted
inserted
replaced
|
1 /** |
|
2 * Invoice.cs |
|
3 * |
|
4 * @author Markus Bröker<broeker.markus@googlemail.com> |
|
5 * @copyright Copyright(C) 2017 4Customers UG |
|
6 * |
|
7 */ |
|
8 using System; |
|
9 using System.Collections.Generic; |
|
10 using System.Linq; |
|
11 using System.Text; |
|
12 using System.Threading.Tasks; |
|
13 |
|
14 using static Sales.Payment; |
|
15 |
|
16 namespace Sales |
|
17 { |
|
18 delegate double InvoiceDelegate(); |
|
19 |
|
20 class Invoice |
|
21 { |
|
22 private double value = 0; |
|
23 private PaymentType till; |
|
24 |
|
25 public Invoice(double value, PaymentType till) |
|
26 { |
|
27 this.value = value; |
|
28 this.till = till; |
|
29 |
|
30 InvoiceDelegate invoiceDelegateReference = this.Rabatt; |
|
31 invoiceDelegateReference += this.AddTax; |
|
32 invoiceDelegateReference += this.Skonto; |
|
33 |
|
34 invoiceDelegateReference(); |
|
35 } |
|
36 |
|
37 public double getFinalResult() |
|
38 { |
|
39 return value; |
|
40 } |
|
41 |
|
42 //Rabatt auf den Netto Preis |
|
43 private double Rabatt() |
|
44 { |
|
45 if (value > 1000.0) |
|
46 { |
|
47 value *= 0.75; |
|
48 } |
|
49 else if (value > 500.0) |
|
50 { |
|
51 value *= 0.85; |
|
52 } |
|
53 |
|
54 return value; |
|
55 } |
|
56 |
|
57 // Steuern auf den rabattierten Nettopreis |
|
58 private double AddTax() |
|
59 { |
|
60 value *= 1.19; |
|
61 return value; |
|
62 } |
|
63 |
|
64 // Skonto immer zum Schluss |
|
65 private double Skonto() |
|
66 { |
|
67 switch (till) |
|
68 { |
|
69 case PaymentType.NOW: |
|
70 value *= 0.97; |
|
71 break; |
|
72 case PaymentType.WEEK: |
|
73 value *= 0.98; |
|
74 break; |
|
75 case PaymentType.MONTH: |
|
76 value *= 0.99; |
|
77 break; |
|
78 } |
|
79 |
|
80 return value; |
|
81 } |
|
82 } |
|
83 } |