mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Working on product fields
This commit is contained in:
parent
044aa6ccaa
commit
bd98591ca7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -488,9 +488,9 @@ NINJA.productFields = function(invoice, isTasks) {
|
||||
var allFields = JSON.parse(account.invoice_fields);
|
||||
|
||||
if (allFields) {
|
||||
if (isTasks && allFields.task_fields) {
|
||||
if (isTasks && allFields.task_fields && allFields.task_fields.length) {
|
||||
return allFields.task_fields;
|
||||
} else if (! isTasks && allFields.product_fields) {
|
||||
} else if (! isTasks && allFields.product_fields && allFields.product_fields.length) {
|
||||
return allFields.product_fields;
|
||||
}
|
||||
}
|
||||
@ -506,6 +506,11 @@ NINJA.productFields = function(invoice, isTasks) {
|
||||
'product.line_total',
|
||||
];
|
||||
|
||||
// add backwards compatibility for 'hide qty' setting
|
||||
if (invoice.account.hide_quantity == '1' && ! isTasks) {
|
||||
fields.splice(5, 1);
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
@ -527,11 +532,20 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
|
||||
for (var i=0; i<fields.length; i++) {
|
||||
var field = fields[i].split('.')[1]; // split to remove 'product.'
|
||||
var headerStyles = styles.concat([snakeToCamel(field), snakeToCamel(field) + 'TableHeader']);
|
||||
var value = invoiceLabels[field];
|
||||
|
||||
if (field == 'custom_value1' && ! invoice.has_custom_item_value1) {
|
||||
continue;
|
||||
} else if (field == 'custom_value2' && ! invoice.has_custom_item_value1) {
|
||||
continue;
|
||||
if (field == 'custom_value1') {
|
||||
if (invoice.has_custom_item_value1) {
|
||||
value = account.custom_invoice_item_label1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (field == 'custom_value2') {
|
||||
if (invoice.has_custom_item_value2) {
|
||||
value = account.custom_invoice_item_label2;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (field == 'tax' && ! invoice.has_item_taxes) {
|
||||
continue;
|
||||
} else if (field == 'product_key' && ! invoice.has_product_key) {
|
||||
@ -540,7 +554,7 @@ NINJA.invoiceLines = function(invoice, isSecondTable) {
|
||||
headerStyles.push('cost');
|
||||
}
|
||||
|
||||
grid[0].push({text: invoiceLabels[field], style: headerStyles});
|
||||
grid[0].push({text: value, style: headerStyles});
|
||||
}
|
||||
|
||||
for (var i=0; i<invoice.invoice_items.length; i++) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
"text": "$entityTypeUC",
|
||||
"margin": [8, 30, 8, 5],
|
||||
"style": "entityTypeLabel"
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
"table": {
|
||||
@ -27,12 +27,12 @@
|
||||
"body": [
|
||||
[
|
||||
{
|
||||
"table": {
|
||||
"table": {
|
||||
"body": "$invoiceDetails"
|
||||
},
|
||||
"margin": [0, 0, 12, 0],
|
||||
"layout": "noBorders"
|
||||
},
|
||||
},
|
||||
{
|
||||
"stack": "$clientDetails"
|
||||
},
|
||||
@ -46,9 +46,9 @@
|
||||
"hLineWidth": "$firstAndLast:.5",
|
||||
"vLineWidth": "$none",
|
||||
"hLineColor": "#D8D8D8",
|
||||
"paddingLeft": "$amount:8",
|
||||
"paddingRight": "$amount:8",
|
||||
"paddingTop": "$amount:6",
|
||||
"paddingLeft": "$amount:8",
|
||||
"paddingRight": "$amount:8",
|
||||
"paddingTop": "$amount:6",
|
||||
"paddingBottom": "$amount:6"
|
||||
}
|
||||
},
|
||||
@ -63,14 +63,14 @@
|
||||
"hLineWidth": "$notFirst:.5",
|
||||
"vLineWidth": "$none",
|
||||
"hLineColor": "#D8D8D8",
|
||||
"paddingLeft": "$amount:8",
|
||||
"paddingRight": "$amount:8",
|
||||
"paddingTop": "$amount:14",
|
||||
"paddingBottom": "$amount:14"
|
||||
"paddingLeft": "$amount:8",
|
||||
"paddingRight": "$amount:8",
|
||||
"paddingTop": "$amount:14",
|
||||
"paddingBottom": "$amount:14"
|
||||
}
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
"columns": [
|
||||
"$notesAndTerms",
|
||||
{
|
||||
"table": {
|
||||
@ -80,10 +80,10 @@
|
||||
"layout": {
|
||||
"hLineWidth": "$none",
|
||||
"vLineWidth": "$none",
|
||||
"paddingLeft": "$amount:34",
|
||||
"paddingRight": "$amount:8",
|
||||
"paddingTop": "$amount:4",
|
||||
"paddingBottom": "$amount:4"
|
||||
"paddingLeft": "$amount:34",
|
||||
"paddingRight": "$amount:8",
|
||||
"paddingTop": "$amount:4",
|
||||
"paddingBottom": "$amount:4"
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -124,7 +124,7 @@
|
||||
},
|
||||
"invoiceDetails": {
|
||||
"margin": [0, 0, 8, 0]
|
||||
},
|
||||
},
|
||||
"accountDetails": {
|
||||
"margin": [0, 2, 0, 2]
|
||||
},
|
||||
@ -150,7 +150,7 @@
|
||||
"subtotalsBalanceDue": {
|
||||
"fontSize": "$fontSizeLarger",
|
||||
"color": "$primaryColor:#37a3c6"
|
||||
},
|
||||
},
|
||||
"invoiceNumber": {
|
||||
"bold": true
|
||||
},
|
||||
@ -169,7 +169,7 @@
|
||||
},
|
||||
"lineTotalTableHeader": {
|
||||
"alignment": "right"
|
||||
},
|
||||
},
|
||||
"invoiceLineItemsTable": {
|
||||
"margin": [0, 16, 0, 16]
|
||||
},
|
||||
@ -190,7 +190,7 @@
|
||||
},
|
||||
"subtotals": {
|
||||
"alignment": "right"
|
||||
},
|
||||
},
|
||||
"termsLabel": {
|
||||
"bold": true
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user