|
@@ -0,0 +1,517 @@
|
|
|
+(function() {
|
|
|
+
|
|
|
+ openerp.widgetInstanceEiruUtilityToolSale = null;
|
|
|
+ openerp.parentInstanceEiruUtilityToolSale = null;
|
|
|
+ var Qweb = openerp.web.qweb;
|
|
|
+ var instance = openerp;
|
|
|
+ var instanceWeb = openerp.web;
|
|
|
+
|
|
|
+ openerp.EiruUtilityToolSale = instance.Widget.extend({
|
|
|
+ template: 'EiruUtilityTool.Sale',
|
|
|
+
|
|
|
+ id: undefined,
|
|
|
+ order: [],
|
|
|
+ calculatorTerm: [],
|
|
|
+ termType: [],
|
|
|
+ accountSaleTerm: [],
|
|
|
+
|
|
|
+ /************
|
|
|
+ | INIT |
|
|
|
+ ************/
|
|
|
+ init: function(parent) {
|
|
|
+ this._super(parent);
|
|
|
+ this.buttons = parent.$buttons;
|
|
|
+ },
|
|
|
+
|
|
|
+ /************
|
|
|
+ | START |
|
|
|
+ ************/
|
|
|
+ start: function() {
|
|
|
+ var self = this;
|
|
|
+ this.$el.click(function() {
|
|
|
+ self.fectchInitial();
|
|
|
+ });
|
|
|
+ self.buttons.click(function(e) {
|
|
|
+ /* E (Editar) */
|
|
|
+ if (e.target.accessKey === 'E')
|
|
|
+ self.$el.css('display','none');
|
|
|
+ /* S (Guarrdar) */
|
|
|
+ if (e.target.accessKey === 'S')
|
|
|
+ self.$el.css('display','flex');
|
|
|
+ /* D (Cancelar) */
|
|
|
+ if (e.target.accessKey === 'D')
|
|
|
+ self.$el.css('display','flex');
|
|
|
+ /* CREAR */
|
|
|
+ if (e.target.accessKey === 'C')
|
|
|
+ self.$el.css('display','none');
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /*===============
|
|
|
+ | ID ORDER |
|
|
|
+ ===============*/
|
|
|
+ updateId: function(id) {
|
|
|
+ var self = this;
|
|
|
+ self.id = id;
|
|
|
+
|
|
|
+ self.$el.css('display','flex');
|
|
|
+ if (!id)
|
|
|
+ self.$el.css('display','none');
|
|
|
+ },
|
|
|
+ /*=====================
|
|
|
+ | Remover Modal |
|
|
|
+ =====================*/
|
|
|
+ removeModal: function() {
|
|
|
+ $('.expired-account-modal').remove();
|
|
|
+ $('.modal-backdrop').remove();
|
|
|
+ },
|
|
|
+ /*===============================
|
|
|
+ | Recargar la Pagina |
|
|
|
+ ===============================*/
|
|
|
+ reloadPage: function() {
|
|
|
+ openerp.parentInstanceEiruUtilityToolSale.reload();
|
|
|
+ },
|
|
|
+ /******************************
|
|
|
+ || Metodo Inicial ||
|
|
|
+ ******************************/
|
|
|
+ fectchInitial: function() {
|
|
|
+ var self = this;
|
|
|
+ self.fetchSaleOrder(self.id).then(function(order) {
|
|
|
+ return order;
|
|
|
+ }).then(function(order) {
|
|
|
+ self.order = order;
|
|
|
+ return self.fetchTypeTerm();
|
|
|
+ }).then(function(termType) {
|
|
|
+ self.termType = termType;
|
|
|
+ return self.fetchTermSale(self.id);
|
|
|
+ }).then(function(accountSaleTerm) {
|
|
|
+ self.accountSaleTerm = accountSaleTerm;
|
|
|
+ console.log(accountSaleTerm);
|
|
|
+ return self.showModal();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /*===============================
|
|
|
+ | GET Order |
|
|
|
+ ===============================*/
|
|
|
+ fetchSaleOrder: function(id) {
|
|
|
+ var order = new openerp.web.Model('sale.order');
|
|
|
+ return order.call('getSaleOrder',[id],{
|
|
|
+ context: new openerp.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /*===============================
|
|
|
+ | GET Sale term |
|
|
|
+ ===============================*/
|
|
|
+ fetchTermSale: function(id) {
|
|
|
+ var order = new openerp.web.Model('sale.order');
|
|
|
+ return order.call('getSaleTerm',[id],{
|
|
|
+ context: new openerp.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /*=========================================
|
|
|
+ | GET Tipo de condicion de pagos |
|
|
|
+ =========================================*/
|
|
|
+ fetchTypeTerm: function() {
|
|
|
+ var typeTerm = new openerp.web.Model('account.payment.term.type');
|
|
|
+ return typeTerm.query(['id','name']).all()
|
|
|
+ },
|
|
|
+ /*===================
|
|
|
+ | Modal |
|
|
|
+ ===================*/
|
|
|
+ showModal: function() {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var state = true;
|
|
|
+ /*Curency Order*/
|
|
|
+ var saleOrder = self.order[0];
|
|
|
+ var accountSaleTerm = self.accountSaleTerm[0];
|
|
|
+ var currencyOrder = saleOrder.currency;
|
|
|
+ // /*term type */
|
|
|
+ var numberFormat = {
|
|
|
+ 'decimalSeparator': ',',
|
|
|
+ 'decimalPlaces': 0,
|
|
|
+ 'thousandsSeparator': '.'
|
|
|
+ }
|
|
|
+ var interstFormat = {
|
|
|
+ 'decimalSeparator': ',',
|
|
|
+ 'decimalPlaces': 2,
|
|
|
+ 'thousandsSeparator': '.'
|
|
|
+ }
|
|
|
+
|
|
|
+ var typeTerm = self.termType;
|
|
|
+ if (!typeTerm.length){
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "No existe tipo de condiciones de pagos.");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ typeTerm.unshift({"id": '', 'name': ''})
|
|
|
+
|
|
|
+ /* Modal */
|
|
|
+ var modal = Qweb.render('EiruUtilityTool.SaleModal',{'termTypes':typeTerm});
|
|
|
+ $('.openerp_webclient_container').after(modal);
|
|
|
+ $('.expired-account-modal').modal();
|
|
|
+
|
|
|
+ var amountOrder = $('.expired-account-modal').find('.amount-order'); //Valor de la orden.
|
|
|
+ var symbolCurrency = $('.expired-account-modal').find('.symbol-currency'); //Symbolo de moneda.
|
|
|
+ var dateSale = $('.expired-account-modal').find('.date-sale'); //Fecha de venta.
|
|
|
+
|
|
|
+ var initialPaymentsAmount = $('.expired-account-modal').find('.initial-payments-amount'); //Valor de Entrega.
|
|
|
+ var amountResidual = $('.expired-account-modal').find('.amount-residual'); //Valor Residual (Venta - Entrega).
|
|
|
+
|
|
|
+ var interestQty = $('.expired-account-modal').find('.interest-qty'); // % de interest.
|
|
|
+ var amountInterest = $('.expired-account-modal').find('.amount-interest'); //Total Interest.
|
|
|
+ var btInterestCalc = $('.expired-account-modal').find('.bt-interest-calc'); //Botton CALCULAR Interest.
|
|
|
+
|
|
|
+ var amountFinal = $('.expired-account-modal').find('.amount-final'); //Valor final (residual + interest).
|
|
|
+
|
|
|
+ var dateQuotaInit = $('.expired-account-modal').find('.date-quota-init'); //Fecha de Primera Cuota.
|
|
|
+ var termSelect = $('.expired-account-modal').find('.term-select'); //Termino de Pago.
|
|
|
+ var amountQuota = $('.expired-account-modal').find('.amount-quota'); //Valor de Cuota.
|
|
|
+ var qtyQuota = $('.expired-account-modal').find('.qty-quota'); //Cantidad de Cuota.
|
|
|
+ var btQuotaCalc = $('.expired-account-modal').find('.bt-quota-calc'); //Calcular Cuotas.
|
|
|
+
|
|
|
+ var tableRow = $('.expired-account-modal').find('.table-tbody'); //Table.
|
|
|
+
|
|
|
+ var buttonAccept = $('.expired-account-modal').find('.button-accept'); //
|
|
|
+
|
|
|
+ /*###### Data INIT ###############################################*/
|
|
|
+ amountOrder.val(instanceWeb.formatCurrency(saleOrder.amountTotal, currencyOrder));
|
|
|
+ amountResidual.val(instanceWeb.formatCurrency(saleOrder.amountTotal, currencyOrder));
|
|
|
+ amountFinal.val(instanceWeb.formatCurrency(saleOrder.amountTotal, currencyOrder));
|
|
|
+ symbolCurrency.text(currencyOrder.symbol);
|
|
|
+ dateSale.val(moment(saleOrder.dateOrder).format("YYYY-MM-DD"));
|
|
|
+ dateQuotaInit.val(moment(saleOrder.dateOrder).format("YYYY-MM-DD"));
|
|
|
+
|
|
|
+ /*######## SALE TERM ##########################################*/
|
|
|
+ if (!!accountSaleTerm) {
|
|
|
+ amountOrder.val(instanceWeb.formatCurrency(accountSaleTerm.saleAmount, currencyOrder));
|
|
|
+ initialPaymentsAmount.val(instanceWeb.formatCurrency(accountSaleTerm.salePaymentsInit, currencyOrder));
|
|
|
+ amountResidual.val(instanceWeb.formatCurrency(accountSaleTerm.saleResidual, currencyOrder));
|
|
|
+
|
|
|
+ interestQty.val(instanceWeb.formatCurrency(accountSaleTerm.interestQty, interstFormat));
|
|
|
+
|
|
|
+ amountInterest.val(instanceWeb.formatCurrency(accountSaleTerm.interestAmount, currencyOrder));
|
|
|
+ amountFinal.val(instanceWeb.formatCurrency(accountSaleTerm.amountTotal, currencyOrder));
|
|
|
+
|
|
|
+ dateQuotaInit.val(!!accountSaleTerm.dateInit ?accountSaleTerm.dateInit :moment(saleOrder.dateOrder).format("YYYY-MM-DD"))
|
|
|
+ termSelect.val(accountSaleTerm.termTypeId)
|
|
|
+ amountQuota.val(instanceWeb.formatCurrency(accountSaleTerm.quotaAmount, currencyOrder));
|
|
|
+ qtyQuota.val(instanceWeb.formatCurrency(accountSaleTerm.quotaQty, numberFormat));
|
|
|
+
|
|
|
+ tableRow.find('tr').remove();
|
|
|
+ var htmlLine = '';
|
|
|
+ self.calculatorTerm = accountSaleTerm.lines
|
|
|
+
|
|
|
+ _.each(self.calculatorTerm, function(line) {
|
|
|
+ var dateMaturity = moment(line.date).format('DD/MM/YYYY');
|
|
|
+ var amount = instanceWeb.formatCurrency(line.amount, currencyOrder) +" "+currencyOrder.symbol;
|
|
|
+ htmlLine +='<tr><td><span>'+line.cuotaNumber+'</span></td><td><span>'+dateMaturity+'</span></td><td><span>'+amount+'</span></td></tr>';
|
|
|
+ })
|
|
|
+ tableRow.append(htmlLine);
|
|
|
+ }
|
|
|
+ /*###### FOCUSIN initialPaymentsAmount ##########################*/
|
|
|
+ initialPaymentsAmount.focusin(function(e){
|
|
|
+ var amount = instanceWeb.unFormatCurrency(initialPaymentsAmount.val());
|
|
|
+ if (amount === 0)
|
|
|
+ initialPaymentsAmount.val('');
|
|
|
+ });
|
|
|
+ initialPaymentsAmount.keyup(function(e) {
|
|
|
+ var amountPayments = instanceWeb.unFormatCurrency(initialPaymentsAmount.val());
|
|
|
+ var saleAmount = instanceWeb.unFormatCurrency(amountOrder.val());
|
|
|
+ if (e.key === currencyOrder.decimalSeparator && currencyOrder.decimalPlaces > 0)
|
|
|
+ return false ;
|
|
|
+
|
|
|
+ initialPaymentsAmount.val(instanceWeb.formatCurrency(amountPayments, currencyOrder));
|
|
|
+ amountResidual.val(instanceWeb.formatCurrency((saleAmount - amountPayments), currencyOrder))
|
|
|
+ amountFinal.val(instanceWeb.formatCurrency((saleAmount - amountPayments), currencyOrder))
|
|
|
+ interestQty.val(0)
|
|
|
+ amountInterest.val(0)
|
|
|
+ });
|
|
|
+ initialPaymentsAmount.focusout(function(e) {
|
|
|
+ var saleAmount = instanceWeb.unFormatCurrency(amountOrder.val());
|
|
|
+ var amount = instanceWeb.unFormatCurrency(initialPaymentsAmount.val());
|
|
|
+
|
|
|
+ if (amount > saleAmount) {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "El valor de la entrega supera el valor de la venta.");
|
|
|
+ initialPaymentsAmount.focus();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $('.expired-account-modal').find('.widget-content.widget-loading-term-configurator').css('display','flex');
|
|
|
+ self.saleTermPaymentsInitial(amount).then(function(paymentsUpdate) {
|
|
|
+ return paymentsUpdate;
|
|
|
+ }).then(function(paymentsUpdate) {
|
|
|
+ $('.expired-account-modal').find('.widget-content.widget-loading-term-configurator').css('display','none');
|
|
|
+ });
|
|
|
+
|
|
|
+ amountResidual.val(instanceWeb.formatCurrency((saleAmount - amount), currencyOrder))
|
|
|
+ amountFinal.val(instanceWeb.formatCurrency((saleAmount - amount), currencyOrder))
|
|
|
+
|
|
|
+ interestQty.val(0)
|
|
|
+ amountInterest.val(0)
|
|
|
+ amountQuota.val(0)
|
|
|
+ qtyQuota.val(0)
|
|
|
+ self.calculatorTerm = [];
|
|
|
+ tableRow.find('tr').remove();
|
|
|
+ });
|
|
|
+
|
|
|
+ /*###### interestQty focusin #####################################*/
|
|
|
+ interestQty.focusin(function(e) {
|
|
|
+ var values = instanceWeb.unFormatCurrency(interestQty.val());
|
|
|
+ if (values === 0)
|
|
|
+ interestQty.val('');
|
|
|
+ });
|
|
|
+ interestQty.keyup(function(e) {
|
|
|
+ var qtyInterest = instanceWeb.unFormatCurrency(interestQty.val());
|
|
|
+ if (e.key === interstFormat.decimalSeparator && interstFormat.decimalPlaces > 0)
|
|
|
+ return false ;
|
|
|
+
|
|
|
+ interestQty.val(instanceWeb.formatCurrency(qtyInterest, interstFormat));
|
|
|
+ });
|
|
|
+ interestQty.focusout(function(e) {
|
|
|
+ amountQuota.val(0)
|
|
|
+ qtyQuota.val(0)
|
|
|
+ calculatorTerm = []
|
|
|
+ tableRow.find('tr').remove();
|
|
|
+ })
|
|
|
+ /*###### CLICK btInterestCalc ###################################*/
|
|
|
+ btInterestCalc.click(function(e) {
|
|
|
+ var interest = instanceWeb.unFormatCurrency(interestQty.val());
|
|
|
+ var residual = instanceWeb.unFormatCurrency(amountResidual.val());
|
|
|
+ var paymentsAmount = instanceWeb.unFormatCurrency(initialPaymentsAmount.val());
|
|
|
+
|
|
|
+ $('.expired-account-modal').find('.widget-content.widget-loading-term-configurator').css('display','flex');
|
|
|
+ self.calculateInterest(interest, paymentsAmount, instanceWeb.formatCurrency(paymentsAmount, interstFormat)).then(function(interestcalc) {
|
|
|
+ return interestcalc;
|
|
|
+ }).then(function(interestcalc) {
|
|
|
+ amountInterest.val(0)
|
|
|
+ amountFinal.val(instanceWeb.formatCurrency(residual, currencyOrder))
|
|
|
+ amountQuota.val(0)
|
|
|
+ qtyQuota.val(0)
|
|
|
+ calculatorTerm = []
|
|
|
+ tableRow.find('tr').remove();
|
|
|
+
|
|
|
+ if (interestcalc.state) {
|
|
|
+ amountInterest.val(instanceWeb.formatCurrency(interestcalc.amountInterest, currencyOrder))
|
|
|
+ amountFinal.val(instanceWeb.formatCurrency(residual + interestcalc.amountInterest, currencyOrder))
|
|
|
+ }
|
|
|
+ $('.expired-account-modal').find('.widget-content.widget-loading-term-configurator').css('display','none');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ /*###### VALOR DE LA CUOTA ######################################*/
|
|
|
+ amountQuota.focusin(function(e) {
|
|
|
+ var amount = instanceWeb.unFormatCurrency( amountQuota.val());
|
|
|
+ if (amount === 0) {
|
|
|
+ amountQuota.val('');
|
|
|
+ qtyQuota.removeAttr("disabled");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ amountQuota.keyup(function(e) {
|
|
|
+ qtyQuota.attr("disabled", true);
|
|
|
+ if (e.key === currencyOrder.decimalSeparator && currencyOrder.decimalPlaces > 0)
|
|
|
+ return false ;
|
|
|
+
|
|
|
+ cuotaAmount = instanceWeb.unFormatCurrency(amountQuota.val());
|
|
|
+ amountQuota.val(instanceWeb.formatCurrency(cuotaAmount, currencyOrder));
|
|
|
+ });
|
|
|
+ amountQuota.focusout(function(e) {
|
|
|
+ var saleAmount = instanceWeb.unFormatCurrency(amountFinal.val());
|
|
|
+ var amount = instanceWeb.unFormatCurrency(amountQuota.val());
|
|
|
+
|
|
|
+ if (amount <= 0) {
|
|
|
+ amountQuota.val('0');
|
|
|
+ qtyQuota.removeAttr("disabled");
|
|
|
+ qtyQuota.focus();
|
|
|
+ }
|
|
|
+ if (amount > (saleAmount)) {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "El valor de la cuota no puede superar el Saldo.\nSaldo ="+saleAmount+"\nCuota = "+amount);
|
|
|
+ amountQuota.focus();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ /*###### CANTIDAD DE CUOTA #######################################*/
|
|
|
+ qtyQuota.focusin(function(e){
|
|
|
+ var qty = instanceWeb.unFormatCurrency( qtyQuota.val());
|
|
|
+ if (qty === 0){
|
|
|
+ amountQuota.removeAttr("disabled");
|
|
|
+ qtyQuota.val('');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ qtyQuota.keyup(function(e) {
|
|
|
+ amountQuota.attr("disabled", true);
|
|
|
+ if (e.key === numberFormat.decimalSeparator && numberFormat.decimalPlaces > 0)
|
|
|
+ return false ;
|
|
|
+
|
|
|
+ cuotaAmount = instanceWeb.unFormatCurrency(qtyQuota.val());
|
|
|
+ qtyQuota.val(instanceWeb.formatCurrency(cuotaAmount, numberFormat));
|
|
|
+ });
|
|
|
+ qtyQuota.focusout(function(e) {
|
|
|
+ var qty = instanceWeb.unFormatCurrency(qtyQuota.val());
|
|
|
+
|
|
|
+ if (qty <= 0) {
|
|
|
+ qtyQuota.val('0');
|
|
|
+ amountQuota.removeAttr("disabled");
|
|
|
+ amountQuota.focus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ /*###### GENERAR CUOTAS ##########################################*/
|
|
|
+ btQuotaCalc.click(function(e) {
|
|
|
+ tableRow.find('tr').remove();
|
|
|
+ var htmlLine = '';
|
|
|
+
|
|
|
+ var finalAmount = instanceWeb.unFormatCurrency(amountFinal.val());
|
|
|
+ var quotaAmount = instanceWeb.unFormatCurrency(amountQuota.val());
|
|
|
+ var quotaQty = instanceWeb.unFormatCurrency(qtyQuota.val());
|
|
|
+ var amountPayments = instanceWeb.unFormatCurrency(initialPaymentsAmount.val());
|
|
|
+
|
|
|
+
|
|
|
+ if (!dateQuotaInit.val()) {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "Debes ingresa la fecha de la primera cuota.");
|
|
|
+ dateQuotaInit.focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!termSelect.val()) {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "Debes de Seleccionar el tipo de plazo de pago.");
|
|
|
+ termSelect.focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (quotaAmount > finalAmount) {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "EL valor de la cuota no puede superar el valor del saldo.");
|
|
|
+ quotaAmount.focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (quotaAmount <=0 && quotaQty<= 0){
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "Debes ingresar un monto o la cantidad de las cuota.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var termSale = {
|
|
|
+ 'orderId': self.id,
|
|
|
+ 'typeTerm': parseInt(termSelect.val().trim()),
|
|
|
+ 'amountCuota': quotaAmount,
|
|
|
+ 'qtyCuota': quotaQty,
|
|
|
+ 'dateInit': dateQuotaInit.val(),
|
|
|
+ 'amountResidual': finalAmount,
|
|
|
+ 'amountPayments':amountPayments,
|
|
|
+ }
|
|
|
+
|
|
|
+ /* GENERAR LA LISTA DE CUOTA */
|
|
|
+ $('.expired-account-modal').find('.widget-content.widget-loading-term-configurator').css('display','flex');
|
|
|
+ self.calculatePaymentTerm(termSale).then(function(calculatorTerm) {
|
|
|
+ return calculatorTerm;
|
|
|
+ }).then(function(calculatorTerm) {
|
|
|
+ self.calculatorTerm = calculatorTerm;
|
|
|
+ // console.log(calculatorTerm);
|
|
|
+ $('.expired-account-modal').find('.widget-content.widget-loading-term-configurator').css('display','none');
|
|
|
+ if (!!calculatorTerm.length) {
|
|
|
+ _.each(calculatorTerm, function(line) {
|
|
|
+ var dateMaturity = moment(line.date).format('DD/MM/YYYY');
|
|
|
+ var amount = instanceWeb.formatCurrency(line.amount, currencyOrder) +" "+currencyOrder.symbol;
|
|
|
+ htmlLine +='<tr><td><span>'+line.cuotaNumber+'</span></td><td><span>'+dateMaturity+'</span></td><td><span>'+amount+'</span></td></tr>';
|
|
|
+ })
|
|
|
+ tableRow.append(htmlLine);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ /*###### ACEPTAR --> GUARDAR #####################################*/
|
|
|
+ buttonAccept.click(function(e) {
|
|
|
+ if (!self.calculatorTerm.length) {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "Debes de calcular las cuota antes de guardar.");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ $('.expired-account-modal').find('.widget-content.widget-loading-term-configurator').css('display','flex');
|
|
|
+ self.accountPaymentTermConfigurator(self.calculatorTerm, self.id).then(function(termConfigurator) {
|
|
|
+ return termConfigurator;
|
|
|
+ }).then(function(termConfigurator) {
|
|
|
+ $('.expired-account-modal').find('.widget-content.widget-loading-term-configurator').css('display','none');
|
|
|
+ self.removeModal(e);
|
|
|
+ state = termConfigurator.state;
|
|
|
+ self.reloadPage();
|
|
|
+ });
|
|
|
+
|
|
|
+ defer.resolve(state);
|
|
|
+ });
|
|
|
+
|
|
|
+ /*###### CERRAR ###########################################*/
|
|
|
+ $('.expired-account-modal').on('hidden.bs.modal', function (e) {
|
|
|
+ defer.resolve(false);
|
|
|
+ self.removeModal(e);
|
|
|
+ self.reloadPage();
|
|
|
+ });
|
|
|
+
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+ /*===============================
|
|
|
+ | Calcular interest |
|
|
|
+ ===============================*/
|
|
|
+ calculateInterest: function(qty, amountPaymenst, paymentsFormat) {
|
|
|
+ var self = this;
|
|
|
+ var order = new instance.web.Model('sale.order');
|
|
|
+ return order.call('calculateInterestSale',[self.id, qty, amountPaymenst, paymentsFormat], {
|
|
|
+ context: new instance.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /*===========================
|
|
|
+ | Update Patments Line |
|
|
|
+ ===========================*/
|
|
|
+ saleTermPaymentsInitial: function(amount) {
|
|
|
+ var self = this;
|
|
|
+ var order = new instance.web.Model('sale.order');
|
|
|
+ return order.call('saleTermUpdatePaymentsInitial',[self.id, amount], {
|
|
|
+ context: new instance.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /*===========================
|
|
|
+ | CALCULATOR TERM |
|
|
|
+ ===========================*/
|
|
|
+ calculatePaymentTerm: function(values) {
|
|
|
+ console.log(values);
|
|
|
+ var order = new instance.web.Model('sale.order');
|
|
|
+ return order.call('calculatePaymentTermSaleOrder',[values], {
|
|
|
+ context: new instance.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /*===========================================
|
|
|
+ | Create / writer - Term Paymen |
|
|
|
+ ===========================================*/
|
|
|
+ accountPaymentTermConfigurator: function(values, id){
|
|
|
+ var term = new instance.web.Model('sale.order');
|
|
|
+ return term.call('accountPaymentTermConfiguratorSale',[values, id], {
|
|
|
+ context: new instance.web.CompoundContext()
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /* INSTANCE*/
|
|
|
+ if (instance.web && instance.web.FormView) {
|
|
|
+ instance.web.FormView.include({
|
|
|
+ load_record: function(record) {
|
|
|
+ this._super.apply(this, arguments);
|
|
|
+
|
|
|
+ if (this.model !== 'sale.order')
|
|
|
+ return;
|
|
|
+
|
|
|
+ openerp.parentInstanceEiruUtilityToolSale = this;
|
|
|
+
|
|
|
+ if (openerp.widgetInstanceEiruUtilityToolSale) {
|
|
|
+ openerp.widgetInstanceEiruUtilityToolSale.updateId(record.id);
|
|
|
+ if (this.$el.find('.bottom-eiru-utility-tool-sale').length !== 0){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.$el.find('.bottom-eiru-utility-tool-sale').length !== 0 )
|
|
|
+ return;
|
|
|
+
|
|
|
+ openerp.widgetInstanceEiruUtilityToolSale = new openerp.EiruUtilityToolSale(this);
|
|
|
+ var elemento = this.$el.find('.oe_form').find('.eiru-sale-utility-tool-sale');
|
|
|
+
|
|
|
+ openerp.widgetInstanceEiruUtilityToolSale.appendTo(elemento);
|
|
|
+ openerp.widgetInstanceEiruUtilityToolSale.updateId(record.id);
|
|
|
+ },
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+})();
|