close #861 Fixed: Sending an invoice sets the wrong "sent date"

This commit is contained in:
Cüneyt Şentürk 2020-03-25 18:09:52 +03:00
parent d8d27c2ba6
commit ee6041ecd1
4 changed files with 18 additions and 4 deletions

View File

@ -101,4 +101,11 @@ class Bill extends DocumentModel
$this->status = 'draft';
$this->bill_number = $this->getNextBillNumber();
}
public function getReceivedAtAttribute($value)
{
$received = $this->histories()->where('status', 'received')->first();
return ($received) ? $received->created_at : null;
}
}

View File

@ -108,4 +108,11 @@ class Invoice extends DocumentModel
$this->status = 'draft';
$this->invoice_number = $this->getNextInvoiceNumber();
}
public function getSentAtAttribute($value)
{
$sent = $this->histories()->where('status', 'sent')->first();
return ($sent) ? $sent->created_at : null;
}
}

View File

@ -99,16 +99,16 @@
@stack('timeline_body_receive_bill_body_message_end')
<div class="mt-3">
@stack('timeline_body_receive_bill_body_button_sent_start')
@stack('timeline_body_receive_bill_body_button_received_start')
@permission('update-purchases-bills')
<a href="{{ route('bills.received', $bill->id) }}" class="btn btn-danger btn-sm btn-alone">{{ trans('bills.mark_received') }}</a>
@endpermission
@stack('timeline_body_receive_bill_body_button_sent_end')
@stack('timeline_body_receive_bill_body_button_received_end')
</div>
@else
@stack('timeline_body_receive_bill_body_message_start')
<small>{{ trans_choice('general.statuses', 1) . ':' }}</small>
<small>{{ trans('bills.messages.status.receive.received', ['date' => Date::parse($bill->created_at)->format($date_format)]) }}</small>
<small>{{ trans('bills.messages.status.receive.received', ['date' => Date::parse($bill->received_at)->format($date_format)]) }}</small>
@stack('timeline_body_receive_bill_body_message_end')
@endif
@stack('timeline_body_receive_bill_body_end')

View File

@ -129,7 +129,7 @@
@else
@stack('timeline_body_send_invoice_body_message_start')
<small>{{ trans_choice('general.statuses', 1) . ':' }}</small>
<small>{{ trans('invoices.messages.status.send.sent', ['date' => Date::parse($invoice->created_at)->format($date_format)]) }}</small>
<small>{{ trans('invoices.messages.status.send.sent', ['date' => Date::parse($invoice->sent_at)->format($date_format)]) }}</small>
@stack('timeline_body_send_invoice_body_message_end')
@endif
@stack('timeline_body_send_invoice_body_end')