Build the stuff for payments.

This commit is contained in:
2025-01-16 15:34:10 +01:00
parent f120559e3b
commit dcedbc71c4
17 changed files with 670 additions and 31 deletions

View File

@@ -19,6 +19,11 @@ class InvoiceController extends Controller
return response()->json(Invoice::whereBetween('created_at', [$from, $end])->with('address')->orderBy('created_at', 'desc')->get());
}
public function open(): JsonResponse
{
return response()->json(Invoice::where('status', '=', 'sent')->orderBy('created_at', 'desc')->with(['customer', 'address', 'payments'])->get());
}
/**
* Store a newly created resource in storage.
*/

View File

@@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Invoice;
use App\Models\Payment;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class PaymentController extends Controller
{
/**
* Display a listing of the resource.
*/
public function indexFilter($from = null, $end = null): JsonResponse
{
return response()->json(Payment::whereBetween('payment_date', [$from, $end])->with(['invoice'])->orderBy('payment_date', 'desc')->get());
}
public function index(Invoice $invoice): JsonResponse
{
return response()->json($invoice->payments);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request, Invoice $invoice): JsonResponse
{
$paymentData = $request->validate([
'invoice_id' => 'required|integer|exists:invoices,id',
'paid_amount' => 'required|numeric',
'payment_date' => 'required|date',
'payment_method' => 'nullable|string',
'status' => 'required|string|in:full,partial',
]);
if ($paymentData['status'] == 'full') {
$invoice->update(['status' => 'paid']);
}
return response()->json($invoice->payments()->create($request->all()));
}
/**
* Display the specified resource.
*/
public function show(Payment $payment)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Payment $payment): JsonResponse
{
$paymentData = $request->validate([
'invoice_id' => 'required|integer|exists:invoices,id',
'paid_amount' => 'required|numeric',
'payment_date' => 'required|date',
'payment_method' => 'nullable|string',
'status' => 'required|string|in:full,partial',
]);
$payment->update($paymentData);
if ($payment->invoice->payments->where('status', 'full')->count() === 0) {
$payment->invoice->update(['status' => 'sent']);
}
return response()->json($payment);
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Payment $payment)
{
//
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Http\Controllers;
use App\Models\Payment;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
class PaymentController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(): View
{
return view('payment.index');
}
/**
* Show the form for creating a new resource.
*/
public function create(): View
{
return view('payment.create');
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Payment $payment): View
{
return view('payment.edit', ['payment' => $payment->load('invoice')]);
}
}

View File

@@ -38,8 +38,6 @@ class Invoice extends Model
/**
* Get the invoice state as translated string.
*
* @return string
*/
public function getLocalizedStateAttribute(): string
{
@@ -56,35 +54,57 @@ class Invoice extends Model
/**
* Get the created_at attribute in local time format.
*
* @return string
*/
public function getCreatedAttribute(): string
{
return $this->created_at->format('d.m.Y');
}
/**
* Get the user, that has created the invoice.
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Get the invoice's customer.
*/
public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class);
}
/**
* Get the invoice's address.
*/
public function address(): BelongsTo
{
return $this->belongsTo(Address::class)->withTrashed();
}
/**
* Get the invoice's delivery address.
*/
public function delivery(): BelongsTo
{
return $this->belongsTo(Address::class)->withTrashed();
}
/**
* Get the items (invoice positions) of this invoice.
*/
public function items(): HasMany
{
return $this->hasMany(Invoiceitem::class);
}
/**
* Get the payments for the invoice
*/
public function payments(): HasMany
{
return $this->hasMany(Payment::class);
}
}

View File

@@ -3,9 +3,58 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Date;
class Payment extends Model
{
use SoftDeletes;
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'invoice_id',
'paid_amount',
'status',
'payment_method',
'payment_date',
];
/**
* The attributes that are appended with attribute getters.
*
* @var string[]
*/
protected $appends = [
'date',
'localized_state'
];
/**
* Get the payment state as translated string.
*/
public function getLocalizedStateAttribute(): string
{
return __('invoice.Payment state ' . $this->status);
}
/**
* Get the payment date as localized string.
*/
public function getDateAttribute(): string
{
return Date::createFromFormat('Y-m-d', $this->payment_date)->format('d.m.Y');
}
/**
* Get the invoice the payment belongs to.
*/
public function invoice(): BelongsTo
{
return $this->belongsTo(Invoice::class);
}
}

