1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Working on credit notes

This commit is contained in:
Hillel Coren 2017-03-26 18:25:59 +03:00
parent e7a1019b08
commit aa709a47dd
5 changed files with 30 additions and 10 deletions

View File

@ -216,6 +216,12 @@ trait PresentsInvoice
'your_statement', 'your_statement',
'statement_issued_to', 'statement_issued_to',
'statement_to', 'statement_to',
'credit_note',
'credit_date',
'credit_number',
'credit_issued_to',
'credit_to',
'your_credit',
]; ];
foreach ($fields as $field) { foreach ($fields as $field) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -197,8 +197,8 @@ NINJA.decodeJavascript = function(invoice, javascript)
'balanceDue': formatMoneyInvoice(invoice.balance_amount, invoice), 'balanceDue': formatMoneyInvoice(invoice.balance_amount, invoice),
'invoiceFooter': NINJA.invoiceFooter(invoice), 'invoiceFooter': NINJA.invoiceFooter(invoice),
'invoiceNumber': invoice.invoice_number || ' ', 'invoiceNumber': invoice.invoice_number || ' ',
'entityType': invoice.is_statement ? invoiceLabels.statement : invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice, 'entityType': invoice.is_statement ? invoiceLabels.statement : invoice.is_quote ? invoiceLabels.quote : invoice.balance < 0 ? invoiceLabels.credit_note : invoiceLabels.invoice,
'entityTypeUC': (invoice.is_statement ? invoiceLabels.statement : invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice).toUpperCase(), 'entityTypeUC': (invoice.is_statement ? invoiceLabels.statement : invoice.is_quote ? invoiceLabels.quote : invoice.balance < 0 ? invoiceLabels.credit_note : invoiceLabels.invoice).toUpperCase(),
'entityTaxType': invoice.is_statement ? invoiceLabels.statement : invoice.is_quote ? invoiceLabels.tax_quote : invoiceLabels.tax_invoice, 'entityTaxType': invoice.is_statement ? invoiceLabels.statement : invoice.is_quote ? invoiceLabels.tax_quote : invoiceLabels.tax_invoice,
'fontSize': NINJA.fontSize, 'fontSize': NINJA.fontSize,
'fontSizeLarger': NINJA.fontSize + 1, 'fontSizeLarger': NINJA.fontSize + 1,
@ -249,7 +249,16 @@ NINJA.decodeJavascript = function(invoice, javascript)
} else if (field == 'invoice_to') { } else if (field == 'invoice_to') {
field = 'statement_to'; field = 'statement_to';
} }
} else if (invoice.balance < 0) {
if (field == 'your_invoice') {
field = 'your_credit';
} else if (field == 'invoice_issued_to') {
field = 'credit_issued_to';
} else if (field == 'invoice_to') {
field = 'credit_to';
}
} }
var label = invoiceLabels[field]; var label = invoiceLabels[field];
if (match.indexOf('UC') >= 0) { if (match.indexOf('UC') >= 0) {
label = label.toUpperCase(); label = label.toUpperCase();
@ -621,7 +630,7 @@ NINJA.subtotals = function(invoice, hideBalance)
} }
var paid = invoice.amount - invoice.balance; var paid = invoice.amount - invoice.balance;
if (!invoice.is_quote && (invoice.account.hide_paid_to_date != '1' || paid)) { if (!invoice.is_quote && invoice.balance >= 0 && (invoice.account.hide_paid_to_date != '1' || paid)) {
data.push([{text:invoiceLabels.paid_to_date, style: ['subtotalsLabel', 'paidToDateLabel']}, {text:formatMoneyInvoice(paid, invoice), style: ['subtotals', 'paidToDate']}]); data.push([{text:invoiceLabels.paid_to_date, style: ['subtotalsLabel', 'paidToDateLabel']}, {text:formatMoneyInvoice(paid, invoice), style: ['subtotals', 'paidToDate']}]);
} }
@ -629,7 +638,7 @@ NINJA.subtotals = function(invoice, hideBalance)
if (!hideBalance || isPartial) { if (!hideBalance || isPartial) {
data.push([ data.push([
{ text: invoice.is_quote ? invoiceLabels.total : invoiceLabels.balance_due, style: ['subtotalsLabel', isPartial ? '' : 'balanceDueLabel'] }, { text: invoice.is_quote || invoice.balance < 0 ? invoiceLabels.total : invoiceLabels.balance_due, style: ['subtotalsLabel', isPartial ? '' : 'balanceDueLabel'] },
{ text: formatMoneyInvoice(invoice.total_amount, invoice), style: ['subtotals', isPartial ? '' : 'balanceDue'] } { text: formatMoneyInvoice(invoice.total_amount, invoice), style: ['subtotals', isPartial ? '' : 'balanceDue'] }
]); ]);
} }
@ -649,7 +658,7 @@ 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 : (invoice.is_quote ? invoiceLabels.total : invoiceLabels.balance_due), style:['subtotalsLabel', 'balanceDueLabel']}, {text: isPartial ? invoiceLabels.partial_due : (invoice.is_quote || invoice.balance < 0 ? invoiceLabels.total : invoiceLabels.balance_due), style:['subtotalsLabel', 'balanceDueLabel']},
{text: formatMoneyInvoice(invoice.balance_amount, invoice), style:['subtotals', 'balanceDue']} {text: formatMoneyInvoice(invoice.balance_amount, invoice), style:['subtotals', 'balanceDue']}
]]; ]];
} }
@ -719,7 +728,7 @@ NINJA.renderInvoiceField = function(invoice, field) {
return false; return false;
} else { } else {
return [ return [
{text: (invoice.is_quote ? invoiceLabels.quote_number : invoiceLabels.invoice_number), style: ['invoiceNumberLabel']}, {text: (invoice.is_quote ? invoiceLabels.quote_number : invoice.balance < 0 ? invoiceLabels.credit_number : invoiceLabels.invoice_number), style: ['invoiceNumberLabel']},
{text: invoice.invoice_number, style: ['invoiceNumber']} {text: invoice.invoice_number, style: ['invoiceNumber']}
]; ];
} }
@ -730,7 +739,7 @@ NINJA.renderInvoiceField = function(invoice, field) {
]; ];
} else if (field == 'invoice.invoice_date') { } else if (field == 'invoice.invoice_date') {
return [ return [
{text: (invoice.is_statement ? invoiceLabels.statement_date : invoice.is_quote ? invoiceLabels.quote_date : invoiceLabels.invoice_date)}, {text: (invoice.is_statement ? invoiceLabels.statement_date : invoice.is_quote ? invoiceLabels.quote_date : invoice.balance < 0 ? invoiceLabels.credit_date : invoiceLabels.invoice_date)},
{text: invoice.invoice_date} {text: invoice.invoice_date}
]; ];
} else if (field == 'invoice.due_date') { } else if (field == 'invoice.due_date') {
@ -758,7 +767,7 @@ NINJA.renderInvoiceField = function(invoice, field) {
} }
} else if (field == 'invoice.balance_due') { } else if (field == 'invoice.balance_due') {
return [ return [
{text: invoice.is_quote ? invoiceLabels.total : invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']}, {text: invoice.is_quote || invoice.balance < 0 ? invoiceLabels.total : invoiceLabels.balance_due, style: ['invoiceDetailBalanceDueLabel']},
{text: formatMoneyInvoice(invoice.total_amount, invoice), style: ['invoiceDetailBalanceDue']} {text: formatMoneyInvoice(invoice.total_amount, invoice), style: ['invoiceDetailBalanceDue']}
]; ];
} else if (field == invoice.partial_due) { } else if (field == invoice.partial_due) {

View File

@ -2440,6 +2440,11 @@ $LANG = array(
'logout_and_delete' => 'Log Out/Delete Account', 'logout_and_delete' => 'Log Out/Delete Account',
'tax_rate_type_help' => 'Inclusive taxes adjust the line item cost when selected.', 'tax_rate_type_help' => 'Inclusive taxes adjust the line item cost when selected.',
'invoice_footer_help' => 'Use $pageNumber and $pageCount to display the page information.', 'invoice_footer_help' => 'Use $pageNumber and $pageCount to display the page information.',
'credit_note' => 'Credit Note',
'credit_issued_to' => 'Credit issued to',
'credit_to' => 'Credit to',
'your_credit' => 'Your Credit',
'credit_number' => 'Credit Number',
); );