|
@@ -0,0 +1,772 @@
|
|
|
+function report_liquidacion_mensual_inmobiliaria(reporting){
|
|
|
+ "use strict";
|
|
|
+
|
|
|
+ var model = openerp;
|
|
|
+
|
|
|
+ reporting.ReportLiquidacionMensualWidget = reporting.Base.extend({
|
|
|
+ template: 'ReportLiquidacionMensual',
|
|
|
+ rowsData :[],
|
|
|
+ content :[],
|
|
|
+ modules: ['point_of_sale','eiru_account_interest'],
|
|
|
+
|
|
|
+ events:{
|
|
|
+ 'click #generate' : 'fetchGenerate',
|
|
|
+ 'change #current-company' : 'updateSelections',
|
|
|
+ 'change #current-date' : 'ShowDateRange',
|
|
|
+ 'click .print-report':'clickOnAction',
|
|
|
+ },
|
|
|
+
|
|
|
+ init : function(parent){
|
|
|
+ this._super(parent);
|
|
|
+ },
|
|
|
+
|
|
|
+ start: function () {
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable({data : self.rowsData});
|
|
|
+ var date = new model.eiru_reports.ReportDatePickerWidget(self);
|
|
|
+ date.fecthFecha();
|
|
|
+ this.fetchInitial();
|
|
|
+ },
|
|
|
+
|
|
|
+ checkModel : function(model){
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.IrModuleModule,function(item){
|
|
|
+ return item.name === model;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ valorNull:function(dato){
|
|
|
+ var valor = "";
|
|
|
+ if (dato){
|
|
|
+ valor = dato;
|
|
|
+ }
|
|
|
+ return valor;
|
|
|
+ },
|
|
|
+
|
|
|
+ ShowDateRange : function(){
|
|
|
+ var self = this;
|
|
|
+ var date = self.$el.find('#current-date').val();
|
|
|
+ if(date == 'range'){
|
|
|
+ self.$el.find('.datepicker').css('display','block');
|
|
|
+ }
|
|
|
+ if(date != 'range'){
|
|
|
+ self.$el.find('.datepicker').css('display','none');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ fetchInitial: function () {
|
|
|
+ var self = this;
|
|
|
+ self.fetchInitialSQL().then(function (InitialSQL) {
|
|
|
+ return InitialSQL;
|
|
|
+ }).then(function(InitialSQL) {
|
|
|
+ /*
|
|
|
+ =================================
|
|
|
+ RES COMPANY
|
|
|
+ =================================
|
|
|
+ */
|
|
|
+ self.ResCompany = InitialSQL.companies;
|
|
|
+ self.CompanyLogo = InitialSQL.logo;
|
|
|
+ if(self.ResCompany.length > 1){
|
|
|
+ self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
|
|
|
+ _.each(self.ResCompany,function(item){
|
|
|
+ self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ self.$el.find('.company').css('display','none');
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ =================================
|
|
|
+ RES STORE
|
|
|
+ =================================
|
|
|
+ */
|
|
|
+ self.ResStore = InitialSQL.stores;
|
|
|
+ if(self.ResStore.length > 1){
|
|
|
+ self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
|
|
|
+ _.each(self.ResStore,function(item){
|
|
|
+ self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ self.$el.find('.store').css('display','none');
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ =================================
|
|
|
+ RES PARTNER
|
|
|
+ =================================
|
|
|
+ */
|
|
|
+ self.ResPartner = InitialSQL.supplier;
|
|
|
+ if(self.ResPartner.length > 0){
|
|
|
+ self.$el.find('#current-supplier').append('<option value="9999999">Todas los propietarios</option>');
|
|
|
+ _.each(self.ResPartner,function(item){
|
|
|
+ self.$el.find('#current-supplier').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ self.$el.find('.supplier').css('display','none');
|
|
|
+ }
|
|
|
+
|
|
|
+ return self.fetchAccountPeriod();
|
|
|
+ }).then(function(AccountPeriod){
|
|
|
+ self.AccountPeriod = AccountPeriod;
|
|
|
+ self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
|
|
|
+ _.each(AccountPeriod,function(item){
|
|
|
+ self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+
|
|
|
+ return self.fethIrModuleModule();
|
|
|
+ }).then(function(IrModuleModule) {
|
|
|
+ self.IrModuleModule = IrModuleModule;
|
|
|
+ return self.fethCheckType();
|
|
|
+ });
|
|
|
+ self.$el.find('#generate').css('display','inline');
|
|
|
+ return;
|
|
|
+ },
|
|
|
+
|
|
|
+ fetchGenerate: function () {
|
|
|
+ var self = this;
|
|
|
+ self.$el.find('.search-form').block({
|
|
|
+ message: null,
|
|
|
+ overlayCSS: {
|
|
|
+ backgroundColor: '#FAFAFA'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ self.$el.find('.report-form').block({
|
|
|
+ message: null,
|
|
|
+ overlayCSS: {
|
|
|
+ backgroundColor: '#FAFAFA'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.fetchDataSQL().then(function(DataSQL) {
|
|
|
+ return DataSQL;
|
|
|
+ }).then(function (DataSQL) {
|
|
|
+
|
|
|
+ self.AccountInvoice = DataSQL.invoices;
|
|
|
+ self.AccountInvoiceLine = DataSQL.invoice_line;
|
|
|
+ self.Contrato = DataSQL.contracts;
|
|
|
+ self.ContractLine = DataSQL.contract_line;
|
|
|
+
|
|
|
+ return self.fetchAccountMoveLine();
|
|
|
+ }).then(function(MoveLine){
|
|
|
+ self.MoveLine = MoveLine;
|
|
|
+ return self.fetchAccountInterest();
|
|
|
+ }).then(function(AccountInterest){
|
|
|
+ self.AccountInterest = AccountInterest;
|
|
|
+ return self.fetchAccountInterestLine();
|
|
|
+ }).then(function(AccountInterestLine){
|
|
|
+ self.AccountInterestLine = AccountInterestLine;
|
|
|
+ return self.BuildTable();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ fetchInitialSQL: function() {
|
|
|
+ var self = this;
|
|
|
+ var data = $.get('/report-filter-data-inmobiliaria');
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+
|
|
|
+ fetchDataSQL: function() {
|
|
|
+ var self = this;
|
|
|
+ var data = $.get('/report-sale-inmobiliaria');
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+
|
|
|
+ fetchAccountPeriod: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var domain = [['special','=',false]];
|
|
|
+ var field =['id', 'name', 'date_start','date_stop','company_id'];
|
|
|
+ var AccountPeriod = new model.web.Model('account.period');
|
|
|
+ AccountPeriod.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ fetchAccountInterest: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var domain = [];
|
|
|
+ var field =['id', 'name', 'reference','invoice_id','state','customer_id','date'];
|
|
|
+ var AccountInterest = new model.web.Model('account.interest');
|
|
|
+ AccountInterest.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ fetchAccountInterestLine: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var domain = [];
|
|
|
+ var field =['id', 'interest_id', 'amount_interest','state'];
|
|
|
+ var AccountInterestLine = new model.web.Model('account.interest.line');
|
|
|
+ AccountInterestLine.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ fethIrModuleModule: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var fields = ['name','id'];
|
|
|
+ var domain=[['state','=','installed'],['name','in',self.modules]];
|
|
|
+ var IrModuleModule = new model.web.Model('ir.module.module');
|
|
|
+ IrModuleModule.query(fields).filter(domain).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*=====================================================================
|
|
|
+ Check type
|
|
|
+ =====================================================================*/
|
|
|
+ fethCheckType: function(){
|
|
|
+ var self = this;
|
|
|
+ var modules = self.checkModel('point_of_sale');
|
|
|
+ if(modules.length == 0){
|
|
|
+ self.$el.find('.type').css('display','none');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ fetchAccountMoveLine: function (){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var domain = [];
|
|
|
+ var field =['id', 'reconcile_ref', 'move_id','date','credit','invoice','period_id'];
|
|
|
+ var AccountMoveLine = new model.web.Model('account.move.line');
|
|
|
+ AccountMoveLine.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*====================================================================
|
|
|
+ UPDATE SELECTIONS
|
|
|
+ ====================================================================*/
|
|
|
+ updateSelections: function () {
|
|
|
+ var self = this;
|
|
|
+ var store;
|
|
|
+ var company = self.$el.find('#current-company').val();
|
|
|
+ if(company != 9999999){
|
|
|
+ store = self.$el.find('#current-store').empty();
|
|
|
+ self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
|
|
|
+ _.each(self.ResStore,function(item){
|
|
|
+ if(parseFloat(company) == item.company_id[0]){
|
|
|
+ self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ store = self.$el.find('#current-store').empty();
|
|
|
+ self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
|
|
|
+ _.each(self.ResStore,function(item){
|
|
|
+ self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ getAccountInvoice:function(origin) {
|
|
|
+ var self = this;
|
|
|
+ var content = self.AccountInvoice;
|
|
|
+ content = _.flatten(_.filter(content,function (item) {
|
|
|
+ return item.origin == origin;
|
|
|
+ }));
|
|
|
+
|
|
|
+ return content;
|
|
|
+ },
|
|
|
+
|
|
|
+ getStoreName:function(store_id){
|
|
|
+ var self = this;
|
|
|
+ var ResStore = _.filter(self.ResStore,function (item) {
|
|
|
+ return item.id == store_id;
|
|
|
+ });
|
|
|
+ return ResStore[0].name;
|
|
|
+ },
|
|
|
+
|
|
|
+ getAccountInvoiceLine:function(invoice_id){
|
|
|
+ var self = this;
|
|
|
+ var supplier = self.$el.find('#current-supplier').val();
|
|
|
+
|
|
|
+ var AccountInvoiceLine = _.filter(self.AccountInvoiceLine,function (item) {
|
|
|
+ return item.invoice_id == invoice_id;
|
|
|
+ });
|
|
|
+ if (supplier & supplier != 9999999){
|
|
|
+ AccountInvoiceLine = _.flatten(_.filter(AccountInvoiceLine,function (item) {
|
|
|
+ return item.t_propietario == supplier;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ return AccountInvoiceLine;
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ getContracts:function(){
|
|
|
+ var self = this;
|
|
|
+ var content = self.Contrato;
|
|
|
+ return content;
|
|
|
+ },
|
|
|
+
|
|
|
+ getContractLine:function(contract_id){
|
|
|
+ var self = this;
|
|
|
+ var ContractLine = _.filter(self.ContractLine,function (item) {
|
|
|
+ return item.analytic_account_id == contract_id;
|
|
|
+ });
|
|
|
+
|
|
|
+ return ContractLine;
|
|
|
+ },
|
|
|
+
|
|
|
+ getUltimoPago:function(move_ids){
|
|
|
+ var self = this;
|
|
|
+ var ref = [];
|
|
|
+ var fechas = [];
|
|
|
+
|
|
|
+ _.each(move_ids,function(item){
|
|
|
+ _.each(self.MoveLine, function(x){
|
|
|
+ if(x.move_id[0] == item && x.reconcile_ref != false){
|
|
|
+ ref.push(x.reconcile_ref)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ _.each(ref,function(item){
|
|
|
+ _.each(self.MoveLine, function(x){
|
|
|
+ if(x.reconcile_ref == item && x.credit > 0){
|
|
|
+ fechas.push(x.date)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ fechas.sort(function (a, b) {
|
|
|
+ if (a> b) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if (a < b) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+
|
|
|
+ return fechas[0]
|
|
|
+ },
|
|
|
+
|
|
|
+ getFechaPago:function(move_id){
|
|
|
+ var self = this;
|
|
|
+ var ref = [];
|
|
|
+ var move = [];
|
|
|
+
|
|
|
+ _.each(self.MoveLine, function(x){
|
|
|
+ if(x.move_id[0] == move_id && x.reconcile_ref != false){
|
|
|
+ ref.push(x.reconcile_ref)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ _.each(ref,function(item){
|
|
|
+ _.each(self.MoveLine, function(x){
|
|
|
+ if(x.reconcile_ref == item && x.credit > 0){
|
|
|
+ move.push(x)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ return move
|
|
|
+ },
|
|
|
+
|
|
|
+ getInterest:function(invoice_id){
|
|
|
+
|
|
|
+ var self = this;
|
|
|
+ var suma = 0;
|
|
|
+ var Interes = _.filter(self.AccountInterest,function (item) {
|
|
|
+ return item.invoice_id[0] == invoice_id;
|
|
|
+ });
|
|
|
+
|
|
|
+ _.each(Interes, function(line){
|
|
|
+
|
|
|
+ var line_ids = _.filter(self.AccountInterestLine,function (item) {
|
|
|
+ return item.interest_id[0] == line.id;
|
|
|
+ });
|
|
|
+
|
|
|
+ _.each(line_ids, function(item){
|
|
|
+ suma = suma + item.amount_interest;
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ return suma
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ BuildTable: function(){
|
|
|
+ var self = this;
|
|
|
+ var data = [];
|
|
|
+ var CurrencyBase = self.ResCompany[0].currency_id;
|
|
|
+ var Contrato = self.getContracts();
|
|
|
+ var period = self.$el.find('#current-period').val();
|
|
|
+ var supplier = self.$el.find('#current-supplier').val();
|
|
|
+
|
|
|
+ _.each(Contrato, function(item){
|
|
|
+ if(item.state == "open"){ var estado = "En curso"};
|
|
|
+ if(item.state == "pending"){ var estado = "A renovar"};
|
|
|
+ if(item.state == "close"){ var estado = "Cerrado"};
|
|
|
+ if(item.state == "cancelled"){ var estado = "Cancelado"};
|
|
|
+
|
|
|
+ var AccountInvoice = self.getAccountInvoice(item.code)
|
|
|
+ var AccountInvoicePaid = _.filter(AccountInvoice,function(x){
|
|
|
+ return x.state == 'paid'
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ var cuotas_pagadas = 0;
|
|
|
+ var cuotas_pagadas_mes = 0;
|
|
|
+ var cuotas_atrasadas = 0;
|
|
|
+ var interes = 0;
|
|
|
+ var suma_interes = 0;
|
|
|
+
|
|
|
+
|
|
|
+ var paid_move_ids = _.flatten(_.map(_.filter(AccountInvoicePaid,function(item){
|
|
|
+ return item.move_id != null;
|
|
|
+ }), function(map){
|
|
|
+ return map.move_id;
|
|
|
+ }));
|
|
|
+
|
|
|
+ var ultimo_pago = self.getUltimoPago(paid_move_ids);
|
|
|
+
|
|
|
+ _.each(AccountInvoicePaid,function(x){
|
|
|
+ cuotas_pagadas = cuotas_pagadas + 1;
|
|
|
+ });
|
|
|
+
|
|
|
+ _.each(_.filter(AccountInvoice,function(x){
|
|
|
+ return x.state == 'open' || x.state == 'draft'
|
|
|
+ }),function(each){
|
|
|
+ cuotas_atrasadas = cuotas_atrasadas + 1;
|
|
|
+ });
|
|
|
+
|
|
|
+ _.each(_.filter(AccountInvoicePaid,function(item){
|
|
|
+ return item.move_id != null;
|
|
|
+ }), function(a){
|
|
|
+ var fecha_pago = self.getFechaPago(a.move_id);
|
|
|
+ a['fecha_pago'] = fecha_pago[0].date;
|
|
|
+ a['period_fecha_pago'] = fecha_pago[0].period_id;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ var suma_comision_inmobiliaria = 0;
|
|
|
+ var suma_comision_vendedor = 0;
|
|
|
+ var suma_comision_total = 0;
|
|
|
+ var owner;
|
|
|
+ var saldo = 0;
|
|
|
+
|
|
|
+ if(period && period != 9999999){
|
|
|
+ AccountInvoicePaid = _.flatten(_.filter(AccountInvoicePaid,function (item) {
|
|
|
+ return item.period_fecha_pago[0] == period;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ _.each(AccountInvoicePaid, function(c){
|
|
|
+
|
|
|
+ interes = self.getInterest(c.invoice_id);
|
|
|
+ suma_interes = suma_interes + interes;
|
|
|
+ cuotas_pagadas_mes = cuotas_pagadas_mes + 1;
|
|
|
+
|
|
|
+ var AccountInvoiceLine = self.getAccountInvoiceLine(c.invoice_id);
|
|
|
+ _.each(AccountInvoiceLine, function(line){
|
|
|
+ suma_comision_inmobiliaria = suma_comision_inmobiliaria + ((line.subtotal * line.comision_inmobiliaria)/100)
|
|
|
+ suma_comision_vendedor = suma_comision_vendedor + ((line.subtotal * line.comision_vendedor)/100)
|
|
|
+ suma_comision_total = suma_comision_total + ((line.subtotal * line.comision_total)/100)
|
|
|
+ owner = line.t_propietario;
|
|
|
+ saldo = (line.price_unit * cuotas_pagadas_mes) + suma_interes - suma_comision_total;
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ var contract_line = self.getContractLine(item.id)
|
|
|
+ if(item.cuota_total > 1){var plazo = item.cuota_total}
|
|
|
+ else{ var plazo = "Contado"}
|
|
|
+
|
|
|
+ _.each(contract_line, function(line){
|
|
|
+
|
|
|
+ if (supplier & supplier != 9999999){
|
|
|
+ if(line.t_propietario == supplier){
|
|
|
+ data.push({
|
|
|
+ id:item.id,
|
|
|
+ t_nro: line.t_nro,
|
|
|
+ t_manzana: line.t_manzana,
|
|
|
+ t_lote:line.t_lote,
|
|
|
+ partner_name: item.partner_name,
|
|
|
+ date_start: moment(item.date_start).format('DD/MM/YYYY'),
|
|
|
+ precio_cuota:accounting.formatMoney(line.price_unit*cuotas_pagadas_mes, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ interes:accounting.formatMoney(suma_interes, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+
|
|
|
+ cuota_total:plazo,
|
|
|
+ ultimo_pago:ultimo_pago != null ? moment(ultimo_pago).format('DD/MM/YYYY') : "",
|
|
|
+ cuotas_pagadas: cuotas_pagadas,
|
|
|
+ cuotas_atrasadas: cuotas_atrasadas,
|
|
|
+ state: estado,
|
|
|
+
|
|
|
+ suma_comision_vendedor:accounting.formatMoney(suma_comision_vendedor, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ suma_comision_inmobiliaria:accounting.formatMoney(suma_comision_inmobiliaria, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ suma_comision_total:accounting.formatMoney(suma_comision_total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ saldo:accounting.formatMoney(saldo, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ ===========================
|
|
|
+ NO FORMAT
|
|
|
+ ===========================
|
|
|
+ */
|
|
|
+ date_no_format: moment(ultimo_pago).format('YYYY-MM-DD'),
|
|
|
+ precio_cuota_no_format: line.price_unit*cuotas_pagadas_mes,
|
|
|
+ interes_no_format:suma_interes,
|
|
|
+ suma_comision_vendedor_no_format: suma_comision_vendedor,
|
|
|
+ suma_comision_inmobiliaria_no_format: suma_comision_inmobiliaria,
|
|
|
+ suma_comision_total_no_format: suma_comision_total,
|
|
|
+ saldo_no_format: saldo,
|
|
|
+
|
|
|
+ /*
|
|
|
+ ===========================
|
|
|
+ FOOTER
|
|
|
+ ===========================
|
|
|
+ */
|
|
|
+ decimal_places:CurrencyBase.decimal_places,
|
|
|
+ thousands_separator:CurrencyBase.thousands_separator,
|
|
|
+ decimal_separator:CurrencyBase.decimal_separator,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ data.push({
|
|
|
+ id:item.id,
|
|
|
+ t_nro: line.t_nro,
|
|
|
+ t_manzana: line.t_manzana,
|
|
|
+ t_lote:line.t_lote,
|
|
|
+ partner_name: item.partner_name,
|
|
|
+ date_start: moment(item.date_start).format('DD/MM/YYYY'),
|
|
|
+ precio_cuota:accounting.formatMoney(line.price_unit*cuotas_pagadas_mes, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ interes:accounting.formatMoney(suma_interes, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+
|
|
|
+ cuota_total:plazo,
|
|
|
+ ultimo_pago:ultimo_pago != null ? moment(ultimo_pago).format('DD/MM/YYYY') : "",
|
|
|
+ cuotas_pagadas: cuotas_pagadas,
|
|
|
+ cuotas_atrasadas: cuotas_atrasadas,
|
|
|
+ state: estado,
|
|
|
+
|
|
|
+ suma_comision_vendedor:accounting.formatMoney(suma_comision_vendedor, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ suma_comision_inmobiliaria:accounting.formatMoney(suma_comision_inmobiliaria, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ suma_comision_total:accounting.formatMoney(suma_comision_total, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ saldo:accounting.formatMoney(saldo, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ ===========================
|
|
|
+ NO FORMAT
|
|
|
+ ===========================
|
|
|
+ */
|
|
|
+ date_no_format: moment(ultimo_pago).format('YYYY-MM-DD'),
|
|
|
+ precio_cuota_no_format: line.price_unit*cuotas_pagadas_mes,
|
|
|
+ interes_no_format:suma_interes,
|
|
|
+ suma_comision_vendedor_no_format: suma_comision_vendedor,
|
|
|
+ suma_comision_inmobiliaria_no_format: suma_comision_inmobiliaria,
|
|
|
+ suma_comision_total_no_format: suma_comision_total,
|
|
|
+ saldo_no_format: saldo,
|
|
|
+
|
|
|
+ /*
|
|
|
+ ===========================
|
|
|
+ FOOTER
|
|
|
+ ===========================
|
|
|
+ */
|
|
|
+ decimal_places:CurrencyBase.decimal_places,
|
|
|
+ thousands_separator:CurrencyBase.thousands_separator,
|
|
|
+ decimal_separator:CurrencyBase.decimal_separator,
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ data.sort(function (a, b) {
|
|
|
+ if (a.date_no_format > b.date_no_format) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if (a.date_no_format < b.date_no_format) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ self.content = data;
|
|
|
+ self.loadTable(data);
|
|
|
+ self.$el.find('.report-form').css('display','block');
|
|
|
+ self.$el.find('.search-form').unblock();
|
|
|
+ self.$el.find('.report-form').unblock();
|
|
|
+ },
|
|
|
+
|
|
|
+ loadTable:function(rowsTable){
|
|
|
+ var self = this;
|
|
|
+ self.rowsData = rowsTable;
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable('load', rowsTable);
|
|
|
+ },
|
|
|
+
|
|
|
+ clickOnAction: function (e) {
|
|
|
+ var self = this;
|
|
|
+ var ResCompany;
|
|
|
+ var CurrencyBase;
|
|
|
+ var action = this.$el.find(e.target).val();
|
|
|
+ var company = $('#current-company').val();
|
|
|
+ if(company && company != 9999999){
|
|
|
+ ResCompany = _.flatten(_.filter(self.ResCompany,function (inv) {
|
|
|
+ return inv.id == company;
|
|
|
+ }));
|
|
|
+ ResCompany = CompanyLogo[0];
|
|
|
+ CurrencyBase = ResCompany[0].currency_id;
|
|
|
+ }else{
|
|
|
+ ResCompany = self.CompanyLogo[0];
|
|
|
+ CurrencyBase = self.ResCompany[0].currency_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ var getColumns=[];
|
|
|
+ var rows=[];
|
|
|
+ var table = this.$el.find("#table");
|
|
|
+ var column = table.bootstrapTable('getVisibleColumns');
|
|
|
+ var row = table.bootstrapTable('getData');
|
|
|
+
|
|
|
+ var price_unit = TotalCuota(row);
|
|
|
+ var interes = TotalInteres(row);
|
|
|
+ var suma_comision_vendedor = TotalComisionVendedor(row);
|
|
|
+ var suma_comision_inmobiliaria = TotalComisionEmpresa(row);
|
|
|
+ var suma_comision_total = TotalComision(row);
|
|
|
+ var saldo = TotalSaldo(row);
|
|
|
+ var cuota_interes = TotalCuotaInteres(row);
|
|
|
+ var iva_vendedor = TotalIvaVendedor(row);
|
|
|
+ var iva_empresa = TotalIvaEmpresa(row);
|
|
|
+ var iva_total = TotalIva(row);
|
|
|
+ var total_desc = TotalDescontar(row);
|
|
|
+ var total_propietario = TotalPropietario(row);
|
|
|
+
|
|
|
+ row.push({
|
|
|
+ t_nro:"Total",
|
|
|
+ precio_cuota:price_unit,
|
|
|
+ cuota_interes:cuota_interes,
|
|
|
+ interes:interes,
|
|
|
+ suma_comision_vendedor:suma_comision_vendedor,
|
|
|
+ suma_comision_inmobiliaria:suma_comision_inmobiliaria,
|
|
|
+ suma_comision_total:suma_comision_total,
|
|
|
+ saldo:saldo,
|
|
|
+ iva_vendedor: iva_vendedor,
|
|
|
+ iva_empresa: iva_empresa,
|
|
|
+ iva_total: iva_total,
|
|
|
+ total_desc:total_desc,
|
|
|
+ total_propietario:total_propietario[0],
|
|
|
+ total_letter:total_propietario[1],
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ if (action === 'pdf') {
|
|
|
+ var data = _.map(column, function (val){
|
|
|
+ return val.field;
|
|
|
+ });
|
|
|
+ _.each(_.map(column,function(val){
|
|
|
+ return val;
|
|
|
+ }), function(item){
|
|
|
+ getColumns.push([{
|
|
|
+ title: item.title,
|
|
|
+ dataKey: item.field
|
|
|
+ }]);
|
|
|
+ });
|
|
|
+ /*
|
|
|
+ ============================================================
|
|
|
+ CONFIGURACION DEL PDF
|
|
|
+ ============================================================
|
|
|
+ */
|
|
|
+ var pdf_title = 'Liquidación Mensual de Cuotas Cobradas.';
|
|
|
+ var pdf_type = 'l';
|
|
|
+ var pdf_name = 'liquidacion_mensual_';
|
|
|
+
|
|
|
+ var pdf_columnStyles = {
|
|
|
+ t_nro:{columnWidth: 10, halign:'center'},
|
|
|
+ t_manzana:{columnWidth:11, halign:'center'},
|
|
|
+ t_lote:{columnWidth: 10, halign:'center'},
|
|
|
+ date_start:{columnWidth: 16,halign:'center'},
|
|
|
+ ultimo_pago:{columnWidth: 16,halign:'center'},
|
|
|
+ cuota_total:{columnWidth:18,align:'center'},
|
|
|
+ cuotas_pagadas:{columnWidth: 16, halign:'center'},
|
|
|
+ cuotas_atrasadas:{columnWidth: 16, halign:'center'},
|
|
|
+ precio_cuota:{columnWidth: 16, halign:'right'},
|
|
|
+ precio_cuota:{columnWidth: 16, halign:'right'},
|
|
|
+ suma_comision_vendedor:{columnWidth: 18, halign:'right'},
|
|
|
+ suma_comision_inmobiliaria:{columnWidth: 18, halign:'right'},
|
|
|
+ suma_comision_total:{columnWidth: 18, halign:'right'},
|
|
|
+ saldo:{columnWidth: 16, halign:'right'},
|
|
|
+ };
|
|
|
+ /*
|
|
|
+ ============================================================
|
|
|
+ LLAMAR FUNCION DE IMPRESION
|
|
|
+ ============================================================
|
|
|
+ */
|
|
|
+ var filter = self.getFilter();
|
|
|
+ var pdf = new reporting.ReportPdfWidgetInmobiliaria(self);
|
|
|
+ pdf.drawPDFInmobiliaria2(
|
|
|
+ _.flatten(getColumns),
|
|
|
+ row,
|
|
|
+ ResCompany,
|
|
|
+ pdf_title,
|
|
|
+ pdf_type,
|
|
|
+ pdf_name,
|
|
|
+ pdf_columnStyles,
|
|
|
+ filter
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getFilter: function(){
|
|
|
+ var self = this;
|
|
|
+ var company = self.$el.find('#current-company').val();
|
|
|
+ var store = self.$el.find('#current-store').val();
|
|
|
+ var supplier = self.$el.find('#current-supplier').val();
|
|
|
+ var period = self.$el.find('#current-period').val();
|
|
|
+
|
|
|
+ var filter = [];
|
|
|
+ if(company && company != 9999999){
|
|
|
+ var ResCompany = _.filter(self.ResCompany, function(item){
|
|
|
+ return item.id == company;
|
|
|
+ });
|
|
|
+ filter.push({
|
|
|
+ title:'Empresa',
|
|
|
+ value: ResCompany[0].name,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(store && store != 9999999){
|
|
|
+ var ResStore = _.filter(self.ResStore,function (item) {
|
|
|
+ return item.id == store;
|
|
|
+ });
|
|
|
+ filter.push({
|
|
|
+ title: 'Sucursal',
|
|
|
+ value: ResStore[0].name,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(supplier && supplier != 9999999){
|
|
|
+ var ResPartner = _.filter(self.ResPartner, function(item){
|
|
|
+ return item.id == supplier;
|
|
|
+ });
|
|
|
+
|
|
|
+ filter.push({
|
|
|
+ title:'Propietario',
|
|
|
+ value: ResPartner[0].name,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(period && period != 9999999){
|
|
|
+ var AccountPeriod = _.filter(self.AccountPeriod, function(item){
|
|
|
+ return item.id == period;
|
|
|
+ });
|
|
|
+ filter.push({
|
|
|
+ title:'Periodo',
|
|
|
+ value: AccountPeriod[0].name,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return filter;
|
|
|
+ },
|
|
|
+ });
|
|
|
+}
|