View File

@@ -18,9 +18,8 @@ return new class extends Migration
$table->decimal('paid_amount', 15, 2);
$table->string('status');
$table->string('payment_method')->nullable();
$table->date('payment_date');
$table->timestamps();
$table->softDeletes();
});
}

View File

@@ -15,5 +15,6 @@ return [
'Dashboard' => 'Dashboard',
'Customers without address' => 'Kunden ohne Rechnungsadresse',
'Invoices not sent' => 'Nicht versendete Rechnungen',
'Invoices not paid' => 'Nicht bezahlte Rechnungen',
];

View File

@@ -51,6 +51,7 @@ return [
'Final sentence' => 'Bitte überweisen Sie den fälligen Rechnungsbetrag in Höhe von :sum bis spätestens :date auf das unten genannte Konto.',
'state_created' => 'Erstellt',
'state_sent' => 'Gesendet',
'state_paid' => 'Bezahlt',
'Mail' => 'E-Mail',
'Send email to your customer with attachments.' => 'E-Mail mit Anlagen an den Kunden versenden.',
'Invoice body' => 'Sehr geehrte Kundin, sehr geehrter Kunde\n\nim Anhang erhalten Sie die Rechnung :invoice_number.\n\nMit freundlichen Grüßen',
@@ -59,5 +60,22 @@ return [
'Manual Mail' => 'Manueller E-Mail Versand',
'Send email to your customer with attachments manually.' => 'E-Mail mit Anlagen über ein externes Programm versenden.',
'Sent menually' => 'Manuell versendet',
'Payment' => 'Zahlung',
'Payment for invoice' => 'Zahlung zur Rechnung',
'Payments' => 'Zahlungen',
'Existing payments' => 'Bestehende Zahlungseingänge',
'Add new payment' => 'Neuen Zahlungseingang erstellen',
'Add new payment by clicking add' => 'Durch Klick auf "Anlegen" neuen Zahlungseingang erstellen',
'Create new payment' => 'Neuen Zahlungseingang erstellen',
'Select invoice' => 'Rechnung wählen',
'Select your invoice for payment' => 'Wähle die Rechnung für den Zahlungseingang aus',
'Enter your payment data' => 'Gib die Daten für den Zahlungseingang ein',
'Payment state full' => 'Vollständiger Zahlungseingang',
'Payment state partial' => 'Teilzahlung',
'Payment status?' => 'Wurde der verbleibende Rechnungsbetrag vollständig bezahlt?',
'Payment date' => 'Zahlungsdatum',
'Payment amount' => 'Zahlungsbetrag',
'Existing payments for invoice' => 'Bestehende Teilzahlungen für Rechnung',
'Paid at' => 'Bezahlt am',
];

View File

@@ -1,6 +1,7 @@
@php
$customers = \App\Models\Customer::doesntHave('address')->get();
$invoices = \App\Models\Invoice::where('status', '=', 'created')->orderBy('created_at')->get();
$created_invoices = \App\Models\Invoice::where('status', '=', 'created')->orderBy('created_at')->get();
$sent_invoices = \App\Models\Invoice::where('status', '=', 'sent')->orderBy('created_at')->get();
@endphp
@@ -12,10 +13,40 @@
</x-slot>
<div class="py-12">
<div class="max-w mx-auto sm:px-6 lg:px-8 grid grid-cols-4 gap-4">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 grid grid-cols-3 gap-4">
<!-- Invoices not paid -->
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg col-span-2">
<div class="p-6 text-gray-900 dark:text-gray-100">
<h2 class="mb-4 text-lg font-medium text-gray-900 dark:text-gray-100">{{ __('dashboard.Invoices not paid') }}</h2>
@foreach($sent_invoices as $invoice)
<a href="{{ route('payment.create') }}"
class="flex max-w even:bg-gray-100 odd:bg-white">
<div class="w-1/4">{{ $invoice->number }}</div>
<div class="w-1/4">{{ $invoice->address->name }}</div>
<div class="w-1/4">{{ $invoice->sum }}</div>
<div class="w-1/4">{{ $invoice->created }}</div>
</a>
@endforeach
</div>
</div>
<!-- Invoices not sent -->
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900 dark:text-gray-100">
<h2 class="mb-4 text-lg font-medium text-gray-900 dark:text-gray-100">{{ __('dashboard.Invoices not sent') }}</h2>
@foreach($created_invoices as $invoice)
<a href="{{ route('invoice.edit', $invoice->id) }}"
class="flex max-w even:bg-gray-100 odd:bg-white">
<div class="w-1/2">{{ $invoice->number }}</div>
<div class="w-1/2">{{ $invoice->address->name }}</div>
</a>
@endforeach
</div>
</div>
<!-- Customers without address -->
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg col-span-2">
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900 dark:text-gray-100">
<h2 class="mb-4 text-lg font-medium text-gray-900 dark:text-gray-100">{{ __('dashboard.Customers without address') }}</h2>
@foreach($customers as $customer)
@@ -28,20 +59,6 @@
</div>
</div>
<!-- Invoices not sent -->
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg col-span-2">
<div class="p-6 text-gray-900 dark:text-gray-100">
<h2 class="mb-4 text-lg font-medium text-gray-900 dark:text-gray-100">{{ __('dashboard.Invoices not sent') }}</h2>
@foreach($invoices as $invoice)
<a href="{{ route('invoice.edit', $invoice->id) }}"
class="flex max-w even:bg-gray-100 odd:bg-white">
<div class="w-1/2">{{ $invoice->number }}</div>
<div class="w-1/2">{{ $invoice->address->name }}</div>
</a>
@endforeach
</div>
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -97,7 +97,7 @@
fetchInvoices() {
let vm = this;
axios.get('/invoice/' + this.from + '/' + this.end)
axios.get('/invoice-filter/' + this.from + '/' + this.end)
.then(function (response) {
vm.invoices = response.data;
vm.calculateSum();

View File

@@ -23,6 +23,10 @@
:active="\Illuminate\Support\Str::startsWith(request()->route()->getName(), 'invoice.')">
{{ __('invoice.Invoices') }}
</x-nav-link>
<x-nav-link :href="route('payment.index')"
:active="\Illuminate\Support\Str::startsWith(request()->route()->getName(), 'payment.')">
{{ __('invoice.Payments') }}
</x-nav-link>
<x-nav-link :href="route('taxrate.index')"
:active="\Illuminate\Support\Str::startsWith(request()->route()->getName(), 'taxrate.')">
{{ __('configuration.Taxrates') }}
@@ -93,7 +97,7 @@
<div :class="{'block': open, 'hidden': ! open}" class="hidden sm:hidden">
<div class="pt-2 pb-3 space-y-1">
<x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
{{ __('common.Dashboard') }}
{{ __('dashboard.Dashboard') }}
</x-responsive-nav-link>
</div>

View File

@@ -0,0 +1,206 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('invoice.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">
{{ __('invoice.Select invoice') }}
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("invoice.Select your invoice for payment") }}
</p>
</header>
<div class="mt-8">
<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' : ''"
x-on:click="invoice_id = invoice.id;getPayments(index);">
<div x-text="invoice.number"></div>
<div x-text="invoice.customer.name"></div>
<div x-text="invoice.customer.email"></div>
<div x-text="invoice.sum + ' €'"></div>
</div>
</template>
</div>
</section>
</div>
</div>
<!-- Existing payments for selected invoice -->
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg" x-show="payments.length != 0">
<div class="max-w">
<section>
<header>
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100 mb-4">
{{ __('invoice.Existing payments for invoice') }}
<span x-text="selected_invoice.number"></span>
</h2>
</header>
<template x-for="(payment, index) in payments">
<div class="w-1/2 grid grid-cols-2 even:bg-gray-100 odd:bg-white">
<div x-text="payment.date"></div>
<div x-text="payment.paid_amount + ' €'"></div>
</div>
</template>
</section>
</div>
</div>
<!-- Payment data -->
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg" x-show="invoice_id != 0">
<div class="max-w">
<section>
<header>
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('invoice.Payment for invoice') }}
<span x-text="selected_invoice.number"></span>
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("invoice.Enter your payment data") }}
</p>
</header>
<form class="mt-6 space-y-6" @submit.prevent="">
<p class="text-red-600 font-bold" x-text="message" x-show="error"></p>
<div>
<x-input-label :value="__('invoice.Payment status?')"/>
<div class="flex flex-row">
<x-input-label class="w-1/4" for="status_full" :value="__('invoice.Payment state full')"/>
<x-text-input id="status_full" name="status" type="radio" class="mt-1"
value="full" required autofocus autocomplete="name"
x-model="payment_data.status"/>
</div>
<div class="flex flex-row">
<x-input-label class="w-1/4" for="status_partial" :value="__('invoice.Payment state partial')"/>
<x-text-input id="status_partial" name="status" type="radio" class="mt-1"
value="partial" required autofocus autocomplete="name"
x-model="payment_data.status"/>
</div>
</div>
<div class="flex flex-row items-center">
<x-input-label class="w-1/4" for="payment_date" :value="__('invoice.Payment date')"/>
<x-text-input id="payment_date" name="payment_date" type="date" class="mt-1"
:value="old('payment_date')" required
x-model="payment_data.payment_date"/>
</div>
<div class="flex flex-row items-center">
<x-input-label class="w-1/4" for="paid_amount" :value="__('invoice.Payment amount')"/>
<x-text-input id="paid_amount" name="paid_amount" type="number" class="mt-1" step="0.01"
:value="old('paid_amount')" required
x-bind:disabled="payment_data.status == 'full'"
x-model="payment_data.paid_amount"/>
</div>
<div class="flex items-center gap-4">
<x-primary-button @click="submit">{{ __('form.Save') }}</x-primary-button>
</div>
</form>
</section>
</div>
</div>
</div>
</div>
</x-app-layout>
<script>
function paymentForm() {
return {
index: 0,
invoice_id: 0,
invoices: [],
payments: [],
selected_invoice: {},
number: '',
sum: 0,
payment_data: {
paid_amount: 0,
status: 'full',
payment_date: "{{ \Illuminate\Support\Facades\Date::now()->addDays(14)->format('Y-m-d') }}"
},
error: false,
message: '',
init() {
let vm = this;
axios.get('/invoice_open')
.then(function(response) {
vm.invoices = response.data;
}).catch(function (error) {
vm.error = true;
vm.message = error.response.data.message;
})
},
getPayments(index) {
this.index = index;
this.selected_invoice = this.invoices[index];
this.number = this.selected_invoice.number;
this.payment_data.invoice_id = this.selected_invoice.id;
let vm = this;
axios.get('/invoice/' + this.invoice_id + '/payment')
.then(function(response) {
vm.payments = response.data;
vm.calculateSum();
}).catch(function(error) {
vm.error = true;
vm.message = error.response.data.message;
})
},
calculateSum() {
this.sum = 0;
for (const [key, payment] of Object.entries(this.payments)) {
this.sum += parseFloat(payment.paid_amount);
}
this.sum = this.sum.toFixed(2)
this.payment_data.paid_amount = (this.selected_invoice.sum - this.sum).toFixed(2);
},
submit() {
let vm = this;
axios.post('/invoice/' + this.invoice_id + '/payment', this.payment_data)
.then(function(response) {
if (vm.payment_data.status === 'full') {
vm.invoice_id = 0;
vm.selected_invoice = {};
vm.invoices.splice(vm.index, 1);
vm.payments = [];
} else {
vm.getPayments(vm.index);
}
}).catch(function (error) {
vm.error = true;
vm.message = error.response.data.message;
})
}
}
}
</script>

