-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
8 changed files
with
272 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\POS; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\User; | ||
use App\Models\Checkout\Checkout; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Support\Facades\Auth; | ||
use Inertia\Inertia; | ||
use Illuminate\Http\Request; | ||
use Inertia\Response; | ||
use \Exception; | ||
|
||
class CashRegisterController extends Controller | ||
{ | ||
|
||
public function __invoke(): Response | ||
{ | ||
return Inertia::render('POS/CashRegister/Show', [ | ||
'backToRoute' => 'pos.dashboard', | ||
'wallet' => Auth::guard('machine')->user()->wallet | ||
]); | ||
} | ||
|
||
public function moneyAddForm(): Response { | ||
return Inertia::render('POS/CashRegister/AddMoney', [ | ||
'backToRoute' => 'pos.wallet.show', | ||
]); | ||
} | ||
|
||
public function moneyRemoveForm(): Response { | ||
return Inertia::render('POS/CashRegister/RemoveMoney', [ | ||
'balance' => Auth::guard('machine')->user()->wallet->balance, | ||
'backToRoute' => 'pos.wallet.show', | ||
]); | ||
} | ||
|
||
public function moneyAdd(Request $request): RedirectResponse { | ||
|
||
$deposit = Auth::guard('machine')->user()->wallet->deposit(intval($request->get('amount'))); | ||
|
||
if (!$deposit) return redirect()->back()->withErrors(['amount' => 'Could not add amount to cash register']); | ||
else return redirect()->route('pos.wallet.show'); | ||
} | ||
|
||
public function moneyRemove(Request $request): RedirectResponse { | ||
try { | ||
Auth::guard('machine')->user()->wallet->withdraw(intval($request->get('amount'))); | ||
} catch (Exception $ex) { | ||
return redirect()->back()->withErrors(['amount' => 'Could not withdraw amount to cash register']); | ||
} | ||
return redirect()->route('pos.wallet.show'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<script setup> | ||
import { Head } from "@inertiajs/vue3"; | ||
import POSLayout from "@/Layouts/POSLayout.vue"; | ||
import { useForm } from "laravel-precognition-vue-inertia"; | ||
import SimpleKeyboard from "@/Components/SimpleKeyboard.vue"; | ||
import ConfirmModal from "@/Components/POS/ConfirmModal.vue"; | ||
import {ref} from "vue"; | ||
import Message from "primevue/message"; | ||
defineOptions({ | ||
layout: POSLayout, | ||
}); | ||
const form = useForm('POST', route('pos.wallet.money.add.submit'), { | ||
amount: '' | ||
}); | ||
const amount = ref(''); | ||
const showConfirmModal = ref(false); | ||
const keyboardOptions = { | ||
layout: { | ||
default: ["7 8 9", "4 5 6","1 2 3", "0 {backspace} {enter}"] | ||
}, | ||
display: { | ||
"{backspace}": "Delete", | ||
"{enter}": "Add Amount", | ||
}, | ||
autoUseTouchEvents: false, | ||
theme: "hg-theme-default hg-layout-numeric numeric-theme" | ||
} | ||
const submit = () => { | ||
form.amount = amount; | ||
form.submit(); | ||
showConfirmModal.value = false; | ||
}; | ||
const keyPress = (event) => { | ||
switch (event) { | ||
case "{backspace}": | ||
amount.value = amount.value.slice(0, -1); | ||
break; | ||
case "{enter}": | ||
if(amount.value.length > 0) | ||
showConfirmModal.value = true; | ||
break; | ||
default: | ||
amount.value += event; | ||
break; | ||
} | ||
}; | ||
</script> | ||
|
||
<template> | ||
<Head title="Machine Wallet"/> | ||
<div> | ||
<ConfirmModal | ||
title="Confirm Amount" | ||
:message="'Are you sure you want to add ' + (parseInt(amount || 0) / 100.0).toFixed(2) + ' € to the cash register?'" | ||
:show="showConfirmModal" | ||
@confirm="submit()" | ||
@cancel="showConfirmModal = false" | ||
/> | ||
</div> | ||
<div class="grow flex flex-col gap-3 items-center w-full max-w-lg mx-auto"> | ||
<Message v-if="form.invalid('amount')" class="w-full !my-0" severity="error" :closable="false">{{ form.errors.amount }}</Message> | ||
<div class="text-6xl text-gray-700 my-10"> | ||
{{ (parseInt(amount || 0) / 100.0).toFixed(2) }} € | ||
</div> | ||
<SimpleKeyboard @onKeyPress="keyPress" :options='keyboardOptions'></SimpleKeyboard> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<script setup> | ||
import { Head } from "@inertiajs/vue3"; | ||
import POSLayout from "@/Layouts/POSLayout.vue"; | ||
import { useForm } from "laravel-precognition-vue-inertia"; | ||
import SimpleKeyboard from "@/Components/SimpleKeyboard.vue"; | ||
import ConfirmModal from "@/Components/POS/ConfirmModal.vue"; | ||
import {ref} from "vue"; | ||
import Button from 'primevue/button'; | ||
import Message from "primevue/message"; | ||
defineOptions({ | ||
layout: POSLayout, | ||
}); | ||
const props = defineProps({ | ||
balance: String | ||
}); | ||
const form = useForm('POST', route('pos.wallet.money.remove.submit'), { | ||
amount: '' | ||
}); | ||
const amount = ref(''); | ||
const showConfirmModal = ref(false); | ||
const showWithdrawAllModal = ref(false); | ||
const keyboardOptions = { | ||
layout: { | ||
default: ["7 8 9", "4 5 6","1 2 3", "0 {backspace} {enter}"] | ||
}, | ||
display: { | ||
"{backspace}": "Delete", | ||
"{enter}": "Withdraw Amount", | ||
}, | ||
autoUseTouchEvents: false, | ||
theme: "hg-theme-default hg-layout-numeric numeric-theme" | ||
} | ||
const submit = () => { | ||
form.amount = amount; | ||
form.submit(); | ||
showConfirmModal.value = false; | ||
}; | ||
const withdrawAll = () => { | ||
form.amount = `${props.balance || 0}`; | ||
form.submit(); | ||
showWithdrawAllModal.value = false; | ||
} | ||
const keyPress = (event) => { | ||
switch (event) { | ||
case "{backspace}": | ||
amount.value = amount.value.slice(0, -1); | ||
break; | ||
case "{enter}": | ||
if(amount.value.length > 0) | ||
showConfirmModal.value = true; | ||
break; | ||
default: | ||
amount.value += event; | ||
if (parseInt(amount.value) >= parseInt(props.balance || 0)) | ||
amount.value = props.balance || 0; | ||
break; | ||
} | ||
}; | ||
</script> | ||
|
||
<template> | ||
<Head title="Machine Wallet"/> | ||
<div> | ||
<ConfirmModal | ||
title="Confirm Amount" | ||
:message="'Are you sure you want to withdraw ' + (parseInt(amount || 0) / 100.0).toFixed(2) + ' € from the cash register?'" | ||
:show="showConfirmModal" | ||
@confirm="submit()" | ||
@cancel="showConfirmModal = false;" | ||
/> | ||
<ConfirmModal | ||
title="Confirm Amount" | ||
:message="'Are you sure you want to withdraw ' + (parseInt(props.balance || 0) / 100.0).toFixed(2) + ' € from the cash register?'" | ||
:show="showWithdrawAllModal" | ||
@confirm="withdrawAll()" | ||
@cancel="showWithdrawAllModal = false;" | ||
/> | ||
</div> | ||
<div class="grow flex flex-col gap-3 items-center w-full max-w-lg mx-auto"> | ||
<Message v-if="form.invalid('amount')" class="w-full !my-0" severity="error" :closable="false">{{ form.errors.amount }}</Message> | ||
<div class="text-6xl text-gray-700 my-3"> | ||
{{ (parseInt(amount || 0) / 100.0).toFixed(2) }} € | ||
</div> | ||
<SimpleKeyboard @onKeyPress="keyPress" :options='keyboardOptions'></SimpleKeyboard> | ||
<Button label="Withdraw all" severity="danger" class="w-full py-4" @click="showWithdrawAllModal = true" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script setup> | ||
import { Head } from "@inertiajs/vue3"; | ||
import POSLayout from "@/Layouts/POSLayout.vue"; | ||
import DashboardButton from "@/Components/POS/DashboardButton.vue"; | ||
const props = defineProps({ | ||
wallet: Object | ||
}); | ||
defineOptions({ | ||
layout: POSLayout, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<Head title="Machine Wallet"/> | ||
<div class="grow flex flex-col h-full items-center"> | ||
<h1 class="text-xl text-gray-600">{{ wallet.holder.name }}</h1> | ||
<div class="text-gray-800 text-6xl mt-4 mb-40"> | ||
{{ (parseInt(wallet.balance) / 100.0).toFixed(wallet.decimal_places) }} € | ||
</div> | ||
|
||
<div class="flex flex-row gap-4"> | ||
<DashboardButton label="Add Money" icon="pi pi-plus-circle" :route="route('pos.wallet.money.add')" class="w-48" /> | ||
<DashboardButton label="Remove Money" icon="pi pi-minus-circle" :route="route('pos.wallet.money.remove')" class="w-48" /> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters