Skip to content
Permalink
Browse files

Allow invoices to be marked as abandonned

  • Loading branch information...
lovett committed Jun 23, 2019
1 parent 06c64d0 commit 347cff414a93600d7b25e7687e19a07e43a032d8
@@ -52,6 +52,7 @@ public function rules()
'sent' => 'nullable|date_format:Y-m-d',
'due' => 'nullable|date_format:Y-m-d',
'paid' => 'nullable|date_format:Y-m-d',
'abandonned' => 'nullable|date_format:Y-m-d',
'receipt' => 'nullable|file|min:1|mimes:txt,pdf,jpeg,png',
];
}
@@ -87,6 +88,30 @@ public function withValidator(Validator $validator)
$this->cookie('TIMEZONE', 'UTC')
)->setTimezone('UTC');
if ($this->input('due')) {
$fields['due'] = Carbon::createFromFormat(
'Y-m-d g:i A',
sprintf('%s 12:00 AM', $this->input('due')),
$this->cookie('TIMEZONE', 'UTC')
)->setTimezone('UTC');
}
if ($this->input('paid')) {
$fields['paid'] = Carbon::createFromFormat(
'Y-m-d g:i A',
sprintf('%s 12:00 AM', $this->input('paid')),
$this->cookie('TIMEZONE', 'UTC')
)->setTimezone('UTC');
}
if ($this->input('abandonned')) {
$fields['abandonned'] = Carbon::createFromFormat(
'Y-m-d g:i A',
sprintf('%s 12:00 AM', $this->input('abandonned')),
$this->cookie('TIMEZONE', 'UTC')
)->setTimezone('UTC');
}
$this->merge($fields);
});
}
@@ -82,6 +82,7 @@ class Invoice extends Model
'end',
'summary',
'receiptType',
'abandonned',
];
/**
@@ -110,6 +111,7 @@ class Invoice extends Model
'sent',
'start',
'updated_at',
'abandonned',
];
/**
@@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Allow invoices to be marked as abandonned.
*/
class AbandonnedInvoice extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('invoices', function (Blueprint $table) {
$table->date('abandonned')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('invoices', function (Blueprint $table) {
$table->dropColumn(['abandonned']);
});
}
}
@@ -73,6 +73,8 @@

@include('partials.formgroup-date', ['name' => 'paid', 'label' => 'Paid', 'autofill' => false, 'pickable' => ['relday', 'month', 'day', 'year']])

@include('partials.formgroup-date', ['name' => 'abandonned', 'label' => 'Abandonned', 'autofill' => false, 'pickable' => ['relday', 'month', 'day', 'year']])

@include('partials.save-button')

{!! Form::close() !!}
@@ -15,7 +15,8 @@
@foreach ($collection as $invoice)
@php($overdueClass = ($invoice->daysUntilDue < 0)? 'table-danger' : '')
@php($upcomingClass = ($invoice->daysUntilDue > 0)? 'table-warning' : '')
<tr class="{{ $overdueClass }} {{ $upcomingClass }}">
@php($abandonnedClass = ($invoice->abandonned)? 'table-dark' : '')
<tr class="{{ $overdueClass }} {{ $upcomingClass }} {{ $abandonnedClass }}">
<td>
<a href="{{ route('invoice.edit', $invoice) }}">
{{ $invoice->name }}
@@ -65,6 +66,11 @@
{{ str_plural('day', $invoice->daysUntilDue) }}
<svg class="icon"><use xlink:href="#icon-clock"></use></svg>
</p>
@elseif ($invoice->abandonned)
abandonned
<p class="small">
{{ TimeHelper::date($invoice->abandonned) }}
</p>
@else
overdue
<p class="small">

0 comments on commit 347cff4

Please sign in to comment.
You can’t perform that action at this time.