bug fixes [trigger:composer]

This commit is contained in:
Hillel Coren 2014-01-09 10:39:20 +00:00
parent 9f79628579
commit ac917c2b51
7 changed files with 67 additions and 39 deletions

View File

@ -74,10 +74,13 @@ class Utils
public static function formatMoney($value, $currencyId) public static function formatMoney($value, $currencyId)
{ {
$currency = Currency::find($currencyId); $currency = Currency::remember(DEFAULT_QUERY_CACHE)->find($currencyId);
if (!$currency) {
$currency = Currency::find(1); if (!$currency)
{
$currency = Currency::remember(DEFAULT_QUERY_CACHE)->find(1);
} }
return $currency->symbol . number_format($value, $currency->precision, $currency->decimal_separator, $currency->thousand_separator); return $currency->symbol . number_format($value, $currency->precision, $currency->decimal_separator, $currency->thousand_separator);
} }
@ -318,7 +321,7 @@ class Utils
public static function encodeActivity($person = null, $action, $entity = null, $otherPerson = null) public static function encodeActivity($person = null, $action, $entity = null, $otherPerson = null)
{ {
$person = $person ? $person->getDisplayName() : '<i>System</i>'; $person = $person ? $person->getDisplayName() : '<i>System</i>';
$entity = $entity ? '[' . $entity->getKey() . ']' : ''; $entity = $entity ? '[' . $entity->getActivityKey() . ']' : '';
$otherPerson = $otherPerson ? 'to ' . $otherPerson->getDisplayName() : ''; $otherPerson = $otherPerson ? 'to ' . $otherPerson->getDisplayName() : '';
return trim("$person $action $entity $otherPerson"); return trim("$person $action $entity $otherPerson");

View File

@ -127,7 +127,7 @@ class Activity extends Eloquent
$activity->client_id = $invoice->client_id; $activity->client_id = $invoice->client_id;
$activity->activity_type_id = ACTIVITY_TYPE_ARCHIVE_INVOICE; $activity->activity_type_id = ACTIVITY_TYPE_ARCHIVE_INVOICE;
$activity->message = Utils::encodeActivity(Auth::user(), 'archived', $invoice); $activity->message = Utils::encodeActivity(Auth::user(), 'archived', $invoice);
$activity->balance = $client->balance; $activity->balance = $invoice->client->balance;
$activity->adjustment = $invoice->balance; $activity->adjustment = $invoice->balance;
$activity->save(); $activity->save();
@ -179,7 +179,7 @@ class Activity extends Eloquent
$activity->invoice_id = $invoice->id; $activity->invoice_id = $invoice->id;
$activity->activity_type_id = ACTIVITY_TYPE_DELETE_INVOICE; $activity->activity_type_id = ACTIVITY_TYPE_DELETE_INVOICE;
$activity->message = Utils::encodeActivity(Auth::user(), 'deleted', $invoice); $activity->message = Utils::encodeActivity(Auth::user(), 'deleted', $invoice);
$activity->balance = $client->balance; $activity->balance = $invoice->client->balance;
$activity->adjustment = $invoice->balance * -1; $activity->adjustment = $invoice->balance * -1;
$activity->save(); $activity->save();
} }

View File

@ -3,7 +3,7 @@
class EntityModel extends Eloquent class EntityModel extends Eloquent
{ {
protected $softDelete = true; protected $softDelete = true;
public $timestamps = false; public $timestamps = true;
protected $hidden = ['id', 'created_at', 'deleted_at', 'updated_at']; protected $hidden = ['id', 'created_at', 'deleted_at', 'updated_at'];
@ -42,7 +42,7 @@ class EntityModel extends Eloquent
return $className::scope($publicId)->pluck('id'); return $className::scope($publicId)->pluck('id');
} }
public function getKey() public function getActivityKey()
{ {
return $this->getEntityType() . ':' . $this->public_id . ':' . $this->getName(); return $this->getEntityType() . ':' . $this->public_id . ':' . $this->getName();
} }

View File

@ -144,3 +144,8 @@ Invoice::updating(function($invoice)
{ {
Activity::updateInvoice($invoice); Activity::updateInvoice($invoice);
}); });
Invoice::deleting(function($invoice)
{
Activity::archiveInvoice($invoice);
});

View File

