diff --git a/app/Domain/Checkout/Models/Checkout/Transitions/ToFinished.php b/app/Domain/Checkout/Models/Checkout/Transitions/ToFinished.php index 40e10e8..b126528 100644 --- a/app/Domain/Checkout/Models/Checkout/Transitions/ToFinished.php +++ b/app/Domain/Checkout/Models/Checkout/Transitions/ToFinished.php @@ -31,6 +31,14 @@ public function handle() } }); + // if cash deposit money to cash register + if ($this->checkout->payment_method === 'cash') { + $this->checkout->machine->wallet->deposit($this->checkout->total); + } + + // add money to user wallet to zero out his balance + $this->checkout->user->wallet->deposit($this->checkout->total); + activity() ->performedOn($this->checkout) ->causedBy(auth('machine-user')->user()) diff --git a/app/Http/Controllers/POS/AttendeeController.php b/app/Http/Controllers/POS/AttendeeController.php index 23c241b..1387238 100644 --- a/app/Http/Controllers/POS/AttendeeController.php +++ b/app/Http/Controllers/POS/AttendeeController.php @@ -4,6 +4,7 @@ use App\Domain\Checkout\Models\Checkout\Checkout; use App\Http\Controllers\Controller; +use App\Models\Fursuit\States\Rejected; use App\Models\User; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; @@ -30,7 +31,11 @@ public function lookupSubmit(Request $request): RedirectResponse public function show(string $attendeeId, Request $request): Response { $user = User::where('attendee_id', $attendeeId)->first(); - $badges = $user->badges()->with('fursuit.species')->get(); + $badges = $user->badges() + ->whereHas('fursuit', function ($query) { + $query->where('status','!=',Rejected::$name); + }) + ->with('fursuit.species')->get(); return Inertia::render('POS/Attendee/Show', [ 'attendee' => $user->load('wallet'), diff --git a/app/Http/Controllers/POS/CheckoutController.php b/app/Http/Controllers/POS/CheckoutController.php index 34e3f8b..374ca3b 100644 --- a/app/Http/Controllers/POS/CheckoutController.php +++ b/app/Http/Controllers/POS/CheckoutController.php @@ -64,10 +64,21 @@ public function store(Request $request) $data['badge_ids'] = Badge::whereHas('fursuit.user', function ($query) use ($data) { $query->where('id', $data['user_id']); })->where('status', 'unpaid')->pluck('id')->toArray(); + } else { + + $data['badge_ids'] = Badge::whereHas('fursuit.user', function ($query) use ($data) { + $query->where('id', $data['user_id']); + })->where('status', 'unpaid') + ->whereIn('id', $data['badge_ids']) + ->pluck('id')->toArray(); + } + + $badges = Badge::whereIn('id', $data['badge_ids'])->get(); + if ($badges->isEmpty()) { + return redirect()->back()->with(['error' => 'No badges found']); } - $checkout = DB::transaction(function () use ($data) { - $badges = Badge::whereIn('id', $data['badge_ids'])->get(); + $checkout = DB::transaction(function () use ($badges, $data) { $total = $badges->sum('total'); $subtotal = $badges->sum('subtotal'); $tax = $badges->sum('tax'); diff --git a/resources/js/Components/POS/Attendee/BadgesTable.vue b/resources/js/Components/POS/Attendee/BadgesTable.vue index 916ce2a..34125aa 100644 --- a/resources/js/Components/POS/Attendee/BadgesTable.vue +++ b/resources/js/Components/POS/Attendee/BadgesTable.vue @@ -46,6 +46,7 @@ function changeHandout(badgeId, undo) { <Column selectionMode="multiple" headerStyle="width: 3rem"></Column> <Column field="custom_id" header="ID"></Column> <Column field="fursuit.name" header="Fursuit"></Column> + <Column field="fursuit.status" header="Fursuit Status"></Column> <Column field="printed_at" header="Print"> <template #body="slotProps"> {{ (slotProps.data.printed_at) ? dayjs(slotProps.data.printed_at).format('DD.MM.YY') : '-' }} diff --git a/resources/js/Components/POS/Attendee/FursuitTable.vue b/resources/js/Components/POS/Attendee/FursuitTable.vue index 2603f0d..fabee3b 100644 --- a/resources/js/Components/POS/Attendee/FursuitTable.vue +++ b/resources/js/Components/POS/Attendee/FursuitTable.vue @@ -20,6 +20,7 @@ defineProps({ </template> </Column> <Column field="name" header="Name" /> + <Column field="status" header="Status" /> <Column field="species.name" header="Species" /> <Column field="catch_em_all" header="Catch em all"> <template #body="slotProps"> diff --git a/resources/js/Pages/POS/Checkout/Show.vue b/resources/js/Pages/POS/Checkout/Show.vue index 3839547..2dd4758 100644 --- a/resources/js/Pages/POS/Checkout/Show.vue +++ b/resources/js/Pages/POS/Checkout/Show.vue @@ -223,8 +223,8 @@ function receiptForm(via) { </div> <Message :closable="false" :severity="getSeverityFromTransactionStatus(transaction.status)" v-if="transaction">{{ transaction.status }}</Message> <div class="flex justify-between gap-4 shrink"> - <Button :disabled="transaction && transaction.status === 'SUCCESSFUL'" severity="contrast" label="Cancel Transaction" @click="cancel" class="grow"></Button> - <Button :disabled="transaction && transaction.status !== 'FAILED'" :loading="startCardPaymentForm.processing" label="Pay With Card" @click="startCardPayment" class="grow"></Button> + <Button :disabled="checkout.status === 'FINISHED' || (transaction && (transaction.status === 'SUCCESSFUL' || transaction.status === 'PENDING'))" severity="contrast" label="Cancel Transaction" @click="cancel" class="grow"></Button> + <Button :disabled="checkout.status === 'FINISHED' || (transaction && (transaction.status === 'SUCCESSFUL' || transaction.status === 'PENDING'))" :loading="startCardPaymentForm.processing" label="Pay With Card" @click="startCardPayment" class="grow"></Button> </div> </div> </div>