mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Merge branch 'master' of github.com:tlbdk/invoice-ninja
Conflicts: app/lang/en/texts.php
This commit is contained in:
commit
33bb86ee85
@ -818,7 +818,8 @@ class AccountController extends \BaseController {
|
|||||||
{
|
{
|
||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
$account->name = trim(Input::get('name'));
|
$account->name = trim(Input::get('name'));
|
||||||
$account->vat_number = trim(Input::get('vat_number'));
|
$account->id_number = trim(Input::get('id_number'));
|
||||||
|
$account->vat_number = trim(Input::get('vat_number'));
|
||||||
$account->work_email = trim(Input::get('work_email'));
|
$account->work_email = trim(Input::get('work_email'));
|
||||||
$account->work_phone = trim(Input::get('work_phone'));
|
$account->work_phone = trim(Input::get('work_phone'));
|
||||||
$account->address1 = trim(Input::get('address1'));
|
$account->address1 = trim(Input::get('address1'));
|
||||||
|
@ -199,7 +199,8 @@ class ClientController extends \BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$client->name = trim(Input::get('name'));
|
$client->name = trim(Input::get('name'));
|
||||||
$client->vat_number = trim(Input::get('vat_number'));
|
$client->id_number = trim(Input::get('id_number'));
|
||||||
|
$client->vat_number = trim(Input::get('vat_number'));
|
||||||
$client->work_phone = trim(Input::get('work_phone'));
|
$client->work_phone = trim(Input::get('work_phone'));
|
||||||
$client->custom_value1 = trim(Input::get('custom_value1'));
|
$client->custom_value1 = trim(Input::get('custom_value1'));
|
||||||
$client->custom_value2 = trim(Input::get('custom_value2'));
|
$client->custom_value2 = trim(Input::get('custom_value2'));
|
||||||
|
@ -17,7 +17,7 @@ class AddCompanyVatNumber extends Migration {
|
|||||||
$table->string('vat_number')->nullable();
|
$table->string('vat_number')->nullable();
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::table('clients', function($table)
|
Schema::table('clients', function($table)
|
||||||
{
|
{
|
||||||
$table->string('vat_number')->nullable();
|
$table->string('vat_number')->nullable();
|
||||||
});
|
});
|
||||||
@ -34,7 +34,7 @@ class AddCompanyVatNumber extends Migration {
|
|||||||
{
|
{
|
||||||
$table->dropColumn('vat_number');
|
$table->dropColumn('vat_number');
|
||||||
});
|
});
|
||||||
Schema::table('clients', function($table)
|
Schema::table('clients', function($table)
|
||||||
{
|
{
|
||||||
$table->dropColumn('vat_number');
|
$table->dropColumn('vat_number');
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddCompanyIdNumber extends Migration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('accounts', function($table)
|
||||||
|
{
|
||||||
|
$table->string('id_number')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('clients', function($table)
|
||||||
|
{
|
||||||
|
$table->string('id_number')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('accounts', function($table)
|
||||||
|
{
|
||||||
|
$table->dropColumn('id_number');
|
||||||
|
});
|
||||||
|
Schema::table('clients', function($table)
|
||||||
|
{
|
||||||
|
$table->dropColumn('id_number');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,8 @@ return array(
|
|||||||
// client
|
// client
|
||||||
'organization' => 'Organisation',
|
'organization' => 'Organisation',
|
||||||
'name' => 'Navn',
|
'name' => 'Navn',
|
||||||
'vat_number' => 'CVR nummer',
|
'id_number' => 'SE/CVR nummer',
|
||||||
|
'vat_number' => 'SE/CVR nummer',
|
||||||
'website' => 'Webside',
|
'website' => 'Webside',
|
||||||
'work_phone' => 'Telefon',
|
'work_phone' => 'Telefon',
|
||||||
'address' => 'Adresse',
|
'address' => 'Adresse',
|
||||||
|
@ -457,7 +457,10 @@ return array(
|
|||||||
'more_designs_self_host_text' => '',
|
'more_designs_self_host_text' => '',
|
||||||
'buy' => 'Buy',
|
'buy' => 'Buy',
|
||||||
'bought_designs' => 'Successfully added additional invoice designs',
|
'bought_designs' => 'Successfully added additional invoice designs',
|
||||||
|
|
||||||
'sent' => 'sent',
|
'sent' => 'sent',
|
||||||
|
|
||||||
|
'id_number' => 'ID Number',
|
||||||
|
'vat_number' => 'VAT Number',
|
||||||
|
|
||||||
'timesheets' => 'Timesheets',
|
'timesheets' => 'Timesheets',
|
||||||
);
|
);
|
||||||
|
@ -131,11 +131,23 @@ class Client extends EntityModel
|
|||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVatNumber()
|
public function getIdNumber()
|
||||||
{
|
{
|
||||||
$str = '';
|
$str = '';
|
||||||
|
|
||||||
if ($this->work_phone)
|
if ($this->id_number)
|
||||||
|
{
|
||||||
|
$str .= '<i class="fa fa-vat-number" style="width: 20px"></i>' . $this->vat_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVatNumber()
|
||||||
|
{
|
||||||
|
$str = '';
|
||||||
|
|
||||||
|
if ($this->vat_number)
|
||||||
{
|
{
|
||||||
$str .= '<i class="fa fa-vat-number" style="width: 20px"></i>' . $this->vat_number;
|
$str .= '<i class="fa fa-vat-number" style="width: 20px"></i>' . $this->vat_number;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,8 @@ class Invoice extends EntityModel
|
|||||||
|
|
||||||
$this->client->setVisible([
|
$this->client->setVisible([
|
||||||
'name',
|
'name',
|
||||||
'vat_number',
|
'id_number',
|
||||||
|
'vat_number',
|
||||||
'address1',
|
'address1',
|
||||||
'address2',
|
'address2',
|
||||||
'city',
|
'city',
|
||||||
@ -111,7 +112,8 @@ class Invoice extends EntityModel
|
|||||||
|
|
||||||
$this->account->setVisible([
|
$this->account->setVisible([
|
||||||
'name',
|
'name',
|
||||||
'vat_number',
|
'id_number',
|
||||||
|
'vat_number',
|
||||||
'address1',
|
'address1',
|
||||||
'address2',
|
'address2',
|
||||||
'city',
|
'city',
|
||||||
|
@ -45,7 +45,7 @@ class AccountRepository
|
|||||||
|
|
||||||
public function getSearchData()
|
public function getSearchData()
|
||||||
{
|
{
|
||||||
$clients = \DB::table('clients')
|
$clients = \DB::table('clients')
|
||||||
->where('clients.deleted_at', '=', null)
|
->where('clients.deleted_at', '=', null)
|
||||||
->where('clients.account_id', '=', \Auth::user()->account_id)
|
->where('clients.account_id', '=', \Auth::user()->account_id)
|
||||||
->whereRaw("clients.name <> ''")
|
->whereRaw("clients.name <> ''")
|
||||||
|
@ -62,7 +62,10 @@ class ClientRepository
|
|||||||
if (isset($data['name'])) {
|
if (isset($data['name'])) {
|
||||||
$client->name = trim($data['name']);
|
$client->name = trim($data['name']);
|
||||||
}
|
}
|
||||||
if (isset($data['vat_number'])) {
|
if (isset($data['id_number'])) {
|
||||||
|
$client->id_number = trim($data['id_number']);
|
||||||
|
}
|
||||||
|
if (isset($data['vat_number'])) {
|
||||||
$client->vat_number = trim($data['vat_number']);
|
$client->vat_number = trim($data['vat_number']);
|
||||||
}
|
}
|
||||||
if (isset($data['work_phone'])) {
|
if (isset($data['work_phone'])) {
|
||||||
|
@ -29,7 +29,8 @@
|
|||||||
|
|
||||||
{{ Former::legend('details') }}
|
{{ Former::legend('details') }}
|
||||||
{{ Former::text('name') }}
|
{{ Former::text('name') }}
|
||||||
{{ Former::text('vat_number') }}
|
{{ Former::text('id_number') }}
|
||||||
|
{{ Former::text('vat_number') }}
|
||||||
{{ Former::text('work_email') }}
|
{{ Former::text('work_email') }}
|
||||||
{{ Former::text('work_phone') }}
|
{{ Former::text('work_phone') }}
|
||||||
{{ Former::file('logo')->max(2, 'MB')->accept('image')->inlineHelp(trans('texts.logo_help')) }}
|
{{ Former::file('logo')->max(2, 'MB')->accept('image')->inlineHelp(trans('texts.logo_help')) }}
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
{{ Former::legend('Organization') }}
|
{{ Former::legend('Organization') }}
|
||||||
{{ Former::text('name') }}
|
{{ Former::text('name') }}
|
||||||
{{ Former::text('vat_number') }}
|
{{ Former::text('id_number') }}
|
||||||
|
{{ Former::text('vat_number') }}
|
||||||
{{ Former::text('work_phone')->label('Phone') }}
|
{{ Former::text('work_phone')->label('Phone') }}
|
||||||
{{ Former::textarea('notes') }}
|
{{ Former::textarea('notes') }}
|
||||||
|
|
||||||
|
@ -23,8 +23,9 @@
|
|||||||
|
|
||||||
{{ Former::legend('organization') }}
|
{{ Former::legend('organization') }}
|
||||||
{{ Former::text('name')->data_bind("attr { placeholder: placeholderName }") }}
|
{{ Former::text('name')->data_bind("attr { placeholder: placeholderName }") }}
|
||||||
{{ Former::text('vat_number') }}
|
{{ Former::text('id_number') }}
|
||||||
{{ Former::text('website') }}
|
{{ Former::text('vat_number') }}
|
||||||
|
{{ Former::text('website') }}
|
||||||
{{ Former::text('work_phone') }}
|
{{ Former::text('work_phone') }}
|
||||||
|
|
||||||
@if (Auth::user()->isPro())
|
@if (Auth::user()->isPro())
|
||||||
|
@ -39,8 +39,9 @@
|
|||||||
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<h3>{{ trans('texts.details') }}</h3>
|
<h3>{{ trans('texts.details') }}</h3>
|
||||||
|
<p>{{ $client->getIdNumber() }}</p>
|
||||||
<p>{{ $client->getVatNumber() }}</p>
|
<p>{{ $client->getVatNumber() }}</p>
|
||||||
<p>{{ $client->getAddress() }}</p>
|
<p>{{ $client->getAddress() }}</p>
|
||||||
<p>{{ $client->getCustomFields() }}</p>
|
<p>{{ $client->getCustomFields() }}</p>
|
||||||
<p>{{ $client->getPhone() }}</p>
|
<p>{{ $client->getPhone() }}</p>
|
||||||
<p>{{ $client->getNotes() }}</p>
|
<p>{{ $client->getNotes() }}</p>
|
||||||
|
@ -341,7 +341,8 @@
|
|||||||
|
|
||||||
{{ Former::legend('organization') }}
|
{{ Former::legend('organization') }}
|
||||||
{{ Former::text('name')->data_bind("value: name, valueUpdate: 'afterkeydown', attr { placeholder: name.placeholder }") }}
|
{{ Former::text('name')->data_bind("value: name, valueUpdate: 'afterkeydown', attr { placeholder: name.placeholder }") }}
|
||||||
{{ Former::text('vat_number')->data_bind("value: vat_number, valueUpdate: 'afterkeydown'") }}
|
{{ Former::text('id_number')->data_bind("value: id_number, valueUpdate: 'afterkeydown'") }}
|
||||||
|
{{ Former::text('vat_number')->data_bind("value: vat_number, valueUpdate: 'afterkeydown'") }}
|
||||||
|
|
||||||
{{ Former::text('website')->data_bind("value: website, valueUpdate: 'afterkeydown'") }}
|
{{ Former::text('website')->data_bind("value: website, valueUpdate: 'afterkeydown'") }}
|
||||||
{{ Former::text('work_phone')->data_bind("value: work_phone, valueUpdate: 'afterkeydown'") }}
|
{{ Former::text('work_phone')->data_bind("value: work_phone, valueUpdate: 'afterkeydown'") }}
|
||||||
@ -1222,7 +1223,8 @@
|
|||||||
var self = this;
|
var self = this;
|
||||||
self.public_id = ko.observable(0);
|
self.public_id = ko.observable(0);
|
||||||
self.name = ko.observable('');
|
self.name = ko.observable('');
|
||||||
self.vat_number = ko.observable('');
|
self.id_number = ko.observable('');
|
||||||
|
self.vat_number = ko.observable('');
|
||||||
self.work_phone = ko.observable('');
|
self.work_phone = ko.observable('');
|
||||||
self.custom_value1 = ko.observable('');
|
self.custom_value1 = ko.observable('');
|
||||||
self.custom_value2 = ko.observable('');
|
self.custom_value2 = ko.observable('');
|
||||||
|
184
public/built.js
184
public/built.js
@ -30978,7 +30978,7 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
|
|||||||
|
|
||||||
var invoiceOld;
|
var invoiceOld;
|
||||||
function generatePDF(invoice, javascript, force) {
|
function generatePDF(invoice, javascript, force) {
|
||||||
invoice = calculateAmounts(invoice);
|
invoice = calculateAmounts(invoice);
|
||||||
var a = copyInvoice(invoice);
|
var a = copyInvoice(invoice);
|
||||||
var b = copyInvoice(invoiceOld);
|
var b = copyInvoice(invoiceOld);
|
||||||
if (!force && _.isEqual(a, b)) {
|
if (!force && _.isEqual(a, b)) {
|
||||||
@ -31023,7 +31023,7 @@ function GetPdf(invoice, javascript){
|
|||||||
layout.descriptionLeft -= 20;
|
layout.descriptionLeft -= 20;
|
||||||
layout.unitCostRight -= 40;
|
layout.unitCostRight -= 40;
|
||||||
layout.qtyRight -= 40;
|
layout.qtyRight -= 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
|
@param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
|
||||||
@ -31111,24 +31111,24 @@ function processVariables(str) {
|
|||||||
if (!str) return '';
|
if (!str) return '';
|
||||||
var variables = ['MONTH','QUARTER','YEAR'];
|
var variables = ['MONTH','QUARTER','YEAR'];
|
||||||
for (var i=0; i<variables.length; i++) {
|
for (var i=0; i<variables.length; i++) {
|
||||||
var variable = variables[i];
|
var variable = variables[i];
|
||||||
var regexp = new RegExp(':' + variable + '[+-]?[\\d]*', 'g');
|
var regexp = new RegExp(':' + variable + '[+-]?[\\d]*', 'g');
|
||||||
var matches = str.match(regexp);
|
var matches = str.match(regexp);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var j=0; j<matches.length; j++) {
|
for (var j=0; j<matches.length; j++) {
|
||||||
var match = matches[j];
|
var match = matches[j];
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
if (match.split('+').length > 1) {
|
if (match.split('+').length > 1) {
|
||||||
offset = match.split('+')[1];
|
offset = match.split('+')[1];
|
||||||
} else if (match.split('-').length > 1) {
|
} else if (match.split('-').length > 1) {
|
||||||
offset = parseInt(match.split('-')[1]) * -1;
|
offset = parseInt(match.split('-')[1]) * -1;
|
||||||
}
|
}
|
||||||
str = str.replace(match, getDatePart(variable, offset));
|
str = str.replace(match, getDatePart(variable, offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31151,7 +31151,7 @@ function getMonth(offset) {
|
|||||||
var months = [ "January", "February", "March", "April", "May", "June",
|
var months = [ "January", "February", "March", "April", "May", "June",
|
||||||
"July", "August", "September", "October", "November", "December" ];
|
"July", "August", "September", "October", "November", "December" ];
|
||||||
var month = today.getMonth();
|
var month = today.getMonth();
|
||||||
month = parseInt(month) + offset;
|
month = parseInt(month) + offset;
|
||||||
month = month % 12;
|
month = month % 12;
|
||||||
if (month < 0) {
|
if (month < 0) {
|
||||||
month += 12;
|
month += 12;
|
||||||
@ -31171,7 +31171,7 @@ function getQuarter(offset) {
|
|||||||
quarter += offset;
|
quarter += offset;
|
||||||
quarter = quarter % 4;
|
quarter = quarter % 4;
|
||||||
if (quarter == 0) {
|
if (quarter == 0) {
|
||||||
quarter = 4;
|
quarter = 4;
|
||||||
}
|
}
|
||||||
return 'Q' + quarter;
|
return 'Q' + quarter;
|
||||||
}
|
}
|
||||||
@ -31360,7 +31360,7 @@ function enableHoverClick($combobox, $entityId, url) {
|
|||||||
setAsLink($combobox, false);
|
setAsLink($combobox, false);
|
||||||
}).on('click', function() {
|
}).on('click', function() {
|
||||||
var clientId = $entityId.val();
|
var clientId = $entityId.val();
|
||||||
if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {
|
if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {
|
||||||
if (parseInt(clientId) > 0) {
|
if (parseInt(clientId) > 0) {
|
||||||
window.open(url + '/' + clientId, '_blank');
|
window.open(url + '/' + clientId, '_blank');
|
||||||
} else {
|
} else {
|
||||||
@ -31374,10 +31374,10 @@ function enableHoverClick($combobox, $entityId, url) {
|
|||||||
function setAsLink($input, enable) {
|
function setAsLink($input, enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
$input.css('text-decoration','underline');
|
$input.css('text-decoration','underline');
|
||||||
$input.css('cursor','pointer');
|
$input.css('cursor','pointer');
|
||||||
} else {
|
} else {
|
||||||
$input.css('text-decoration','none');
|
$input.css('text-decoration','none');
|
||||||
$input.css('cursor','text');
|
$input.css('cursor','text');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31408,45 +31408,45 @@ if (window.ko) {
|
|||||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||||
if (id) $(element).val(id);
|
if (id) $(element).val(id);
|
||||||
//console.log("combo-init: %s", id);
|
//console.log("combo-init: %s", id);
|
||||||
$(element).combobox(options);
|
$(element).combobox(options);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ko.utils.registerEventHandler(element, "change", function () {
|
ko.utils.registerEventHandler(element, "change", function () {
|
||||||
console.log("change: %s", $(element).val());
|
console.log("change: %s", $(element).val());
|
||||||
//var
|
//var
|
||||||
valueAccessor($(element).val());
|
valueAccessor($(element).val());
|
||||||
//$(element).combobox('refresh');
|
//$(element).combobox('refresh');
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
},
|
},
|
||||||
update: function (element, valueAccessor) {
|
update: function (element, valueAccessor) {
|
||||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||||
//console.log("combo-update: %s", id);
|
//console.log("combo-update: %s", id);
|
||||||
if (id) {
|
if (id) {
|
||||||
$(element).val(id);
|
$(element).val(id);
|
||||||
$(element).combobox('refresh');
|
$(element).combobox('refresh');
|
||||||
} else {
|
} else {
|
||||||
$(element).combobox('clearTarget');
|
$(element).combobox('clearTarget');
|
||||||
$(element).combobox('clearElement');
|
$(element).combobox('clearElement');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ko.bindingHandlers.datePicker = {
|
ko.bindingHandlers.datePicker = {
|
||||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||||
if (value) $(element).datepicker('update', value);
|
if (value) $(element).datepicker('update', value);
|
||||||
$(element).change(function() {
|
$(element).change(function() {
|
||||||
var value = valueAccessor();
|
var value = valueAccessor();
|
||||||
value($(element).val());
|
value($(element).val());
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
update: function (element, valueAccessor) {
|
update: function (element, valueAccessor) {
|
||||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||||
if (value) $(element).datepicker('update', value);
|
if (value) $(element).datepicker('update', value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31464,11 +31464,11 @@ function wordWrapText(value, width)
|
|||||||
while (j++ < lines[i].length) {
|
while (j++ < lines[i].length) {
|
||||||
if (lines[i].charAt(j) === ' ') space = j;
|
if (lines[i].charAt(j) === ' ') space = j;
|
||||||
}
|
}
|
||||||
if (space == lines[i].length) space = width/6;
|
if (space == lines[i].length) space = width/6;
|
||||||
lines[i + 1] = lines[i].substring(space + 1) + ' ' + (lines[i + 1] || '');
|
lines[i + 1] = lines[i].substring(space + 1) + ' ' + (lines[i + 1] || '');
|
||||||
lines[i] = lines[i].substring(0, space);
|
lines[i] = lines[i].substring(0, space);
|
||||||
}
|
}
|
||||||
|
|
||||||
var newValue = (lines.join("\n")).trim();
|
var newValue = (lines.join("\n")).trim();
|
||||||
|
|
||||||
if (value == newValue) {
|
if (value == newValue) {
|
||||||
@ -31497,14 +31497,14 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
var clientMap = {};
|
var clientMap = {};
|
||||||
var invoiceMap = {};
|
var invoiceMap = {};
|
||||||
var invoicesForClientMap = {};
|
var invoicesForClientMap = {};
|
||||||
var $clientSelect = $('select#client');
|
var $clientSelect = $('select#client');
|
||||||
|
|
||||||
for (var i=0; i<invoices.length; i++) {
|
for (var i=0; i<invoices.length; i++) {
|
||||||
var invoice = invoices[i];
|
var invoice = invoices[i];
|
||||||
var client = invoice.client;
|
var client = invoice.client;
|
||||||
|
|
||||||
if (!invoicesForClientMap.hasOwnProperty(client.public_id)) {
|
if (!invoicesForClientMap.hasOwnProperty(client.public_id)) {
|
||||||
invoicesForClientMap[client.public_id] = [];
|
invoicesForClientMap[client.public_id] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
invoicesForClientMap[client.public_id].push(invoice);
|
invoicesForClientMap[client.public_id].push(invoice);
|
||||||
@ -31516,28 +31516,28 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
clientMap[client.public_id] = client;
|
clientMap[client.public_id] = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
$clientSelect.append(new Option('', ''));
|
$clientSelect.append(new Option('', ''));
|
||||||
for (var i=0; i<clients.length; i++) {
|
for (var i=0; i<clients.length; i++) {
|
||||||
var client = clients[i];
|
var client = clients[i];
|
||||||
$clientSelect.append(new Option(getClientDisplayName(client), client.public_id));
|
$clientSelect.append(new Option(getClientDisplayName(client), client.public_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientId) {
|
if (clientId) {
|
||||||
$clientSelect.val(clientId);
|
$clientSelect.val(clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$clientSelect.combobox();
|
$clientSelect.combobox();
|
||||||
$clientSelect.on('change', function(e) {
|
$clientSelect.on('change', function(e) {
|
||||||
var clientId = $('input[name=client]').val();
|
var clientId = $('input[name=client]').val();
|
||||||
var invoiceId = $('input[name=invoice]').val();
|
var invoiceId = $('input[name=invoice]').val();
|
||||||
var invoice = invoiceMap[invoiceId];
|
var invoice = invoiceMap[invoiceId];
|
||||||
if (invoice && invoice.client.public_id == clientId) {
|
if (invoice && invoice.client.public_id == clientId) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setComboboxValue($('.invoice-select'), '', '');
|
setComboboxValue($('.invoice-select'), '', '');
|
||||||
$invoiceCombobox = $('select#invoice');
|
$invoiceCombobox = $('select#invoice');
|
||||||
$invoiceCombobox.find('option').remove().end().combobox('refresh');
|
$invoiceCombobox.find('option').remove().end().combobox('refresh');
|
||||||
$invoiceCombobox.append(new Option('', ''));
|
$invoiceCombobox.append(new Option('', ''));
|
||||||
var list = clientId ? (invoicesForClientMap.hasOwnProperty(clientId) ? invoicesForClientMap[clientId] : []) : invoices;
|
var list = clientId ? (invoicesForClientMap.hasOwnProperty(clientId) ? invoicesForClientMap[clientId] : []) : invoices;
|
||||||
for (var i=0; i<list.length; i++) {
|
for (var i=0; i<list.length; i++) {
|
||||||
@ -31551,11 +31551,11 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
$('select#invoice').combobox('refresh');
|
$('select#invoice').combobox('refresh');
|
||||||
});
|
});
|
||||||
|
|
||||||
var $invoiceSelect = $('select#invoice').on('change', function(e) {
|
var $invoiceSelect = $('select#invoice').on('change', function(e) {
|
||||||
$clientCombobox = $('select#client');
|
$clientCombobox = $('select#client');
|
||||||
var invoiceId = $('input[name=invoice]').val();
|
var invoiceId = $('input[name=invoice]').val();
|
||||||
if (invoiceId) {
|
if (invoiceId) {
|
||||||
var invoice = invoiceMap[invoiceId];
|
var invoice = invoiceMap[invoiceId];
|
||||||
var client = clientMap[invoice.client.public_id];
|
var client = clientMap[invoice.client.public_id];
|
||||||
setComboboxValue($('.client-select'), client.public_id, getClientDisplayName(client));
|
setComboboxValue($('.client-select'), client.public_id, getClientDisplayName(client));
|
||||||
if (!parseFloat($('#amount').val())) {
|
if (!parseFloat($('#amount').val())) {
|
||||||
@ -31564,7 +31564,7 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$invoiceSelect.combobox();
|
$invoiceSelect.combobox();
|
||||||
|
|
||||||
if (invoiceId) {
|
if (invoiceId) {
|
||||||
var invoice = invoiceMap[invoiceId];
|
var invoice = invoiceMap[invoiceId];
|
||||||
@ -31579,7 +31579,7 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
$clientSelect.trigger('change');
|
$clientSelect.trigger('change');
|
||||||
} else {
|
} else {
|
||||||
$clientSelect.trigger('change');
|
$clientSelect.trigger('change');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -31606,6 +31606,7 @@ function displayAccount(doc, invoice, x, y, layout) {
|
|||||||
|
|
||||||
var data1 = [
|
var data1 = [
|
||||||
account.name,
|
account.name,
|
||||||
|
account.id_number,
|
||||||
account.vat_number,
|
account.vat_number,
|
||||||
account.work_email,
|
account.work_email,
|
||||||
account.work_phone
|
account.work_phone
|
||||||
@ -31613,10 +31614,10 @@ function displayAccount(doc, invoice, x, y, layout) {
|
|||||||
|
|
||||||
var data2 = [
|
var data2 = [
|
||||||
concatStrings(account.address1, account.address2),
|
concatStrings(account.address1, account.address2),
|
||||||
concatStrings(account.city, account.state, account.postal_code),
|
concatStrings(account.city, account.state, account.postal_code),
|
||||||
account.country ? account.country.name : false,
|
account.country ? account.country.name : false,
|
||||||
invoice.account.custom_value1 ? invoice.account['custom_label1'] + ' ' + invoice.account.custom_value1 : false,
|
invoice.account.custom_value1 ? invoice.account['custom_label1'] + ' ' + invoice.account.custom_value1 : false,
|
||||||
invoice.account.custom_value2 ? invoice.account['custom_label2'] + ' ' + invoice.account.custom_value2 : false,
|
invoice.account.custom_value2 ? invoice.account['custom_label2'] + ' ' + invoice.account.custom_value2 : false,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (layout.singleColumn) {
|
if (layout.singleColumn) {
|
||||||
@ -31632,7 +31633,7 @@ function displayAccount(doc, invoice, x, y, layout) {
|
|||||||
width = Math.max(emailWidth, nameWidth, 120);
|
width = Math.max(emailWidth, nameWidth, 120);
|
||||||
x += width;
|
x += width;
|
||||||
|
|
||||||
displayGrid(doc, invoice, data2, x, y, layout);
|
displayGrid(doc, invoice, data2, x, y, layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31641,16 +31642,17 @@ function displayClient(doc, invoice, x, y, layout) {
|
|||||||
var client = invoice.client;
|
var client = invoice.client;
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = [
|
var data = [
|
||||||
getClientDisplayName(client),
|
getClientDisplayName(client),
|
||||||
|
client.id_number,
|
||||||
client.vat_number,
|
client.vat_number,
|
||||||
concatStrings(client.address1, client.address2),
|
concatStrings(client.address1, client.address2),
|
||||||
concatStrings(client.city, client.state, client.postal_code),
|
concatStrings(client.city, client.state, client.postal_code),
|
||||||
client.country ? client.country.name : false,
|
client.country ? client.country.name : false,
|
||||||
client.contacts && getClientDisplayName(client) != client.contacts[0].email ? client.contacts[0].email : false,
|
client.contacts && getClientDisplayName(client) != client.contacts[0].email ? client.contacts[0].email : false,
|
||||||
invoice.client.custom_value1 ? invoice.account['custom_client_label1'] + ' ' + invoice.client.custom_value1 : false,
|
invoice.client.custom_value1 ? invoice.account['custom_client_label1'] + ' ' + invoice.client.custom_value1 : false,
|
||||||
invoice.client.custom_value2 ? invoice.account['custom_client_label2'] + ' ' + invoice.client.custom_value2 : false,
|
invoice.client.custom_value2 ? invoice.account['custom_client_label2'] + ' ' + invoice.client.custom_value2 : false,
|
||||||
];
|
];
|
||||||
return displayGrid(doc, invoice, data, x, y, layout, {hasheader:true});
|
return displayGrid(doc, invoice, data, x, y, layout, {hasheader:true});
|
||||||
}
|
}
|
||||||
@ -31676,7 +31678,7 @@ function getInvoiceDetails(invoice) {
|
|||||||
{'invoice_date': invoice.invoice_date},
|
{'invoice_date': invoice.invoice_date},
|
||||||
{'due_date': invoice.due_date},
|
{'due_date': invoice.due_date},
|
||||||
{'balance_due': formatMoney(invoice.balance_amount, invoice.client.currency_id)},
|
{'balance_due': formatMoney(invoice.balance_amount, invoice.client.currency_id)},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInvoiceDetailsHeight(invoice, layout) {
|
function getInvoiceDetailsHeight(invoice, layout) {
|
||||||
@ -31710,20 +31712,20 @@ function displaySubtotals(doc, layout, invoice, y, rightAlignTitleX)
|
|||||||
{'discount': invoice.discount_amount > 0 ? formatMoney(invoice.discount_amount, invoice.client.currency_id) : false}
|
{'discount': invoice.discount_amount > 0 ? formatMoney(invoice.discount_amount, invoice.client.currency_id) : false}
|
||||||
];
|
];
|
||||||
|
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
||||||
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
|
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
||||||
data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
|
data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
data.push({'tax': invoice.tax_amount > 0 ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false});
|
data.push({'tax': invoice.tax_amount > 0 ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false});
|
||||||
|
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
||||||
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
|
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
||||||
data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
|
data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
var paid = invoice.amount - invoice.balance;
|
var paid = invoice.amount - invoice.balance;
|
||||||
@ -31734,7 +31736,7 @@ function displaySubtotals(doc, layout, invoice, y, rightAlignTitleX)
|
|||||||
var options = {
|
var options = {
|
||||||
hasheader: true,
|
hasheader: true,
|
||||||
rightAlignX: 550,
|
rightAlignX: 550,
|
||||||
rightAlignTitleX: rightAlignTitleX
|
rightAlignTitleX: rightAlignTitleX
|
||||||
};
|
};
|
||||||
|
|
||||||
return displayGrid(doc, invoice, data, 300, y, layout, options) + 10;
|
return displayGrid(doc, invoice, data, 300, y, layout, options) + 10;
|
||||||
@ -31765,7 +31767,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
|
|||||||
var origY = y;
|
var origY = y;
|
||||||
for (var i=0; i<data.length; i++) {
|
for (var i=0; i<data.length; i++) {
|
||||||
doc.setFontType('normal');
|
doc.setFontType('normal');
|
||||||
|
|
||||||
if (invoice.invoice_design_id == 1 && i > 0 && origY === layout.accountTop) {
|
if (invoice.invoice_design_id == 1 && i > 0 && origY === layout.accountTop) {
|
||||||
SetPdfColor('GrayText',doc);
|
SetPdfColor('GrayText',doc);
|
||||||
}
|
}
|
||||||
@ -31779,7 +31781,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
|
|||||||
doc.setFontType('bold');
|
doc.setFontType('bold');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof row === 'object') {
|
if (typeof row === 'object') {
|
||||||
for (var key in row) {
|
for (var key in row) {
|
||||||
if (row.hasOwnProperty(key)) {
|
if (row.hasOwnProperty(key)) {
|
||||||
var value = row[key] ? row[key] + '' : false;
|
var value = row[key] ? row[key] + '' : false;
|
||||||
@ -31787,16 +31789,16 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
|
|||||||
}
|
}
|
||||||
if (!value) {
|
if (!value) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var marginLeft;
|
var marginLeft;
|
||||||
if (options.rightAlignX) {
|
if (options.rightAlignX) {
|
||||||
marginLeft = options.rightAlignX - (doc.getStringUnitWidth(value) * doc.internal.getFontSize());
|
marginLeft = options.rightAlignX - (doc.getStringUnitWidth(value) * doc.internal.getFontSize());
|
||||||
} else {
|
} else {
|
||||||
marginLeft = x + 80;
|
marginLeft = x + 80;
|
||||||
}
|
}
|
||||||
doc.text(marginLeft, y, value);
|
doc.text(marginLeft, y, value);
|
||||||
|
|
||||||
doc.setFontType('normal');
|
doc.setFontType('normal');
|
||||||
if (invoice.is_quote) {
|
if (invoice.is_quote) {
|
||||||
if (key == 'invoice_number') {
|
if (key == 'invoice_number') {
|
||||||
@ -31822,7 +31824,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
|
|||||||
marginLeft = x;
|
marginLeft = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.text(marginLeft, y, key);
|
doc.text(marginLeft, y, key);
|
||||||
} else {
|
} else {
|
||||||
doc.text(x, y, row);
|
doc.text(x, y, row);
|
||||||
}
|
}
|
||||||
@ -31841,16 +31843,16 @@ function displayNotesAndTerms(doc, layout, invoice, y)
|
|||||||
|
|
||||||
if (invoice.public_notes) {
|
if (invoice.public_notes) {
|
||||||
doc.text(layout.marginLeft, y, invoice.public_notes);
|
doc.text(layout.marginLeft, y, invoice.public_notes);
|
||||||
y += 16 + (doc.splitTextToSize(invoice.public_notes, 300).length * doc.internal.getFontSize());
|
y += 16 + (doc.splitTextToSize(invoice.public_notes, 300).length * doc.internal.getFontSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoice.terms) {
|
if (invoice.terms) {
|
||||||
doc.setFontType("bold");
|
doc.setFontType("bold");
|
||||||
doc.text(layout.marginLeft, y, invoiceLabels.terms);
|
doc.text(layout.marginLeft, y, invoiceLabels.terms);
|
||||||
y += 16;
|
y += 16;
|
||||||
doc.setFontType("normal");
|
doc.setFontType("normal");
|
||||||
doc.text(layout.marginLeft, y, invoice.terms);
|
doc.text(layout.marginLeft, y, invoice.terms);
|
||||||
y += 16 + (doc.splitTextToSize(invoice.terms, 300).length * doc.internal.getFontSize());
|
y += 16 + (doc.splitTextToSize(invoice.terms, 300).length * doc.internal.getFontSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
return y - origY;
|
return y - origY;
|
||||||
@ -31867,7 +31869,7 @@ function calculateAmounts(invoice) {
|
|||||||
tax = parseFloat(item.tax.rate);
|
tax = parseFloat(item.tax.rate);
|
||||||
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
|
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
|
||||||
tax = parseFloat(item.tax_rate);
|
tax = parseFloat(item.tax_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
|
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
|
||||||
if (tax) {
|
if (tax) {
|
||||||
@ -31890,11 +31892,11 @@ function calculateAmounts(invoice) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// custom fields with taxes
|
// custom fields with taxes
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
||||||
total += roundToTwo(invoice.custom_value1);
|
total += roundToTwo(invoice.custom_value1);
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
||||||
total += roundToTwo(invoice.custom_value2);
|
total += roundToTwo(invoice.custom_value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var tax = 0;
|
var tax = 0;
|
||||||
@ -31910,11 +31912,11 @@ function calculateAmounts(invoice) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// custom fields w/o with taxes
|
// custom fields w/o with taxes
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
||||||
total += roundToTwo(invoice.custom_value1);
|
total += roundToTwo(invoice.custom_value1);
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
||||||
total += roundToTwo(invoice.custom_value2);
|
total += roundToTwo(invoice.custom_value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
invoice.balance_amount = roundToTwo(total) - (roundToTwo(invoice.amount) - roundToTwo(invoice.balance));
|
invoice.balance_amount = roundToTwo(total) - (roundToTwo(invoice.amount) - roundToTwo(invoice.balance));
|
||||||
@ -31931,7 +31933,7 @@ function getInvoiceTaxRate(invoice) {
|
|||||||
tax = parseFloat(invoice.tax.rate);
|
tax = parseFloat(invoice.tax.rate);
|
||||||
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
|
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
|
||||||
tax = parseFloat(invoice.tax_rate);
|
tax = parseFloat(invoice.tax_rate);
|
||||||
}
|
}
|
||||||
return tax;
|
return tax;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31972,9 +31974,9 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
var line = 1;
|
var line = 1;
|
||||||
var total = 0;
|
var total = 0;
|
||||||
var shownItem = false;
|
var shownItem = false;
|
||||||
var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
|
var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
|
||||||
var tableTop = layout.tableTop;
|
var tableTop = layout.tableTop;
|
||||||
var hideQuantity = invoice.account.hide_quantity == '1';
|
var hideQuantity = invoice.account.hide_quantity == '1';
|
||||||
|
|
||||||
doc.setFontSize(8);
|
doc.setFontSize(8);
|
||||||
for (var i=0; i<invoice.invoice_items.length; i++) {
|
for (var i=0; i<invoice.invoice_items.length; i++) {
|
||||||
@ -31988,12 +31990,12 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
tax = parseFloat(item.tax.rate);
|
tax = parseFloat(item.tax.rate);
|
||||||
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
|
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
|
||||||
tax = parseFloat(item.tax_rate);
|
tax = parseFloat(item.tax_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// show at most one blank line
|
// show at most one blank line
|
||||||
if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) {
|
if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
shownItem = true;
|
shownItem = true;
|
||||||
|
|
||||||
var numLines = doc.splitTextToSize(item.notes, 200).length + 2;
|
var numLines = doc.splitTextToSize(item.notes, 200).length + 2;
|
||||||
@ -32041,18 +32043,18 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
|
|
||||||
|
|
||||||
if (invoice.invoice_design_id == 1) {
|
if (invoice.invoice_design_id == 1) {
|
||||||
if (i%2 == 0) {
|
if (i%2 == 0) {
|
||||||
doc.setDrawColor(255,255,255);
|
doc.setDrawColor(255,255,255);
|
||||||
doc.setFillColor(246,246,246);
|
doc.setFillColor(246,246,246);
|
||||||
doc.rect(left, top, width-left, newTop-top, 'FD');
|
doc.rect(left, top, width-left, newTop-top, 'FD');
|
||||||
|
|
||||||
doc.setLineWidth(0.3);
|
doc.setLineWidth(0.3);
|
||||||
doc.setDrawColor(200,200,200);
|
doc.setDrawColor(200,200,200);
|
||||||
doc.line(left, top, width, top);
|
doc.line(left, top, width, top);
|
||||||
doc.line(left, newTop, width, newTop);
|
doc.line(left, newTop, width, newTop);
|
||||||
}
|
}
|
||||||
} else if (invoice.invoice_design_id == 2) {
|
} else if (invoice.invoice_design_id == 2) {
|
||||||
if (i%2 == 0) {
|
if (i%2 == 0) {
|
||||||
left = 0;
|
left = 0;
|
||||||
width = 1000;
|
width = 1000;
|
||||||
|
|
||||||
@ -32062,17 +32064,17 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else if (invoice.invoice_design_id == 5) {
|
} else if (invoice.invoice_design_id == 5) {
|
||||||
if (i%2 == 0) {
|
if (i%2 == 0) {
|
||||||
doc.setDrawColor(255,255,255);
|
doc.setDrawColor(255,255,255);
|
||||||
doc.setFillColor(247,247,247);
|
doc.setFillColor(247,247,247);
|
||||||
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
||||||
} else {
|
} else {
|
||||||
doc.setDrawColor(255,255,255);
|
doc.setDrawColor(255,255,255);
|
||||||
doc.setFillColor(232,232,232);
|
doc.setFillColor(232,232,232);
|
||||||
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
||||||
}
|
}
|
||||||
} else if (invoice.invoice_design_id == 6) {
|
} else if (invoice.invoice_design_id == 6) {
|
||||||
if (i%2 == 0) {
|
if (i%2 == 0) {
|
||||||
doc.setDrawColor(232,232,232);
|
doc.setDrawColor(232,232,232);
|
||||||
doc.setFillColor(232,232,232);
|
doc.setFillColor(232,232,232);
|
||||||
doc.rect(left, top, width-left, newTop-top, 'FD');
|
doc.rect(left, top, width-left, newTop-top, 'FD');
|
||||||
@ -32146,7 +32148,7 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
|
|
||||||
doc.line(qtyX-45, y-16,qtyX-45, y+55);
|
doc.line(qtyX-45, y-16,qtyX-45, y+55);
|
||||||
|
|
||||||
if (invoice.has_taxes) {
|
if (invoice.has_taxes) {
|
||||||
doc.line(taxX-15, y-16,taxX-15, y+55);
|
doc.line(taxX-15, y-16,taxX-15, y+55);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32198,7 +32200,7 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
if (tax) {
|
if (tax) {
|
||||||
doc.text(taxX, y+2, tax+'%');
|
doc.text(taxX, y+2, tax+'%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y = tableTop + (line * layout.tableRowHeight) + (3 * layout.tablePadding);
|
y = tableTop + (line * layout.tableRowHeight) + (3 * layout.tablePadding);
|
||||||
|
|
||||||
@ -32472,6 +32474,6 @@ function roundToTwo(num, toString) {
|
|||||||
return toString ? val.toFixed(2) : val;
|
return toString ? val.toFixed(2) : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate(str, length) {
|
function truncate(str, length) {
|
||||||
return (str && str.length > length) ? (str.substr(0, length-1) + '...') : str;
|
return (str && str.length > length) ? (str.substr(0, length-1) + '...') : str;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
|
|||||||
|
|
||||||
var invoiceOld;
|
var invoiceOld;
|
||||||
function generatePDF(invoice, javascript, force) {
|
function generatePDF(invoice, javascript, force) {
|
||||||
invoice = calculateAmounts(invoice);
|
invoice = calculateAmounts(invoice);
|
||||||
var a = copyInvoice(invoice);
|
var a = copyInvoice(invoice);
|
||||||
var b = copyInvoice(invoiceOld);
|
var b = copyInvoice(invoiceOld);
|
||||||
if (!force && _.isEqual(a, b)) {
|
if (!force && _.isEqual(a, b)) {
|
||||||
@ -54,7 +54,7 @@ function GetPdf(invoice, javascript){
|
|||||||
layout.descriptionLeft -= 20;
|
layout.descriptionLeft -= 20;
|
||||||
layout.unitCostRight -= 40;
|
layout.unitCostRight -= 40;
|
||||||
layout.qtyRight -= 40;
|
layout.qtyRight -= 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
|
@param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
|
||||||
@ -142,24 +142,24 @@ function processVariables(str) {
|
|||||||
if (!str) return '';
|
if (!str) return '';
|
||||||
var variables = ['MONTH','QUARTER','YEAR'];
|
var variables = ['MONTH','QUARTER','YEAR'];
|
||||||
for (var i=0; i<variables.length; i++) {
|
for (var i=0; i<variables.length; i++) {
|
||||||
var variable = variables[i];
|
var variable = variables[i];
|
||||||
var regexp = new RegExp(':' + variable + '[+-]?[\\d]*', 'g');
|
var regexp = new RegExp(':' + variable + '[+-]?[\\d]*', 'g');
|
||||||
var matches = str.match(regexp);
|
var matches = str.match(regexp);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var j=0; j<matches.length; j++) {
|
for (var j=0; j<matches.length; j++) {
|
||||||
var match = matches[j];
|
var match = matches[j];
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
if (match.split('+').length > 1) {
|
if (match.split('+').length > 1) {
|
||||||
offset = match.split('+')[1];
|
offset = match.split('+')[1];
|
||||||
} else if (match.split('-').length > 1) {
|
} else if (match.split('-').length > 1) {
|
||||||
offset = parseInt(match.split('-')[1]) * -1;
|
offset = parseInt(match.split('-')[1]) * -1;
|
||||||
}
|
}
|
||||||
str = str.replace(match, getDatePart(variable, offset));
|
str = str.replace(match, getDatePart(variable, offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ function getMonth(offset) {
|
|||||||
var months = [ "January", "February", "March", "April", "May", "June",
|
var months = [ "January", "February", "March", "April", "May", "June",
|
||||||
"July", "August", "September", "October", "November", "December" ];
|
"July", "August", "September", "October", "November", "December" ];
|
||||||
var month = today.getMonth();
|
var month = today.getMonth();
|
||||||
month = parseInt(month) + offset;
|
month = parseInt(month) + offset;
|
||||||
month = month % 12;
|
month = month % 12;
|
||||||
if (month < 0) {
|
if (month < 0) {
|
||||||
month += 12;
|
month += 12;
|
||||||
@ -202,7 +202,7 @@ function getQuarter(offset) {
|
|||||||
quarter += offset;
|
quarter += offset;
|
||||||
quarter = quarter % 4;
|
quarter = quarter % 4;
|
||||||
if (quarter == 0) {
|
if (quarter == 0) {
|
||||||
quarter = 4;
|
quarter = 4;
|
||||||
}
|
}
|
||||||
return 'Q' + quarter;
|
return 'Q' + quarter;
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ function enableHoverClick($combobox, $entityId, url) {
|
|||||||
setAsLink($combobox, false);
|
setAsLink($combobox, false);
|
||||||
}).on('click', function() {
|
}).on('click', function() {
|
||||||
var clientId = $entityId.val();
|
var clientId = $entityId.val();
|
||||||
if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {
|
if ($(combobox).closest('.combobox-container').hasClass('combobox-selected')) {
|
||||||
if (parseInt(clientId) > 0) {
|
if (parseInt(clientId) > 0) {
|
||||||
window.open(url + '/' + clientId, '_blank');
|
window.open(url + '/' + clientId, '_blank');
|
||||||
} else {
|
} else {
|
||||||
@ -405,10 +405,10 @@ function enableHoverClick($combobox, $entityId, url) {
|
|||||||
function setAsLink($input, enable) {
|
function setAsLink($input, enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
$input.css('text-decoration','underline');
|
$input.css('text-decoration','underline');
|
||||||
$input.css('cursor','pointer');
|
$input.css('cursor','pointer');
|
||||||
} else {
|
} else {
|
||||||
$input.css('text-decoration','none');
|
$input.css('text-decoration','none');
|
||||||
$input.css('cursor','text');
|
$input.css('cursor','text');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,45 +439,45 @@ if (window.ko) {
|
|||||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||||
if (id) $(element).val(id);
|
if (id) $(element).val(id);
|
||||||
//console.log("combo-init: %s", id);
|
//console.log("combo-init: %s", id);
|
||||||
$(element).combobox(options);
|
$(element).combobox(options);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ko.utils.registerEventHandler(element, "change", function () {
|
ko.utils.registerEventHandler(element, "change", function () {
|
||||||
console.log("change: %s", $(element).val());
|
console.log("change: %s", $(element).val());
|
||||||
//var
|
//var
|
||||||
valueAccessor($(element).val());
|
valueAccessor($(element).val());
|
||||||
//$(element).combobox('refresh');
|
//$(element).combobox('refresh');
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
},
|
},
|
||||||
update: function (element, valueAccessor) {
|
update: function (element, valueAccessor) {
|
||||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||||
//console.log("combo-update: %s", id);
|
//console.log("combo-update: %s", id);
|
||||||
if (id) {
|
if (id) {
|
||||||
$(element).val(id);
|
$(element).val(id);
|
||||||
$(element).combobox('refresh');
|
$(element).combobox('refresh');
|
||||||
} else {
|
} else {
|
||||||
$(element).combobox('clearTarget');
|
$(element).combobox('clearTarget');
|
||||||
$(element).combobox('clearElement');
|
$(element).combobox('clearElement');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ko.bindingHandlers.datePicker = {
|
ko.bindingHandlers.datePicker = {
|
||||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||||
if (value) $(element).datepicker('update', value);
|
if (value) $(element).datepicker('update', value);
|
||||||
$(element).change(function() {
|
$(element).change(function() {
|
||||||
var value = valueAccessor();
|
var value = valueAccessor();
|
||||||
value($(element).val());
|
value($(element).val());
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
update: function (element, valueAccessor) {
|
update: function (element, valueAccessor) {
|
||||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||||
if (value) $(element).datepicker('update', value);
|
if (value) $(element).datepicker('update', value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,11 +495,11 @@ function wordWrapText(value, width)
|
|||||||
while (j++ < lines[i].length) {
|
while (j++ < lines[i].length) {
|
||||||
if (lines[i].charAt(j) === ' ') space = j;
|
if (lines[i].charAt(j) === ' ') space = j;
|
||||||
}
|
}
|
||||||
if (space == lines[i].length) space = width/6;
|
if (space == lines[i].length) space = width/6;
|
||||||
lines[i + 1] = lines[i].substring(space + 1) + ' ' + (lines[i + 1] || '');
|
lines[i + 1] = lines[i].substring(space + 1) + ' ' + (lines[i + 1] || '');
|
||||||
lines[i] = lines[i].substring(0, space);
|
lines[i] = lines[i].substring(0, space);
|
||||||
}
|
}
|
||||||
|
|
||||||
var newValue = (lines.join("\n")).trim();
|
var newValue = (lines.join("\n")).trim();
|
||||||
|
|
||||||
if (value == newValue) {
|
if (value == newValue) {
|
||||||
@ -528,14 +528,14 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
var clientMap = {};
|
var clientMap = {};
|
||||||
var invoiceMap = {};
|
var invoiceMap = {};
|
||||||
var invoicesForClientMap = {};
|
var invoicesForClientMap = {};
|
||||||
var $clientSelect = $('select#client');
|
var $clientSelect = $('select#client');
|
||||||
|
|
||||||
for (var i=0; i<invoices.length; i++) {
|
for (var i=0; i<invoices.length; i++) {
|
||||||
var invoice = invoices[i];
|
var invoice = invoices[i];
|
||||||
var client = invoice.client;
|
var client = invoice.client;
|
||||||
|
|
||||||
if (!invoicesForClientMap.hasOwnProperty(client.public_id)) {
|
if (!invoicesForClientMap.hasOwnProperty(client.public_id)) {
|
||||||
invoicesForClientMap[client.public_id] = [];
|
invoicesForClientMap[client.public_id] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
invoicesForClientMap[client.public_id].push(invoice);
|
invoicesForClientMap[client.public_id].push(invoice);
|
||||||
@ -547,28 +547,28 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
clientMap[client.public_id] = client;
|
clientMap[client.public_id] = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
$clientSelect.append(new Option('', ''));
|
$clientSelect.append(new Option('', ''));
|
||||||
for (var i=0; i<clients.length; i++) {
|
for (var i=0; i<clients.length; i++) {
|
||||||
var client = clients[i];
|
var client = clients[i];
|
||||||
$clientSelect.append(new Option(getClientDisplayName(client), client.public_id));
|
$clientSelect.append(new Option(getClientDisplayName(client), client.public_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientId) {
|
if (clientId) {
|
||||||
$clientSelect.val(clientId);
|
$clientSelect.val(clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$clientSelect.combobox();
|
$clientSelect.combobox();
|
||||||
$clientSelect.on('change', function(e) {
|
$clientSelect.on('change', function(e) {
|
||||||
var clientId = $('input[name=client]').val();
|
var clientId = $('input[name=client]').val();
|
||||||
var invoiceId = $('input[name=invoice]').val();
|
var invoiceId = $('input[name=invoice]').val();
|
||||||
var invoice = invoiceMap[invoiceId];
|
var invoice = invoiceMap[invoiceId];
|
||||||
if (invoice && invoice.client.public_id == clientId) {
|
if (invoice && invoice.client.public_id == clientId) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setComboboxValue($('.invoice-select'), '', '');
|
setComboboxValue($('.invoice-select'), '', '');
|
||||||
$invoiceCombobox = $('select#invoice');
|
$invoiceCombobox = $('select#invoice');
|
||||||
$invoiceCombobox.find('option').remove().end().combobox('refresh');
|
$invoiceCombobox.find('option').remove().end().combobox('refresh');
|
||||||
$invoiceCombobox.append(new Option('', ''));
|
$invoiceCombobox.append(new Option('', ''));
|
||||||
var list = clientId ? (invoicesForClientMap.hasOwnProperty(clientId) ? invoicesForClientMap[clientId] : []) : invoices;
|
var list = clientId ? (invoicesForClientMap.hasOwnProperty(clientId) ? invoicesForClientMap[clientId] : []) : invoices;
|
||||||
for (var i=0; i<list.length; i++) {
|
for (var i=0; i<list.length; i++) {
|
||||||
@ -582,11 +582,11 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
$('select#invoice').combobox('refresh');
|
$('select#invoice').combobox('refresh');
|
||||||
});
|
});
|
||||||
|
|
||||||
var $invoiceSelect = $('select#invoice').on('change', function(e) {
|
var $invoiceSelect = $('select#invoice').on('change', function(e) {
|
||||||
$clientCombobox = $('select#client');
|
$clientCombobox = $('select#client');
|
||||||
var invoiceId = $('input[name=invoice]').val();
|
var invoiceId = $('input[name=invoice]').val();
|
||||||
if (invoiceId) {
|
if (invoiceId) {
|
||||||
var invoice = invoiceMap[invoiceId];
|
var invoice = invoiceMap[invoiceId];
|
||||||
var client = clientMap[invoice.client.public_id];
|
var client = clientMap[invoice.client.public_id];
|
||||||
setComboboxValue($('.client-select'), client.public_id, getClientDisplayName(client));
|
setComboboxValue($('.client-select'), client.public_id, getClientDisplayName(client));
|
||||||
if (!parseFloat($('#amount').val())) {
|
if (!parseFloat($('#amount').val())) {
|
||||||
@ -595,7 +595,7 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$invoiceSelect.combobox();
|
$invoiceSelect.combobox();
|
||||||
|
|
||||||
if (invoiceId) {
|
if (invoiceId) {
|
||||||
var invoice = invoiceMap[invoiceId];
|
var invoice = invoiceMap[invoiceId];
|
||||||
@ -610,7 +610,7 @@ function populateInvoiceComboboxes(clientId, invoiceId) {
|
|||||||
$clientSelect.trigger('change');
|
$clientSelect.trigger('change');
|
||||||
} else {
|
} else {
|
||||||
$clientSelect.trigger('change');
|
$clientSelect.trigger('change');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -637,6 +637,7 @@ function displayAccount(doc, invoice, x, y, layout) {
|
|||||||
|
|
||||||
var data1 = [
|
var data1 = [
|
||||||
account.name,
|
account.name,
|
||||||
|
account.id_number,
|
||||||
account.vat_number,
|
account.vat_number,
|
||||||
account.work_email,
|
account.work_email,
|
||||||
account.work_phone
|
account.work_phone
|
||||||
@ -644,10 +645,10 @@ function displayAccount(doc, invoice, x, y, layout) {
|
|||||||
|
|
||||||
var data2 = [
|
var data2 = [
|
||||||
concatStrings(account.address1, account.address2),
|
concatStrings(account.address1, account.address2),
|
||||||
concatStrings(account.city, account.state, account.postal_code),
|
concatStrings(account.city, account.state, account.postal_code),
|
||||||
account.country ? account.country.name : false,
|
account.country ? account.country.name : false,
|
||||||
invoice.account.custom_value1 ? invoice.account['custom_label1'] + ' ' + invoice.account.custom_value1 : false,
|
invoice.account.custom_value1 ? invoice.account['custom_label1'] + ' ' + invoice.account.custom_value1 : false,
|
||||||
invoice.account.custom_value2 ? invoice.account['custom_label2'] + ' ' + invoice.account.custom_value2 : false,
|
invoice.account.custom_value2 ? invoice.account['custom_label2'] + ' ' + invoice.account.custom_value2 : false,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (layout.singleColumn) {
|
if (layout.singleColumn) {
|
||||||
@ -663,7 +664,7 @@ function displayAccount(doc, invoice, x, y, layout) {
|
|||||||
width = Math.max(emailWidth, nameWidth, 120);
|
width = Math.max(emailWidth, nameWidth, 120);
|
||||||
x += width;
|
x += width;
|
||||||
|
|
||||||
displayGrid(doc, invoice, data2, x, y, layout);
|
displayGrid(doc, invoice, data2, x, y, layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,16 +673,17 @@ function displayClient(doc, invoice, x, y, layout) {
|
|||||||
var client = invoice.client;
|
var client = invoice.client;
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = [
|
var data = [
|
||||||
getClientDisplayName(client),
|
getClientDisplayName(client),
|
||||||
|
client.id_number,
|
||||||
client.vat_number,
|
client.vat_number,
|
||||||
concatStrings(client.address1, client.address2),
|
concatStrings(client.address1, client.address2),
|
||||||
concatStrings(client.city, client.state, client.postal_code),
|
concatStrings(client.city, client.state, client.postal_code),
|
||||||
client.country ? client.country.name : false,
|
client.country ? client.country.name : false,
|
||||||
client.contacts && getClientDisplayName(client) != client.contacts[0].email ? client.contacts[0].email : false,
|
client.contacts && getClientDisplayName(client) != client.contacts[0].email ? client.contacts[0].email : false,
|
||||||
invoice.client.custom_value1 ? invoice.account['custom_client_label1'] + ' ' + invoice.client.custom_value1 : false,
|
invoice.client.custom_value1 ? invoice.account['custom_client_label1'] + ' ' + invoice.client.custom_value1 : false,
|
||||||
invoice.client.custom_value2 ? invoice.account['custom_client_label2'] + ' ' + invoice.client.custom_value2 : false,
|
invoice.client.custom_value2 ? invoice.account['custom_client_label2'] + ' ' + invoice.client.custom_value2 : false,
|
||||||
];
|
];
|
||||||
return displayGrid(doc, invoice, data, x, y, layout, {hasheader:true});
|
return displayGrid(doc, invoice, data, x, y, layout, {hasheader:true});
|
||||||
}
|
}
|
||||||
@ -707,7 +709,7 @@ function getInvoiceDetails(invoice) {
|
|||||||
{'invoice_date': invoice.invoice_date},
|
{'invoice_date': invoice.invoice_date},
|
||||||
{'due_date': invoice.due_date},
|
{'due_date': invoice.due_date},
|
||||||
{'balance_due': formatMoney(invoice.balance_amount, invoice.client.currency_id)},
|
{'balance_due': formatMoney(invoice.balance_amount, invoice.client.currency_id)},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInvoiceDetailsHeight(invoice, layout) {
|
function getInvoiceDetailsHeight(invoice, layout) {
|
||||||
@ -741,20 +743,20 @@ function displaySubtotals(doc, layout, invoice, y, rightAlignTitleX)
|
|||||||
{'discount': invoice.discount_amount > 0 ? formatMoney(invoice.discount_amount, invoice.client.currency_id) : false}
|
{'discount': invoice.discount_amount > 0 ? formatMoney(invoice.discount_amount, invoice.client.currency_id) : false}
|
||||||
];
|
];
|
||||||
|
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
||||||
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
|
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
||||||
data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
|
data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
data.push({'tax': invoice.tax_amount > 0 ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false});
|
data.push({'tax': invoice.tax_amount > 0 ? formatMoney(invoice.tax_amount, invoice.client.currency_id) : false});
|
||||||
|
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
||||||
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
|
data.push({'custom_invoice_label1': formatMoney(invoice.custom_value1, invoice.client.currency_id) })
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
||||||
data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
|
data.push({'custom_invoice_label2': formatMoney(invoice.custom_value2, invoice.client.currency_id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
var paid = invoice.amount - invoice.balance;
|
var paid = invoice.amount - invoice.balance;
|
||||||
@ -765,7 +767,7 @@ function displaySubtotals(doc, layout, invoice, y, rightAlignTitleX)
|
|||||||
var options = {
|
var options = {
|
||||||
hasheader: true,
|
hasheader: true,
|
||||||
rightAlignX: 550,
|
rightAlignX: 550,
|
||||||
rightAlignTitleX: rightAlignTitleX
|
rightAlignTitleX: rightAlignTitleX
|
||||||
};
|
};
|
||||||
|
|
||||||
return displayGrid(doc, invoice, data, 300, y, layout, options) + 10;
|
return displayGrid(doc, invoice, data, 300, y, layout, options) + 10;
|
||||||
@ -796,7 +798,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
|
|||||||
var origY = y;
|
var origY = y;
|
||||||
for (var i=0; i<data.length; i++) {
|
for (var i=0; i<data.length; i++) {
|
||||||
doc.setFontType('normal');
|
doc.setFontType('normal');
|
||||||
|
|
||||||
if (invoice.invoice_design_id == 1 && i > 0 && origY === layout.accountTop) {
|
if (invoice.invoice_design_id == 1 && i > 0 && origY === layout.accountTop) {
|
||||||
SetPdfColor('GrayText',doc);
|
SetPdfColor('GrayText',doc);
|
||||||
}
|
}
|
||||||
@ -810,7 +812,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
|
|||||||
doc.setFontType('bold');
|
doc.setFontType('bold');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof row === 'object') {
|
if (typeof row === 'object') {
|
||||||
for (var key in row) {
|
for (var key in row) {
|
||||||
if (row.hasOwnProperty(key)) {
|
if (row.hasOwnProperty(key)) {
|
||||||
var value = row[key] ? row[key] + '' : false;
|
var value = row[key] ? row[key] + '' : false;
|
||||||
@ -818,16 +820,16 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
|
|||||||
}
|
}
|
||||||
if (!value) {
|
if (!value) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var marginLeft;
|
var marginLeft;
|
||||||
if (options.rightAlignX) {
|
if (options.rightAlignX) {
|
||||||
marginLeft = options.rightAlignX - (doc.getStringUnitWidth(value) * doc.internal.getFontSize());
|
marginLeft = options.rightAlignX - (doc.getStringUnitWidth(value) * doc.internal.getFontSize());
|
||||||
} else {
|
} else {
|
||||||
marginLeft = x + 80;
|
marginLeft = x + 80;
|
||||||
}
|
}
|
||||||
doc.text(marginLeft, y, value);
|
doc.text(marginLeft, y, value);
|
||||||
|
|
||||||
doc.setFontType('normal');
|
doc.setFontType('normal');
|
||||||
if (invoice.is_quote) {
|
if (invoice.is_quote) {
|
||||||
if (key == 'invoice_number') {
|
if (key == 'invoice_number') {
|
||||||
@ -853,7 +855,7 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
|
|||||||
marginLeft = x;
|
marginLeft = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.text(marginLeft, y, key);
|
doc.text(marginLeft, y, key);
|
||||||
} else {
|
} else {
|
||||||
doc.text(x, y, row);
|
doc.text(x, y, row);
|
||||||
}
|
}
|
||||||
@ -872,16 +874,16 @@ function displayNotesAndTerms(doc, layout, invoice, y)
|
|||||||
|
|
||||||
if (invoice.public_notes) {
|
if (invoice.public_notes) {
|
||||||
doc.text(layout.marginLeft, y, invoice.public_notes);
|
doc.text(layout.marginLeft, y, invoice.public_notes);
|
||||||
y += 16 + (doc.splitTextToSize(invoice.public_notes, 300).length * doc.internal.getFontSize());
|
y += 16 + (doc.splitTextToSize(invoice.public_notes, 300).length * doc.internal.getFontSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoice.terms) {
|
if (invoice.terms) {
|
||||||
doc.setFontType("bold");
|
doc.setFontType("bold");
|
||||||
doc.text(layout.marginLeft, y, invoiceLabels.terms);
|
doc.text(layout.marginLeft, y, invoiceLabels.terms);
|
||||||
y += 16;
|
y += 16;
|
||||||
doc.setFontType("normal");
|
doc.setFontType("normal");
|
||||||
doc.text(layout.marginLeft, y, invoice.terms);
|
doc.text(layout.marginLeft, y, invoice.terms);
|
||||||
y += 16 + (doc.splitTextToSize(invoice.terms, 300).length * doc.internal.getFontSize());
|
y += 16 + (doc.splitTextToSize(invoice.terms, 300).length * doc.internal.getFontSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
return y - origY;
|
return y - origY;
|
||||||
@ -898,7 +900,7 @@ function calculateAmounts(invoice) {
|
|||||||
tax = parseFloat(item.tax.rate);
|
tax = parseFloat(item.tax.rate);
|
||||||
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
|
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
|
||||||
tax = parseFloat(item.tax_rate);
|
tax = parseFloat(item.tax_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
|
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
|
||||||
if (tax) {
|
if (tax) {
|
||||||
@ -921,11 +923,11 @@ function calculateAmounts(invoice) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// custom fields with taxes
|
// custom fields with taxes
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
||||||
total += roundToTwo(invoice.custom_value1);
|
total += roundToTwo(invoice.custom_value1);
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
||||||
total += roundToTwo(invoice.custom_value2);
|
total += roundToTwo(invoice.custom_value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var tax = 0;
|
var tax = 0;
|
||||||
@ -941,11 +943,11 @@ function calculateAmounts(invoice) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// custom fields w/o with taxes
|
// custom fields w/o with taxes
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
||||||
total += roundToTwo(invoice.custom_value1);
|
total += roundToTwo(invoice.custom_value1);
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
||||||
total += roundToTwo(invoice.custom_value2);
|
total += roundToTwo(invoice.custom_value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
invoice.balance_amount = roundToTwo(total) - (roundToTwo(invoice.amount) - roundToTwo(invoice.balance));
|
invoice.balance_amount = roundToTwo(total) - (roundToTwo(invoice.amount) - roundToTwo(invoice.balance));
|
||||||
@ -962,7 +964,7 @@ function getInvoiceTaxRate(invoice) {
|
|||||||
tax = parseFloat(invoice.tax.rate);
|
tax = parseFloat(invoice.tax.rate);
|
||||||
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
|
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
|
||||||
tax = parseFloat(invoice.tax_rate);
|
tax = parseFloat(invoice.tax_rate);
|
||||||
}
|
}
|
||||||
return tax;
|
return tax;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1003,9 +1005,9 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
var line = 1;
|
var line = 1;
|
||||||
var total = 0;
|
var total = 0;
|
||||||
var shownItem = false;
|
var shownItem = false;
|
||||||
var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
|
var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
|
||||||
var tableTop = layout.tableTop;
|
var tableTop = layout.tableTop;
|
||||||
var hideQuantity = invoice.account.hide_quantity == '1';
|
var hideQuantity = invoice.account.hide_quantity == '1';
|
||||||
|
|
||||||
doc.setFontSize(8);
|
doc.setFontSize(8);
|
||||||
for (var i=0; i<invoice.invoice_items.length; i++) {
|
for (var i=0; i<invoice.invoice_items.length; i++) {
|
||||||
@ -1019,12 +1021,12 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
tax = parseFloat(item.tax.rate);
|
tax = parseFloat(item.tax.rate);
|
||||||
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
|
} else if (item.tax_rate && parseFloat(item.tax_rate)) {
|
||||||
tax = parseFloat(item.tax_rate);
|
tax = parseFloat(item.tax_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// show at most one blank line
|
// show at most one blank line
|
||||||
if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) {
|
if (shownItem && (!cost || cost == '0.00') && !notes && !productKey) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
shownItem = true;
|
shownItem = true;
|
||||||
|
|
||||||
var numLines = doc.splitTextToSize(item.notes, 200).length + 2;
|
var numLines = doc.splitTextToSize(item.notes, 200).length + 2;
|
||||||
@ -1072,18 +1074,18 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
|
|
||||||
|
|
||||||
if (invoice.invoice_design_id == 1) {
|
if (invoice.invoice_design_id == 1) {
|
||||||
if (i%2 == 0) {
|
if (i%2 == 0) {
|
||||||
doc.setDrawColor(255,255,255);
|
doc.setDrawColor(255,255,255);
|
||||||
doc.setFillColor(246,246,246);
|
doc.setFillColor(246,246,246);
|
||||||
doc.rect(left, top, width-left, newTop-top, 'FD');
|
doc.rect(left, top, width-left, newTop-top, 'FD');
|
||||||
|
|
||||||
doc.setLineWidth(0.3);
|
doc.setLineWidth(0.3);
|
||||||
doc.setDrawColor(200,200,200);
|
doc.setDrawColor(200,200,200);
|
||||||
doc.line(left, top, width, top);
|
doc.line(left, top, width, top);
|
||||||
doc.line(left, newTop, width, newTop);
|
doc.line(left, newTop, width, newTop);
|
||||||
}
|
}
|
||||||
} else if (invoice.invoice_design_id == 2) {
|
} else if (invoice.invoice_design_id == 2) {
|
||||||
if (i%2 == 0) {
|
if (i%2 == 0) {
|
||||||
left = 0;
|
left = 0;
|
||||||
width = 1000;
|
width = 1000;
|
||||||
|
|
||||||
@ -1093,17 +1095,17 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else if (invoice.invoice_design_id == 5) {
|
} else if (invoice.invoice_design_id == 5) {
|
||||||
if (i%2 == 0) {
|
if (i%2 == 0) {
|
||||||
doc.setDrawColor(255,255,255);
|
doc.setDrawColor(255,255,255);
|
||||||
doc.setFillColor(247,247,247);
|
doc.setFillColor(247,247,247);
|
||||||
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
||||||
} else {
|
} else {
|
||||||
doc.setDrawColor(255,255,255);
|
doc.setDrawColor(255,255,255);
|
||||||
doc.setFillColor(232,232,232);
|
doc.setFillColor(232,232,232);
|
||||||
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
||||||
}
|
}
|
||||||
} else if (invoice.invoice_design_id == 6) {
|
} else if (invoice.invoice_design_id == 6) {
|
||||||
if (i%2 == 0) {
|
if (i%2 == 0) {
|
||||||
doc.setDrawColor(232,232,232);
|
doc.setDrawColor(232,232,232);
|
||||||
doc.setFillColor(232,232,232);
|
doc.setFillColor(232,232,232);
|
||||||
doc.rect(left, top, width-left, newTop-top, 'FD');
|
doc.rect(left, top, width-left, newTop-top, 'FD');
|
||||||
@ -1177,7 +1179,7 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
|
|
||||||
doc.line(qtyX-45, y-16,qtyX-45, y+55);
|
doc.line(qtyX-45, y-16,qtyX-45, y+55);
|
||||||
|
|
||||||
if (invoice.has_taxes) {
|
if (invoice.has_taxes) {
|
||||||
doc.line(taxX-15, y-16,taxX-15, y+55);
|
doc.line(taxX-15, y-16,taxX-15, y+55);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1229,7 +1231,7 @@ function displayInvoiceItems(doc, invoice, layout) {
|
|||||||
if (tax) {
|
if (tax) {
|
||||||
doc.text(taxX, y+2, tax+'%');
|
doc.text(taxX, y+2, tax+'%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y = tableTop + (line * layout.tableRowHeight) + (3 * layout.tablePadding);
|
y = tableTop + (line * layout.tableRowHeight) + (3 * layout.tablePadding);
|
||||||
|
|
||||||
@ -1503,6 +1505,6 @@ function roundToTwo(num, toString) {
|
|||||||
return toString ? val.toFixed(2) : val;
|
return toString ? val.toFixed(2) : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate(str, length) {
|
function truncate(str, length) {
|
||||||
return (str && str.length > length) ? (str.substr(0, length-1) + '...') : str;
|
return (str && str.length > length) ? (str.substr(0, length-1) + '...') : str;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user