|
@@ -10,18 +10,14 @@
|
|
|
id: undefined,
|
|
|
buttons: undefined,
|
|
|
bankStatement: [],
|
|
|
- accountJournal :[],
|
|
|
- statementOpen: [],
|
|
|
- /** config */
|
|
|
- statementConfig: [],
|
|
|
resUser: [],
|
|
|
- statementUser: [],
|
|
|
+ statementConfig: [],
|
|
|
+ cashBoxTransfer: [],
|
|
|
/* init */
|
|
|
init: function(parent) {
|
|
|
this._super(parent);
|
|
|
this.buttons = parent.$buttons;
|
|
|
},
|
|
|
-
|
|
|
/* start */
|
|
|
start: function () {
|
|
|
var self = this
|
|
@@ -43,24 +39,20 @@
|
|
|
self.$el.css('display','flex');
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
/* Actualizar Id de la visat actual */
|
|
|
updateId: function(id) {
|
|
|
var self = this;
|
|
|
self.id = id;
|
|
|
},
|
|
|
-
|
|
|
/* Reload Page*/
|
|
|
reloadPage: function() {
|
|
|
openerp.parentInstanceStatementTransferDeleted.reload();
|
|
|
},
|
|
|
-
|
|
|
/* Description: Función para remover el modal */
|
|
|
removeModal: function() {
|
|
|
$('.expired-account-modal').remove();
|
|
|
$('.modal-backdrop').remove();
|
|
|
},
|
|
|
-
|
|
|
/*Get User*/
|
|
|
fetchGetUserLogin: function(){
|
|
|
var bankStatementUser = new instanceWeb.Model('account.bank.statement');
|
|
@@ -75,7 +67,6 @@
|
|
|
var statementConfig = new openerp.web.Model('account.bank.statement.config');
|
|
|
return statementConfig.query(fields).filter(domain).all();
|
|
|
},
|
|
|
-
|
|
|
/* Método inicial */
|
|
|
fetchInitial: function() {
|
|
|
var self = this;
|
|
@@ -110,45 +101,12 @@
|
|
|
return cashBoxTransfer;
|
|
|
}).then(function(cashBoxTransfer){
|
|
|
self.cashBoxTransfer = cashBoxTransfer;
|
|
|
- console.log(cashBoxTransfer);
|
|
|
+ if (!self.cashBoxTransfer.length) {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "La caja no tiene ninguna transferencia.");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return self.showModalTransfer();
|
|
|
})
|
|
|
- // delete_transfer_user_ids
|
|
|
- // var statementConfig = self.statementConfig[0];
|
|
|
- // var resUser = self.resUser[0];
|
|
|
- // var statementUser = self.bankStatement[0];
|
|
|
- // /* Verificar si el tipo caja tiene permiso para la transferencia */
|
|
|
- // if (!(_.contains(statementConfig.transfer_statement_ids, statementUser.typeStatement))) {
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "El tipo caja no tiene permiso para realizar transferencia.");
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // /* Verificar si el usuario tiene permiso para la transferencia*/
|
|
|
- // if (!(_.contains(statementConfig.transfer_user_ids, resUser.id))) {
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "El usuario no tiene permiso para realizar transferencia.");
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- //
|
|
|
- // if (self.bankStatement[0].amount <= 0) {
|
|
|
- // if (!self.statementConfig.length){
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "La caja seleccionada no tiene saldo disponible.");
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // if (!self.statementConfig[0].transfer_negative_amount){
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "La caja seleccionada no tiene saldo disponible.");
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // self.fetchAccountJournal(self.id).then(function(accountJournal) {
|
|
|
- // return accountJournal;
|
|
|
- // }).then(function(accountJournal) {
|
|
|
- // self.accountJournal = accountJournal;
|
|
|
- // if (!accountJournal[0].statementJournal.length){
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "No tienes ninguna caja abierta.");
|
|
|
- // return false;
|
|
|
- // }
|
|
|
-
|
|
|
- // return self.showModalTransfer();
|
|
|
- // });
|
|
|
});
|
|
|
},
|
|
|
/* Account bank Statement */
|
|
@@ -158,15 +116,6 @@
|
|
|
context: new instanceWeb.CompoundContext()
|
|
|
});
|
|
|
},
|
|
|
- // /* Account Journal*/
|
|
|
- // fetchAccountJournal: function(id) {
|
|
|
- // var accountJournal = new instanceWeb.Model('account.bank.statement');
|
|
|
- // return accountJournal.call('get_account_journal_utility',[id], {
|
|
|
- // context: new instanceWeb.CompoundContext()
|
|
|
- // });
|
|
|
- // },
|
|
|
-
|
|
|
-
|
|
|
/* cash_box_transfer*/
|
|
|
fetchCashBoxTransfer: function(id) {
|
|
|
var cashBoxTransfer = new instanceWeb.Model('account.bank.statement');
|
|
@@ -174,169 +123,133 @@
|
|
|
context: new instanceWeb.CompoundContext()
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
- // /* Get statement Journal */
|
|
|
- // getStatementJournal(id) {
|
|
|
- // var self = this;
|
|
|
- // var journal = _.filter(self.accountJournal, function(item) {
|
|
|
- // return item.id === id ;
|
|
|
- // });
|
|
|
- // return _.flatten(_.map(journal, function(map) {
|
|
|
- // return map.statementJournal;
|
|
|
- // }));
|
|
|
- // },
|
|
|
- // /* Save Statement transfer */
|
|
|
- // statementCompletTransfers: function(values) {
|
|
|
- // var bankStatementTransfer = new instanceWeb.Model('account.bank.statement');
|
|
|
- // return bankStatementTransfer.call('statement_complet_transfers',[values], {
|
|
|
- // context: new instanceWeb.CompoundContext()
|
|
|
- // });
|
|
|
- // },
|
|
|
-
|
|
|
+ /*filter line transfer selected*/
|
|
|
+ filterRowTransfer: function(id){
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.cashBoxTransfer, function(item){
|
|
|
+ return item.id === id;
|
|
|
+ });
|
|
|
+ },
|
|
|
/*Modal Transfer */
|
|
|
showModalTransfer: function() {
|
|
|
var self = this;
|
|
|
var defer =$.Deferred();
|
|
|
var results = true;
|
|
|
- // var accountJournal = self.accountJournal;
|
|
|
- //
|
|
|
- // accountJournal.unshift({'name': '', 'id': ''});
|
|
|
+ var rowSelected = [];
|
|
|
|
|
|
- var modal = QWeb.render('ModalStatementUtility.TransferDeleted');
|
|
|
+ var modal = QWeb.render('ModalStatementUtility.TransferDeleted',{
|
|
|
+ cashBoxTransfer: self.cashBoxTransfer
|
|
|
+ });
|
|
|
|
|
|
$('.openerp_webclient_container').after(modal);
|
|
|
$('.expired-account-modal').modal();
|
|
|
|
|
|
+ var statementOutput = $('.expired-account-modal').find('.statement-output');
|
|
|
+ var statementInput = $('.expired-account-modal').find('.statement-input');
|
|
|
+ var transferRef = $('.expired-account-modal').find('.transfer-ref');
|
|
|
+ var transferAmount = $('.expired-account-modal').find('.transfer-amount');
|
|
|
+ var transferAmountSymbol = $('.expired-account-modal').find('.transfer-amount-symbol');
|
|
|
+ var refTransferDeleted = $('.expired-account-modal').find('.ref-transfer-deleted');
|
|
|
+ /* Table */
|
|
|
+ var tableRow = $('.expired-account-modal').find('.table-tbody').find('tr');
|
|
|
+ var buttonDeleted = $('.expired-account-modal').find('.button-deleted')
|
|
|
+
|
|
|
+ buttonDeleted.attr("disabled", true);
|
|
|
+ refTransferDeleted.attr("disabled", true);
|
|
|
+
|
|
|
+ /* Seleccionar fila */
|
|
|
+ tableRow.click(function (e) {
|
|
|
+ row_export = $(e.target);
|
|
|
+
|
|
|
+ buttonDeleted.attr("disabled", true);
|
|
|
+ refTransferDeleted.attr("disabled", true);
|
|
|
+ tableRow.removeClass('table-row-select');
|
|
|
+ $(e.target).closest('tr').addClass('table-row-select');
|
|
|
+
|
|
|
+ var idRow = parseInt(($(e.target).closest('tr').children()[0].textContent).trim())
|
|
|
+ rowSelected = self.filterRowTransfer(idRow).shift();
|
|
|
+
|
|
|
+ statementOutput.val('')
|
|
|
+ statementInput.val('')
|
|
|
+ transferRef.val('')
|
|
|
+ transferAmount.val(0)
|
|
|
+ transferAmountSymbol.text("")
|
|
|
+ refTransferDeleted.val('')
|
|
|
+
|
|
|
+ if (!rowSelected){
|
|
|
+ tableRow.removeClass('table-row-select');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( rowSelected.outputStatement.typeJournal === 'cash' ) {
|
|
|
+ if (rowSelected.outputStatement.state !== 'open') {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "No podes continuar con esa operación, la caja origen no esta abierta");
|
|
|
+ tableRow.removeClass('table-row-select');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (rowSelected.inputStatement.state !== 'open') {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "No podes continuar con esa operación, la caja destino no esta abierta");
|
|
|
+ tableRow.removeClass('table-row-select');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( rowSelected.outputStatement.typeJournal === 'bank' ){
|
|
|
+ if (rowSelected.outputStatement.state === 'confirm'){
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "No podes continuar con esa operación, la caja origen no esta abierta");
|
|
|
+ tableRow.removeClass('table-row-select');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (rowSelected.inputStatement.state === 'confirm') {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "No podes continuar con esa operación, la caja destino no esta abierta");
|
|
|
+ tableRow.removeClass('table-row-select');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // var statementAmount = $('.expired-account-modal').find('.statement-amount');
|
|
|
- // var statementAmountSymbol = $('.expired-account-modal').find('.statement-amount-symbol');
|
|
|
- // var selectedJournal = $('.expired-account-modal').find('.selected-Journal');
|
|
|
- // var statementOpen = $('.expired-account-modal').find('.statement-open-selected');
|
|
|
- // var amountTransfer = $('.expired-account-modal').find('.amount-transfer');
|
|
|
- // var amountTransferSymbol = $('.expired-account-modal').find('.amount-transfer-symbol');
|
|
|
- // var refTransfer = $('.expired-account-modal').find('.ref-transfer');
|
|
|
- // /* Button */
|
|
|
- // var buttonSave = $('.expired-account-modal').find('.button-save');
|
|
|
- // var currency = self.bankStatement[0].currencystatement;
|
|
|
- //
|
|
|
- // /* Monto */
|
|
|
- // statementAmount.val(accounting.formatNumber(self.bankStatement[0].amount, currency.decimalPlaces, currency.thousandsSeparator, currency.decimalSeparator));
|
|
|
- // /* Symbol */
|
|
|
- // statementAmountSymbol.text(currency.symbol);
|
|
|
- // amountTransferSymbol.text(currency.symbol);
|
|
|
- // /*select Journal */
|
|
|
- // selectedJournal.focus();
|
|
|
- // selectedJournal.change(function(e) {
|
|
|
- // statementOpen.empty();
|
|
|
- //
|
|
|
- // var statementJournal = self.getStatementJournal(parseInt(selectedJournal.val()));
|
|
|
- // if (!!statementJournal.length)
|
|
|
- // statementOpen.append('<option value=""></option>');
|
|
|
- //
|
|
|
- // _.each(statementJournal, function(item) {
|
|
|
- // statementOpen.append('<option value="' + item.id + '">' + item.statementname + '</option>');
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // /* amountTransfer.keyup*/
|
|
|
- // amountTransfer.keyup(function(e) {
|
|
|
- // var amount = accounting.unformat(amountTransfer.val(),currency.decimalSeparator);
|
|
|
- // amountTransfer.val(accounting.formatNumber(amount,0, currency.thousandsSeparator, currency.decimalSeparator));
|
|
|
- // amountTransfer.css('border-color','#ccc');
|
|
|
- //
|
|
|
- // if (e.keyCode === 13)
|
|
|
- // refTransfer.focus();
|
|
|
- // });
|
|
|
- // /* amountTransfer. focusout*/
|
|
|
- // amountTransfer.focusout(function(e) {
|
|
|
- // var amountAvailable = accounting.unformat(statementAmount.val(),currency.decimalSeparator);
|
|
|
- // var amount = Math.abs(accounting.unformat(amountTransfer.val(),currency.decimalSeparator));
|
|
|
- //
|
|
|
- // if (amountAvailable < amount && !self.statementConfig[0].transfer_negative_amount) {
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "El valor a transferir supera el saldo disponible de la caja .");
|
|
|
- // amountTransfer.css('border-color','red');
|
|
|
- // amountTransfer.focus();
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- //
|
|
|
- // amountTransfer.val(accounting.formatNumber( amount,currency.decimalPlaces, currency.thousandsSeparator, currency.decimalSeparator));
|
|
|
- // });
|
|
|
- //
|
|
|
- // /*Click buttonSave*/
|
|
|
- // buttonSave.click(function(e){
|
|
|
- // var amountAvailable = accounting.unformat(statementAmount.val(),currency.decimalSeparator);
|
|
|
- // var amount = accounting.unformat(amountTransfer.val(),currency.decimalSeparator);
|
|
|
- //
|
|
|
- // /* Journal */
|
|
|
- // if (!selectedJournal.val()) {
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "Debes seleccionar un tipo de pago para continuar.");
|
|
|
- // selectedJournal.css('border-color','red');
|
|
|
- // selectedJournal.focus();
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // selectedJournal.css('border-color','#ccc');
|
|
|
- // /* Statement Open */
|
|
|
- // if (!statementOpen.val()) {
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "Debes seleccionar la caja donde vas a transferir.");
|
|
|
- // statementOpen.css('border-color','red');
|
|
|
- // statementOpen.focus();
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // statementOpen.css('border-color','#ccc');
|
|
|
- //
|
|
|
- // /* ammount transfer*/
|
|
|
- // if (amount <= 0) {
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "El valor a transferir debe ser mayor a cero.");
|
|
|
- // amountTransfer.css('border-color','red');
|
|
|
- // amountTransfer.focus();
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- //
|
|
|
- // if (amountAvailable < amount) {
|
|
|
- // if (!self.statementConfig.length){
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "El valor a transferir supera el saldo disponible de la caja .");
|
|
|
- // amountTransfer.css('border-color','red');
|
|
|
- // amountTransfer.focus();
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // if (!self.statementConfig[0].transfer_negative_amount){
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "El valor a transferir supera el saldo disponible de la caja .");
|
|
|
- // amountTransfer.css('border-color','red');
|
|
|
- // amountTransfer.focus();
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // amountTransfer.css('border-color','#ccc');
|
|
|
- // /* Ref transfer */
|
|
|
- // if (!refTransfer.val()) {
|
|
|
- // instanceWeb.notification.do_warn("Atencion", "Debes de ingresar un motivo para la transferencia.");
|
|
|
- // refTransfer.css('border-color','red');
|
|
|
- // refTransfer.focus();
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // refTransfer.css('border-color','#ccc');
|
|
|
- //
|
|
|
- // statementTransfer = {
|
|
|
- // 'statementOriginId': self.bankStatement[0].id,
|
|
|
- // 'statementDestinyId': parseInt(statementOpen.val()),
|
|
|
- // 'amountTransfer': amount,
|
|
|
- // 'refTransfer': refTransfer.val().trim(),
|
|
|
- // 'journalID': parseInt(selectedJournal.val())
|
|
|
- // }
|
|
|
- //
|
|
|
- // /* Save Payments */
|
|
|
- // self.statementCompletTransfers(statementTransfer).then(function(resultsTransfer) {
|
|
|
- // return resultsTransfer;
|
|
|
- // }).then(function(resultsTransfer) {
|
|
|
- // self.reloadPage();
|
|
|
- // self.removeModal(e);
|
|
|
- // if (!resultsTransfer)
|
|
|
- // results = false;
|
|
|
- // });
|
|
|
- //
|
|
|
- // defer.resolve(results);
|
|
|
- //
|
|
|
- // });
|
|
|
+ statementOutput.val(rowSelected.outputStatement.name)
|
|
|
+ statementInput.val(rowSelected.inputStatement.name)
|
|
|
+ transferRef.val(rowSelected.ref)
|
|
|
+ transferAmount.val(accounting.formatNumber(rowSelected.amount, rowSelected.outputStatement.currency.decimalPlaces, rowSelected.outputStatement.currency.thousandsSeparator,rowSelected.outputStatement.currency.decimalSeparator))
|
|
|
+ transferAmountSymbol.text(rowSelected.outputStatement.currency.symbol)
|
|
|
+ refTransferDeleted.val('')
|
|
|
+ buttonDeleted.removeAttr("disabled");
|
|
|
+ refTransferDeleted.removeAttr("disabled");
|
|
|
+ refTransferDeleted.focus();
|
|
|
+ });
|
|
|
+
|
|
|
+ buttonDeleted.click(function(e) {
|
|
|
+ if (!refTransferDeleted.val()) {
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "Debes ingresar un motivo para continuar.");
|
|
|
+ refTransferDeleted.css('border-color','red');
|
|
|
+ refTransferDeleted.focus();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ refTransferDeleted.css('border-color','#ccc');
|
|
|
+
|
|
|
+ if (!rowSelected){
|
|
|
+ instanceWeb.notification.do_warn("Atencion", "Debes seleccionar una transferencia para continuar.");
|
|
|
+ tableRow.focus()
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var unlinkTransfer ={
|
|
|
+ 'statementId': self.id,
|
|
|
+ 'transferId': rowSelected.id,
|
|
|
+ 'comment': !!refTransferDeleted.val() ? refTransferDeleted.val() : ''
|
|
|
+ }
|
|
|
+
|
|
|
+ self.unlinkTransfer(unlinkTransfer).then(function(transfer){
|
|
|
+ return transfer;
|
|
|
+ }).then(function(transfer){
|
|
|
+ self.reloadPage();
|
|
|
+ self.removeModal(e);
|
|
|
+ if (!transfer)
|
|
|
+ results = false;
|
|
|
+ })
|
|
|
+
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
|
|
|
/* Click Cerrar */
|
|
|
$('.expired-account-modal').on('hidden.bs.modal', function(e) {
|
|
@@ -347,6 +260,13 @@
|
|
|
|
|
|
return defer;
|
|
|
},
|
|
|
+ /* Unlink transfer */
|
|
|
+ unlinkTransfer: function(values){
|
|
|
+ var bankStatementTransfer = new instanceWeb.Model('account.bank.statement');
|
|
|
+ return bankStatementTransfer.call('unlink_transfer',[values], {
|
|
|
+ context: new instanceWeb.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
if (openerp.web && openerp.web.FormView) {
|