View File

@@ -0,0 +1,95 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('invoice.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">
<!-- Payment 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">
{{ __('invoice.Payment for invoice') }}
<span x-text="payment.invoice.number"></span>
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("invoice.Enter your payment data") }}
</p>
</header>
<form class="mt-6 space-y-6" @submit.prevent="">
<p class="text-red-600 font-bold" x-text="message" x-show="error"></p>
<div>
<x-input-label :value="__('invoice.Payment status?')"/>
<div class="flex flex-row">
<x-input-label class="w-1/4" for="status_full" :value="__('invoice.Payment state full')"/>
<x-text-input id="status_full" name="status" type="radio" class="mt-1"
value="full" required autofocus autocomplete="name"
x-model="payment.status"/>
</div>
<div class="flex flex-row">
<x-input-label class="w-1/4" for="status_partial" :value="__('invoice.Payment state partial')"/>
<x-text-input id="status_partial" name="status" type="radio" class="mt-1"
value="partial" required autofocus autocomplete="name"
x-model="payment.status"/>
</div>
</div>
<div class="flex flex-row items-center">
<x-input-label class="w-1/4" for="payment_date" :value="__('invoice.Payment date')"/>
<x-text-input id="payment_date" name="payment_date" type="date" class="mt-1"
:value="old('payment_date')" required
x-model="payment.payment_date"/>
</div>
<div class="flex flex-row items-center">
<x-input-label class="w-1/4" for="paid_amount" :value="__('invoice.Payment amount')"/>
<x-text-input id="paid_amount" name="paid_amount" type="number" class="mt-1" step="0.01"
:value="old('paid_amount')" required
x-bind:disabled="payment.status == 'full'"
x-model="payment.paid_amount"/>
</div>
<div class="flex items-center gap-4">
<x-primary-button @click="submit">{{ __('form.Save') }}</x-primary-button>
</div>
</form>
</section>
</div>
</div>
</div>
</div>
</x-app-layout>
<script>
function paymentForm() {
return {
payment: {!! $payment !!},
error: false,
message: '',
submit() {
let vm = this;
axios.put('/payment/' + this.payment.id, this.payment)
.then(function(response) {
window.location.href = '/payment/';
}).catch(function (error) {
vm.error = true;
vm.message = error.response.data.message;
})
}
}
}
</script>

