Skip to content

Commit

Permalink
Rework estimate listing and data model
Browse files Browse the repository at this point in the history
Add field for statement of work. Take changelog-style presentation of
dates out of list view because it answers questions that aren't being
asked.
  • Loading branch information
lovett committed Jan 27, 2019
1 parent a999936 commit 7cdc799
Show file tree
Hide file tree
Showing 8 changed files with 481 additions and 121 deletions.
2 changes: 1 addition & 1 deletion app/Estimate.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static function listing(Builder $builder)

$builder->selectRaw('clients.name as clientName');
$builder->selectRaw('clients.id as clientId');
$builder->orderByRaw('LOWER(estimates.name) ASC');
$builder->orderByRaw('created_at DESC');
return $builder;
}

Expand Down
25 changes: 23 additions & 2 deletions app/Helpers/CurrencyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,36 @@ class CurrencyHelper
/**
* Format a monetary value with cents
*
* @param float $value The value to format.
* @param float|null $value The value to format.
*
* @return string
*/
public static function money(float $value)
public static function money(?float $value)
{
if ($value === null) {
return '';
}

return money_format('%.2n', $value);
}

/**
* Format a monetary value without cents
*
* @param float|null $value The value to format.
*
* @return string
*/
public static function dollars(?float $value)
{
if ($value === null) {
return '';
}

return money_format('%.0n', $value);
}


/**
* Calculate an hourly rate
*
Expand Down
12 changes: 8 additions & 4 deletions app/Helpers/TimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function minutesToHours(int $minutes, int $precision = 2)
*
* @return string
*/
public static function readableShortDate(Carbon $value = null)
public static function readableShortDate(?Carbon $value = null)
{
if ($value === null) {
return '';
Expand Down Expand Up @@ -120,7 +120,7 @@ public static function shiftTimezone(Carbon $value, string $timezone = null)
*
* @return string
*/
public static function longDate(Carbon $value = null)
public static function longDate(?Carbon $value = null)
{
if ($value === null) {
return '';
Expand All @@ -136,7 +136,7 @@ public static function longDate(Carbon $value = null)
*
* @return string
*/
public static function time(Carbon $value = null)
public static function time(?Carbon $value = null)
{
if ($value === null) {
return '';
Expand Down Expand Up @@ -181,8 +181,12 @@ public static function roundToNearestMultiple(int $value, int $multiple)
*
* @return string
*/
public static function daysAgo(Carbon $value = null)
public static function daysAgo(?Carbon $value = null)
{
if ($value === null) {
return '';
}

return self::shiftTimezone($value)->diffForHumans();
}
}
1 change: 1 addition & 0 deletions app/Http/Requests/EstimateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function rules()
'fee' => 'nullable|numeric',
'hours' => 'nullable|numeric',
'summary' => 'nullable',
'statement_of_work' => 'nullable',
];
}

Expand Down
3 changes: 2 additions & 1 deletion database/migrations/2015_12_08_031825_create_base_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function (Blueprint $table) {
$table->integer('fee')->nullable();
$table->integer('hours')->unsigned()->nullable();
$table->text('summary')->nullable();
$table->text('statement_of_work')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreign('client_id')->references('id')->on('clients');
Expand Down Expand Up @@ -115,7 +116,7 @@ function (Blueprint $table) {
function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('estimatedDuration')->unsigned();
$table->integer('estimatedDuration')->unsigned()->default(0);
$table->integer('project_id')->unsigned();
$table->integer('invoice_id')->nullable()->unsigned();
$table->dateTime('start')->nullable();
Expand Down
Loading

0 comments on commit 7cdc799

Please sign in to comment.