|
@@ -61,11 +61,35 @@ function report_amortization_and_interest(reporting){
|
|
|
self.fetchDataSQL().then(function (DataSQL) {
|
|
|
return DataSQL;
|
|
|
}).then(function(DataSQL) {
|
|
|
- self.AccountInvoice = DataSQL.invoices;
|
|
|
- self.AccountInvoiceLine = DataSQL.invoice_lines;
|
|
|
- self.AccountJournal = DataSQL.journals;
|
|
|
self.ResCompany = DataSQL.companies;
|
|
|
+ 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');
|
|
|
+ }
|
|
|
self.ResStore = DataSQL.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');
|
|
|
+ }
|
|
|
+ self.AccountJournal = DataSQL.journals;
|
|
|
+ if(self.AccountJournal.length > 1){
|
|
|
+ self.$el.find('#current-journal').append('<option value="9999999">Todas las Facturas</option>');
|
|
|
+ _.each(self.AccountJournal,function(item){
|
|
|
+ self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ self.$el.find('.journal').css('display','none');
|
|
|
+ }
|
|
|
+ self.AccountInvoice = DataSQL.invoices;
|
|
|
+ self.AccountInvoiceLine = DataSQL.invoice_lines;
|
|
|
self.AccountMoveLine = DataSQL.move_lines;
|
|
|
self.AccountVoucher = DataSQL.vouchers;
|
|
|
});
|
|
@@ -87,6 +111,7 @@ function report_amortization_and_interest(reporting){
|
|
|
backgroundColor: '#FAFAFA'
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
return self.BuildTable();
|
|
|
},
|
|
|
|
|
@@ -132,13 +157,95 @@ function report_amortization_and_interest(reporting){
|
|
|
}));
|
|
|
},
|
|
|
|
|
|
+ getContent: function (id) {
|
|
|
+ var self = this;
|
|
|
+ var content = self.AccountInvoice;
|
|
|
+
|
|
|
+ var company = $('#current-company').val();
|
|
|
+ var store = $('#current-store').val();
|
|
|
+ var journal = $('#current-journal').val();
|
|
|
+ var state = $('#current-state').val();
|
|
|
+ var date = self.$el.find('#current-date').val();
|
|
|
+ var desde = self.$el.find('#from').val();
|
|
|
+ var hasta = self.$el.find('#to').val();
|
|
|
+
|
|
|
+ if(company && company != 9999999){
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return item.company_id == company;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(store && store != 9999999){
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return item.store_id == store;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(journal && journal != 9999999){
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return item.journal_id == journal;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(state && state != 9999999){
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return item.state == state;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(date && date != 9999999){
|
|
|
+ if(date == 'range'){
|
|
|
+ if(desde){
|
|
|
+ date = desde.split('/');
|
|
|
+ date = (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return item.date >= date;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(hasta){
|
|
|
+ date = hasta.split('/');
|
|
|
+ date = (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return item.date <= date;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(date == 'today'){
|
|
|
+ var today = moment().format('YYYY-MM-DD');
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return item.date == today;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(date == 'yesterday'){
|
|
|
+ var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return item.date == yesterday;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(date == 'currentMonth'){
|
|
|
+ var currentMonth = moment().format('YYYY-MM');
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return moment(item.date).format('YYYY-MM') == currentMonth;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(date == 'lastMonth'){
|
|
|
+ var lastMonth = moment().add(-1,'months').format('YYYY-MM');
|
|
|
+ content = _.filter(content,function (item) {
|
|
|
+ return moment(item.date).format('YYYY-MM') == lastMonth;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return content;
|
|
|
+ },
|
|
|
+
|
|
|
BuildTable: function(){
|
|
|
var self = this;
|
|
|
- console.log(self);
|
|
|
var columns = [];
|
|
|
var data = [];
|
|
|
+ var AccountInvoice = self.getContent();
|
|
|
var CurrencyBase = self.ResCompany[0].currency_id;
|
|
|
- _.each(self.AccountInvoice,function(item) {
|
|
|
+ _.each(AccountInvoice,function(item) {
|
|
|
if(item.is_interest == null){
|
|
|
var pagado = self.getAccountVoucher(item.number);
|
|
|
var AccountInvoiceLine = self.getAccountInvoiceLine(item.invoice_id);
|
|
@@ -187,6 +294,7 @@ function report_amortization_and_interest(reporting){
|
|
|
DATOS SIN FORMATO
|
|
|
########################
|
|
|
*/
|
|
|
+ date:item.date,
|
|
|
capital_amount_value: capital,
|
|
|
interest_amount_value:interes,
|
|
|
amount_value:item.amount,
|
|
@@ -194,6 +302,15 @@ function report_amortization_and_interest(reporting){
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
+ data.sort(function (a, b) {
|
|
|
+ if (a.date > b.date) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if (a.date < b.date) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
self.loadTable(data);
|
|
|
self.$el.find('.report-form').css('display','block');
|
|
|
self.$el.find('.search-form').unblock();
|