View File

@@ -0,0 +1,101 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('invoice.Payments') }}
</h2>
</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">
{{ __('invoice.Add new payment') }}
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __("invoice.Add new payment by clicking add") }}
</p>
</header>
<a class="mt-6 inline-block" href="{{ route('payment.create') }}"><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="paymentForm">
<section>
<header>
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('invoice.Existing payments') }}
</h2>
<div class="flex flex-row space-x-4 items-center">
<x-input-label for="from" :value="__('invoice.From')"/>
<x-text-input type="date" id="from" name="from" x-model="from" x-on:change="fetchPayments()"/>
<x-input-label for="end" :value="__('invoice.End')"/>
<x-text-input type="date" id="end" name="end" x-model="end" x-on:change="fetchPayments()"/>
</div>
</header>
<summary class="flex flex-row w-full mt-4">
<div class="w-1/4 font-bold border-b-2">{{ __('invoice.Invoice Number') }}</div>
<div class="w-1/4 font-bold border-b-2">{{ __('invoice.State') }}</div>
<div class="w-1/4 text-right font-bold border-b-2 text-right">{{ __('invoice.Sum') }}</div>
<div class="w-1/4 text-right font-bold border-b-2 text-right">{{ __('invoice.Paid at') }}</div>
</summary>
<template x-for="payment in payments">
<details class="even:bg-gray-100 odd:bg-white">
<summary class="cursor-pointer flex flex-row w-full" @click="window.location.href='/payment/' + payment.id + '/edit';">
<div class="w-1/4" x-text="payment.invoice.number"></div>
<div class="w-1/4" x-text="payment.localized_state"></div>
<div class="w-1/4 text-right" x-text="payment.paid_amount + ' €'"></div>
<div class="w-1/4 text-right" x-text="payment.date"></div>
</summary>
</details>
</template>
</section>
</div>
</div>
</div>
</div>
</x-app-layout>
<script>
function paymentForm() {
return {
from: "{{ \Illuminate\Support\Facades\Date::now()->firstOfMonth()->format('Y-m-d') }}",
end: "{{ \Illuminate\Support\Facades\Date::now()->format('Y-m-d') }}",
payments: [],
sum: 0,
init() {
this.fetchPayments();
},
fetchPayments() {
let vm = this;
axios.get('/payment-filter/' + this.from + '/' + this.end)
.then(function (response) {
vm.payments = response.data;
vm.calculateSum();
})
.catch(function (error) {
console.log(error);
})
},
calculateSum() {
this.sum = 0;
for (const [key, payment] of Object.entries(this.payments)) {
this.sum += parseFloat(payment.sum);
}
this.sum = this.sum.toFixed(2);
}
}
}
</script>

