Selaa lähdekoodia

Add page for financial transactions

Vijayakrishnan Krishnan 5 vuotta sitten
vanhempi
commit
c4b672b018

+ 3 - 1
app/Http/Controllers/PracticeManagementController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Models\AppSession;
 use App\Models\Client;
+use App\Models\ProTransaction;
 use Illuminate\Http\Request;
 
 class PracticeManagementController extends Controller
@@ -25,7 +26,8 @@ class PracticeManagementController extends Controller
 
     public function financialTransactions(Request $request)
     {
-        return view('app.practice-management.financial-transactions');
+        $transactions = ProTransaction::where('pro_id', $this->performer()->pro->id)->orderBy('created_at', 'desc')->get();
+        return view('app.practice-management.financial-transactions', compact('transactions'));
     }
 
     public function pendingBillsToSign(Request $request)

+ 4 - 0
app/Models/Bill.php

@@ -7,4 +7,8 @@ namespace App\Models;
 class Bill extends Model
 {
     protected $table = 'bill';
+
+    public function careMonth() {
+        return $this->belongsTo(CareMonth::class);
+    }
 }

+ 8 - 0
app/Models/Pro.php

@@ -18,4 +18,12 @@ class Pro extends Model
     {
         return $this->hasMany(Bill::class, 'hcp_pro_id');
     }
+
+    public function lastPayment() {
+        return ProTransaction
+            ::where('pro_id', $this->id)
+            ->where('plus_or_minus', 'PLUS')
+            ->orderBy('created_at', 'desc')
+            ->first();
+    }
 }

+ 8 - 0
app/Models/ProTransaction.php

@@ -7,4 +7,12 @@ namespace App\Models;
 class ProTransaction extends Model
 {
     protected $table = 'pro_transaction';
+
+    public function client() {
+        return $this->belongsTo(Client::class);
+    }
+
+    public function bill() {
+        return $this->belongsTo(Bill::class);
+    }
 }

+ 45 - 1
resources/views/app/practice-management/financial-transactions.blade.php

@@ -5,5 +5,49 @@
 @endsection
 
 @section('inner-content')
-    CONTENT
+    <div class="mcp-theme-1">
+        <table class="table table-sm">
+            <thead>
+                <tr>
+                    <th>Date</th>
+                    <th>Type</th>
+                    <th>Client</th>
+                    <th>Care Month</th>
+                    <th>Bill/Code</th>
+                    <th>Memo</th>
+                    <th>Amount</th>
+                    <th>Balance</th>
+                </tr>
+            </thead>
+            <tbody>
+                @foreach($transactions as $transaction)
+                    <tr>
+                        <td>
+                            {{ friendly_date_time($transaction->created_at, true) }}
+                        </td>
+                        <td>
+                            {{ $transaction->PLUS === 'PLUS' ? 'Credit' : 'Debit' }}
+                        </td>
+                        <td>
+                            <a href="/patients/view/{{ $transaction->client->uid }}">
+                                <b>{{ implode(", ", [$transaction->client->name_last, $transaction->client->name_first]) }}</b>
+                            </a>
+                        </td>
+                        <td>
+                            <a href="/patients/view/{{ $transaction->client->uid }}/care-months/view/{{ $transaction->bill->careMonth->uid }}">
+                                <b>{{ friendly_month($transaction->bill->careMonth->start_date) }}</b>
+                            </a>
+                        </td>
+                        <td>
+                            <b>{{ $transaction->bill->code }}</b>
+                            <div class="text-secondary text-sm">Created: {{ friendly_date_time($transaction->bill->created_at, true) }}</div>
+                        </td>
+                        <td>{{ $transaction->custom_memo ? $transaction->custom_memo : '-' }}</td>
+                        <td>${{ $transaction->amount }}</td>
+                        <td>${{ $transaction->resulting_balance }}</td>
+                    </tr>
+                @endforeach
+            </tbody>
+        </table>
+    </div>
 @endsection

+ 11 - 6
resources/views/layouts/practice-management.blade.php

@@ -4,7 +4,7 @@
 @section('content')
     <div class="container-fluid">
         <div class="row">
-            <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse px-0">
+            {{--<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse px-0">
                 <div class="sidebar-sticky pt-3">
                     <div>
                         <h4>
@@ -20,20 +20,25 @@
                         <li class="nav-item"><a class="nav-link" href="{{ route('practice-management.hr') }}">HR</a></li>
                     </ul>
                 </div>
-            </nav>
+            </nav>--}}
 
-            <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
+            {{--<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">--}}
+            <main role="main" class="col-12">
                 <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                     <h1 class="h2">@yield('section-title')</h1>
                     <div class="mb-2 mb-md-0">
                         <span class="">
-                            <strong>Current Balance:</strong> $1,024.00
+                            <strong>Current Balance:</strong> ${{ $pro->balance }}
                         </span>&nbsp;
                         <span class="">
-                            <strong>Next payment date:</strong> 30 June, 2020
+                            <strong>Next Payment date:</strong> -
                         </span>&nbsp;
                         <span>
-                            <strong>Last payment:</strong> $489.00 (15 June, 2020)
+                            <?php
+                            $lastPayment = $pro->lastPayment();
+                            ?>
+                            <strong>Last Payment:</strong>
+                                {{ $lastPayment ? '$' . $lastPayment->amount . ' (' . friendly_date_time($lastPayment->created_at, false) . ')' : '-' }}
                         </span>
                     </div>
                 </div>

+ 5 - 5
resources/views/layouts/template.blade.php

@@ -49,12 +49,12 @@
                 <li class="nav-item dropdown">
                     <a class="nav-link dropdown-toggle" href="#" id="practice-management" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="mr-1 fas fa-tasks"></i> Practice Management</a>
                     <div class="dropdown-menu" aria-labelledby="practice-management">
-                        <a class="dropdown-item" href="{{ route('practice-management.dashboard') }}">Dashboard</a>
-                        <a class="dropdown-item" href="/practice-management/rates">Payment Rates</a>
-                        <a class="dropdown-item" href="/practice-management/previous-bills">Previous Bills</a>
+                        {{--<a class="dropdown-item" href="{{ route('practice-management.dashboard') }}">Dashboard</a>--}}
+                        {{--<a class="dropdown-item" href="/practice-management/rates">Payment Rates</a>--}}
+                        {{--<a class="dropdown-item" href="/practice-management/previous-bills">Previous Bills</a>--}}
                         <a class="dropdown-item" href="/practice-management/financial-transactions">Financial Transactions</a>
-                        <a class="dropdown-item" href="/practice-management/pending-bills-to-sign">Pending Bills to Sign</a>
-                        <a class="dropdown-item" href="/practice-management/hr">HR</a>
+                        {{--<a class="dropdown-item" href="/practice-management/pending-bills-to-sign">Pending Bills to Sign</a>--}}
+                        {{--<a class="dropdown-item" href="/practice-management/hr">HR</a>--}}
                     </div>
                 </li>
             </ul>