- /**
- * 2016-07-16
- * Returns the current quote's grand total value.
- * By analogy with https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Checkout/view/frontend/web/js/view/summary/grand-total.js#L20-L26
- * How to get the current quote's grant total value
- * on the frontend checkout page's client side? https://mage2.pro/t/1873
- *
- * 2016-08-07
- * Note 1.
- * Previously, I have used the folowing code here:
- *
- * var totals = q.getTotals()()
- * return totals['grand_total']
- *
- * But today I have noticed that it can ignore the taxes
- * (may be not always, but with a particular backend settings combination).
- *
- * Note 2.
- * Another solution is to use the 'Magento_Checkout/js/model/totals' class instance
- * as follows: totals.getSegment('grand_total').value
- * However, the current implementation of getSegment() non-optimal:
- * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js#L32-L50
- *
- * 2016-09-06
- * I have noticed today, that while totals['grand_total'] does not include the taxes,
- * the totals['base_grand_total'] includes the taxes, for example:
- * base_grand_total: 83.83
- * grand_total: 74.7
- * base_tax_amount: 9.13
- * tax_amount: 9.13
- * It allows me to use a shorter implementation for the grandTotalBase() method below.
- *
- * 2017-03-03
- * The previous implementation was:
- *
- * var totals = q.getTotals()();
- * var segments = totals['total_segments'];
- * return segments[segments.length - 1].value;
- *
- * But today I have noticed an incorrect behaviour of the aheadWorks Gift Card extension:
- * «aheadWorks Gift Card adds its entry at the end of a totals array,
- * and its «value» is incorrect (always 0)»: https://mage2.pro/t/3499
- *
- * https://lodash.com/docs/4.17.4#find
- * https://lodash.com/docs/4.17.4#findLast
- *
- * @returns {Number}
- */
- grandTotal: function() {return parseFloat(
- _.findLast(q.getTotals()()['total_segments'], 'value').value
- );},