Build overview and handling for unpaid incoming.

This commit is contained in:
2025-02-13 11:28:30 +01:00
parent c5a58436e1
commit 447a7d59d5
12 changed files with 284 additions and 7 deletions

View File

@@ -24,6 +24,25 @@ class IncomingController extends Controller
return response()->json(Incoming::whereBetween('issue_date', [$from, $end])->with(['supplier'])->orderBy('issue_date', 'desc')->get());
}
/**
* Display a listing of the resource.
*/
public function payment($from = null, $end = null): JsonResponse
{
Option::updateOrCreate(['name' => 'incoming_payments_from'], ['value' => $from]);
Option::updateOrCreate(['name' => 'incoming_payments_end'], ['value' => $end]);
return response()->json(Incoming::whereBetween('pay_date', [$from, $end])->with(['supplier'])->orderBy('pay_date', 'desc')->get());
}
/**
* Display a listing of the resource that are not paid.
*/
public function open(): JsonResponse
{
return response()->json(Incoming::where('pay_date', '=', null)->orderBy('issue_date', 'desc')->with(['supplier'])->get());
}
/**
* Process an upload file for the resource.
*/

View File

@@ -29,6 +29,26 @@ class IncomingController extends Controller
return view('incoming.index', ['first' => $first, 'last' => $last]);
}
/**
* Display a listing of the resource.
*/
public function payment(): View
{
if (Option::where('name', '=', 'incoming_payments_from')->count() > 0) {
$first = Option::where('name', '=', 'incoming_payments_from')->first()->value;
} else {
$first = Date::now()->firstOfMonth()->format('Y-m-d');
}
if (Option::where('name', '=', 'incoming_payments_end')->count() > 0) {
$last = Option::where('name', '=', 'incoming_payments_end')->first()->value;
} else {
$last = Date::now()->format('Y-m-d');
}
return view('incoming.payment', ['first' => $first, 'last' => $last]);
}
/**
* Show the form for creating a new resource.
*/
@@ -37,6 +57,15 @@ class IncomingController extends Controller
return view('incoming.create');
}
/**
* Show the form for creating a new resource.
*/
public function createPayment(): View
{
return view('incoming.create-payment');
}
/**
* Show the form for uploading a new resource.
*/

View File

@@ -19,8 +19,8 @@ return [
'Generate' => 'Generieren',
'Outgoing invoices' => 'Ausgangsrechnungen',
'Incoming payments' => 'Zahlungseingang',
'Incoming by issue date' => 'Eingang nach Rechnungsdatum',
'Outgoing by pay date' => 'Eingang nach Zahlungsdatum',
'Incoming invoices' => 'Eingangrechnungen',
'Outgoing payments' => 'Zahlungsausgang',
];

View File

@@ -26,5 +26,12 @@ return [
'Select supplier' => 'Lieferant wählen',
'Create incoming' => 'Neue Eingangsrechnung anlegen',
'Incoming invoices' => 'Eingangsrechnungen',
'Incoming payments' => 'Zahlungsausgang',
'Add new payment' => 'Neuen Zahlungsausgang erstellen',
'Add new payment by clicking add' => 'Durch Klick auf "Anlegen" neuen Zahlungsausgang erstellen',
'Create new payment' => 'Neuen Zahlungsausgang anlegen',
'Select invoice' => 'Eingangsrechnung auswählen',
'Select your invoice for payment' => 'Wähle die Rechnung für den Zahlungsasusgang aus'
];

View File

