show latest payment on contract
parent
97e389bf90
commit
45cb165d20
|
|
@ -104,6 +104,11 @@ class Contract extends Model
|
||||||
return $this->hasMany(Payment::class);
|
return $this->hasMany(Payment::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deposit()
|
||||||
|
{
|
||||||
|
return $this->payments()->oldest('date')->first();
|
||||||
|
}
|
||||||
|
|
||||||
public function contact()
|
public function contact()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Contact::class)->withTrashed();
|
return $this->belongsTo(Contact::class)->withTrashed();
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,11 @@ class Payment extends Model
|
||||||
return $type == PaymentType::Transaction() ? 'Überweisung' : 'Barzahlung';
|
return $type == PaymentType::Transaction() ? 'Überweisung' : 'Barzahlung';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTypeTextAttribute()
|
||||||
|
{
|
||||||
|
return $this->type == PaymentType::Transaction() ? 'Als Überweisung erhalten' : 'in bar erhalten';
|
||||||
|
}
|
||||||
|
|
||||||
public function getDeleteLinkAttribute()
|
public function getDeleteLinkAttribute()
|
||||||
{
|
{
|
||||||
return route('payments.destroy', [$this->contract->id, $this->id]);
|
return route('payments.destroy', [$this->contract->id, $this->id]);
|
||||||
|
|
|
||||||
|
|
@ -208,11 +208,12 @@ Mündliche Vereinbarungen sind ungültig.
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<br><br><br><br>
|
<br><br><br><br>
|
||||||
|
@if ($contract->deposit())
|
||||||
<table width="100%" style="padding-top: 5px; border-top: 1px solid black;">
|
<table width="100%" style="padding-top: 5px; border-top: 1px solid black;">
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20%"><b>Quittung</b></td>
|
<td width="20%"><b>Quittung</b></td>
|
||||||
<td width="30%">Den Betrag von</td>
|
<td width="30%">Den Betrag von {{ $contract->deposit()->amount->format() }}</td>
|
||||||
<td>in bar erhalten</td>
|
<td>{{ $contract->deposit()->type_text }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td> </td></tr>
|
<tr><td> </td></tr>
|
||||||
<tr><td> </td></tr>
|
<tr><td> </td></tr>
|
||||||
|
|
@ -221,5 +222,6 @@ Mündliche Vereinbarungen sind ungültig.
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@endif
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue