small fixes to contract pdf
parent
b4c610f9be
commit
5ef5e79d7c
|
|
@ -347,7 +347,7 @@ class CarController extends Controller
|
|||
'stammnummer' => ['required', 'unique:cars', 'string', 'size:11', 'regex:/[0-9]{3}[.][0-9]{3}[.][0-9]{3}/i'],
|
||||
'vin' => ['required', 'unique:cars', 'string', 'size:17'],
|
||||
'initial_date' => ['required', 'date_format:"d.m.Y"'],
|
||||
'last_check_date' => ['required', 'date_format:"d.m.Y"'],
|
||||
'last_check_date' => ['date_format:"d.m.Y"'],
|
||||
'colour' => ['nullable', 'max:75'],
|
||||
'car_model_id' => ['required', 'exists:App\Models\CarModel,id'],
|
||||
'kilometers' => ['required', 'max:75'],
|
||||
|
|
@ -438,7 +438,7 @@ class CarController extends Controller
|
|||
'stammnummer' => ['required', 'unique:cars,stammnummer,' . $car->id, 'string', 'size:11', 'regex:/[0-9]{3}[.][0-9]{3}[.][0-9]{3}/i'],
|
||||
'vin' => ['required', 'unique:cars,vin,' . $car->id, 'string', 'size:17'],
|
||||
'initial_date' => ['required', 'date_format:"d.m.Y"'],
|
||||
'last_check_date' => ['required', 'date_format:"d.m.Y"'],
|
||||
'last_check_date' => ['date_format:"d.m.Y"'],
|
||||
'colour' => ['nullable', 'max:75'],
|
||||
'car_model_id' => ['required', 'exists:App\Models\CarModel,id'],
|
||||
'kilometers' => ['required', 'max:75'],
|
||||
|
|
|
|||
|
|
@ -51,6 +51,18 @@ class Contract extends Model
|
|||
return Money::CHF($this->payments()->sum('amount'));
|
||||
}
|
||||
|
||||
public function getPaidInCashAttribute()
|
||||
{
|
||||
|
||||
return Money::CHF($this->payments()->cashOnly()->sum('amount'));
|
||||
}
|
||||
|
||||
public function getPaidInTransactionAttribute()
|
||||
{
|
||||
|
||||
return Money::CHF($this->payments()->transactionOnly()->sum('amount'));
|
||||
}
|
||||
|
||||
public function getLeftToPayAttribute()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,21 @@ class Payment extends Model
|
|||
|
||||
public function getTypeTextAttribute()
|
||||
{
|
||||
return $this->type == PaymentType::Transaction() ? 'Als Banküberweisung erhalten' : 'in bar erhalten';
|
||||
return $this->type == 'Banküberweisung' ? 'via Banküberweisung erhalten' : 'in bar erhalten';
|
||||
}
|
||||
|
||||
public function getDeleteLinkAttribute()
|
||||
{
|
||||
return route('payments.destroy', [$this->contract->id, $this->id]);
|
||||
}
|
||||
|
||||
public function scopeCashOnly($query)
|
||||
{
|
||||
$query->where('type', PaymentType::Cash());
|
||||
}
|
||||
|
||||
public function scopeTransactionOnly($query)
|
||||
{
|
||||
$query->where('type', PaymentType::Transaction());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,10 +118,8 @@ MwSt-Nr: CHE-226.272.050
|
|||
@endif
|
||||
<tr><td> </td></tr>
|
||||
</table>
|
||||
<h3>Fahrzeug</h3>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><h3>Fahrzeug</h3></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="20%">Marke & Modell</td>
|
||||
<td width="30%">{{ $contract->car->name }}</td>
|
||||
|
|
@ -152,8 +150,14 @@ MwSt-Nr: CHE-226.272.050
|
|||
<td><b>{{ $contract->price }}</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Anzahlung</td>
|
||||
<td>{{ $contract->paid }}</td>
|
||||
<td valign="top">Anzahlung</td>
|
||||
@if ($contract->paid_in_cash->getAmount() && $contract->paid_in_transaction->getAmount())
|
||||
<td>{{ $contract->paid_in_cash }} in bar<br>{{ $contract->paid_in_transaction }} via Überweisung</td>
|
||||
@elseif ($contract->paid_in_cash->getAmount())
|
||||
<td>{{ $contract->paid_in_cash }} in bar</td>
|
||||
@elseif ($contract->paid_in_transaction->getAmount())
|
||||
<td>{{ $contract->paid_in_transaction }} via Überweisung</td>
|
||||
@endif
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Restbetrag</td>
|
||||
|
|
@ -208,19 +212,16 @@ Mündliche Vereinbarungen sind ungültig.
|
|||
</tr>
|
||||
</table>
|
||||
<br><br><br><br>
|
||||
@if ($contract->deposit())
|
||||
@if ($contract->payments())
|
||||
<h3>Quittung</h3>
|
||||
<table width="100%" style="padding-top: 5px; border-top: 1px solid black;">
|
||||
@foreach($contract->payments as $payment)
|
||||
<tr>
|
||||
<td width="20%"><b>Quittung</b></td>
|
||||
<td width="30%">Den Betrag von {{ $contract->deposit()->amount->format() }}</td>
|
||||
<td>{{ $contract->deposit()->type_text }}</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td>Datum: </td>
|
||||
<td> </td>
|
||||
<td width="20%">Am {{ $payment->date }}</td>
|
||||
<td width="30%">den Betrag von {{ $payment->amount->format() }}</td>
|
||||
<td>{{ $payment->type_text }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
@endif
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in New Issue