diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index b88fe68f..ca1529bb 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -12,7 +12,7 @@ use App\Payment\PaymentResource; class MemberView { public function index(Request $request) { return [ - 'data' => MemberResource::collection(Member::select('*')->search($request->query('search', null))->with('billKind')->withSubscriptionName()->withIsConfirmed()->orderByRaw('lastname, firstname')->paginate(15)), + 'data' => MemberResource::collection(Member::select('*')->search($request->query('search', null))->with('billKind')->withSubscriptionName()->withIsConfirmed()->withPendingPayment()->orderByRaw('lastname, firstname')->paginate(15)), 'toolbar' => [ ['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus'] ] ]; } diff --git a/app/Member/Member.php b/app/Member/Member.php index 1a69b1bb..78daf741 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -25,6 +25,7 @@ class Member extends Model public $dates = ['joined_at', 'birthday']; public $casts = [ + 'pending_payment' => 'integer', 'send_newspaper' => 'boolean', 'gender_id' => 'integer', 'way_id' => 'integer', @@ -150,4 +151,13 @@ class Member extends Model ]); } + public function scopeWithPendingPayment($q) { + return $q->addSelect([ + 'pending_payment' => Payment::selectRaw('SUM(subscriptions.amount)') + ->whereColumn('payments.member_id', 'members.id') + ->whereNeedsPayment() + ->join('subscriptions', 'subscriptions.id', 'payments.subscription_id') + ]); + } + } diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 8dac4296..03fa409d 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -49,6 +49,7 @@ class MemberResource extends JsonResource 'is_confirmed' => $this->is_confirmed, 'children_phone' => $this->children_phone, 'payments' => PaymentResource::collection($this->whenLoaded('payments')), + 'pending_payment' => $this->pending_payment ? number_format($this->pending_payment / 100, 2, ',', '.').' €' : null, ]; } } diff --git a/app/Payment/Payment.php b/app/Payment/Payment.php index d58604c3..3b27ae88 100644 --- a/app/Payment/Payment.php +++ b/app/Payment/Payment.php @@ -25,4 +25,10 @@ class Payment extends Model public function status() { return $this->belongsTo(Status::class); } + + public function scopeWhereNeedsPayment($q) { + return $q->whereHas('status', function($q) { + return $q->needsPayment(); + }); + } } diff --git a/app/Payment/Status.php b/app/Payment/Status.php index 195ef917..c017331e 100644 --- a/app/Payment/Status.php +++ b/app/Payment/Status.php @@ -24,4 +24,11 @@ class Status extends Model public function isAccepted() { return $this->is_bill === false && $this->is_remember === false; } + + // ---------------------------------- Scopes ----------------------------------- + public function scopeNeedsPayment($q) { + return $q->where(function($q) { + $q->where('is_bill', true)->orWhere('is_remember', true); + }); + } } diff --git a/resources/css/bool.css b/resources/css/bool.css index 0ca6b414..71c1d0e4 100644 --- a/resources/css/bool.css +++ b/resources/css/bool.css @@ -1,5 +1,8 @@ .bool { - @apply rounded-full text-xs w-5 h-5 flex items-center justify-center leading-none; + @apply rounded-full w-5 h-5 text-xs flex items-center justify-center leading-none; + &.bool-inline { + @apply w-auto; + } &.enabled { @apply bg-green-800 text-red-100; } diff --git a/resources/css/buttons.css b/resources/css/buttons.css index 56151021..2f412dd7 100644 --- a/resources/css/buttons.css +++ b/resources/css/buttons.css @@ -5,7 +5,7 @@ } &.btn-sm { - @apply text-xs w-6 h-6 px-1 py-1; + @apply text-xs px-2 py-1; svg { @apply w-3 h-3 text-primary-100 flex-none; } diff --git a/resources/js/views/member/Index.vue b/resources/js/views/member/Index.vue index 3f6300fb..3cb57ef3 100644 --- a/resources/js/views/member/Index.vue +++ b/resources/js/views/member/Index.vue @@ -10,8 +10,9 @@
Ort
Tags
Beitrag
-
Rechnung
Geburtstag
+
Rechnung
+
Ausstand
Eintritt
@@ -30,11 +31,18 @@
-
-
-
Kein
-
+
+
+
+
Kein
+
+
+
+
+
+
+