121 lines
5.6 KiB
PHP
121 lines
5.6 KiB
PHP
<x-app-layout>
|
|
<x-slot name="header">
|
|
<div class="flex flex-row w-full">
|
|
<h2 class="grow font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
|
|
{{ __('invoice.Payments') }}
|
|
</h2>
|
|
<a href="{{ route('excel') }}" class="relative flex flex-row">
|
|
<x-excel-icon class="text-gray-800 cursor-pointer"/>
|
|
</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">
|
|
{{ __('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 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="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>
|
|
|
|
<div class="w-full border-t-2"></div>
|
|
|
|
<div class="w-1/2 grid grid-cols-2">
|
|
<div>{{ __('invoice.Net') }}</div>
|
|
<div class="text-right" x-text="(sum - tax).toFixed(2) + ' €'"></div>
|
|
<div>{{ __('invoice.Tax') }}</div>
|
|
<div class="text-right" x-text="tax + ' €'"></div>
|
|
<div class="font-bold">{{ __('invoice.Sum') }}</div>
|
|
<div class="font-bold text-right" x-text="sum + ' €'"></div>
|
|
</div>
|
|
|
|
</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,
|
|
tax: 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;
|
|
this.tax = 0;
|
|
for (const [key, payment] of Object.entries(this.payments)) {
|
|
this.sum += parseFloat(payment.paid_amount);
|
|
this.tax += payment.invoice.tax * payment.paid_amount / payment.invoice.sum;
|
|
}
|
|
this.sum = this.sum.toFixed(2);
|
|
this.tax = this.tax.toFixed(2);
|
|
}
|
|
}
|
|
}
|
|
</script>
|