Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Utils.formatMoney = function( num, precision ) {
if( precision === 'auto' ) {
precision = Utils.decimalPlaces(num);
}
if( !_.isFinite( parseInt(precision, 10) ) ) {
precision = accounting.settings.currency.precision;
}
// round the number to even
num = Utils.round(num, precision);
return accounting.formatMoney(num);
};
hbs.registerHelper('money', function(num, options){
var defaultPrecision = accounting.settings.currency.precision,
precision = options.hash.precision || defaultPrecision;
if( precision === 'auto' ) {
precision = Utils.decimalPlaces(num);
}
// round the number to even
num = Utils.round(num, precision);
if(options.hash.negative) {
num = num * -1;
}
return accounting.formatMoney(num);
});
exports.formatMoney = function formatMoney(result) {
accounting.settings = global._config.accountingSettings;
result.subtotal=accounting.formatMoney(result.subtotal);
result.vat_amount=accounting.formatMoney(result.vat_amount);
result.shipping_costs=accounting.formatMoney(result.shipping_costs);
result.total=accounting.formatMoney(result.total);
for (var item in result.items) {
if (result.items[item]) {
result.items[item].price=accounting.formatMoney(result.items[item].price);
result.items[item].amount=accounting.formatMoney(result.items[item].amount);
}
}
return result;
};
exports.formatMoney = function formatMoney(result) {
accounting.settings = global._config.accountingSettings;
result.subtotal=accounting.formatMoney(result.subtotal);
result.vat_amount=accounting.formatMoney(result.vat_amount);
result.shipping_costs=accounting.formatMoney(result.shipping_costs);
result.total=accounting.formatMoney(result.total);
for (var item in result.items) {
if (result.items[item]) {
result.items[item].price=accounting.formatMoney(result.items[item].price);
result.items[item].amount=accounting.formatMoney(result.items[item].amount);
}
}
return result;
};
exports.formatMoney = function formatMoney(result) {
accounting.settings = global._config.accountingSettings;
result.subtotal=accounting.formatMoney(result.subtotal);
result.vat_amount=accounting.formatMoney(result.vat_amount);
result.shipping_costs=accounting.formatMoney(result.shipping_costs);
result.total=accounting.formatMoney(result.total);
for (var item in result.items) {
if (result.items[item]) {
result.items[item].price=accounting.formatMoney(result.items[item].price);
result.items[item].amount=accounting.formatMoney(result.items[item].amount);
}
}
return result;
};
exports.formatMoney = function formatMoney(result) {
accounting.settings = global._config.accountingSettings;
result.subtotal=accounting.formatMoney(result.subtotal);
result.vat_amount=accounting.formatMoney(result.vat_amount);
result.shipping_costs=accounting.formatMoney(result.shipping_costs);
result.total=accounting.formatMoney(result.total);
for (var item in result.items) {
if (result.items[item]) {
result.items[item].price=accounting.formatMoney(result.items[item].price);
result.items[item].amount=accounting.formatMoney(result.items[item].amount);
}
}
return result;
};
money: function (chunk, context, bodies, params) {
var amt = dust.helpers.tap((params && params.key) ? params.key : bodies.block, chunk, context),
cur = 'USD';
if (params && params.code) {
cur = dust.helpers.tap(params.code, chunk, context);
}
if (amt instanceof BigNumber) {
amt = amt.toString();
}
return chunk.write(accounting.formatMoney(amt, Invoice.Currencies[cur].symbol));
},
currencySymbol: function (chunk, context, bodies, params) {
render() {
return (
<div>
<div>
<div>
<div><label>SubTotal: </label></div>
<div>{accounting.formatMoney(store.RTotal, { symbol: "", format: "%s%v" }) }</div>
<div><label>Tax: </label></div>
<div>{accounting.formatMoney(store.TTotal, { symbol: "", format: "%s%v" }) }</div>
<div><label>Total: </label></div>
<div>{accounting.formatMoney(store.GTotal, { symbol: "", format: "%s%v" }) }</div>
</div>
</div>
</div>
);
}
}
render() {
return (
<div>
<div>
<div>
<div><label>SubTotal: </label></div>
<div>{accounting.formatMoney(store.RTotal, { symbol: "", format: "%s%v" }) }</div>
<div><label>Tax: </label></div>
<div>{accounting.formatMoney(store.TTotal, { symbol: "", format: "%s%v" }) }</div>
<div><label>Total: </label></div>
<div>{accounting.formatMoney(store.GTotal, { symbol: "", format: "%s%v" }) }</div>
</div>
</div>
</div>
);
}
}
render() {
return (
<div>
<div>
<div>
<div><label>Running Total: </label></div>
<div>{accounting.formatMoney(store.RTotal, { symbol: "", format: "%s%v" }) }</div>
<div><label>Tax Total: </label></div>
<div>{accounting.formatMoney(store.TTotal, { symbol: "", format: "%s%v" }) }</div>
<div><label>Grand Total: </label></div>
<div>{accounting.formatMoney(store.GTotal, { symbol: "", format: "%s%v" }) }</div>
</div>
</div>
</div>
);
}
}