mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-20 08:21:34 +02:00
Merge pull request #911 from haleksandre/invoice-subtotals
Add custom labelling and style to multiple labels and amount in the subtotals table
This commit is contained in:
commit
31fc4ad59c
@ -975,7 +975,7 @@ class AccountController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$labels = [];
|
$labels = [];
|
||||||
foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms', 'balance_due', 'partial_due'] as $field) {
|
foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms', 'balance_due', 'partial_due', 'subtotal', 'paid_to_date', 'discount'] as $field) {
|
||||||
$labels[$field] = Input::get("labels_{$field}");
|
$labels[$field] = Input::get("labels_{$field}");
|
||||||
}
|
}
|
||||||
$account->invoice_labels = json_encode($labels);
|
$account->invoice_labels = json_encode($labels);
|
||||||
|
149
public/built.js
149
public/built.js
File diff suppressed because one or more lines are too long
@ -13,7 +13,7 @@ NINJA.TEMPLATES = {
|
|||||||
PHOTO:"10"
|
PHOTO:"10"
|
||||||
};
|
};
|
||||||
|
|
||||||
function GetPdfMake(invoice, javascript, callback) {
|
function GetPdfMake(invoice, javascript, callback) {
|
||||||
|
|
||||||
javascript = NINJA.decodeJavascript(invoice, javascript);
|
javascript = NINJA.decodeJavascript(invoice, javascript);
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ function GetPdfMake(invoice, javascript, callback) {
|
|||||||
val = NINJA.parseMarkdownText(val, false);
|
val = NINJA.parseMarkdownText(val, false);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,10 +95,10 @@ function GetPdfMake(invoice, javascript, callback) {
|
|||||||
dd.footer[1].columns[0].stack.push({image: logoImages.imageLogo3, alignment: 'left', width: 130, margin: [40, 6, 0, 0]});
|
dd.footer[1].columns[0].stack.push({image: logoImages.imageLogo3, alignment: 'left', width: 130, margin: [40, 6, 0, 0]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set page size
|
// set page size
|
||||||
dd.pageSize = invoice.account.page_size;
|
dd.pageSize = invoice.account.page_size;
|
||||||
|
|
||||||
pdfMake.fonts = {}
|
pdfMake.fonts = {}
|
||||||
fonts = window.invoiceFonts || invoice.invoice_fonts;
|
fonts = window.invoiceFonts || invoice.invoice_fonts;
|
||||||
|
|
||||||
@ -119,15 +119,15 @@ function GetPdfMake(invoice, javascript, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dd.defaultStyle)dd.defaultStyle = {font:NINJA.bodyFont};
|
if(!dd.defaultStyle)dd.defaultStyle = {font:NINJA.bodyFont};
|
||||||
else if(!dd.defaultStyle.font)dd.defaultStyle.font = NINJA.bodyFont;
|
else if(!dd.defaultStyle.font)dd.defaultStyle.font = NINJA.bodyFont;
|
||||||
|
|
||||||
doc = pdfMake.createPdf(dd);
|
doc = pdfMake.createPdf(dd);
|
||||||
doc.save = function(fileName) {
|
doc.save = function(fileName) {
|
||||||
this.download(fileName);
|
this.download(fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
|
|||||||
var json = {
|
var json = {
|
||||||
'accountName': account.name || ' ',
|
'accountName': account.name || ' ',
|
||||||
'accountLogo': window.accountLogo || blankImage,
|
'accountLogo': window.accountLogo || blankImage,
|
||||||
'accountDetails': NINJA.accountDetails(invoice),
|
'accountDetails': NINJA.accountDetails(invoice),
|
||||||
'accountAddress': NINJA.accountAddress(invoice),
|
'accountAddress': NINJA.accountAddress(invoice),
|
||||||
'invoiceDetails': NINJA.invoiceDetails(invoice),
|
'invoiceDetails': NINJA.invoiceDetails(invoice),
|
||||||
'invoiceDetailsHeight': (NINJA.invoiceDetails(invoice).length * 16) + 16,
|
'invoiceDetailsHeight': (NINJA.invoiceDetails(invoice).length * 16) + 16,
|
||||||
@ -153,7 +153,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
|
|||||||
'notesAndTerms': NINJA.notesAndTerms(invoice),
|
'notesAndTerms': NINJA.notesAndTerms(invoice),
|
||||||
'subtotals': NINJA.subtotals(invoice),
|
'subtotals': NINJA.subtotals(invoice),
|
||||||
'subtotalsHeight': (NINJA.subtotals(invoice).length * 16) + 16,
|
'subtotalsHeight': (NINJA.subtotals(invoice).length * 16) + 16,
|
||||||
'subtotalsWithoutBalance': NINJA.subtotals(invoice, true),
|
'subtotalsWithoutBalance': NINJA.subtotals(invoice, true),
|
||||||
'subtotalsBalance': NINJA.subtotalsBalance(invoice),
|
'subtotalsBalance': NINJA.subtotalsBalance(invoice),
|
||||||
'balanceDue': formatMoneyInvoice(invoice.balance_amount, invoice),
|
'balanceDue': formatMoneyInvoice(invoice.balance_amount, invoice),
|
||||||
'invoiceFooter': NINJA.invoiceFooter(invoice),
|
'invoiceFooter': NINJA.invoiceFooter(invoice),
|
||||||
@ -181,10 +181,10 @@ NINJA.decodeJavascript = function(invoice, javascript)
|
|||||||
javascript = javascript.replace(regExp, val);
|
javascript = javascript.replace(regExp, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// search/replace labels
|
// search/replace labels
|
||||||
var regExp = new RegExp('"\\$\\\w*?Label(UC)?(:)?(\\\?)?"', 'g');
|
var regExp = new RegExp('"\\$\\\w*?Label(UC)?(:)?(\\\?)?"', 'g');
|
||||||
var matches = javascript.match(regExp);
|
var matches = javascript.match(regExp);
|
||||||
|
|
||||||
if (matches) {
|
if (matches) {
|
||||||
for (var i=0; i<matches.length; i++) {
|
for (var i=0; i<matches.length; i++) {
|
||||||
var match = matches[i];
|
var match = matches[i];
|
||||||
@ -208,12 +208,12 @@ NINJA.decodeJavascript = function(invoice, javascript)
|
|||||||
label = ' ';
|
label = ' ';
|
||||||
}
|
}
|
||||||
javascript = javascript.replace(match, '"'+label+'"');
|
javascript = javascript.replace(match, '"'+label+'"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// search/replace values
|
// search/replace values
|
||||||
var regExp = new RegExp('"\\$[a-z][\\\w\\\.]*?[Value]?"', 'g');
|
var regExp = new RegExp('"\\$[a-z][\\\w\\\.]*?[Value]?"', 'g');
|
||||||
var matches = javascript.match(regExp);
|
var matches = javascript.match(regExp);
|
||||||
|
|
||||||
if (matches) {
|
if (matches) {
|
||||||
for (var i=0; i<matches.length; i++) {
|
for (var i=0; i<matches.length; i++) {
|
||||||
@ -229,7 +229,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
|
|||||||
field = match.substring(2, match.indexOf('Value'));
|
field = match.substring(2, match.indexOf('Value'));
|
||||||
} else {
|
} else {
|
||||||
field = match.substring(2, match.length - 1);
|
field = match.substring(2, match.length - 1);
|
||||||
}
|
}
|
||||||
field = toSnakeCase(field);
|
field = toSnakeCase(field);
|
||||||
|
|
||||||
var value = getDescendantProp(invoice, field) || ' ';
|
var value = getDescendantProp(invoice, field) || ' ';
|
||||||
@ -336,7 +336,7 @@ NINJA.invoiceLines = function(invoice) {
|
|||||||
}
|
}
|
||||||
if (invoice.features.invoice_ettings && account.custom_invoice_item_label2) {
|
if (invoice.features.invoice_ettings && account.custom_invoice_item_label2) {
|
||||||
grid[0].push({text: account.custom_invoice_item_label2, style: ['tableHeader', 'custom2TableHeader']});
|
grid[0].push({text: account.custom_invoice_item_label2, style: ['tableHeader', 'custom2TableHeader']});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hideQuantity) {
|
if (!hideQuantity) {
|
||||||
grid[0].push({text: invoiceLabels.unit_cost, style: ['tableHeader', 'costTableHeader']});
|
grid[0].push({text: invoiceLabels.unit_cost, style: ['tableHeader', 'costTableHeader']});
|
||||||
@ -356,11 +356,11 @@ NINJA.invoiceLines = function(invoice) {
|
|||||||
var qty = NINJA.parseFloat(item.qty) ? roundToTwo(NINJA.parseFloat(item.qty)) + '' : '';
|
var qty = NINJA.parseFloat(item.qty) ? roundToTwo(NINJA.parseFloat(item.qty)) + '' : '';
|
||||||
var notes = item.notes;
|
var notes = item.notes;
|
||||||
var productKey = item.product_key;
|
var productKey = item.product_key;
|
||||||
var tax1 = '';
|
var tax1 = '';
|
||||||
var tax2 = '';
|
var tax2 = '';
|
||||||
var custom_value1 = item.custom_value1;
|
var custom_value1 = item.custom_value1;
|
||||||
var custom_value2 = item.custom_value2;
|
var custom_value2 = item.custom_value2;
|
||||||
|
|
||||||
if (showItemTaxes) {
|
if (showItemTaxes) {
|
||||||
if (item.tax_name1) {
|
if (item.tax_name1) {
|
||||||
tax1 = parseFloat(item.tax_rate1);
|
tax1 = parseFloat(item.tax_rate1);
|
||||||
@ -389,11 +389,11 @@ NINJA.invoiceLines = function(invoice) {
|
|||||||
lineTotal = formatMoneyInvoice(lineTotal, invoice);
|
lineTotal = formatMoneyInvoice(lineTotal, invoice);
|
||||||
|
|
||||||
rowStyle = (i % 2 == 0) ? 'odd' : 'even';
|
rowStyle = (i % 2 == 0) ? 'odd' : 'even';
|
||||||
|
|
||||||
if (invoice.has_product_key) {
|
if (invoice.has_product_key) {
|
||||||
row.push({style:["productKey", rowStyle], text:productKey || ' '}); // product key can be blank when selecting from a datalist
|
row.push({style:["productKey", rowStyle], text:productKey || ' '}); // product key can be blank when selecting from a datalist
|
||||||
}
|
}
|
||||||
row.push({style:["notes", rowStyle], stack:[{text:notes || ' '}]});
|
row.push({style:["notes", rowStyle], stack:[{text:notes || ' '}]});
|
||||||
if (invoice.features.invoice_settings && account.custom_invoice_item_label1) {
|
if (invoice.features.invoice_settings && account.custom_invoice_item_label1) {
|
||||||
row.push({style:["customValue1", rowStyle], text:custom_value1 || ' '});
|
row.push({style:["customValue1", rowStyle], text:custom_value1 || ' '});
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ NINJA.invoiceLines = function(invoice) {
|
|||||||
row.push({style:["lineTotal", rowStyle], text:lineTotal || ' '});
|
row.push({style:["lineTotal", rowStyle], text:lineTotal || ' '});
|
||||||
|
|
||||||
grid.push(row);
|
grid.push(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NINJA.prepareDataTable(grid, 'invoiceItems');
|
return NINJA.prepareDataTable(grid, 'invoiceItems');
|
||||||
}
|
}
|
||||||
@ -429,20 +429,20 @@ NINJA.invoiceDocuments = function(invoice) {
|
|||||||
if(!invoice.account.invoice_embed_documents)return[];
|
if(!invoice.account.invoice_embed_documents)return[];
|
||||||
var stack = [];
|
var stack = [];
|
||||||
var stackItem = null;
|
var stackItem = null;
|
||||||
|
|
||||||
var j = 0;
|
var j = 0;
|
||||||
for (var i = 0; i < invoice.documents.length; i++)addDoc(invoice.documents[i]);
|
for (var i = 0; i < invoice.documents.length; i++)addDoc(invoice.documents[i]);
|
||||||
|
|
||||||
if(invoice.expenses){
|
if(invoice.expenses){
|
||||||
for (var i = 0; i < invoice.expenses.length; i++) {
|
for (var i = 0; i < invoice.expenses.length; i++) {
|
||||||
var expense = invoice.expenses[i];
|
var expense = invoice.expenses[i];
|
||||||
for (var i = 0; i < expense.documents.length; i++)addDoc(expense.documents[i]);
|
for (var i = 0; i < expense.documents.length; i++)addDoc(expense.documents[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDoc(document){
|
function addDoc(document){
|
||||||
var path = document.base64;
|
var path = document.base64;
|
||||||
|
|
||||||
if(!path)path = 'docs/'+document.public_id+'/'+document.name;
|
if(!path)path = 'docs/'+document.public_id+'/'+document.name;
|
||||||
if(path && (window.pdfMake.vfs[path] || document.base64)){
|
if(path && (window.pdfMake.vfs[path] || document.base64)){
|
||||||
// Only embed if we actually have an image for it
|
// Only embed if we actually have an image for it
|
||||||
@ -466,65 +466,65 @@ NINJA.subtotals = function(invoice, hideBalance)
|
|||||||
|
|
||||||
var account = invoice.account;
|
var account = invoice.account;
|
||||||
var data = [];
|
var data = [];
|
||||||
data.push([{text: invoiceLabels.subtotal}, {text: formatMoneyInvoice(invoice.subtotal_amount, invoice)}]);
|
data.push([{text: invoiceLabels.subtotal, style: ['subtotalsLabel', 'subtotalLabel']}, {text: formatMoneyInvoice(invoice.subtotal_amount, invoice), style: ['subtotals', 'subtotal']}]);
|
||||||
|
|
||||||
if (invoice.discount_amount != 0) {
|
if (invoice.discount_amount != 0) {
|
||||||
data.push([{text: invoiceLabels.discount}, {text: formatMoneyInvoice(invoice.discount_amount, invoice)}]);
|
data.push([{text: invoiceLabels.discount , style: ['subtotalsLabel', 'discountLabel']}, {text: formatMoneyInvoice(invoice.discount_amount, invoice), style: ['subtotals', 'discount']}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 == '1') {
|
||||||
data.push([{text: account.custom_invoice_label1}, {text: formatMoneyInvoice(invoice.custom_value1, invoice)}]);
|
data.push([{text: account.custom_invoice_label1, style: ['subtotalsLabel', 'customTax1Label']}, {text: formatMoneyInvoice(invoice.custom_value1, invoice), style: ['subtotals', 'customTax1']}]);
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 == '1') {
|
||||||
data.push([{text: account.custom_invoice_label2}, {text: formatMoneyInvoice(invoice.custom_value2, invoice)}]);
|
data.push([{text: account.custom_invoice_label2, style: ['subtotalsLabel', 'customTax2Label']}, {text: formatMoneyInvoice(invoice.custom_value2, invoice), style: ['subtotals', 'customTax2']}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var key in invoice.item_taxes) {
|
for (var key in invoice.item_taxes) {
|
||||||
if (invoice.item_taxes.hasOwnProperty(key)) {
|
if (invoice.item_taxes.hasOwnProperty(key)) {
|
||||||
var taxRate = invoice.item_taxes[key];
|
var taxRate = invoice.item_taxes[key];
|
||||||
var taxStr = taxRate.name + ' ' + (taxRate.rate*1).toString() + '%';
|
var taxStr = taxRate.name + ' ' + (taxRate.rate*1).toString() + '%';
|
||||||
data.push([{text: taxStr}, {text: formatMoneyInvoice(taxRate.amount, invoice)}]);
|
data.push([{text: taxStr, style: ['subtotalsLabel', 'taxLabel']}, {text: formatMoneyInvoice(taxRate.amount, invoice), style: ['subtotals', 'tax']}]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoice.tax_amount1) {
|
if (invoice.tax_amount1) {
|
||||||
var taxStr = invoice.tax_name1 + ' ' + (invoice.tax_rate1*1).toString() + '%';
|
var taxStr = invoice.tax_name1 + ' ' + (invoice.tax_rate1*1).toString() + '%';
|
||||||
data.push([{text: taxStr}, {text: formatMoneyInvoice(invoice.tax_amount1, invoice)}]);
|
data.push([{text: taxStr, style: ['subtotalsLabel', 'tax1Label']}, {text: formatMoneyInvoice(invoice.tax_amount1, invoice), style: ['subtotals', 'tax1']}]);
|
||||||
}
|
}
|
||||||
if (invoice.tax_amount2) {
|
if (invoice.tax_amount2) {
|
||||||
var taxStr = invoice.tax_name2 + ' ' + (invoice.tax_rate2*1).toString() + '%';
|
var taxStr = invoice.tax_name2 + ' ' + (invoice.tax_rate2*1).toString() + '%';
|
||||||
data.push([{text: taxStr}, {text: formatMoneyInvoice(invoice.tax_amount2, invoice)}]);
|
data.push([{text: taxStr, style: ['subtotalsLabel', 'tax2Label']}, {text: formatMoneyInvoice(invoice.tax_amount2, invoice), style: ['subtotals', 'tax2']}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {
|
||||||
data.push([{text: account.custom_invoice_label1}, {text: formatMoneyInvoice(invoice.custom_value1, invoice)}]);
|
data.push([{text: account.custom_invoice_label1, style: ['subtotalsLabel', 'custom1Label']}, {text: formatMoneyInvoice(invoice.custom_value1, invoice), style: ['subtotals', 'custom1']}]);
|
||||||
}
|
}
|
||||||
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
if (NINJA.parseFloat(invoice.custom_value2) && invoice.custom_taxes2 != '1') {
|
||||||
data.push([{text: account.custom_invoice_label2}, {text: formatMoneyInvoice(invoice.custom_value2, invoice)}]);
|
data.push([{text: account.custom_invoice_label2, style: ['subtotalsLabel', 'custom2Label']}, {text: formatMoneyInvoice(invoice.custom_value2, invoice), style: ['subtotals', 'custom2']}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var paid = invoice.amount - invoice.balance;
|
var paid = invoice.amount - invoice.balance;
|
||||||
if (invoice.account.hide_paid_to_date != '1' || paid) {
|
if (invoice.account.hide_paid_to_date != '1' || paid) {
|
||||||
data.push([{text:invoiceLabels.paid_to_date}, {text:formatMoneyInvoice(paid, invoice)}]);
|
data.push([{text:invoiceLabels.paid_to_date, style: ['subtotalsLabel', 'paidToDateLabel']}, {text:formatMoneyInvoice(paid, invoice), style: ['subtotals', 'paidToDate']}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPartial = NINJA.parseFloat(invoice.partial);
|
var isPartial = NINJA.parseFloat(invoice.partial);
|
||||||
|
|
||||||
if (!hideBalance || isPartial) {
|
if (!hideBalance || isPartial) {
|
||||||
data.push([
|
data.push([
|
||||||
{ text: invoiceLabels.balance_due, style: [isPartial ? '' : 'balanceDueLabel'] },
|
{ text: invoiceLabels.balance_due, style: ['subtotalsLabel', isPartial ? '' : 'balanceDueLabel'] },
|
||||||
{ text: formatMoneyInvoice(invoice.total_amount, invoice), style: [isPartial ? '' : 'balanceDue'] }
|
{ text: formatMoneyInvoice(invoice.total_amount, invoice), style: ['subtotals', isPartial ? '' : 'balanceDue'] }
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hideBalance) {
|
if (!hideBalance) {
|
||||||
if (isPartial) {
|
if (isPartial) {
|
||||||
data.push([
|
data.push([
|
||||||
{ text: invoiceLabels.partial_due, style: ['balanceDueLabel'] },
|
{ text: invoiceLabels.partial_due, style: ['subtotalsLabel', 'balanceDueLabel'] },
|
||||||
{ text: formatMoneyInvoice(invoice.balance_amount, invoice), style: ['balanceDue'] }
|
{ text: formatMoneyInvoice(invoice.balance_amount, invoice), style: ['subtotals', 'balanceDue'] }
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NINJA.prepareDataPairs(data, 'subtotals');
|
return NINJA.prepareDataPairs(data, 'subtotals');
|
||||||
}
|
}
|
||||||
@ -532,8 +532,8 @@ NINJA.subtotals = function(invoice, hideBalance)
|
|||||||
NINJA.subtotalsBalance = function(invoice) {
|
NINJA.subtotalsBalance = function(invoice) {
|
||||||
var isPartial = NINJA.parseFloat(invoice.partial);
|
var isPartial = NINJA.parseFloat(invoice.partial);
|
||||||
return [[
|
return [[
|
||||||
{text: isPartial ? invoiceLabels.partial_due : invoiceLabels.balance_due, style:['balanceDueLabel']},
|
{text: isPartial ? invoiceLabels.partial_due : invoiceLabels.balance_due, style:['subtotalsLabel', 'balanceDueLabel']},
|
||||||
{text: formatMoneyInvoice(invoice.balance_amount, invoice), style:['balanceDue']}
|
{text: formatMoneyInvoice(invoice.balance_amount, invoice), style:['subtotals', 'balanceDue']}
|
||||||
]];
|
]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,18 +541,18 @@ NINJA.accountDetails = function(invoice) {
|
|||||||
var account = invoice.account;
|
var account = invoice.account;
|
||||||
var data = [
|
var data = [
|
||||||
{text:account.name, style: ['accountName']},
|
{text:account.name, style: ['accountName']},
|
||||||
{text:account.id_number},
|
{text:account.id_number, style: ['idNumber']},
|
||||||
{text:account.vat_number},
|
{text:account.vat_number, style: ['vatNumber']},
|
||||||
{text:account.website},
|
{text:account.website, style: ['website']},
|
||||||
{text:account.work_email},
|
{text:account.work_email, style: ['email']},
|
||||||
{text:account.work_phone}
|
{text:account.work_phone, style: ['phone']}
|
||||||
];
|
];
|
||||||
return NINJA.prepareDataList(data, 'accountDetails');
|
return NINJA.prepareDataList(data, 'accountDetails');
|
||||||
}
|
}
|
||||||
|
|
||||||
NINJA.accountAddress = function(invoice) {
|
NINJA.accountAddress = function(invoice) {
|
||||||
var account = invoice.account;
|
var account = invoice.account;
|
||||||
var cityStatePostal = '';
|
var cityStatePostal = '';
|
||||||
if (account.city || account.state || account.postal_code) {
|
if (account.city || account.state || account.postal_code) {
|
||||||
var swap = account.country && account.country.swap_postal_code;
|
var swap = account.country && account.country.swap_postal_code;
|
||||||
cityStatePostal = formatAddress(account.city, account.state, account.postal_code, swap);
|
cityStatePostal = formatAddress(account.city, account.state, account.postal_code, swap);
|
||||||
@ -580,15 +580,15 @@ NINJA.invoiceDetails = function(invoice) {
|
|||||||
{text: invoice.invoice_number, style: ['invoiceNumber']}
|
{text: invoice.invoice_number, style: ['invoiceNumber']}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{text: invoiceLabels.po_number},
|
{text: invoiceLabels.po_number},
|
||||||
{text: invoice.po_number}
|
{text: invoice.po_number}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{text: (invoice.is_quote ? invoiceLabels.quote_date : invoiceLabels.invoice_date)},
|
{text: (invoice.is_quote ? invoiceLabels.quote_date : invoiceLabels.invoice_date)},
|
||||||
{text: invoice.invoice_date}
|
{text: invoice.invoice_date}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{text: (invoice.is_quote ? invoiceLabels.valid_until : invoiceLabels.due_date)},
|
{text: (invoice.is_quote ? invoiceLabels.valid_until : invoiceLabels.due_date)},
|
||||||
{text: invoice.is_recurring ? false : invoice.due_date}
|
{text: invoice.is_recurring ? false : invoice.due_date}
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@ -617,7 +617,7 @@ NINJA.invoiceDetails = function(invoice) {
|
|||||||
{text: formatMoneyInvoice(invoice.balance_amount, invoice), style: ['invoiceDetailBalanceDue']}
|
{text: formatMoneyInvoice(invoice.balance_amount, invoice), style: ['invoiceDetailBalanceDue']}
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
return NINJA.prepareDataPairs(data, 'invoiceDetails');
|
return NINJA.prepareDataPairs(data, 'invoiceDetails');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,7 +630,7 @@ NINJA.clientDetails = function(invoice) {
|
|||||||
var account = invoice.account;
|
var account = invoice.account;
|
||||||
var contact = client.contacts[0];
|
var contact = client.contacts[0];
|
||||||
var clientName = client.name || (contact.first_name || contact.last_name ? (contact.first_name + ' ' + contact.last_name) : contact.email);
|
var clientName = client.name || (contact.first_name || contact.last_name ? (contact.first_name + ' ' + contact.last_name) : contact.email);
|
||||||
var clientEmail = client.contacts[0].email == clientName ? '' : client.contacts[0].email;
|
var clientEmail = client.contacts[0].email == clientName ? '' : client.contacts[0].email;
|
||||||
|
|
||||||
var cityStatePostal = '';
|
var cityStatePostal = '';
|
||||||
if (client.city || client.state || client.postal_code) {
|
if (client.city || client.state || client.postal_code) {
|
||||||
@ -676,25 +676,25 @@ NINJA.prepareDataList = function(oldData, section) {
|
|||||||
newData.push(item);
|
newData.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
NINJA.prepareDataTable = function(oldData, section) {
|
NINJA.prepareDataTable = function(oldData, section) {
|
||||||
var newData = [];
|
var newData = [];
|
||||||
for (var i=0; i<oldData.length; i++) {
|
for (var i=0; i<oldData.length; i++) {
|
||||||
var row = oldData[i];
|
var row = oldData[i];
|
||||||
var newRow = [];
|
var newRow = [];
|
||||||
for (var j=0; j<row.length; j++) {
|
for (var j=0; j<row.length; j++) {
|
||||||
var item = NINJA.processItem(row[j], section);
|
var item = NINJA.processItem(row[j], section);
|
||||||
if (item.text || item.stack) {
|
if (item.text || item.stack) {
|
||||||
newRow.push(item);
|
newRow.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newRow.length) {
|
if (newRow.length) {
|
||||||
newData.push(newRow);
|
newData.push(newRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
NINJA.prepareDataPairs = function(oldData, section) {
|
NINJA.prepareDataPairs = function(oldData, section) {
|
||||||
@ -760,7 +760,7 @@ NINJA.parseMarkdownStack = function(val)
|
|||||||
if (typeof line === 'string') {
|
if (typeof line === 'string') {
|
||||||
line = [line];
|
line = [line];
|
||||||
}
|
}
|
||||||
|
|
||||||
var regExp = '^\\\* (.*[\r\n|\n|\r]?)';
|
var regExp = '^\\\* (.*[\r\n|\n|\r]?)';
|
||||||
var formatter = function(data) {
|
var formatter = function(data) {
|
||||||
return {"ul": [data.text]};
|
return {"ul": [data.text]};
|
||||||
@ -768,7 +768,7 @@ NINJA.parseMarkdownStack = function(val)
|
|||||||
|
|
||||||
val = NINJA.parseRegExp(line, regExp, formatter, false);
|
val = NINJA.parseRegExp(line, regExp, formatter, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@ -777,7 +777,7 @@ NINJA.parseRegExp = function(val, regExpStr, formatter, groupText)
|
|||||||
{
|
{
|
||||||
var regExp = new RegExp(regExpStr, 'gm');
|
var regExp = new RegExp(regExpStr, 'gm');
|
||||||
var parts = [];
|
var parts = [];
|
||||||
|
|
||||||
for (var i=0; i<val.length; i++) {
|
for (var i=0; i<val.length; i++) {
|
||||||
var line = val[i];
|
var line = val[i];
|
||||||
parts = parts.concat(NINJA.parseRegExpLine(line, regExp, formatter, groupText));
|
parts = parts.concat(NINJA.parseRegExpLine(line, regExp, formatter, groupText));
|
||||||
@ -790,7 +790,7 @@ NINJA.parseRegExpLine = function(line, regExp, formatter, groupText)
|
|||||||
{
|
{
|
||||||
var parts = [];
|
var parts = [];
|
||||||
var lastIndex = 0;
|
var lastIndex = 0;
|
||||||
|
|
||||||
while (match = regExp.exec(line)) {
|
while (match = regExp.exec(line)) {
|
||||||
if (match.index > lastIndex) {
|
if (match.index > lastIndex) {
|
||||||
parts.push(line.substring(lastIndex, match.index));
|
parts.push(line.substring(lastIndex, match.index));
|
||||||
@ -810,4 +810,4 @@ NINJA.parseRegExpLine = function(line, regExp, formatter, groupText)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
@ -208,12 +208,15 @@
|
|||||||
{!! Former::text('labels_description')->label(trans('texts.description')) !!}
|
{!! Former::text('labels_description')->label(trans('texts.description')) !!}
|
||||||
{!! Former::text('labels_unit_cost')->label(trans('texts.unit_cost')) !!}
|
{!! Former::text('labels_unit_cost')->label(trans('texts.unit_cost')) !!}
|
||||||
{!! Former::text('labels_quantity')->label(trans('texts.quantity')) !!}
|
{!! Former::text('labels_quantity')->label(trans('texts.quantity')) !!}
|
||||||
|
{!! Former::text('labels_line_total')->label(trans('texts.line_total')) !!}
|
||||||
|
{!! Former::text('labels_terms')->label(trans('texts.terms')) !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{!! Former::text('labels_line_total')->label(trans('texts.line_total')) !!}
|
{!! Former::text('labels_subtotal')->label(trans('texts.subtotal')) !!}
|
||||||
{!! Former::text('labels_terms')->label(trans('texts.terms')) !!}
|
{!! Former::text('labels_discount')->label(trans('texts.discount')) !!}
|
||||||
{!! Former::text('labels_balance_due')->label(trans('texts.balance_due')) !!}
|
{!! Former::text('labels_paid_to_date')->label(trans('texts.paid_to_date')) !!}
|
||||||
{!! Former::text('labels_partial_due')->label(trans('texts.partial_due')) !!}
|
{!! Former::text('labels_balance_due')->label(trans('texts.balance_due')) !!}
|
||||||
|
{!! Former::text('labels_partial_due')->label(trans('texts.partial_due')) !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user