Add pending payment to member index
This commit is contained in:
parent
782983686b
commit
7954efe1b0
|
@ -12,7 +12,7 @@ use App\Payment\PaymentResource;
|
||||||
class MemberView {
|
class MemberView {
|
||||||
public function index(Request $request) {
|
public function index(Request $request) {
|
||||||
return [
|
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'] ]
|
'toolbar' => [ ['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus'] ]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Member extends Model
|
||||||
public $dates = ['joined_at', 'birthday'];
|
public $dates = ['joined_at', 'birthday'];
|
||||||
|
|
||||||
public $casts = [
|
public $casts = [
|
||||||
|
'pending_payment' => 'integer',
|
||||||
'send_newspaper' => 'boolean',
|
'send_newspaper' => 'boolean',
|
||||||
'gender_id' => 'integer',
|
'gender_id' => 'integer',
|
||||||
'way_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')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ class MemberResource extends JsonResource
|
||||||
'is_confirmed' => $this->is_confirmed,
|
'is_confirmed' => $this->is_confirmed,
|
||||||
'children_phone' => $this->children_phone,
|
'children_phone' => $this->children_phone,
|
||||||
'payments' => PaymentResource::collection($this->whenLoaded('payments')),
|
'payments' => PaymentResource::collection($this->whenLoaded('payments')),
|
||||||
|
'pending_payment' => $this->pending_payment ? number_format($this->pending_payment / 100, 2, ',', '.').' €' : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,10 @@ class Payment extends Model
|
||||||
public function status() {
|
public function status() {
|
||||||
return $this->belongsTo(Status::class);
|
return $this->belongsTo(Status::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeWhereNeedsPayment($q) {
|
||||||
|
return $q->whereHas('status', function($q) {
|
||||||
|
return $q->needsPayment();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,4 +24,11 @@ class Status extends Model
|
||||||
public function isAccepted() {
|
public function isAccepted() {
|
||||||
return $this->is_bill === false && $this->is_remember === false;
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
.bool {
|
.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 {
|
&.enabled {
|
||||||
@apply bg-green-800 text-red-100;
|
@apply bg-green-800 text-red-100;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&.btn-sm {
|
&.btn-sm {
|
||||||
@apply text-xs w-6 h-6 px-1 py-1;
|
@apply text-xs px-2 py-1;
|
||||||
svg {
|
svg {
|
||||||
@apply w-3 h-3 text-primary-100 flex-none;
|
@apply w-3 h-3 text-primary-100 flex-none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
<div>Ort</div>
|
<div>Ort</div>
|
||||||
<div>Tags</div>
|
<div>Tags</div>
|
||||||
<div>Beitrag</div>
|
<div>Beitrag</div>
|
||||||
<div>Rechnung</div>
|
|
||||||
<div>Geburtstag</div>
|
<div>Geburtstag</div>
|
||||||
|
<div>Rechnung</div>
|
||||||
|
<div>Ausstand</div>
|
||||||
<div>Eintritt</div>
|
<div>Eintritt</div>
|
||||||
<div></div>
|
<div></div>
|
||||||
</header>
|
</header>
|
||||||
|
@ -30,11 +31,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-text="member.subscription_name"></div>
|
<div v-text="member.subscription_name"></div>
|
||||||
<div>
|
|
||||||
<div class="py-1 rounded-full flex text-xs items-center justify-center leading-none bg-primary-900" v-text="member.bill_kind_name" v-if="member.bill_kind_name"></div>
|
|
||||||
<div class="py-1 rounded-full flex text-xs items-center justify-center leading-none" v-else>Kein</div>
|
|
||||||
</div>
|
|
||||||
<div v-text="`${member.birthday_human}`"></div>
|
<div v-text="`${member.birthday_human}`"></div>
|
||||||
|
<div>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<div class="btn btn-sm label primary" v-text="member.bill_kind_name" v-if="member.bill_kind_name"></div>
|
||||||
|
<div class="text-xs" v-else>Kein</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<div class="btn btn-sm label primary" v-show="member.pending_payment" v-text="member.pending_payment"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div v-text="`${member.joined_at_human}`"></div>
|
<div v-text="`${member.joined_at_human}`"></div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<inertia-link :href="`/member/${member.id}/edit`" class="inline-flex btn btn-warning btn-sm"><sprite src="pencil"></sprite></inertia-link>
|
<inertia-link :href="`/member/${member.id}/edit`" class="inline-flex btn btn-warning btn-sm"><sprite src="pencil"></sprite></inertia-link>
|
||||||
|
|
Loading…
Reference in New Issue