|
@@ -0,0 +1,591 @@
|
|
|
+function report_normal_pos_utilidad(reporting){
|
|
|
+ "use strict";
|
|
|
+
|
|
|
+ var instance = openerp;
|
|
|
+
|
|
|
+ reporting.ReportNormalPosUtilidadWidget = reporting.Base.extend({
|
|
|
+ template: 'ReportNormalPosUtilidad',
|
|
|
+ content: [],
|
|
|
+ rowsData :[],
|
|
|
+ modules:[],
|
|
|
+
|
|
|
+ events:{
|
|
|
+ 'click #toolbar > button' : 'clickOnAction',
|
|
|
+ 'click #X' : 'factSearch',
|
|
|
+ 'click #A' : 'factSearch',
|
|
|
+ 'click #B' : 'factSearch',
|
|
|
+ 'click #C' : 'factSearch',
|
|
|
+ 'click #D' : 'factSearch',
|
|
|
+ 'click #Z' : 'factSearch',
|
|
|
+ 'change #from' : 'factSearch',
|
|
|
+ 'change #to' : 'factSearch',
|
|
|
+ 'change #user' : 'factSearch',
|
|
|
+ 'change #current-journal' : 'factSearch',
|
|
|
+ 'change #current-store' : 'factSearch',
|
|
|
+ 'click-row.bs.table #table ' : 'ckickAnalysisDetail',
|
|
|
+ },
|
|
|
+
|
|
|
+ init : function(parent){
|
|
|
+ this._super(parent);
|
|
|
+ },
|
|
|
+
|
|
|
+ start: function () {
|
|
|
+ var self = this;
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable({data : self.rowsData});
|
|
|
+ this.submitForm();
|
|
|
+ },
|
|
|
+
|
|
|
+ submitForm: function () {
|
|
|
+ var self = this;
|
|
|
+ self.fetchPosOrder().then(function(PosOrder){
|
|
|
+ return PosOrder;
|
|
|
+ }).then(function(PosOrder) {
|
|
|
+ self.PosOrder = PosOrder;
|
|
|
+ return self.fetchPosOrderLine();
|
|
|
+ }).then(function (PosOrderLine){
|
|
|
+ self.PosOrderLine = PosOrderLine;
|
|
|
+ return self.fetchAccountInvoice();
|
|
|
+ }).then(function (AccountInvoice){
|
|
|
+ self.AccountInvoice = AccountInvoice;
|
|
|
+ return self.fetchAccountInvoiceLine();
|
|
|
+ }).then(function (AccountInvoiceLine){
|
|
|
+ self.AccountInvoiceLine = AccountInvoiceLine;
|
|
|
+ return self.fetchProductProduct();
|
|
|
+ }).then(function (ProductProduct){
|
|
|
+ self.ProductProduct = ProductProduct;
|
|
|
+ return self.fetchAccountPeriod();
|
|
|
+ }).then(function (AccountPeriod){
|
|
|
+ self.AccountPeriod = AccountPeriod;
|
|
|
+ return self.fecthAccountJournal();
|
|
|
+ }).then(function(AccountJournal){
|
|
|
+ self.AccountJournal = AccountJournal;
|
|
|
+ return self.fetchResCompany();
|
|
|
+ }).then(function(ResCompany) {
|
|
|
+ self.ResCompany = ResCompany;
|
|
|
+ return self.fetchResCurrency();
|
|
|
+ }).then(function(ResCurrency) {
|
|
|
+ self.ResCurrency = ResCurrency;
|
|
|
+ return self.showMonth();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /*=============
|
|
|
+ POS ORDER
|
|
|
+ =============*/
|
|
|
+ fetchPosOrder: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var domain =[['state', 'in',['done','paid','invoiced']]];
|
|
|
+ var field =['id', 'partner_id','name', 'session_id', 'state', 'table_id', 'statement_ids','create_date','amount_total','user_id','amount_tax','sale_journal','date_order'];
|
|
|
+ var PosOrder = new instance.web.Model('pos.order');
|
|
|
+ PosOrder.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*==================
|
|
|
+ POS ORDER LINE
|
|
|
+ ==================*/
|
|
|
+ fetchPosOrderLine: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var order_ids = _.flatten(_.map(self.PosOrder, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ var domain =[['order_id', 'in',order_ids]];
|
|
|
+ var field =['id', 'product_id','order_id'];
|
|
|
+ var PosOrderLine = new instance.web.Model('pos.order.line');
|
|
|
+ PosOrderLine.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*===================
|
|
|
+ ACCOUNT INVOICE
|
|
|
+ ===================*/
|
|
|
+ fetchAccountInvoice: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var domain = [['state','in',['open','paid']]];
|
|
|
+ var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'date_invoice','amount_total','amount_tax','amount_untaxed'];
|
|
|
+ var AccountInvoice = new instance.web.Model('account.invoice');
|
|
|
+ AccountInvoice.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*========================
|
|
|
+ ACCOUNT INVOICE LINE
|
|
|
+ ========================*/
|
|
|
+ fetchAccountInvoiceLine: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var invoice_ids = _.flatten(_.map(self.AccountInvoice, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ var domain = [['invoice_id','in',invoice_ids]];
|
|
|
+ var field =['id', 'product_id','invoice_id'];
|
|
|
+ var AccountInvoiceLine = new instance.web.Model('account.invoice.line');
|
|
|
+ AccountInvoiceLine.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*===================
|
|
|
+ PRODUCT PRODUCT
|
|
|
+ ===================*/
|
|
|
+ fetchProductProduct: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var field =['id', 'name','standard_price'];
|
|
|
+ var ProductProduct = new instance.web.Model('product.product');
|
|
|
+ ProductProduct.query(field).filter().all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*==================
|
|
|
+ ACCOUNT PERIOD
|
|
|
+ ==================*/
|
|
|
+ fetchAccountPeriod: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var domain = [['special','=',false]];
|
|
|
+ var field =['id', 'name', 'date_start'];
|
|
|
+ var AccountPeriod = new instance.web.Model('account.period');
|
|
|
+ AccountPeriod.query(field).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*===================
|
|
|
+ ACCOUNT JOURNAL
|
|
|
+ ===================*/
|
|
|
+ fecthAccountJournal: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var field = ['id', 'name','store_ids','type'];
|
|
|
+ var domain = [['active','=',true],['type','in',['sale','sale_refund']]];
|
|
|
+ var AccountJournal = new instance.web.Model('account.journal');
|
|
|
+ AccountJournal.query(field).filter(domain).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*===============
|
|
|
+ RES COMPANY
|
|
|
+ ===============*/
|
|
|
+ fetchResCompany: function() {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var fields = ['id','name', 'currency_id'];
|
|
|
+ var domain = [['id', '=', self.session.company_id]];
|
|
|
+ var ResCompany = new instance.web.Model('res.company');
|
|
|
+ ResCompany.query(fields).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*================
|
|
|
+ RES CURRENCY
|
|
|
+ ================*/
|
|
|
+ fetchResCurrency : function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
|
|
|
+ var domain = [['active', '=', true]];
|
|
|
+ var ResCurrency = new instance.web.Model('res.currency');
|
|
|
+ ResCurrency.query(fields).filter(domain).all().then(function(results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*=============================
|
|
|
+ GET CURRENCY BASE DETAILS
|
|
|
+ ===============================*/
|
|
|
+ getResCurrency: function (id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.ResCurrency,function (item) {
|
|
|
+ return item.id === id;
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /*======================
|
|
|
+ POS ORDER BY MONTH
|
|
|
+ ======================*/
|
|
|
+ getMonthPosOrder:function(mes) {
|
|
|
+ var self = this;
|
|
|
+ return _.flatten(_.filter(self.PosOrder,function (inv) {
|
|
|
+ var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
|
|
|
+ return moment(utc._d).format('YYYY-MM') === moment(mes).format('YYYY-MM');
|
|
|
+ }));
|
|
|
+ },
|
|
|
+
|
|
|
+ /*======================
|
|
|
+ GET POS ORDER LINE
|
|
|
+ ======================*/
|
|
|
+ getPosOrderLine:function(order) {
|
|
|
+ var self = this;
|
|
|
+ var order_ids = _.flatten(_.map(order, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ return _.flatten(_.filter(self.PosOrderLine,function (inv) {
|
|
|
+ return _.contains(order_ids, inv.order_id[0]);
|
|
|
+ }));
|
|
|
+ },
|
|
|
+
|
|
|
+ /*============================
|
|
|
+ ACCOUNT INVOICE BY MONTH
|
|
|
+ ============================*/
|
|
|
+ getMonthAccountInvoice:function(mes, type) {
|
|
|
+ var self = this;
|
|
|
+ var journals = _.filter(self.AccountJournal,function (inv) {
|
|
|
+ return inv.type == type;
|
|
|
+ });
|
|
|
+ if(journals.length > 0){
|
|
|
+ var journal_ids = _.flatten(_.map(journals, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ return _.flatten(_.filter(self.AccountInvoice,function (inv) {
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM') === moment(mes).format('YYYY-MM') & _.contains(journal_ids, inv.journal_id[0]);
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /*============================
|
|
|
+ GET ACCOUNT INVOICE LINE
|
|
|
+ ============================*/
|
|
|
+ getAccountInvoiceLine:function(invoice) {
|
|
|
+ var self = this;
|
|
|
+ var invoice_ids = _.flatten(_.map(invoice, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ return _.flatten(_.filter(self.AccountInvoiceLine,function (inv) {
|
|
|
+ return _.contains(invoice_ids, inv.invoice_id[0]);
|
|
|
+ }));
|
|
|
+ },
|
|
|
+
|
|
|
+ /*=======================
|
|
|
+ GET PRODUCT PRODUCT
|
|
|
+ =======================*/
|
|
|
+ getProductProduct: function (id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.ProductProduct,function (item) {
|
|
|
+ return item.id === id;
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /*==============
|
|
|
+ GET LINES
|
|
|
+ ==============*/
|
|
|
+ getCost:function(lines) {
|
|
|
+ var self = this;
|
|
|
+ var data = [];
|
|
|
+ var product;
|
|
|
+ _.each(lines, function (item) {
|
|
|
+ product = self.getProductProduct(item.product_id[0]);
|
|
|
+ data.push({
|
|
|
+ name: product[0].name,
|
|
|
+ standard_price: product[0].standard_price,
|
|
|
+ })
|
|
|
+ });
|
|
|
+ var total = _.reduce(_.map(data,function(item) {
|
|
|
+ return item.standard_price;
|
|
|
+ }),function(memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ },0);
|
|
|
+ return total;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*=========
|
|
|
+ BUILD
|
|
|
+ =========*/
|
|
|
+ showMonth: function() {
|
|
|
+ var self = this;
|
|
|
+ var AccountPeriod = self.AccountPeriod;
|
|
|
+ var order;
|
|
|
+ var order_line;
|
|
|
+ var invoice;
|
|
|
+ var invoice_line;
|
|
|
+ var invoice_refund;
|
|
|
+ var title = [];
|
|
|
+ var body = [];
|
|
|
+ var data = [];
|
|
|
+ var array = [];
|
|
|
+ var order_cost = 0;
|
|
|
+ var invoice_cost = 0;
|
|
|
+ var total_cost = 0;
|
|
|
+ var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
|
|
|
+ _.each(AccountPeriod, function (index) {
|
|
|
+
|
|
|
+ order = self.getMonthPosOrder(index.date_start);
|
|
|
+ order_line = self.getPosOrderLine(order);
|
|
|
+ order_cost = self.getCost(order_line);
|
|
|
+
|
|
|
+ invoice = self.getMonthAccountInvoice(index.date_start, 'sale');
|
|
|
+ invoice_line = self.getAccountInvoiceLine(invoice);
|
|
|
+ invoice_cost = self.getCost(invoice_line);
|
|
|
+
|
|
|
+ invoice_refund = self.getMonthAccountInvoice(index.date_start, 'sale_refund');
|
|
|
+
|
|
|
+ total_cost = order_cost + invoice_cost;
|
|
|
+
|
|
|
+ /*=============
|
|
|
+ POS ORDER
|
|
|
+ =============*/
|
|
|
+ var order_total_tax = _.reduce(_.map(order,function(item) {
|
|
|
+ return item.amount_tax;
|
|
|
+ }),function(memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ },0);
|
|
|
+
|
|
|
+ var order_total = _.reduce(_.map(order,function(item) {
|
|
|
+ return item.amount_total;
|
|
|
+ }),function(memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ },0);
|
|
|
+
|
|
|
+ var order_total_untaxed = order_total - order_total_tax;
|
|
|
+
|
|
|
+
|
|
|
+ /*================
|
|
|
+ SALE INVOICE
|
|
|
+ ================*/
|
|
|
+ array = [];
|
|
|
+ _.each(invoice, function (item) {
|
|
|
+ var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
|
+ array.push({
|
|
|
+ amount_untaxed: item.amount_untaxed * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
+ amount_tax: item.amount_tax * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
+ amount_total: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
+ })
|
|
|
+ });
|
|
|
+ var invoice_total_untaxed = 0;
|
|
|
+ var invoice_total_tax = 0;
|
|
|
+ var invoice_total = 0;
|
|
|
+ if(array.length > 0){
|
|
|
+ /*===========
|
|
|
+ UNTAXED
|
|
|
+ ===========*/
|
|
|
+ invoice_total_untaxed = _.reduce(_.map(array, function (map) {
|
|
|
+ return map.amount_untaxed;
|
|
|
+ }), function (memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ });
|
|
|
+
|
|
|
+ /*===========
|
|
|
+ TAXED
|
|
|
+ ===========*/
|
|
|
+ invoice_total_tax = _.reduce(_.map(array, function (map) {
|
|
|
+ return map.amount_tax;
|
|
|
+ }), function (memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ });
|
|
|
+
|
|
|
+ /*=========
|
|
|
+ TOTAL
|
|
|
+ =========*/
|
|
|
+ invoice_total = _.reduce(_.map(array, function (map) {
|
|
|
+ return map.amount_total;
|
|
|
+ }), function (memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /*===============
|
|
|
+ SALE REFUND
|
|
|
+ ===============*/
|
|
|
+ array = [];
|
|
|
+ _.each(invoice_refund, function (item) {
|
|
|
+ var currency = self.getResCurrency(item.currency_id[0]).shift();
|
|
|
+ array.push({
|
|
|
+ amount_untaxed: item.amount_untaxed * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
+ amount_tax: item.amount_tax * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
+ amount_total: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
|
|
|
+ })
|
|
|
+ });
|
|
|
+ var invoice_refund_total_untaxed = 0;
|
|
|
+ var invoice_refund_total_tax = 0;
|
|
|
+ var invoice_refund_total = 0;
|
|
|
+ if(array.length > 0){
|
|
|
+ /*===========
|
|
|
+ UNTAXED
|
|
|
+ ===========*/
|
|
|
+ invoice_refund_total_untaxed = _.reduce(_.map(array, function (map) {
|
|
|
+ return map.amount_untaxed;
|
|
|
+ }), function (memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ });
|
|
|
+
|
|
|
+ /*===========
|
|
|
+ TAXED
|
|
|
+ ===========*/
|
|
|
+ invoice_refund_total_tax = _.reduce(_.map(array, function (map) {
|
|
|
+ return map.amount_tax;
|
|
|
+ }), function (memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ });
|
|
|
+
|
|
|
+ /*=========
|
|
|
+ TOTAL
|
|
|
+ =========*/
|
|
|
+ invoice_refund_total = _.reduce(_.map(array, function (map) {
|
|
|
+ return map.amount_total;
|
|
|
+ }), function (memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /*======================
|
|
|
+ SALE UNTAXED TOTAL
|
|
|
+ ======================*/
|
|
|
+ var sale_untaxed_total = order_total_untaxed + invoice_total_untaxed - invoice_refund_total_untaxed;
|
|
|
+
|
|
|
+ /*====================
|
|
|
+ SALE TAXED TOTAL
|
|
|
+ ====================*/
|
|
|
+ var sale_tax_total = order_total_tax + invoice_total_tax - invoice_refund_total_tax;
|
|
|
+
|
|
|
+ /*==============
|
|
|
+ SALE TOTAL
|
|
|
+ ==============*/
|
|
|
+ var sale_total = order_total + invoice_total - invoice_refund_total;
|
|
|
+
|
|
|
+ /*=============
|
|
|
+ BENEFICIO
|
|
|
+ =============*/
|
|
|
+ var profit = sale_untaxed_total - total_cost;
|
|
|
+
|
|
|
+ /*==========
|
|
|
+ MARGIN
|
|
|
+ ==========*/
|
|
|
+
|
|
|
+ var margin = (total_cost * 100)/sale_untaxed_total;
|
|
|
+ margin = 100 - margin;
|
|
|
+
|
|
|
+ if(sale_untaxed_total > 0 || sale_tax_total > 0 || sale_total > 0){
|
|
|
+ data.push({
|
|
|
+ name: index.name,
|
|
|
+ subtotal: accounting.formatMoney(sale_untaxed_total, CurrencyBase.symbol, 2, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ tax: accounting.formatMoney(sale_tax_total, CurrencyBase.symbol, 2, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ cost: accounting.formatMoney(total_cost, CurrencyBase.symbol, 2, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ margin: accounting.formatNumber(margin,2,".",",") + '%',
|
|
|
+ total: accounting.formatMoney(sale_total, CurrencyBase.symbol, 2, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ profit: accounting.formatMoney(profit, CurrencyBase.symbol, 2, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ body.push(sale_total);
|
|
|
+ title.push(index.name);
|
|
|
+
|
|
|
+ });
|
|
|
+ self.loadTable(data);
|
|
|
+ self.fetchChart(title,body,CurrencyBase);
|
|
|
+ },
|
|
|
+
|
|
|
+ loadTable:function(rowsTable){
|
|
|
+ var self = this;
|
|
|
+ self.rowsData = rowsTable;
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable('load',rowsTable);
|
|
|
+ },
|
|
|
+
|
|
|
+ /*===============
|
|
|
+ BUILD CHART
|
|
|
+ ===============*/
|
|
|
+ fetchChart: function (title,body,CurrencyBase) {
|
|
|
+ var self = this;
|
|
|
+ var label = title;
|
|
|
+ var body = body;
|
|
|
+
|
|
|
+ Chart.scaleService.updateScaleDefaults('linear', {
|
|
|
+ ticks: {
|
|
|
+ callback: function(tick) {
|
|
|
+ return tick.toLocaleString('de-DE');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
|
|
|
+ var dataset = data.datasets[tooltipItem.datasetIndex];
|
|
|
+ var datasetLabel = dataset.label || '';
|
|
|
+ return datasetLabel + dataset.data[tooltipItem.index].toLocaleString('de-DE');
|
|
|
+ };
|
|
|
+
|
|
|
+ var chart = new Chart($('.reporting-chart'), {
|
|
|
+ type: 'line',
|
|
|
+ data: {
|
|
|
+ labels: label,
|
|
|
+ datasets: [
|
|
|
+ {
|
|
|
+ label: false,
|
|
|
+ data: body,
|
|
|
+ backgroundColor: '#bbdefb',
|
|
|
+ borderColor: '#0288d1',
|
|
|
+ borderWidth: 1,
|
|
|
+ fill: true,
|
|
|
+ datalabels : {
|
|
|
+ align : 'end',
|
|
|
+ anchor : 'end',
|
|
|
+ display: true,
|
|
|
+ backgroundColor: function(context) {
|
|
|
+ return context.dataset.backgroundColor;
|
|
|
+ },
|
|
|
+ borderRadius: 4,
|
|
|
+ color: '#001f3f',
|
|
|
+ font: {
|
|
|
+ weight: 'bold'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ responsiveAnimationDuration:10,
|
|
|
+ maintainAspectRatio:false,
|
|
|
+
|
|
|
+ title: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ layout: {
|
|
|
+ padding: {
|
|
|
+ top: 0,
|
|
|
+ bottom: 45,
|
|
|
+ left : 0,
|
|
|
+ rigth: 0,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ events: ['click'],
|
|
|
+ tooltips: {
|
|
|
+ callbacks: {
|
|
|
+ label: function(tooltipItem, data) {
|
|
|
+ var label = data.datasets[tooltipItem.datasetIndex].label || '';
|
|
|
+
|
|
|
+ if (label) {
|
|
|
+ label += ': ';
|
|
|
+ }
|
|
|
+ label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ });
|
|
|
+}
|