@@ -19,63 +19,63 @@ public function index(Request $request)
1919
2020 $ costTypes = CostType::all ();
2121
22- //calculate all needed number for revenues
22+ // calculate all needed number for revenues
2323 $ revenues = Revenue::whereYear ('payment_date ' , $ year )->get ();
2424 $ revTaxSum = $ revenues ->sum ('tax ' );
2525 $ revNetSum = $ revenues ->sum ('net ' );
2626
27- //calculate vat payments
27+ // calculate vat payments
2828 $ vatNotices = VatNotice::whereYear ('notice_date ' , $ year )->get ();
29- //This is the sum of all received payments from the financial office during the year (months where expenses are higher than revenues)
29+ // This is the sum of all received payments from the financial office during the year (months where expenses are higher than revenues)
3030 $ receivedVatPayments = 0 ;
31- //This is the sum of all payments to the financial office during the year (months where revenues are higher than expenses)
31+ // This is the sum of all payments to the financial office during the year (months where revenues are higher than expenses)
3232 $ alreadyPaidVat = 0 ;
3333 foreach ($ vatNotices as $ notice ) {
34- //for each vat notice, we calculate the difference between received vat (from revenues) and paid vat (from expenses)
34+ // for each vat notice, we calculate the difference between received vat (from revenues) and paid vat (from expenses)
3535 $ noticeBalance = $ notice ->vat_received - $ notice ->vat_paid ;
36- //if the difference is positive, it means we already had to pay the vat to the financial office, so we add it to the alreadyPaidVat
36+ // if the difference is positive, it means we already had to pay the vat to the financial office, so we add it to the alreadyPaidVat
3737 if ($ noticeBalance > 0 ) {
3838 $ alreadyPaidVat += $ noticeBalance ;
39- //if the difference is negative, it means we received money from the financial office, so we add it to the receivedVatPayments
39+ // if the difference is negative, it means we received money from the financial office, so we add it to the receivedVatPayments
4040 } else {
4141 $ receivedVatPayments += -1 * $ noticeBalance ;
4242 }
4343 }
4444 $ revTotal = $ revNetSum + $ revTaxSum + $ receivedVatPayments ;
4545
46- //--------------------------------------------------------------------------------------------------------------
46+ // --------------------------------------------------------------------------------------------------------------
4747
48- //get all travel allowances for the year
48+ // get all travel allowances for the year
4949 $ travelAllowance = TravelAllowance::whereYear ('travel_date ' , $ year )->get ();
5050
51- //get all expenses for the year
51+ // get all expenses for the year
5252 $ costsByCostType = Expense::join ('cost_types ' , 'expenses.cost_type_id ' , '= ' , 'cost_types.id ' )
5353 ->groupBy ('cost_types.id ' )
5454 ->select ('cost_types.id ' , 'cost_types.elster_id ' , 'cost_types.full_name ' , 'cost_types.description ' , DB ::raw ('SUM(expenses.net) * cost_types.ratio as total_net ' ), DB ::raw ('SUM(expenses.tax) * cost_types.ratio as total_tax ' ))
5555 ->whereYear ('payment_date ' , $ year )
5656 ->groupBy ('cost_type_id ' )
5757 ->get ();
5858
59- //tax is calculated from ALL expenses of the year including afa
59+ // tax is calculated from ALL expenses of the year including afa
6060 $ expTaxSum = $ costsByCostType ->sum ('total_tax ' );
6161
62- //remove afa from costs
62+ // remove afa from costs
6363 $ costsByCostType = $ costsByCostType ->reject (function ($ value ) {
6464 return $ value ->id == 6 ;
6565 });
6666
67- //get all depreciations for the year
67+ // get all depreciations for the year
6868 $ expensesWithTypeAfa = Expense::whereHas ('costType ' , function ($ query ) {
6969 $ query ->where ('id ' , 6 );
7070 })->get ();
7171
72- //calculate afa for the year
72+ // calculate afa for the year
7373 $ afaSum = AssetController::calcAfaForYear ($ expensesWithTypeAfa , $ year );
7474
75- //calculate travel allowance for the year
75+ // calculate travel allowance for the year
7676 $ expTravel = $ travelAllowance ->sum ('refund ' );
7777
78- //add afa, tax and travel allowance to costs
78+ // add afa, tax and travel allowance to costs
7979 $ expAfaObject = new Expense ;
8080 $ expAfaObject ->total_net = $ afaSum ;
8181 $ expAfaObject ->full_name = $ costTypes ->where ('id ' , 6 )->first ()->full_name ;
@@ -110,10 +110,10 @@ public function index(Request $request)
110110 $ payedVat ['total_net ' ] += $ alreadyPaidVat ;
111111 }
112112
113- //sort costs by elster_id to use them in the statement view in the correct order
113+ // sort costs by elster_id to use them in the statement view in the correct order
114114 $ costsByCostType = $ costsByCostType ->sortBy ('elster_id ' );
115115
116- //sum of all expenses, including afa of current year
116+ // sum of all expenses, including afa of current year
117117 $ expTotal = $ costsByCostType ->sum ('total_net ' );
118118
119119 return view ('statement ' , [
0 commit comments