--- v7/bi/assets/infocommerce.obr.bi/assets/js/views/tariffs.js +++ mockup/tariffs.js @@ -799,7 +799,9 @@ unconvertible = true; return NaN; } - return Math.round(value); + // [mockup D23, D52: rounded once, to the cent, where v7 rounds each amount to whole units] + return window.mockupDifferences.roundOnce(value); + // [/mockup] }; taxEstimationItem.InvoiceAmount = numberOrZero(declarationAmount('#invoiceNumber')); taxEstimationItem.PackagesNumber = numberOrZero(parseInt($('#packagesNumber').val())); @@ -931,6 +933,13 @@ $("#absolute-total, .duties-total span").text((result.Total / result.ExchangeRate).formatMoney(2, ',', '.')); $("#local-absolute-total").text(result.Total.formatMoney(2, ',', '.')); $("#result-currency, #total-amount-due").text(result.CurrencyCode); + // [mockup D46, D47: under a total in another currency, the local one beside it, and the rate with its date and source] + showMockupLocalTotal(result); + // [/mockup] + // [mockup D4: the estimate notice under the total, after every result] + $('.duties-total').closest('.duties-card').append('

' + + escapeHtml(window.mockupDifferences.text('notice', document.documentElement.lang)) + '

'); + // [/mockup] $("#items-total-value").text(result.Taxes.length + result.Items.reduce((acc, val) => acc + val.Taxes.length, 0)); let isNotLocalCurrency = result.BaseCurrencyCode !== result.CurrencyCode; if (isNotLocalCurrency) { @@ -1014,6 +1023,9 @@ $('#messages-row').html(''); inProgress('show'); $('.duties-total-table-container').removeClass('filled'); + // [mockup D54, D33: asking again ends the result's out-of-date state, and the differences' lines go with it] + clearMockupResult(); + // [/mockup] } }); }); @@ -1120,8 +1132,49 @@ $('.duties-total-table .showing').removeClass('showing').addClass('hidden'); $('.duties-total-table-container').removeClass('filled'); $('#messages-row').hide().html(''); + // [mockup D54: a new product or tab clears the result, out of date or not] + clearMockupResult(); + // [/mockup] } +// [mockup D54, D33: a field changed after a result dims it and marks it out of date until the next estimate. A new +// product or tab still clears it (resetEstimateResult), and the typed words of a search are not a change.] +var mockupResultCard = '.tariffs-card.duties-total-table-container'; + +$('#tariffs-form').on('input change', 'input, select, textarea', function (event) { + let $result = $(mockupResultCard); + if ($(event.target).is('input.search') || !$result.hasClass('filled') || $result.hasClass('mockup-out-of-date')) + return; + $result.addClass('mockup-out-of-date').before('
' + + escapeHtml(window.mockupDifferences.text('outOfDate', document.documentElement.lang)) + '
'); +}); + +function clearMockupResult() { + $(mockupResultCard).removeClass('mockup-out-of-date'); + $('.mockup-out-of-date-text, .mockup-notice, .mockup-local-total, .mockup-rate').remove(); +} + +$('head').append(''); +// [/mockup] + +// [mockup D46, D47: a result in a currency other than the local one gets the local currency beside its total, as +// customs' original, and the rate the estimate used, to six decimals, dated by the rates answer the page received +// and named after the customs service] +function showMockupLocalTotal(result) { + let differences = window.mockupDifferences; + if (!differences.showsLocalCurrency(result)) + return; + let lang = document.documentElement.lang; + let $rate = $('

'); + $('.duties-total').after($('

').text(differences.localBeside(result.Total / result.ExchangeRate, + result.CurrencyCode, result.Total, result.BaseCurrencyCode, lang)), $rate); + differences.ratesRecording().then(function (recording) { + let quoted = (Array.isArray(recording.answer) ? recording.answer : []).find(r => r.Code === result.CurrencyCode); + $rate.text(differences.rateLabel(result.ExchangeRate, differences.rateDate(quoted, recording), differences.customsService(window.tariffsCountryId), lang)); + }); +} +// [/mockup] + function showOperation(next) { let previous = operation; operation = next === 'EX' ? 'EX' : 'IM';