View File

@@ -35,7 +35,7 @@
href="{{ url('/dashboard') }}"
class="rounded-md px-3 py-2 text-black ring-1 ring-transparent transition hover:text-black/70 focus:outline-none focus-visible:ring-[#FF2D20] dark:text-white dark:hover:text-white/80 dark:focus-visible:ring-white"
>
{{ __('common.Dashboard') }}
{{ __('dashboard.Dashboard') }}
</a>
@else
<a

View File

@@ -7,6 +7,7 @@ use App\Http\Controllers\Api\InvoiceController;
use App\Http\Controllers\Api\InvoiceitemController;
use App\Http\Controllers\Api\MailController;
use App\Http\Controllers\Api\OptionController;
use App\Http\Controllers\Api\PaymentController;
use App\Http\Controllers\Api\TaxrateController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
@@ -26,14 +27,18 @@ Route::group(['as' => 'api.'], function () {
Route::apiResource('/customer', CustomerController::class);
Route::apiResource('/customer.address', AddressController::class)->shallow();
Route::apiResource('/taxrate', TaxRateController::class)->except(['show']);
Route::get('/invoice/{start?}/{end?}', [InvoiceController::class, 'index'])->name('invoice.index');
Route::get('/invoice-filter/{start}/{end}', [InvoiceController::class, 'index'])->name('invoice.index');
Route::post('/invoice', [InvoiceController::class, 'store'])->name('invoice.store');
Route::get('/invoice_open', [InvoiceController::class, 'open'])->name('invoice.open');
Route::put('/invoice/{invoice}', [InvoiceController::class, 'update'])->name('invoice.update');
Route::put('/invoice/{invoice}/state', [InvoiceController::class, 'state'])->name('invoice.state');
Route::apiResource('/invoice.item', InvoiceItemController::class)->shallow();
Route::get('/option', [OptionController::class, 'index'])->name('option.index');
Route::post('/option', [OptionController::class, 'store'])->name('option.store');
Route::post('/sendInvoice', [MailController::class, 'sendInvoice'])->name('sendInvoice');
Route::get('/payment-filter/{start}/{end}', [PaymentController::class, 'indexFilter'])->name('payment.index');
Route::apiResource('/invoice.payment', PaymentController::class)->shallow();
});
});

