Эх сурвалжийг харах

AccountingItem integration into note, caremonth and supply order contexts

Vijayakrishnan Krishnan 16 цаг өмнө
parent
commit
2456d47faf

+ 19 - 0
app/Models/AccountingItem.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class AccountingItem extends Model
+{
+    protected $table = 'accounting_item';
+
+    public function client() {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
+    public function pro() {
+        return $this->hasOne(Account::class, 'id', 'pro_id');
+    }
+
+}

+ 2 - 0
resources/views/app/patient/care-month/dashboard.blade.php

@@ -1719,6 +1719,8 @@ $leanView = request()->input('popupmode') && request()->input('fromNoteUid');
                     </div>
                     <hr class="m-negator mt-4 mb-3">
                     @include('app.patient.care-month.partials.admin-settings')
+                    <hr class="m-negator mt-4 mb-3">
+                    @include('app.patient.partials.accounting-items', ['entityType' => 'CareMonth', 'entityUid' => $careMonth->uid])
                 @endif
 
                 {{-- generic bills --}}{{--

+ 8 - 0
resources/views/app/patient/note/dashboard.blade.php

@@ -1365,6 +1365,14 @@ use App\Models\Handout;
 
                 @endif
 
+                @if($pro->pro_type === 'ADMIN')
+
+                    <div class="p-3">
+                        @include('app.patient.partials.accounting-items', ['entityType' => 'Note', 'entityUid' => $note->uid])
+                    </div>
+
+                @endif
+
                 {{-- addendums --}}
                 @if($note->is_signed_by_hcp)
                 <div class="border-top p-3" data-non-segment-section="Addendums">

+ 111 - 0
resources/views/app/patient/partials/accounting-items.blade.php

@@ -0,0 +1,111 @@
+@if($pro->pro_type === 'ADMIN')
+
+    <?php
+    $uidParamName = [
+        'Note' => 'noteUid',
+        'CareMonth' => 'careMonthUid',
+        'Bill' => 'billUid',
+        'SupplyOrder' => 'supplyOrderUid',
+    ];
+    $records = \App\Models\AccountingItem
+        ::where('entity_type', $entityType)
+        ->where('entity_uid', $entityUid)
+        ->orderBy('last_updated_at', 'DESC')
+        ->get();
+    ?>
+
+    <div class="">
+        <div class="d-flex align-items-center mb-2">
+            <p class="font-weight-bold m-0">Accounting Items</p>
+            <span class="mx-2 text-secondary">|</span>
+            @include('app.patient.partials.create-edit-accounting-item', ['entityType' => $entityType, 'entityUid' => $entityUid])
+        </div>
+
+        <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
+            <thead class="bg-light">
+            <tr>
+                @if(@$showPro)
+                    <th class="border-bottom-0">Pro</th>
+                @endif
+                @if(@$showClient)
+                    <th class="border-bottom-0">Client</th>
+                @endif
+                <th class="border-bottom-0 pl-2">Type</th>
+                <th class="border-bottom-0">Expected</th>
+                <th class="border-bottom-0">Actual</th>
+                <th class="border-bottom-0">Open</th>
+                <th class="border-bottom-0">Memo</th>
+                <th class="border-bottom-0">Updated</th>
+                <th class="border-bottom-0">Active</th>
+                <th class="border-bottom-0">&nbsp;</th>
+            </tr>
+            </thead>
+            <tbody>
+                @foreach($records as $record)
+                    <tr>
+                        @if(@$showPro)
+                            <td class="border-bottom-0">
+                                {{$record->pro ? $record->pro->displayName() : '-'}}
+                            </td>
+                        @endif
+                        @if(@$showClient)
+                            <td class="border-bottom-0">
+                                {{$record->client ? $record->client->displayName() : '-'}}
+                            </td>
+                        @endif
+                        <td class="border-bottom-0 pl-2">
+                            {{$record->positive_or_negative == 0 ? 'Revenue' : 'Cost'}}
+                        </td>
+                        <td class="border-bottom-0">
+                            {{$record->expected_value ? '$' . $record->expected_value : '-'}}
+                        </td>
+                        <td class="border-bottom-0">
+                            {{$record->received_value ? '$' . $record->received_value : '-'}}
+                        </td>
+                        <td class="border-bottom-0">
+                            {{$record->is_open ? 'Yes' : 'No'}}
+                        </td>
+                        <td class="border-bottom-0">
+                            {{$record->memo ? $record->memo : ''}}
+                        </td>
+                        <td class="border-bottom-0">
+                            {{friendly_date_time($record->last_updated_at)}}
+                        </td>
+                        <td class="border-bottom-0">
+                            {{$record->is_active ? 'Yes' : 'No'}}
+                        </td>
+                        <td class="border-bottom-0">
+                            @include('app.patient.partials.create-edit-accounting-item', ['entityType' => $entityType, 'entityUid' => $entityUid, 'record' => $record])
+                            <span class="mx-2 text-secondary">|</span>
+                            @if($record->is_active)
+                                <div moe relative="" class="ml-2">
+                                    <a start show class="py-0 mb-3">Deactivate</a>
+                                    <form url="/api/accountingItem/deactivate" class="mcp-theme-1" right="">
+                                        <input type="hidden" name="uid" value="{{$record->uid}}">
+                                        <p>Deactivate this record?</p>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <div moe relative="" class="ml-2">
+                                    <a start show class="py-0 mb-3">Reactivate</a>
+                                    <form url="/api/accountingItem/reactivate" class="mcp-theme-1" right="">
+                                        <input type="hidden" name="uid" value="{{$record->uid}}">
+                                        <p>Reactivate this record?</p>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+                        </td>
+                    </tr>
+                @endforeach
+            </tbody>
+        </table>
+    </div>
+@endif

+ 37 - 0
resources/views/app/patient/partials/create-edit-accounting-item.blade.php

@@ -0,0 +1,37 @@
+<?php
+$ep = !@$record ? "/api/accountingItem/createFor{$entityType}" : '/api/accountingItem/update';
+?>
+<div moe relative>
+    <a href="" start show class="">{{!@$record ? 'Create' : 'Update'}}</a>
+    <form url="{{$ep}}" class="mcp-theme-1" {{!@$record ? '' : 'right'}}>
+        @if(!@$record)
+            <input type="hidden" name="{{$uidParamName[$entityType]}}" value="{{$entityUid}}" />
+        @else
+            <input type="hidden" name="uid" value="{{@$record->uid}}" />
+        @endif
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Expected:</label>
+            <input type="number" name="expectedValue" value="{{@$record->expected_value}}" class="form-control form-control-sm">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Received/Actual:</label>
+            <input type="number" name="receivedValue" value="{{@$record->received_value}}" class="form-control form-control-sm">
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Is Open?</label>
+            <select name="isOpen" class="form-control form-control-sm">
+                <option value=""> --select-- </option>
+                <option value="1" {{@$record->is_open == 1 ? 'selected' : ''}}>Yes</option>
+                <option value="0" {{@$record->is_open == 0 ? 'selected' : ''}}>No</option>
+            </select>
+        </div>
+        <div class="mb-2">
+            <label class="text-sm text-secondary mb-1">Memo:</label>
+            <textarea name="memo" class="form-control form-control-sm">{{@$record->memo}}</textarea>
+        </div>
+        <div class="mb-2">
+            <button class="btn btn-sm btn-primary" submit>Submit</button>
+            <button class="btn btn-sm btn-default border" close>Close</button>
+        </div>
+    </form>
+</div>

+ 5 - 2
resources/views/app/patient/supply-orders.blade.php

@@ -172,7 +172,7 @@
                 </table>
             </div>
             @if($supplyOrder)
-                <div class="min-width-500px ml-2 border align-self-stretch p-3">
+                <div class="min-width-700px ml-2 border align-self-stretch p-3">
                     <div class="d-flex align-items-center">
                         <h3 class="font-size-16 m-0">{{$supplyOrder->product->title}}</h3>
                         <a class="ml-auto" href="/patients/view/{{$patient->uid}}/supply-orders{{request()->input('filter') ? '?filter=' . request()->input('filter') : ''}}">
@@ -532,9 +532,12 @@
                         @endif
                     @endif
 
-                    <hr class="m-neg-4">
+                    <hr class="m-neg-3">
                     @include('app.generic-bills.inline', ['patient' => $patient, 'entityType' => 'SupplyOrder', 'entityUid' => $supplyOrder->uid])
 
+                    <hr class="m-neg-3">
+                    @include('app.patient.partials.accounting-items', ['entityType' => 'SupplyOrder', 'entityUid' => $supplyOrder->uid])
+
                 </div>
             @endif
         </div>