소스 검색

Bills pending sign logic fixes

Vijayakrishnan 3 년 전
부모
커밋
3790310014
2개의 변경된 파일55개의 추가작업 그리고 111개의 파일을 삭제
  1. 37 65
      app/Http/Controllers/PracticeManagementController.php
  2. 18 46
      resources/views/app/practice-management/bills.blade.php

+ 37 - 65
app/Http/Controllers/PracticeManagementController.php

@@ -479,41 +479,27 @@ OFFSET {$offset} LIMIT {$perPage}
     {
         $proID = $this->performer()->pro->id;
         $isAdmin = $this->performer()->pro->pro_type === 'ADMIN';
-        $query = Bill::where('is_cancelled', false)->where('bill_service_type', 'NOTE');
+        $query = Bill::where('is_cancelled', false)->whereRaw("(bill_service_type = 'NOTE' OR bill_service_type = 'GENERIC')");
         switch ($filter) {
             case 'not-yet-signed':
                 $query = $query
                     ->where(function ($q) use ($proID, $isAdmin) {
                         $q->where(function ($q2) use ($proID, $isAdmin) {
                             $q2->where('is_signed_by_hcp', false);
-                            if(!$isAdmin) {
+                            if (!$isAdmin) {
                                 $q2->where('hcp_pro_id', $proID);
+                            } else {
+                                $q2->whereNotNull('hcp_pro_id');
                             }
-                        })/*
-                        ->orWhere(function ($q2) use ($proID, $isAdmin) {
-                            $q2->where('is_signed_by_cm', false);
-                            if(!$isAdmin) {
-                                $q2->where('cm_pro_id', $proID);
-                            }
-                        })
-                        ->orWhere(function ($q2) use ($proID, $isAdmin) {
-                            $q2->where('is_signed_by_rme', false);
-                            if(!$isAdmin) {
-                                $q2->where('rme_pro_id', $proID);
-                            }
-                        })
-                        ->orWhere(function ($q2) use ($proID, $isAdmin) {
-                            $q2->where('is_signed_by_rmm', false);
-                            if(!$isAdmin) {
-                                $q2->where('rmm_pro_id', $proID);
-                            }
-                        })
-                        ->orWhere(function ($q2) use ($proID, $isAdmin) {
+                        })->orWhere(function ($q2) use ($proID, $isAdmin) {
                             $q2->where('is_signed_by_generic_pro', false);
-                            if(!$isAdmin) {
+                            if (!$isAdmin) {
                                 $q2->where('generic_pro_id', $proID);
                             }
-                        })*/;
+                            else {
+                                $q2->whereNotNull('generic_pro_id');
+                            }
+                        });
                     });
                 break;
 
@@ -522,56 +508,42 @@ OFFSET {$offset} LIMIT {$perPage}
                     ->where(function ($q) use ($proID, $isAdmin) {
                         $q->where(function ($q2) use ($proID, $isAdmin) {
                             $q2->where('is_signed_by_hcp', true);
-                            if(!$isAdmin) {
+                            if (!$isAdmin) {
                                 $q2->where('hcp_pro_id', $proID);
+                            } else {
+                                $q2->whereNotNull('hcp_pro_id');
                             }
-                        })/*
-                            ->orWhere(function ($q2) use ($proID, $isAdmin) {
-                                $q2->where('is_signed_by_cm', true);
-                                if(!$isAdmin) {
-                                    $q2->where('cm_pro_id', $proID);
-                                }
-                            })
-                            ->orWhere(function ($q2) use ($proID, $isAdmin) {
-                                $q2->where('is_signed_by_rme', true);
-                                if(!$isAdmin) {
-                                    $q2->where('rme_pro_id', $proID);
-                                }
-                            })
-                            ->orWhere(function ($q2) use ($proID, $isAdmin) {
-                                $q2->where('is_signed_by_rmm', true);
-                                if(!$isAdmin) {
-                                    $q2->where('rmm_pro_id', $proID);
-                                }
-                            })
-                            ->orWhere(function ($q2) use ($proID, $isAdmin) {
-                                $q2->where('is_signed_by_generic_pro', true);
-                                if(!$isAdmin) {
-                                    $q2->where('generic_pro_id', $proID);
-                                }
-                            })*/;
+                        })->orWhere(function ($q2) use ($proID, $isAdmin) {
+                            $q2->where('is_signed_by_generic_pro', true);
+                            if (!$isAdmin) {
+                                $q2->where('generic_pro_id', $proID);
+                            }
+                            else {
+                                $q2->whereNotNull('generic_pro_id');
+                            }
+                        });
                     });
                 break;
 
             // more cases can be added as needed
             default:
