|
@@ -11,11 +11,9 @@ function report_amortization_and_interest(reporting){
|
|
|
modules: ['point_of_sale'],
|
|
|
|
|
|
events:{
|
|
|
- // 'click #toolbar > button' : 'clickOnAction',
|
|
|
+ 'click #toolbar > button' : 'clickOnAction',
|
|
|
'click #generate' : 'fetchGenerate',
|
|
|
- // 'change #current-company' : 'updateSelections',
|
|
|
'change #current-date' : 'ShowDateRange',
|
|
|
- // 'change #current-period' : 'updatePeriodSelections',
|
|
|
},
|
|
|
|
|
|
init : function(parent){
|
|
@@ -88,6 +86,7 @@ function report_amortization_and_interest(reporting){
|
|
|
}else{
|
|
|
self.$el.find('.journal').css('display','none');
|
|
|
}
|
|
|
+ self.ResCompanyLogo = DataSQL.company_logo;
|
|
|
self.AccountInvoice = DataSQL.invoices;
|
|
|
self.AccountInvoiceLine = DataSQL.invoice_lines;
|
|
|
self.AccountMoveLine = DataSQL.move_lines;
|
|
@@ -241,6 +240,7 @@ function report_amortization_and_interest(reporting){
|
|
|
|
|
|
BuildTable: function(){
|
|
|
var self = this;
|
|
|
+ console.log(self);
|
|
|
var columns = [];
|
|
|
var data = [];
|
|
|
var AccountInvoice = self.getContent();
|
|
@@ -494,122 +494,9 @@ function report_amortization_and_interest(reporting){
|
|
|
$el.bootstrapTable({
|
|
|
columns: columns,
|
|
|
data: data,
|
|
|
- // onExpandRow: function (index, row, $detail) {
|
|
|
- // self.expandSubTable($detail,row.id);
|
|
|
- // }
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- // expandSubTable: function($detail,id) {
|
|
|
- // var self = this;
|
|
|
- // self.BuildSubSubTable($detail.html('<table data-detail-view="true" data-classes="table table-condensed"></table>').find('table'),id);
|
|
|
- // },
|
|
|
- //
|
|
|
- // BuildSubSubTable: function($el,id) {
|
|
|
- // var self = this;
|
|
|
- // var columns = [];
|
|
|
- // var data = [];
|
|
|
- // columns.push({
|
|
|
- // field: 'id',
|
|
|
- // title: 'ID',
|
|
|
- // visible: false,
|
|
|
- // });
|
|
|
- // columns.push({
|
|
|
- // field: 'ruc',
|
|
|
- // title: 'RUC',
|
|
|
- // with:'15%',
|
|
|
- // });
|
|
|
- // columns.push({
|
|
|
- // field: 'name',
|
|
|
- // title: 'Nombre',
|
|
|
- // });
|
|
|
- // columns.push({
|
|
|
- // field: 'amount',
|
|
|
- // title: 'Valor',
|
|
|
- // align:'right',
|
|
|
- // with:'15%',
|
|
|
- // });
|
|
|
- // var company = $('#current-company').val();
|
|
|
- // if(company && company != 9999999){
|
|
|
- // var ResCompany = self.getResCompany(company).shift();
|
|
|
- // var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
|
|
|
- // }else{
|
|
|
- // var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
|
- // };
|
|
|
- // _.each(self.ResPartner,function(item) {
|
|
|
- // if(item.state_id.id == id){
|
|
|
- // var amount = self.getAmount([item.id]);
|
|
|
- // data.push({
|
|
|
- // 'id': item.id,
|
|
|
- // 'ruc': self.valorNull(item.ruc),
|
|
|
- // 'name': item.name,
|
|
|
- // 'amount': accounting.formatMoney(amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
- // });
|
|
|
- // };
|
|
|
- // });
|
|
|
- // $el.bootstrapTable({
|
|
|
- // columns: columns,
|
|
|
- // data: data,
|
|
|
- // onExpandRow: function (index, row, $detail) {
|
|
|
- // self.expandSubSubTable($detail,row.id);
|
|
|
- // }
|
|
|
- // });
|
|
|
- // },
|
|
|
- //
|
|
|
- // expandSubSubTable: function($detail,id) {
|
|
|
- // var self = this;
|
|
|
- // self.BuildSubSubSubTable($detail.html('<table data-classes="table table-condensed"></table>').find('table'),id);
|
|
|
- // },
|
|
|
- //
|
|
|
- // BuildSubSubSubTable: function($el,id) {
|
|
|
- // var self = this;
|
|
|
- // var columns = [];
|
|
|
- // var data = [];
|
|
|
- // columns.push({
|
|
|
- // field: 'date',
|
|
|
- // title: 'Fecha',
|
|
|
- // with:'15%',
|
|
|
- // });
|
|
|
- // columns.push({
|
|
|
- // field: 'number',
|
|
|
- // title: 'Factura',
|
|
|
- // });
|
|
|
- // columns.push({
|
|
|
- // field: 'amount',
|
|
|
- // title: 'Valor',
|
|
|
- // align:'right',
|
|
|
- // with:'15%',
|
|
|
- // });
|
|
|
- // var company = $('#current-company').val();
|
|
|
- // if(company && company != 9999999){
|
|
|
- // var ResCompany = self.getResCompany(company).shift();
|
|
|
- // var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
|
|
|
- // }else{
|
|
|
- // var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
|
- // }
|
|
|
- // var invoice = self.getInvoiceDetails([id]);
|
|
|
- // _.each(invoice,function(index) {
|
|
|
- // data.push({
|
|
|
- // 'date': moment(index.date_invoice).format('DD/MM/YYYY'),
|
|
|
- // 'number': index.number,
|
|
|
- // 'amount': accounting.formatMoney(index.amount_currency, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
- // });
|
|
|
- // });
|
|
|
- // var pos = self.getPosDetails([id]);
|
|
|
- // _.each(pos,function(index) {
|
|
|
- // var utc = moment.utc(index.date_order,'YYYY-MM-DD h:mm:ss A');
|
|
|
- // data.push({
|
|
|
- // 'date': moment(utc._d).format('DD/MM/YYYY'),
|
|
|
- // 'number': index.number,
|
|
|
- // 'amount': accounting.formatMoney(index.amount_currency, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
- // });
|
|
|
- // });
|
|
|
- // $el.bootstrapTable({
|
|
|
- // columns: columns,
|
|
|
- // data: data,
|
|
|
- // });
|
|
|
- // },
|
|
|
-
|
|
|
loadTable:function(rowsTable){
|
|
|
var self = this;
|
|
|
self.rowsData = rowsTable;
|
|
@@ -617,5 +504,154 @@ function report_amortization_and_interest(reporting){
|
|
|
table.bootstrapTable('load', rowsTable);
|
|
|
},
|
|
|
|
|
|
+ /*====================================================================
|
|
|
+ GET RES COMPANY
|
|
|
+ ====================================================================*/
|
|
|
+ getResCompany: function (id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.ResCompanyLogo,function (item) {
|
|
|
+ return item.id == id;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ clickOnAction: function (e) {
|
|
|
+ var self = this;
|
|
|
+ var ResCompany;
|
|
|
+ var action = this.$el.find(e.target).val();
|
|
|
+ var company = $('#current-company').val();
|
|
|
+ var CurrencyBase;
|
|
|
+ if(company && company != 9999999){
|
|
|
+ ResCompany = self.getResCompany(company).shift();
|
|
|
+ CurrencyBase = self.ResCompany[0].currency_id;
|
|
|
+ }else{
|
|
|
+ ResCompany = self.ResCompanyLogo[0];
|
|
|
+ CurrencyBase = self.ResCompany[0].currency_id;
|
|
|
+ }
|
|
|
+ var getColumns=[];
|
|
|
+ var rows=[];
|
|
|
+ var table = this.$el.find("#xtable");
|
|
|
+ var column = table.bootstrapTable('getVisibleColumns');
|
|
|
+ var row = table.bootstrapTable('getData');
|
|
|
+
|
|
|
+ var capital_amount = CapitalAmountFormatter(row);
|
|
|
+ var interest_amount = InterestAmountFormatter(row);
|
|
|
+ var amount = AmountFormatter(row);
|
|
|
+ var residual = ResidualAmountFormatter(row);
|
|
|
+
|
|
|
+ row.push({
|
|
|
+ number:'Totales',
|
|
|
+ capital_amount:capital_amount,
|
|
|
+ interest_amount:interest_amount,
|
|
|
+ amount:amount,
|
|
|
+ residual:residual,
|
|
|
+ });
|
|
|
+
|
|
|
+ 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
|
|
|
+ }]);
|
|
|
+ });
|
|
|
+
|
|
|
+ var pdf_title = 'Amortizaciones e Intereses';
|
|
|
+ var pdf_type = '';
|
|
|
+ var pdf_name = 'amortizaciones_e_intereses';
|
|
|
+ var pdf_columnStyles = {
|
|
|
+ number:{columnWidth: 20, halign:'left'},
|
|
|
+ origin:{columnWidth: 20, halign:'left'},
|
|
|
+ customer_name:{halign:'left'},
|
|
|
+ date_invoice:{columnWidth: 20, halign:'left'},
|
|
|
+ capital_amount :{columnWidth: 25, halign:'right'},
|
|
|
+ interest_amount :{columnWidth: 25, halign:'right'},
|
|
|
+ amount :{columnWidth: 25, halign:'right'},
|
|
|
+ residual:{columnWidth: 25, halign:'right'},
|
|
|
+ };
|
|
|
+
|
|
|
+ var filter = self.getFilter();
|
|
|
+ var pdf = new model.eiru_reports.ReportPdfWidget(self);
|
|
|
+ pdf.drawPDF(
|
|
|
+ _.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 date = self.$el.find('#current-date').val();
|
|
|
+ var desde = self.$el.find('#from').val();
|
|
|
+ var hasta = self.$el.find('#to').val();
|
|
|
+ var filter = [];
|
|
|
+ var fecha;
|
|
|
+ if(company && company){
|
|
|
+ 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(date && date != 9999999){
|
|
|
+ moment.locale('es', {
|
|
|
+ months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
|
|
|
+ });
|
|
|
+ if(date == 'range'){
|
|
|
+ filter.push({
|
|
|
+ title: 'Fecha',
|
|
|
+ value: desde +' al '+hasta,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if(date == 'today'){
|
|
|
+ fecha = moment().format('DD/MM/YYYY');
|
|
|
+ }
|
|
|
+ if(date == 'yesterday'){
|
|
|
+ fecha = moment().add(-1,'days').format('DD/MM/YYYY');
|
|
|
+ }
|
|
|
+ if(date == 'currentMonth'){
|
|
|
+ fecha = moment().format('MMMM/YYYY');
|
|
|
+ }
|
|
|
+ if(date == 'lastMonth'){
|
|
|
+ fecha = moment().add(-1,'months').format('MMMM/YYYY');
|
|
|
+ }
|
|
|
+ filter.push({
|
|
|
+ title: 'Fecha',
|
|
|
+ value: fecha,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return filter;
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
}
|