Forráskód Böngészése

Invoice-center - customer portal UI - transactions

Vijayakrishnan 3 éve
szülő
commit
aa86568025

+ 4 - 0
app/Models/Customer.php

@@ -21,4 +21,8 @@ class Customer extends Model
     public function invoices() {
         return $this->hasMany(Invoice::class, 'customer_id', 'id')->orderBy('created_at', 'DESC');
     }
+
+    public function customerTransactions() {
+        return $this->hasMany(CustomerTransaction::class, 'customer_id', 'id')->orderBy('created_at', 'ASC');
+    }
 }

+ 35 - 1
resources/views/app/invoice-center/ic-customer-portal.blade.php

@@ -62,7 +62,41 @@
                     </tbody>
                 </table>
             @else
-                <div class="text-secondary">No invoices yet!</div>
+                <div class="text-secondary mb-3">No invoices yet!</div>
+            @endif
+            <div class="mb-3 font-weight-bold">Transactions</div>
+            @if(count($customer->customerTransactions))
+                <table class="table table-sm table-bordered">
+                    <thead>
+                    <tr>
+                        <th class="border-bottom-0 text-secondary bg-light">Date</th>
+                        <th class="border-bottom-0 text-secondary bg-light">Type</th>
+                        <th class="border-bottom-0 text-secondary bg-light">Remarks</th>
+                        <th class="border-bottom-0 text-secondary bg-light">Amount</th>
+                        <th class="border-bottom-0 text-secondary bg-light">Starting Balance</th>
+                        <th class="border-bottom-0 text-secondary bg-light">Ending Balance</th>
+                    </tr>
+                    </thead>
+                    <tbody class="font-weight-normal">
+                    <?php
+                    $totalAmount = 0;
+                    $totalPaid = 0;
+                    $totalBalance = 0;
+                    ?>
+                    @foreach($customer->customerTransactions as $transaction)
+                        <tr>
+                            <td>{{friendly_date($transaction->created_at)}}</td>
+                            <td class="{{$transaction->plus_or_minus === 'PLUS' ? 'text-success' : 'text-warning-dark'}}">{{$transaction->plus_or_minus === 'PLUS' ? 'Credit' : 'Debit'}}</td>
+                            <td>{{ sanitize_state_name($transaction->reason_type)}}</td>
+                            <td class="{{$transaction->plus_or_minus === 'PLUS' ? 'text-success' : 'text-warning-dark'}}">${{!is_null($transaction->amount) ? $transaction->amount : 0}}</td>
+                            <td>${{!is_null($transaction->starting_balance) ? $transaction->starting_balance : 0}}</td>
+                            <td>${{!is_null($transaction->resulting_balance) ? $transaction->resulting_balance : 0}}</td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            @else
+                <div class="text-secondary">No transactions yet!</div>
             @endif
         </div>
         <div class="col-md-4 border-left">