-                if(!$isAdmin) {
-                    $query = $query
-                        ->where(function ($q) use ($proID) {
-                            $q->where(function ($q2) use ($proID) {
+                $query = $query
+                    ->where(function ($q) use ($proID, $isAdmin) {
+                        $q->where(function ($q2) use ($proID, $isAdmin) {
+                            if (!$isAdmin) {
                                 $q2->where('hcp_pro_id', $proID);
-                            })/*
-                                ->orWhere(function ($q2) use ($proID) {
-                                    $q2->where('cm_pro_id', $proID);
-                                })
-                                ->orWhere(function ($q2) use ($proID) {
-                                    $q2->where('rme_pro_id', $proID);
-                                })
-                                ->orWhere(function ($q2) use ($proID) {
-                                    $q2->where('rmm_pro_id', $proID);
-                                })*/;
+                            } else {
+                                $q2->whereNotNull('hcp_pro_id');
+                            }
+                        })->orWhere(function ($q2) use ($proID, $isAdmin) {
+                            if (!$isAdmin) {
+                                $q2->where('generic_pro_id', $proID);
+                            }
+                            else {
+                                $q2->whereNotNull('generic_pro_id');
+                            }
                         });
-                }
+                    });
                 break;
         }
         $bills = $query->orderBy('created_at', 'desc')->paginate(50);

+ 18 - 46
resources/views/app/practice-management/bills.blade.php

@@ -43,6 +43,8 @@
                         <td class="">
                             @if($bill->hcp)
                                 {{ $bill->hcp->displayName() }}
+                            @elseif($bill->genericPro)
+                                {{ $bill->genericPro->displayName() }}
                             @endif
                         </td>
                         <td class="stag-no-wrap-td">
@@ -64,69 +66,39 @@
                             @endif
                         </td>
                         <td>
-                            <?php
-                            $roles = [];
-                            if($bill->hcp_pro_id === $pro->id) $roles[] = 'HCP';
-                            /*if($bill->cm_pro_id === $pro->id) $roles[] = 'CM';
-                            if($bill->rme_pro_id === $pro->id) $roles[] = 'RME';
-                            if($bill->rmm_pro_id === $pro->id) $roles[] = 'RMM';*/
-                            $roles = implode("<br>", $roles);
-                            ?>
-                            {!! $roles !!}
+                            @if($bill->hcp)
+                                HCP
+                            @elseif($bill->genericPro)
+                                GENERIC
+                            @endif
                         </td>
                         <td>
-                            @if($pro->pro_type === 'ADMIN' || $bill->hcp_pro_id === $pro->id)
+                            @if($bill->hcp_pro_id && ($pro->pro_type === 'ADMIN' || $bill->hcp_pro_id === $pro->id))
                                 @if($bill->has_hcp_been_paid)
                                     <div>
-                                        <span class="text-dark">HCP Received:</span>
-                                        <span class="font-weight-bold text-success ml-2">${{ $bill->hcp_payment_amount }}</span>
+                                        <span class="text-dark">Received:</span>
+                                        <span class="font-weight-bold text-success ml-2">${{ friendly_money($bill->hcp_payment_amount) }}</span>
                                     </div>
                                 @else
                                     <div>
-                                        <span class="text-dark">HCP Expected:</span>
-                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->hcp_expected_payment_amount ? '$' . $bill->hcp_expected_payment_amount : '-' }}</span>
+                                        <span class="text-dark">Expected:</span>
+                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->hcp_expected_payment_amount ? '$' . friendly_money($bill->hcp_expected_payment_amount) : '-' }}</span>
                                     </div>
                                 @endif
                             @endif
-                            {{--@if($pro->pro_type === 'ADMIN' || $bill->cm_pro_id === $pro->id)
-                                @if($bill->has_cm_been_paid)
+                            @if($bill->generic_pro_id && ($pro->pro_type === 'ADMIN' || $bill->generic_pro_id === $pro->id))
+                                @if($bill->has_generic_pro_been_paid)
                                     <div>
-                                        <span class="text-dark">CM Received:</span>
-                                        <span class="font-weight-bold text-success ml-2">${{ $bill->cm_payment_amount }}</span>
+                                        <span class="text-dark">Received:</span>
+                                        <span class="font-weight-bold text-success ml-2">${{ friendly_money($bill->generic_pro_payment_amount) }}</span>
                                     </div>
                                 @else
                                     <div>
-                                        <span class="text-dark">CM Expected:</span>
-                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->cm_expected_payment_amount ? '$' . $bill->cm_expected_payment_amount : '-' }}</span>
+                                        <span class="text-dark">Expected:</span>
+                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->generic_pro_expected_payment_amount ? '$' . friendly_money($bill->generic_pro_expected_payment_amount) : '-' }}</span>
                                     </div>
                                 @endif
                             @endif
-                            @if($pro->pro_type === 'ADMIN' || $bill->rmm_pro_id === $pro->id)
-                                @if($bill->has_rmm_been_paid)
-                                    <div>
-                                        <span class="text-dark">RMM Received:</span>
-                                        <span class="font-weight-bold text-success ml-2">${{ $bill->rmm_payment_amount }}</span>
-                                    </div>
-                                @else
-                                    <div>
-                                        <span class="text-dark">RMM Expected:</span>
-                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->rmm_expected_payment_amount ? '$' . $bill->rmm_expected_payment_amount : '-' }}</span>
-                                    </div>
-                                @endif
-                            @endif
-                            @if($pro->pro_type === 'ADMIN' || $bill->rme_pro_id === $pro->id)
-                                @if($bill->has_rme_been_paid)
-                                    <div>
-                                        <span class="text-dark">RME Received:</span>
-                                        <span class="font-weight-bold text-success ml-2">${{ $bill->rme_payment_amount }}</span>
-                                    </div>
-                                @else
-                                    <div>
-                                        <span class="text-dark">RME Expected:</span>
-                                        <span class="font-weight-bold text-dark ml-2">{{ $bill->rme_expected_payment_amount ? '$' . $bill->rme_expected_payment_amount : '-' }}</span>
-                                    </div>
-                                @endif
-                            @endif--}}
                         </td>
                     </tr>
                 @endforeach