View File

@@ -5,6 +5,7 @@ use App\Http\Controllers\CustomerController;
use App\Http\Controllers\EController;
use App\Http\Controllers\InvoiceController;
use App\Http\Controllers\OptionController;
use App\Http\Controllers\PaymentController;
use App\Http\Controllers\PdfController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\TaxrateController;
@@ -26,11 +27,12 @@ Route::middleware('auth')->group(function () {
Route::resource('/customer', CustomerController::class)->only(['index', 'create', 'edit']);
Route::get('/address/{id}/edit', [AddressController::class, 'edit'])->name('address.edit');
Route::resource('/taxrate', TaxrateController::class)->only(['index', 'create', 'edit']);
Route::resource('/invoice', InvoiceController::class)->only(['index', 'create', 'show', 'edit']);
Route::get('/option', [OptionController::class, 'index'])->name('option.index');
Route::resource('/invoice', InvoiceController::class)->only(['index', 'create', 'show', 'edit']);
Route::get('/invoice/{id}/pdf-download', [PdfController::class, 'downloadInvoice'])->name('invoice.pdfDownload');
Route::get('/invoice/{id}/xml-download', [EController::class, 'downloadInvoice'])->name('invoice.eDownload');
Route::get('/invoice/{id}/mail', [InvoiceController::class, 'mail'])->name('invoice.mail');
Route::resource('/payment', PaymentController::class)->only(['index', 'create', 'edit']);
});
require __DIR__.'/auth.php';