|
@@ -14,11 +14,11 @@ openerp.account_bank_voucher_import = function (instance, local) {
|
|
|
this._super(parent);
|
|
|
},
|
|
|
// Actualizar id del Objeto
|
|
|
- updateId: function(id){
|
|
|
+ updateId: function(id) {
|
|
|
var self = this;
|
|
|
self.id = id;
|
|
|
},
|
|
|
- start: function () {
|
|
|
+ start: function() {
|
|
|
var self = this;
|
|
|
this.$el.click(function() {
|
|
|
self.fetchInitial();
|
|
@@ -28,35 +28,35 @@ openerp.account_bank_voucher_import = function (instance, local) {
|
|
|
fetchInitial: function() {
|
|
|
var self = this;
|
|
|
|
|
|
+ self.$el.attr("disabled", true);
|
|
|
+
|
|
|
self.fetchBankStatement().then(function(accountStatement) {
|
|
|
return accountStatement;
|
|
|
- }).then(function(accountStatement){
|
|
|
+ }).then(function(accountStatement) {
|
|
|
self.accountStatement = accountStatement;
|
|
|
- return self.fetchBankStatementLine();
|
|
|
- }).then(function(statementLine){
|
|
|
- self.statementLine = statementLine;
|
|
|
return self.fetchVoucher();
|
|
|
- }).then(function(accountVouche){
|
|
|
+ }).then(function(accountVouche) {
|
|
|
self.accountVouche = accountVouche;
|
|
|
return self.fetchJoinVoucher();
|
|
|
- }).then(function(voucherImport){
|
|
|
+ }).then(function(voucherImport) {
|
|
|
self.voucherImport = voucherImport;
|
|
|
return self.insertBankStatementLine();
|
|
|
- }).then(function(bankLine){
|
|
|
+ }).then(function(bankLine) {
|
|
|
local.parentInstance.reload();
|
|
|
- if (bankLine){
|
|
|
+ if (bankLine) {
|
|
|
instance.web.notification.do_notify("Felicitaciones","Has importado los pagos con éxito.");
|
|
|
- }else{
|
|
|
+ }else {
|
|
|
instance.web.notification.do_warn("Atención ","No tienes pagos que importar en esa caja.");
|
|
|
}
|
|
|
+ self.$el.removeAttr("disabled");
|
|
|
});
|
|
|
},
|
|
|
// Registro de Caja
|
|
|
fetchBankStatement: function() {
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
- var fields=['id', 'journal_id'];
|
|
|
- var domain=[['id', 'in', self.id]];
|
|
|
+ var fields = ['id', 'journal_id'];
|
|
|
+ var domain = [['id', '=', self.id]];
|
|
|
var statement = new instance.web.Model('account.bank.statement');
|
|
|
|
|
|
statement.query(fields).filter(domain).all().then(function (results) {
|
|
@@ -65,32 +65,16 @@ openerp.account_bank_voucher_import = function (instance, local) {
|
|
|
|
|
|
return defer;
|
|
|
},
|
|
|
- // Linea del Registro de Caja
|
|
|
- fetchBankStatementLine: function() {
|
|
|
- var defer = $.Deferred();
|
|
|
- var fields=['id', 'voucher_id'];
|
|
|
- var domain=[['voucher_id', '!=', false]];
|
|
|
-
|
|
|
- var statementLine = new instance.web.Model('account.bank.statement.line');
|
|
|
- statementLine.query(fields).filter(domain).all().then(function (results) {
|
|
|
- defer.resolve(results);
|
|
|
- });
|
|
|
-
|
|
|
- return defer;
|
|
|
- },
|
|
|
//Consultar Voucher
|
|
|
fetchVoucher: function() {
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
|
-
|
|
|
var journal = _.flatten(_.map(self.accountStatement,function(map) {
|
|
|
return map.journal_id[0];
|
|
|
}));
|
|
|
- var voucher =_.flatten(_.map(self.statementLine,function(map) {
|
|
|
- return map.voucher_id[0];
|
|
|
- }));
|
|
|
- var fields =['id', 'partner_id', 'amount', 'journal_id', 'reference', 'move_id', 'account_id', 'state', 'type'];
|
|
|
- var domain =[['state', '=', 'posted'], ['journal_id', 'in', journal], ["id", 'not in', voucher]];
|
|
|
+ var fields = ['id', 'partner_id', 'amount', 'journal_id', 'reference', 'move_id', 'account_id', 'state', 'type'];
|
|
|
+ var domain = [['state', '=', 'posted'], ['journal_id', 'in', journal], ["bank_statement_line_ids", '=', false]];
|
|
|
+
|
|
|
var accountVouche = new instance.web.Model('account.voucher');
|
|
|
|
|
|
accountVouche.query(fields).filter(domain).all().then(function(results) {
|
|
@@ -110,7 +94,7 @@ openerp.account_bank_voucher_import = function (instance, local) {
|
|
|
itemvoucher = self.accountVouche[i];
|
|
|
if (itemvoucher.type === 'payment'){
|
|
|
ammount = (itemvoucher.amount * -1 );
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
ammount = (itemvoucher.amount);
|
|
|
}
|
|
|
|
|
@@ -125,6 +109,7 @@ openerp.account_bank_voucher_import = function (instance, local) {
|
|
|
journal_entry_id: itemvoucher.move_id[0]
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
defer.resolve(voucherImport);
|
|
|
|
|
|
return defer;
|
|
@@ -152,11 +137,11 @@ openerp.account_bank_voucher_import = function (instance, local) {
|
|
|
/* ---------------------------------------------------------------------
|
|
|
* Description: Async loop util v2 written by Robert Gauto.
|
|
|
* --------------------------------------------------------------------*/
|
|
|
- asyncLoopFactory : function (iterations, func, callback) {
|
|
|
+ asyncLoopFactory: function (iterations, func, callback) {
|
|
|
var index = 0;
|
|
|
var done = false;
|
|
|
var loop = {
|
|
|
- next: function () {
|
|
|
+ next: function() {
|
|
|
if (done) {
|
|
|
return;
|
|
|
}
|