From 130a17688877b5bca657be9bd49c20df945a765b Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 27 Dec 2013 11:10:32 +0200 Subject: [PATCH] Bug fixes --- ...11_05_180133_confide_setup_users_table.php | 23 ++ app/models/TaxRate.php | 6 + app/ninja/repositories/AccountRepository.php | 28 ++- app/views/header.blade.php | 3 +- app/views/invoices/edit.blade.php | 197 ++++++++++++++---- app/views/master.blade.php | 4 +- public/css/style.css | 5 + public/js/script.js | 28 ++- 8 files changed, 243 insertions(+), 51 deletions(-) create mode 100755 app/models/TaxRate.php mode change 100644 => 100755 app/ninja/repositories/AccountRepository.php diff --git a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php index 1ca9ff22e518..c932efc675b0 100755 --- a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php +++ b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php @@ -10,6 +10,7 @@ class ConfideSetupUsersTable extends Migration { */ public function up() { + Schema::dropIfExists('tax_rates'); Schema::dropIfExists('themes'); Schema::dropIfExists('credits'); Schema::dropIfExists('activities'); @@ -348,6 +349,9 @@ class ConfideSetupUsersTable extends Migration { $t->decimal('cost', 10, 2); $t->decimal('qty', 10, 2); + $t->string('tax_name'); + $t->decimal('tax_rate', 10, 2); + $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); $t->foreign('product_id')->references('id')->on('products'); $t->foreign('user_id')->references('id')->on('users'); @@ -408,6 +412,24 @@ class ConfideSetupUsersTable extends Migration { $t->unique( array('account_id','public_id') ); }); + Schema::create('tax_rates', function($t) + { + $t->increments('id'); + $t->unsignedInteger('account_id')->index(); + $t->unsignedInteger('user_id'); + $t->timestamps(); + $t->softDeletes(); + + $t->string('name'); + $t->decimal('rate', 10, 2); + + $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); + $t->foreign('user_id')->references('id')->on('users'); + + $t->unsignedInteger('public_id'); + $t->unique( array('account_id','public_id') ); + }); + Schema::create('activities', function($t) { $t->increments('id'); @@ -439,6 +461,7 @@ class ConfideSetupUsersTable extends Migration { */ public function down() { + Schema::dropIfExists('tax_rates'); Schema::dropIfExists('themes'); Schema::dropIfExists('credits'); Schema::dropIfExists('activities'); diff --git a/app/models/TaxRate.php b/app/models/TaxRate.php new file mode 100755 index 000000000000..c30d0d1d8569 --- /dev/null +++ b/app/models/TaxRate.php @@ -0,0 +1,6 @@ +where('clients.deleted_at', '=', null) - ->select(\DB::raw("'Clients' as type, clients.public_id, clients.name")); + ->select(\DB::raw("'Clients' as type, clients.public_id, clients.name, '' as token")); $contacts = \DB::table('clients') ->join('contacts', 'contacts.client_id', '=', 'clients.id') ->where('clients.deleted_at', '=', null) - ->select(\DB::raw("'Contacts' as type, clients.public_id, CONCAT(contacts.first_name, ' ', contacts.last_name) as name")); + ->select(\DB::raw("'Contacts' as type, clients.public_id, CONCAT(contacts.first_name, ' ', contacts.last_name, ': ', clients.name) as name, '' as token")); $invoices = \DB::table('clients') ->join('invoices', 'invoices.client_id', '=', 'clients.id') ->where('clients.deleted_at', '=', null) ->where('invoices.deleted_at', '=', null) - ->select(\DB::raw("'Invoices' as type, invoices.public_id, CONCAT(invoices.invoice_number, ': ', clients.name) as name")); - + ->select(\DB::raw("'Invoices' as type, invoices.public_id, CONCAT(invoices.invoice_number, ': ', clients.name) as name, invoices.invoice_number as token")); $data = []; foreach ($clients->union($contacts)->union($invoices)->get() as $row) { - if (!isset($data[$row->type])) + $type = $row->type; + + if (!isset($data[$type])) { - $data[$row->type] = []; + $data[$type] = []; + } + + $tokens = explode(' ', $row->name); + $tokens[] = $type; + + if ($type == 'Invoices') + { + $tokens[] = intVal($row->token) . ''; } - $data[$row->type][] = [ + $data[$type][] = [ 'value' => $row->name, - 'public_id' => $row->public_id + 'public_id' => $row->public_id, + 'tokens' => $tokens ]; } - + return $data; } } \ No newline at end of file diff --git a/app/views/header.blade.php b/app/views/header.blade.php index 8fb262269b5e..6cfe9a95da97 100755 --- a/app/views/header.blade.php +++ b/app/views/header.blade.php @@ -30,7 +30,6 @@ - @@ -501,7 +500,7 @@ if (!data.hasOwnProperty(type)) continue; datasets.push({ name: type, - header: ' ' + type + '', + header: ' ' + type + '', local: data[type] }); } diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index ff285441665a..b21e871b521c 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -67,6 +67,14 @@ {{ Former::text('po_number')->label('PO number')->data_bind("value: po_number, valueUpdate: 'afterkeydown'") }} {{ Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'") }} {{ Former::text('currency')->data_bind("value: discount, valueUpdate: 'afterkeydown'") }} + +
+ + +
+ @@ -82,6 +90,7 @@ Description Unit Cost Quantity + Tax Line Total @@ -92,24 +101,22 @@ - {{ Former::text('product_key')->useDatalist(Product::getProductKeys($products), 'key')->onkeyup('onChange()') + {{ Former::text('product_key')->useDatalist(Product::getProductKeys($products), 'key')->onkeyup('onItemChange()') ->raw()->data_bind("value: product_key, valueUpdate: 'afterkeydown'")->addClass('datalist') }} - + - + - - + @@ -119,26 +126,22 @@ - - + Subtotal - - + Paid to Date - - + Discount - - + Balance Due @@ -184,16 +187,17 @@ -