Add comments to UE4
This commit is contained in:
parent
63231822c5
commit
a8e05a319e
@ -209,6 +209,8 @@ Aufgabe A.1
|
||||
> waup (g, v) = eval_payment_sum $ eval_payment_date (g, v)
|
||||
|
||||
|
||||
Evaluate payment date: determine the type of the payment and calculate the correct date with the correct attribute
|
||||
|
||||
> eval_payment_date :: Kassabucheintrag -> Kassabucheintrag
|
||||
> eval_payment_date (g, v)
|
||||
> | (is_payment v) && (is_date_valid (zahlung_vom v)) =
|
||||
@ -225,10 +227,13 @@ Aufgabe A.1
|
||||
> z = Zahlung (brutto v) (skonto v) (correct_date (zahlung_vom v))
|
||||
> gs = Gutschrift (gutschriftsbetrag v) (correct_date (gutschrift_vom v))
|
||||
|
||||
Simple datatype conversion
|
||||
|
||||
> eval_payment_sum :: Kassabucheintrag -> AP_Kassabucheintrag
|
||||
> eval_payment_sum (g, v) = (g, correct_sum v)
|
||||
|
||||
Calculate the correct date
|
||||
|
||||
> correct_date :: Datum -> Datum
|
||||
> correct_date d
|
||||
> | monat d == Feb =
|
||||
@ -246,6 +251,8 @@ Aufgabe A.1
|
||||
> fm = D (int_to_day 1) Mar y
|
||||
> nm = D (int_to_day 1) (int_to_month ((month_to_int (monat d)) + 1)) y
|
||||
|
||||
Calculate the sum by reducing the "tax" from the brutto sum
|
||||
|
||||
> correct_sum :: Geschaeftsvorfall -> AP_Geschaeftsvorfall
|
||||
> correct_sum g
|
||||
> | is_credit g = P_Gutschrift (gutschriftsbetrag g) (gutschrift_vom g)
|
||||
@ -276,6 +283,8 @@ Nur Werte zwischen 0 und 99 fuer cent!
|
||||
> = KKB [(P_Geschaeftspartner,K_Geschaeftsvorfall)]
|
||||
> deriving (Eq,Show)
|
||||
|
||||
Declare operators for easier calculations
|
||||
|
||||
> instance Num EuroCent where
|
||||
> (+) s s' = (add_ec s s')
|
||||
> (-) s s' = (diff_ec s s')
|
||||
@ -300,6 +309,7 @@ Nur Werte zwischen 0 und 99 fuer cent!
|
||||
> konsolidiere :: Kassabuch -> KonsolidiertesKassabuch
|
||||
> konsolidiere k = consolidate_cash_book k []
|
||||
|
||||
Consolidate each payment and add it to the registry book
|
||||
|
||||
> consolidate_cash_book :: Kassabuch -> [(P_Geschaeftspartner,K_Geschaeftsvorfall)] -> KonsolidiertesKassabuch
|
||||
> consolidate_cash_book (KB (x:xs)) res
|
||||
@ -312,6 +322,8 @@ Nur Werte zwischen 0 und 99 fuer cent!
|
||||
> consolidate_payment :: AP_Kassabucheintrag -> (P_Geschaeftspartner,K_Geschaeftsvorfall)
|
||||
> consolidate_payment (g, v) = (g, consolidate_payment_sum v)
|
||||
|
||||
Split the total sum in euros and cents using the rest and result of division by 100
|
||||
|
||||
> consolidate_payment_sum :: AP_Geschaeftsvorfall -> K_Geschaeftsvorfall
|
||||
> consolidate_payment_sum g
|
||||
> | is_p_credit g =
|
||||
@ -343,6 +355,8 @@ Aufgabe A.3
|
||||
> saldo :: P_Geschaeftspartner -> KonsolidiertesKassabuch -> Saldo
|
||||
> saldo p k = get_balance $ get_partner_cashflow p k []
|
||||
|
||||
Get total balance of the specified cashbook
|
||||
|
||||
> get_balance :: KonsolidiertesKassabuch -> Saldo
|
||||
> get_balance k
|
||||
> | payments == 0 && credit == 0 = Keine_Geschaeftsbeziehung
|
||||
@ -354,6 +368,8 @@ Aufgabe A.3
|
||||
> payments = calculate_partner_payments k init
|
||||
> credit = calculate_partner_credit k init
|
||||
|
||||
Extract partner cashflow from cashbook
|
||||
|
||||
> get_partner_cashflow :: P_Geschaeftspartner -> KonsolidiertesKassabuch -> [(P_Geschaeftspartner,K_Geschaeftsvorfall)] -> KonsolidiertesKassabuch
|
||||
> get_partner_cashflow p (KKB(x:xs)) res
|
||||
> | length x /= 0 && null xs =
|
||||
@ -364,6 +380,8 @@ Aufgabe A.3
|
||||
> where
|
||||
> (g, v) = x
|
||||
|
||||
Calculate the payments of all partners
|
||||
|
||||
> calculate_partner_payments :: KonsolidiertesKassabuch -> EuroCent -> EuroCent
|
||||
> calculate_partner_payments (KKB []) _ = (EC 0 0)
|
||||
> calculate_partner_payments (KKB(x:xs)) res
|
||||
@ -375,6 +393,8 @@ Aufgabe A.3
|
||||
> where
|
||||
> (g,v) = x
|
||||
|
||||
Calculate the cerdits of all partners
|
||||
|
||||
> calculate_partner_credit :: KonsolidiertesKassabuch -> EuroCent -> EuroCent
|
||||
> calculate_partner_credit (KKB []) _ = (EC 0 0)
|
||||
> calculate_partner_credit (KKB(x:xs)) res
|
||||
|
Reference in New Issue
Block a user