@@ -68,7 +68,7 @@ return [
'Sent menually' => 'Manuell versendet',
'Payment' => 'Zahlung',
'Payment for invoice' => 'Zahlung zur Rechnung',
'Payments' => 'Zahlungen',
'Payments' => 'Zahlungseingang',
'Existing payments' => 'Bestehende Zahlungseingänge',
'Add new payment' => 'Neuen Zahlungseingang erstellen',
'Add new payment by clicking add' => 'Durch Klick auf "Anlegen" neuen Zahlungseingang erstellen',
@@ -105,5 +105,6 @@ return [
'Cash discount sum' => 'Skonto-Summe',
'Cash discount until' => 'Skonto bis',
'Cash discount terms in days' => 'Skontogültigkeit in Tagen',
'No invoices' => 'Keine Rechnungen vorhanden',
];

View File

@@ -29,8 +29,8 @@
<select name="report" id="report" x-model="data.report" class="border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm w-1/4">
<option value="invoice">{{ __('excel.Outgoing invoices') }}</option>
<option value="payment">{{ __('excel.Incoming payments') }}</option>
<option value="incoming">{{ __('excel.Incoming by issue date') }}</option>
<option value="outgoing">{{ __('excel.Outgoing by pay date') }}</option>
<option value="incoming">{{ __('excel.Incoming invoices') }}</option>
<option value="outgoing">{{ __('excel.Outgoing payments') }}</option>
</select>
</div>
</header>

View File

@@ -0,0 +1,77 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('incoming.Create new payment') }}
</h2>
</x-slot>
<div class="py-12" x-data="paymentForm()">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
<!-- Invoice data -->
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg">
<div class="max-w">
<section>
<header>
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('incoming.Select invoice') }}
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __('incoming.Select your invoice for payment') }}
</p>
</header>
<div class="mt-8" x-show="invoices.length == 0">
{{ __('invoice.No invoices') }}
</div>
<summary class="cursor-pointer flex flex-row w-full mt-4">
<div class="w-1/3 font-bold border-b-2">{{ __('invoice.Invoice Number') }}</div>
<div class="w-1/3 font-bold border-b-2">{{ __('supplier.Supplier') }}</div>
<div class="w-1/6 font-bold border-b-2 text-right">{{ __('invoice.Sum') }}</div>
<div class="w-1/6 font-bold border-b-2 text-right">{{ __('common.Created at') }}</div>
</summary>
<template x-for="(invoice, index) in invoices" x-bind="invoices">
<a class="cursor-pointer flex flex-row even:bg-gray-100 odd:bg-white hover:bg-gray-400"
:href="'/incoming/' + invoice.id + '/edit'">
<div class="w-1/3" x-text="invoice.invoice_number"></div>
<div class="w-1/3" x-text="invoice.supplier.name"></div>
<div class="w-1/6 text-right" x-text="invoice.gross + ' €'"></div>
<div class="w-1/6 text-right" x-text="invoice.issue_date"></div>
</a>
</template>
</section>
</div>
</div>
</div>
</div>
</x-app-layout>
<script>
function paymentForm() {
return {
invoices: [],
error: false,
message: '',
init() {
let vm = this;
axios.get('/incoming_open')
.then(function (response) {
vm.invoices = response.data;
})
.catch(function (error) {
vm.error = true;
vm.message = error.response.data.message;
})
}
}
}
</script>

View File

@@ -0,0 +1,133 @@
<x-app-layout>
<x-slot name="header">
<div class="flex flex-row w-full items-center">
<h2 class="grow font-semibold pr-12 text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('incoming.Incoming') }}
</h2>
<a href="{{ route('excel') }}">
<x-excel-icon class="text-gray-800 cursor-pointer right-0"/>
</a>
</div>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg">
<div class="max-w-xl">
<section>
<header>
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('incoming.Add new payment') }}
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("incoming.Add new payment by clicking add") }}
</p>
</header>
<a class="mt-6 inline-block" href="{{ route('incoming.create-payment') }}"><x-primary-button>{{ __('form.Add') }}</x-primary-button></a>
</section>
</div>
</div>
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg">
<div class="max-w" x-data="incomingForm">
<section>
<header>
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('incoming.Existing invoices') }}
</h2>
<div class="flex flex-row space-x-4 items-center mt-4">
<x-input-label for="from" :value="__('invoice.From')"/>
<x-text-input type="date" id="from" name="from" x-model="from" x-on:change="fetchInvoices()"/>
<x-input-label for="end" :value="__('invoice.End')"/>
<x-text-input type="date" id="end" name="end" x-model="end" x-on:change="fetchInvoices()"/>
</div>
</header>
<summary class="cursor-pointer flex flex-row w-full mt-4">
<div class="w-1/3 font-bold border-b-2">{{ __('invoice.Invoice Number') }}</div>
<div class="w-1/3 font-bold border-b-2">{{ __('supplier.Supplier') }}</div>
<div class="w-1/6 font-bold border-b-2 text-right">{{ __('invoice.Sum') }}</div>
<div class="w-1/12 font-bold border-b-2 text-right">{{ __('common.Created at') }}</div>
<div class="w-1/12 font-bold border-b-2 text-right">{{ __('common.Paid at') }}</div>
</summary>
<template x-for="invoice in invoices">
<details class="even:bg-gray-100 odd:bg-white hover:bg-gray-400">
<summary class="cursor-pointer flex flex-row w-full" @click="window.location.href='/incoming/' + invoice.id + '/edit';">
<div class="w-1/3" x-text="invoice.invoice_number"></div>
<div class="w-1/3" x-text="invoice.supplier.name"></div>
<div class="w-1/6 text-right" x-text="invoice.gross + ' €'"></div>
<div class="w-1/12 text-right" x-text="invoice.created"></div>
<div class="w-1/12 text-right" x-text="invoice.paid"></div>
</summary>
</details>
</template>
<div class="w-full border-t-2"></div>
<div class="flex flex-row">
<div class="w-1/2">{{ __('invoice.Net') }}</div>
<div class="w-1/3 text-right" x-text="net + ' €'"></div>
</div>
<div class="flex flex-row">
<div class="w-1/2">{{ __('invoice.Tax') }}</div>
<div class="w-1/3 text-right" x-text="tax + ' €'"></div>
</div>
<div class="flex flex-row">
<div class="w-1/2 font-bold">{{ __('invoice.Sum') }}</div>
<div class="w-1/3 font-bold text-right" x-text="gross + ' €'"></div>
</div>
</section>
</div>
</div>
</div>
</div>
</x-app-layout>
<script>
function incomingForm() {
return {
net: 0,
gross: 0,
tax: 0,
from: "{{ $first }}",
end: "{{ $last }}",
invoices: [],
init() {
this.fetchInvoices();
},
fetchInvoices() {
let vm = this;
axios.get('/incoming-payment/' + this.from + '/' + this.end)
.then(function (response) {
vm.invoices = response.data;
vm.calculateSum();
})
.catch(function (error) {
console.log(error);
})
},
calculateSum() {
this.net = 0;
this.gross = 0;
this.tax = 0;
for (const [key, invoice] of Object.entries(this.invoices)) {
this.net += parseFloat(invoice.net);
this.gross += parseFloat(invoice.gross);
this.tax += parseFloat(invoice.tax)
}
this.net = this.net.toFixed(2)
this.gross = this.gross.toFixed(2);
this.tax = this.tax.toFixed(2);
},
}
}
</script>

