1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Compare PHP/JS when PDF is first shown

This commit is contained in:
Hillel Coren 2017-09-03 21:10:11 +03:00
parent e47e42ddfc
commit e6cad704ef

View File

@ -864,17 +864,6 @@
}
}
model.invoice().addItem(); // add blank item
// check amounts are correct
var phpBalance = invoice.balance;
var koBalance = model.invoice().totals.rawTotal();
var jsBalance = calculateAmounts(createInvoiceModel()).total_amount;
if (phpBalance == koBalance && koBalance == jsBalance) {
// do nothing
} else {
var invitationKey = invoice.invitations[0].invitation_key;
window.onerror(invitationKey + ': Balances do not match | PHP: ' + phpBalance + ', JS: ' + jsBalance + ', KO: ' + koBalance);
}
@else
// set the default account tax rate
@if ($account->invoice_taxes)
@ -1160,6 +1149,7 @@
}
var origInvoiceNumber = false;
var checkedInvoiceBalances = false;
function getPDFString(cb, force) {
@if (! $invoice->id && $account->credit_number_counter > 0)
var total = model.invoice().totals.rawTotal();
@ -1173,12 +1163,28 @@
}
@endif
var invoice = createInvoiceModel();
if (! checkedInvoiceBalances) {
// check amounts are correct
checkedInvoiceBalances = true;
var phpBalance = invoice.balance;
var koBalance = model.invoice().totals.rawTotal();
var jsBalance = calculateAmounts(invoice).total_amount;
if (phpBalance == koBalance && koBalance == jsBalance) {
// do nothing
} else {
var invitationKey = invoice.invitations[0].invitation_key;
window.onerror(invitationKey + ': Balances do not match | PHP: ' + phpBalance + ', JS: ' + jsBalance + ', KO: ' + koBalance);
}
}
@if ( ! $account->live_preview)
return;
@endif
var invoice = createInvoiceModel();
var design = getDesignJavascript();
if (!design) return;
generatePDF(invoice, design, force, cb);
}