@ -19,13 +19,33 @@
//dd(gethostname()); //dd(gethostname());
//Log::error('test'); //Log::error('test');
/* /*
DB::listen(function($sql)) { Event::listen('illuminate.query', function($query, $bindings, $time, $name)
Log::info($sql); {
} $data = compact('bindings', 'time', 'name');
// Format binding data for sql insertion
foreach ($bindings as $i => $binding)
{
if ($binding instanceof \DateTime)
{
$bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
}
else if (is_string($binding))
{
$bindings[$i] = "'$binding'";
}
}
// Insert bindings into query
$query = str_replace(array('%', '?'), array('%%', '%s'), $query);
$query = vsprintf($query, $bindings);
Log::info($query, $data);
});
*/ */
// TODO_FIX replace with cron // TODO_FIX replace with cron
Route::get('/send_emails', function() { Route::get('/send_emails', function() {
Artisan::call('ninja:send-invoices'); Artisan::call('ninja:send-invoices');

52
composer.lock generated
View File

@ -68,12 +68,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Anahkiasen/html-object.git", "url": "https://github.com/Anahkiasen/html-object.git",
"reference": "2c6cdc6368d19ac42357f7ae17bd99652a1916e4" "reference": "6264f3dd6b65b40a47632328e9049db83750a4c6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Anahkiasen/html-object/zipball/2c6cdc6368d19ac42357f7ae17bd99652a1916e4", "url": "https://api.github.com/repos/Anahkiasen/html-object/zipball/6264f3dd6b65b40a47632328e9049db83750a4c6",
"reference": "2c6cdc6368d19ac42357f7ae17bd99652a1916e4", "reference": "6264f3dd6b65b40a47632328e9049db83750a4c6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -96,7 +96,7 @@
} }
], ],
"description": "A set of classes to create and manipulate HTML objects abstractions", "description": "A set of classes to create and manipulate HTML objects abstractions",
"time": "2013-11-19 15:20:02" "time": "2014-01-08 20:26:54"
}, },
{ {
"name": "anahkiasen/rocketeer", "name": "anahkiasen/rocketeer",
@ -211,17 +211,17 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git", "url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "d1ec609e371dc081562b106c36a77357641fefa3" "reference": "ae8d5906c95343c7845ffc0c883f7355694b606c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/d1ec609e371dc081562b106c36a77357641fefa3", "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/ae8d5906c95343c7845ffc0c883f7355694b606c",
"reference": "d1ec609e371dc081562b106c36a77357641fefa3", "reference": "ae8d5906c95343c7845ffc0c883f7355694b606c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/support": "~4.0", "illuminate/support": "~4.0",
"maximebf/debugbar": "~1.8", "maximebf/debugbar": "~1.9",
"php": ">=5.3.0" "php": ">=5.3.0"
}, },
"type": "library", "type": "library",
@ -248,7 +248,7 @@
"profiler", "profiler",
"webprofiler" "webprofiler"
], ],
"time": "2014-01-07 10:13:21" "time": "2014-01-08 21:04:27"
}, },
{ {
"name": "chumper/datatable", "name": "chumper/datatable",
@ -638,12 +638,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Intervention/image.git", "url": "https://github.com/Intervention/image.git",
"reference": "ab884ad94b0861bfa43118eff114af8ee7cf4661" "reference": "c932b81171abbbdc8e3365281443cb28d3b974e1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/ab884ad94b0861bfa43118eff114af8ee7cf4661", "url": "https://api.github.com/repos/Intervention/image/zipball/c932b81171abbbdc8e3365281443cb28d3b974e1",
"reference": "ab884ad94b0861bfa43118eff114af8ee7cf4661", "reference": "c932b81171abbbdc8e3365281443cb28d3b974e1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -680,7 +680,7 @@
"thumbnail", "thumbnail",
"watermark" "watermark"
], ],
"time": "2013-12-30 14:38:30" "time": "2014-01-08 18:31:04"
}, },
{ {
"name": "ircmaxell/password-compat", "name": "ircmaxell/password-compat",
@ -915,12 +915,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "a49d68a0c048718d442855f52c4c68b97d76fd89" "reference": "e7bcc5741dff0ac6bd16d0d26248d14d8a285842"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/a49d68a0c048718d442855f52c4c68b97d76fd89", "url": "https://api.github.com/repos/laravel/framework/zipball/e7bcc5741dff0ac6bd16d0d26248d14d8a285842",
"reference": "a49d68a0c048718d442855f52c4c68b97d76fd89", "reference": "e7bcc5741dff0ac6bd16d0d26248d14d8a285842",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1024,7 +1024,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2014-01-07 02:54:25" "time": "2014-01-09 04:59:16"
}, },
{ {
"name": "laravelbook/ardent", "name": "laravelbook/ardent",
@ -2943,12 +2943,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/patricktalmadge/bootstrapper.git", "url": "https://github.com/patricktalmadge/bootstrapper.git",
"reference": "85c8e3ec29d0f98554d85b73d1e454b6600c0432" "reference": "dcc58a6e9cd8324f391d2846cd1d264969145298"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/patricktalmadge/bootstrapper/zipball/85c8e3ec29d0f98554d85b73d1e454b6600c0432", "url": "https://api.github.com/repos/patricktalmadge/bootstrapper/zipball/dcc58a6e9cd8324f391d2846cd1d264969145298",
"reference": "85c8e3ec29d0f98554d85b73d1e454b6600c0432", "reference": "dcc58a6e9cd8324f391d2846cd1d264969145298",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2973,7 +2973,7 @@
], ],
"authors": [ "authors": [
{ {
"name": "Maxime Fabre", "name": "Anahkiasen",
"email": "ehtnam6@gmail.com" "email": "ehtnam6@gmail.com"
}, },
{ {
@ -2990,7 +2990,7 @@
"bootstrap", "bootstrap",
"laravel" "laravel"
], ],
"time": "2014-01-07 16:02:34" "time": "2014-01-08 20:23:07"
}, },
{ {
"name": "phpseclib/phpseclib", "name": "phpseclib/phpseclib",
@ -3092,12 +3092,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nrk/predis.git", "url": "https://github.com/nrk/predis.git",
"reference": "d2debfd43eb8a5201204bb70275a0ef83b3d11ff" "reference": "9d0201ed9ef4fae09ed251897260941af230bed3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nrk/predis/zipball/d2debfd43eb8a5201204bb70275a0ef83b3d11ff", "url": "https://api.github.com/repos/nrk/predis/zipball/9d0201ed9ef4fae09ed251897260941af230bed3",
"reference": "d2debfd43eb8a5201204bb70275a0ef83b3d11ff", "reference": "9d0201ed9ef4fae09ed251897260941af230bed3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3131,7 +3131,7 @@
"predis", "predis",
"redis" "redis"
], ],
"time": "2013-12-22 16:51:18" "time": "2014-01-08 16:38:22"
}, },
{ {
"name": "psr/log", "name": "psr/log",