View File

@@ -66,6 +66,9 @@
<x-dropdown-link :href="route('incoming.index')">
{{ __('incoming.Incoming invoices') }}
</x-dropdown-link>
<x-dropdown-link :href="route('incoming.payment')">
{{ __('incoming.Incoming payments') }}
</x-dropdown-link>
<x-dropdown-link :href="route('supplier.index')">
{{ __('supplier.Suppliers') }}
</x-dropdown-link>

View File

@@ -17,11 +17,15 @@
{{ __('invoice.Select invoice') }}
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("invoice.Select your invoice for payment") }}
{{ __('invoice.Select your invoice for payment') }}
</p>
</header>
<div class="mt-8">
<div class="mt-8" x-show="invoices.length == 0">
{{ __('invoice.No invoices') }}
</div>
<div class="mt-8" x-show="invoice.length != 0">
<template x-for="(invoice, index) in invoices" x-bind="invoices">
<div class="cursor-pointer grid grid-cols-4 even:bg-gray-100 odd:bg-white"
:class="invoice.id == invoice_id ? 'font-bold' : ''"

View File

@@ -48,6 +48,8 @@ Route::group(['as' => 'api.'], function () {
Route::post('/excel', [ExcelController::class, 'export'])->name('excel.export');
Route::post('/incoming-upload', [IncomingController::class, 'upload'])->name('incoming.upload');
Route::get('/incoming-filter/{start}/{end}', [IncomingController::class, 'index'])->name('incoming.index');
Route::get('/incoming-payment/{start}/{end}', [IncomingController::class, 'payment'])->name('incoming.payment');
Route::get('/incoming_open', [IncomingController::class, 'open'])->name('incoming.open');
Route::put('/incoming/{incoming}', [IncomingController::class, 'update'])->name('incoming.update');
Route::post('/incoming', [IncomingController::class, 'store'])->name('incoming.store');
Route::apiResource('/project', ProjectController::class);

View File

@@ -38,6 +38,8 @@ Route::middleware('auth')->group(function () {
Route::get('/excel', function() { return view('excel'); })->name('excel');
Route::resource('/incoming', IncomingController::class)->only(['index', 'create', 'edit']);
Route::get('/incoming-upload', [IncomingController::class, 'upload'])->name('incoming.upload');
Route::get('/incoming-payment', [IncomingController::class, 'payment'])->name('incoming.payment');
Route::get('/incoming-payment/create', [IncomingController::class, 'createPayment'])->name('incoming.create-payment');
Route::resource('/project', ProjectController::class)->only(['index', 'create', 'show', 'edit']);
Route::resource('/supplier', SupplierController::class)->only(['index', 'create', 'show', 'edit']);
});