1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722 |
- "use strict";
- openerp.eiru_reporting = function (instance, local) {
- var QWeb = instance.web.qweb;
- var number= instance.web;
- local.ReportingWidget = instance.Widget.extend({
- template: 'EiruReporting',
- events: {
- 'click .report_action > button': 'clickOnReport',
- },
- reports: [
- {
- title: 'Resumen de ingresos',
- description: 'Permite visualizar de forma global los ingresos obtenidos por la empresa.',
- action: 'ReportResumenIngreso'
- },
- {
- title: 'Resumen de egresos',
- description: 'Permite visualizar de forma global los egresos realizado por la empresa.',
- action: 'ReportResumenEngreso'
- },
- {
- title: 'Utilidad de facturas detalladas',
- description: 'Permite visualizar la ganancia de cada ítem de las facturas detalladamente.',
- action: 'ReportInvoiceUtility'
- },
- {
- title: 'Histórico de compras',
- description: 'Permite visualizar un histórico de compras realizado por la empresa.',
- action: 'AllPurchases'
- },
- {
- title: 'Histórico de gastos',
- description: 'Permite visualizar un histórico de gastos realizado por la empresa.',
- action: 'ReposrtExpenses'
- },
- {
- title: 'Listado de productos por ubicación',
- description: 'Permite visualizar un listado de productos activos.',
- action: 'ReportStockLocation'
- }
- ],
- start: function () {
- },
- clickOnReport: function (e) {
- var templateName = this.$el.find(e.target).val();
- this.renderReport(templateName);
- },
- renderReport: function (templateName) {
- var Widget = this.getWidgetFromTemplate(templateName);
- var WidgetInstance = new Widget(this);
- var container = this.$el.find('.oe_form_sheet.oe_form_sheet_width');
- container.find('.report_view').hide({
- effect: 'fade',
- duration: 200,
- complete: function () {
- WidgetInstance.appendTo(container);
- }
- });
- },
- getWidgetFromTemplate: function (templateName) {
- var widgetName = `${templateName}Widget`;
- return _.pick(local, widgetName)[widgetName];
- },
- });
- // InvoiceUtility
- local.ReportInvoiceUtilityWidget = instance.Widget.extend({
- template: 'ReportInvoiceUtility',
- invoices: [],
- invoiceLines: [],
- productProduct:[],
- Currency:[],
- rowsData :[],
- rowOrigin:[],
- accountJournal:[],
- resCompany:[],
- events:{
- 'click #toolbar > button' : 'clickOnAction',
- 'change #current-journal': 'fectSearch',
- 'change #from' : 'fectSearch',
- 'change #to': 'fectSearch',
- 'click #volver_btn': 'volver',
- },
- init : function(parent){
- this._super(parent);
- },
- start: function () {
- var table = this.$el.find('#table');
- table.bootstrapTable({data : self.rowOrigin});
- this.fecthFecha();
- this.submitForm();
- },
- // volver
- volver: function(){
- this.$el.find('#volver').empty();
- this.$el.find('#grafico').empty();
- this.$el.find('.bootstrap-table').show({
- effect: 'drop',
- direction: 'down',
- duration: 200,
- });
- },
- // Cansultar
- submitForm: function () {
- var self = this;
- this.fetchCurency().then(function(Currency) {
- self.Currency = Currency;
- return Currency;
- }).then(function (Currency) {
- return self.fetchJournal();
- }).then(function (journal) {
- self.accountJournal =journal;
- self.$el.find('#current-journal').append('<option value="9999999">TODAS LAS SUC.</option>');
- _.each(journal, function (item) {
- self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
- });
- return self.fetchInvoiceV2();
- }).then(function (invoices){
- self.invoices = invoices;
- return self.fetchInvoiceLine(invoices);
- }).then(function (invoiceLines) {
- self.invoiceLines = invoiceLines;
- return self.fecthProduct(invoiceLines);
- }).then(function(productProduct){
- self.productProduct = productProduct;
- return self.fecthComanyCurrency();
- }).then(function(resCompany){
- self.resCompany = resCompany;
- return self.invoice_Currency();
- });
- },
- // company_curency
- fecthComanyCurrency: function(){
- var self = this;
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.company');
- var field=['id', 'currency_id'];
- var domain=[['id','=',1]];
- currency.query(field).filter(domain).all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Fecha
- fecthFecha: function() {
- var to;
- var dateFormat1 = "mm/dd/yy",
- from = $( "#from" )
- .datepicker({
- dateFormat: "dd/mm/yy",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
- });
- to = $( "#to" ).datepicker({
- dateFormat: "dd/mm/yy",
- defaultDate: "+7d",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- from.datepicker( "option", "maxDate", getDate(this));
- });
- function getDate( element ) {
- var fechaSel =element.value.split('/');
- var date;
- try {
- date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
- } catch( error ) {
- date = null;
- }
- return date;
- }
- },
- // Buscar Diario
- fetchJournal: function () {
- var self = this;
- var defer = $.Deferred();
- var Journal = new instance.web.Model('account.journal');
- Journal.query(['id', 'name']).filter([['type', '=', 'sale'], ['active', '=', true]]).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Buscar Cambio de Monedas USD,PYG,ARG,BRL
- fetchCurency: function () {
- var defer = $.Deferred();
- var currency_Rate = new instance.web.Model('res.currency.rate');
- var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
- var domain = [['currency_id', '=', [166 , 20, 7, 3]]];
- currency_Rate.query(fields).filter(domain).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Invoice (FACTURAS)
- fetchInvoiceV2: function () {
- var filter ="[['state', '=',['open','paid']],['type', '=', 'out_invoice']";
- var journal_ids = _.flatten(_.map(this.accountJournal, function (item) {
- return item.id;
- }));
- if (journal_ids){
- filter=filter.concat(",['journal_id', '=',["+journal_ids+"]]");
- }
- filter=filter.concat("]");
- var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice'];
- var defer = $.Deferred();
- var Invoice = new instance.web.Model('account.invoice');
- Invoice.query(field).filter(filter).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Invoice line (Linea de Factura)
- fetchInvoiceLine: function (invoices) {
- var defer = $.Deferred();
- var linesIds = _.flatten(_.map(invoices, function (item) {
- return item.invoice_line;
- }));
- var InvoiceLine = new instance.web.Model('account.invoice.line');
- InvoiceLine.query(['id', 'quantity', 'price_unit', 'discount', 'name', 'product_id', 'origin','invoice_id']).filter([['id', 'in', linesIds]]).all().then(function (results) {
- defer.resolve(results)
- });
- return defer;
- },
- // Product Product
- fecthProduct: function(invoiceLines){
- var defer = $.Deferred();
- var porductIDS = _.flatten(_.map(invoiceLines, function (item) {
- return item.product_id[0];
- }));
- var ProductProdcut = new instance.web.Model('product.product');
- var fields = ['id', 'default_code', 'name_template', 'factory_code', 'factory_reference', 'factory_barcode', 'standard_price','type'];
- ProductProdcut.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
- defer.resolve(results)
- });
- return defer;
- },
- // Obtener Monedas de la Factura
- getCutrrency: function (id){
- return _.find(this.Currency,function (curr) {
- return _.contains(curr.currency_id,id);
- });
- },
- // Actualizar cambio de las moneda de Factura
- invoice_Currency: function(){
- for (var i = 0; i < this.invoices.length; i++) {
- var currency_new;
- var item = this.invoices[i];
- var id = item.currency_id[0];
- currency_new = this.getCutrrency(id);
- if (!currency_new){
- currency_new={};
- currency_new.rate=1;
- }
- this.invoices[i].rate=(currency_new.rate);
- }
- return this.fectUtility();
- },
- // Obtener la Detalles de la Factura
- getInvoice: function (id_line){
- return _.find(this.invoices, function (inv) {
- return _.contains(inv.invoice_line, id_line);
- });
- },
- // Obtener las lineas de las Facturas
- getProduct: function(pro_id){
- return _.find(this.productProduct, function(prod){
- return _.contains(pro_id, prod.id);
- });
- },
- // unir los objetos
- fectUtility: function(){
- var data=[];
- var item;
- var invoice;
- var producto;
- for (var i = 0; i < this.invoiceLines.length; i++) {
- item = this.invoiceLines[i];
- invoice = this.getInvoice(item.id);
- producto =this.getProduct(item.product_id);
- if (!producto){
- producto={};
- producto.standard_price=0;
- }
- if (producto.type =="product"){
- data.push({
- number : (invoice.number),
- name : (item.name),
- quantity : accounting.formatNumber((item.quantity),0, ".", ","),
- price_unity : accounting.formatNumber((item.price_unit / invoice.rate),2, ".", ","),
- standar_price : accounting.formatNumber((producto.standard_price),2, ".", ","),
- price_tot : accounting.formatNumber((item.quantity * (item.price_unit / invoice.rate)),2, ".", ","),
- standar_tot : accounting.formatNumber((item.quantity * producto.standard_price),2, ".", ","),
- utility : accounting.formatNumber(((item.quantity * (item.price_unit / invoice.rate)) - (item.quantity * producto.standard_price)),2, ".", ","),
- journal_id :(invoice.journal_id[0]),
- journal_name :(invoice.journal_id[1]),
- date_invoice : (invoice.date_invoice),
- });
- }
- }
- this.rowsData=data;
- this.rowOrigin=data;
- this.loadTable(data)
- },
- // Buscar
- fectSearch: function(){
- var self = this;
- var desde =this.$el.find('#from').val();
- var hasta =this.$el.find('#to').val();
- var suc =this.$el.find('#current-journal').val();
- self.rowsData=self.rowOrigin;
- if (suc != 9999999){
- self.rowsData=_.filter(self.rowsData, function (inv){ return inv.journal_id == suc});
- }
- if (desde){
- var date= desde.split('/')
- self.rowsData=_.filter(self.rowsData, function (inv){
- return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0])
- });
- }
- if (hasta){
- var date= hasta.split('/')
- self.rowsData=_.filter(self.rowsData, function (inv){
- return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0])
- });
- }
- self.loadTable(self.rowsData);
- },
- // cargara la tabla
- loadTable:function(rowsTable){
- var table = this.$el.find('#table');
- table.bootstrapTable('load', rowsTable);
- },
- // imprimir PDF
- clickOnAction: function (e) {
- var action = this.$el.find(e.target).val();
- var self = this;
- var getColumns=[];
- var rows=[];
- var table = this.$el.find("#table");
- var data2 = table.bootstrapTable('getVisibleColumns');
- if (action === 'pdf') {
- var dataNEW = _.map(data2, function (val){ return val.field});
- _.each(this.rowsData,function (item){
- rows.push(_.pick(item, dataNEW));
- });
- // Obtener los nombre de la Cabezera
- _.each(_.map(data2,function(val){
- return val}), function(item){
- getColumns.push([{
- title: item.title,
- dataKey: item.field
- }]);
- });
- // Llamar al pdf
- this.drawPDF(_.flatten(getColumns),rows)
- }
- if (action === 'chart'){
- var suc =this.$el.find('#current-journal').val();
- if (suc == 9999999){
- self.fectCharFilter();
- }else{
- $("#dialog" ).dialog({
- autoOpen: true,
- resizable: false,
- modal: true,
- title: 'Atención',
- open: function() {
- $(this).html('Para Generar el Gráfico debes Seleccionar todas las Sucursales');
- },
- show: {
- effect: "shake",
- duration: 300
- },
- hide: {
- effect: "fade",
- duration: 300
- },
- buttons: {
- Aceptar: function() {
- $(this).dialog('close');
- }
- }
- });
- }
- }
- },
- // Generar pdfDoc
- drawPDF: function (getColumns,rows) {
- var self = this;
- var rowsPdf=[];
- var sucusal = this.sucDescrip = this.$el.find('#current-journal option:selected').text();
- var desde =(this.$el.find('#from').val());
- var hasta =(this.$el.find('#to').val());
- var totalPagesExp = "{total_pages_count_string}";
- var pdfDoc = new jsPDF();
- // rows=this.rowsData;
- var quantity=_.reduce(_.map(rows,function(item){
- var valor=0;
- if (item.quantity){valor = parseFloat(((item.quantity.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
- var precio_unit=_.reduce(_.map(rows,function(item){
- var valor =0;
- if (item.price_unity){valor=parseFloat(((item.price_unity.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num; },0);
- var precio_cost=_.reduce(_.map(rows,function(item){
- var valor=0;
- if(item.standar_price){valor=parseFloat(((item.standar_price.replace(".","")).replace(",",".")))} return valor}), function(memo, num){ return memo + num;},0);
- var tot_unit=_.reduce(_.map(rows,function(item){
- var valor=0;
- if (item.price_tot){valor=parseFloat(((item.price_tot.replace(".","")).replace(",",".")))}return valor}), function(memo, num){ return memo + num; },0);
- var tol_cost=_.reduce(_.map(rows,function(item){
- var valor=0;
- if (item.standar_tot){valor=parseFloat(((item.standar_tot.replace(".","")).replace(",",".")))} return valor }), function(memo, num){ return memo + num; },0);
- var utility=_.reduce(_.map(rows,function(item){
- var valor=0;
- if (item.utility){valor=parseFloat(((item.utility.replace(".","")).replace(",",".")))}return valor }), function(memo, num){ return memo + num; },0);
- rowsPdf=rows;
- var company = _.map(self.resCompany, function (map) {
- return map.currency_id[1];
- });
- rowsPdf.push({
- number : " ",
- name : "TOTAL "+company,
- quantity: accounting.formatNumber(quantity,0, ".", ","),
- price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
- standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
- price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
- standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
- utility : accounting.formatNumber(utility,2, ".", ",")
- });
- rowsPdf.unshift({
- number : " ",
- name : "TOTAL "+company,
- quantity: accounting.formatNumber(quantity,0, ".", ","),
- price_unity : accounting.formatNumber(precio_unit,2, ".", ","),
- standar_price : accounting.formatNumber(precio_cost,2, ".", ","),
- price_tot : accounting.formatNumber(tot_unit,2, ".", ","),
- standar_tot : accounting.formatNumber(tol_cost,2, ".", ","),
- utility : accounting.formatNumber(utility,2, ".", ",")
- });
- pdfDoc.autoTable(getColumns, rowsPdf, {
- styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
- columnStyles: {
- number: {fontStyle: 'bold'},
- name :{columnWidth: '10px'},
- quantity :{halign:'right' },
- price_unity : {halign:'right' },
- standar_price : {halign:'right' },
- price_tot : {halign:'right' },
- standar_tot : {halign:'right' },
- utility : {halign:'right'},
- },
- margin: { top: 16, horizontal: 7},
- addPageContent: function (data) {
- pdfDoc.setFontSize(12);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text('Utilidad de facturas detalladas por '+ sucusal, data.settings.margin.left, 10);
- if(desde.length > 0 || hasta.length > 0){
- var fecha='';
- if(desde){
- fecha=fecha.concat(' Desde '+desde);
- }
- if (hasta){
- fecha=fecha.concat(' Hasta '+hasta);
- }
- pdfDoc.setFontSize(10);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40)
- pdfDoc.text(fecha, data.settings.margin.left,14);
- }
- // FOOTER
- var str = "Pagina " + data.pageCount;
- // Total page number plugin only available in jspdf v1.0+
- if (typeof pdfDoc.putTotalPages === 'function') {
- str = str + " de " + totalPagesExp;
- }
- pdfDoc.setFontSize(9);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
- }
- });
- if (typeof pdfDoc.putTotalPages === 'function') {
- pdfDoc.putTotalPages(totalPagesExp);
- }
- pdfDoc.save('Utilidad de facturas detalladas.pdf')
- },
- // Chart Filter
- fectCharFilter: function(){
- var self = this;
- var dataBody=[];
- var dataHeader=[];
- var canvas="<canvas id='graf_resume'></canvas>";
- this.$el.find('#grafico').append(canvas);
- _.each(self.accountJournal, function(journal){
- dataHeader.push(journal.name);
- var utility=_.reduce(_.map(_.filter(self.rowsData, function (inv){ return inv.journal_id == journal.id}),function(item){
- return parseFloat(((item.utility.replace(".","")).replace(",",".")))}), function(memo, num){ return memo + num; },0);
- dataBody.push(accounting.toFixed((utility),2));
- });
- var selector ="<button type='button' class='oe_button oe_form_button oe_highlight' id='volver_btn' name='volver_btn'><span>Atras</span></button>";
- this.$el.find('#volver').append(selector);
- this.$el.find('.bootstrap-table').hide({
- effect: 'drop',
- direction: 'up',
- duration: 200,
- complete: function () {
- self.drawChart(dataHeader,dataBody);
- }
- });
- },
- // Chart
- drawChart: function (dataHeader,dataBody) {
- var barChart = new Chart(this.$el.find('#graf_resume'), {
- type: 'doughnut',
- data: {
- labels: dataHeader,
- datasets: [
- {
- labels: dataHeader,
- backgroundColor: [
- 'rgba(255, 99, 132, 0.2)',
- 'rgba(54, 162, 235, 0.2)',
- 'rgba(255, 206, 86, 0.2)',
- 'rgba(75, 192, 192, 0.2)',
- 'rgba(153, 102, 255, 0.2)',
- ],
- borderColor: [
- 'rgba(255,99,132,1)',
- 'rgba(54, 162, 235, 1)',
- 'rgba(255, 206, 86, 1)',
- 'rgba(75, 192, 192, 1)',
- 'rgba(153, 102, 255, 1)',
- ],
- borderWidth: 1,
- data: dataBody,
- }
- ]
- },
- options: {
- maintainAspectRatio: false,
- layout: {
- padding: 30
- }
- },
- });
- },
- });
- // ResumenEngreso
- local.ReportResumenEngresoWidget = instance.Widget.extend({
- template :'ReportResumenEngreso',
- accountVoucher:[],
- resCurrency:[],
- accountJournal:[],
- dataVoucher:[],
- currencyRate:[],
- companyCurrency:[],
- modules:[],
- events:{
- 'click #toolbar > button' : 'clickOnAction',
- 'change #current-journal': 'fectSearch',
- 'change #current-currency': 'fectSearch',
- 'change #from' : 'fectSearch',
- 'change #to': 'fectSearch',
- 'click #volver_btn': 'volver',
- },
- init:function(parent){
- this._super(parent);
- },
- start: function(){
- var self = this;
- var table = this.$el.find('#table');
- table.bootstrapTable({data : self.dataVoucher});
- self.fecthFecha();
- self.fecthInitial();
- },
- // Redirecionar
- // renderReport: function () {
- // var self = this;
- //
- // var container = this.$el.closest('.oe_form_sheet.oe_form_sheet_width');
- // this.$el.closest('.report_view').remove();
- // container.find('.report_view').show({
- // effect: 'fade',
- // duration: 200,
- // });
- // },
- // // Verificar el modelo
- // checkModel : function(model){
- // var self = this;
- // return _.filter(self.modules,function(item){return item === model});
- // },
- // // Lanzar el mensaje
- // showMensaje : function(modelos){
- // $("#dialog" ).dialog({
- // autoOpen: true,
- // resizable: false,
- // modal: true,
- // title: 'Atención',
- // width: 500,
- // open: function() {
- // $(this).html('Lo sentimos , pero no contás con las configuraciones adecuado para manipular este informe.\nPóngase en contacto con el administrador del sistema (referencia : '+modelos+' )');
- // },
- // show: {
- // effect: "fade",
- // duration: 200
- // },
- // hide: {
- // effect: "fade",
- // duration: 200
- // },
- // buttons: {
- // Aceptar: function() {
- // $(this).dialog('close');
- // }
- // }
- // });
- // return
- // },
- // Fecha
- fecthFecha: function() {
- var to;
- var dateFormat1 = "mm/dd/yy",
- from = $( "#from" ).datepicker({
- dateFormat: "dd/mm/yy",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
- });
- to = $( "#to" ).datepicker({
- dateFormat: "dd/mm/yy",
- defaultDate: "+7d",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- from.datepicker( "option", "maxDate", getDate(this));
- });
- function getDate( element ) {
- var fechaSel =element.value.split('/');
- var date;
- try {
- date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
- } catch( error ) {
- date = null;
- }
- return date;
- }
- },
- // Metodo inicial
- fecthInitial: function(){
- var self = this;
- // self.modules = instance._modules;
- self.fecthJournalStore().then(function(accountJournal){
- self.accountJournal=accountJournal;
- return accountJournal;
- }).then(function(accountJournal){
- self.$el.find('#current-journal').append('<option value="9999999">Todas las SUC.</option>');
- _.each(accountJournal,function(item){
- self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
- });
- return self.fecthCurrency();
- }).then(function(resCurrency){
- self.$el.find('#current-currency').append('<option value="999">Todas las Monedas</option>');
- _.each(resCurrency,function(item){
- self.$el.find('#current-currency').append('<option value="'+item.id+'">'+item.name +' '+item.symbol+'</option>');
- });
- self.resCurrency =resCurrency;
- return self.fecthCurrencyRate();
- }).then(function(currencyRate){
- self.currencyRate =currencyRate;
- return self.fecthVoucher();
- }).then(function(accountVoucher){
- self.accountVoucher =accountVoucher;
- return self.fecthComanyCurrency();
- }).then(function(companyCurrency){
- self.companyCurrency = companyCurrency;
- return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
- });
- // return self.renderReport()
- },
- // Journal
- fecthJournalStore: function(){
- var self = this;
- var defer = $.Deferred();
- // var modules = self.checkModel('multi_store');
- // if (modules.length <= 0){
- // self.showMensaje('multi_store');
- // return defer;
- // }
- var journal = new instance.web.Model('res.store');
- var field=['id', 'name','out_invoice_id','journal_ids'];
- journal.query(field).order_by('id').all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // company_curency
- fecthComanyCurrency: function(){
- var self = this;
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.company');
- var field=['id', 'currency_id'];
- var domain=[['id','=',1]];
- currency.query(field).filter(domain).all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Moneda
- fecthCurrency:function(){
- var self = this;
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.currency');
- var field = ['id', 'name', 'symbol'];
- var domain = [['active','=', true]];
- currency.query(field).filter(domain).order_by('id').all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Cambio de la moneda
- fecthCurrencyRate:function(){
- var defer = $.Deferred();
- var currency_Rate = new instance.web.Model('res.currency.rate');
- var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
- var domain = [['currency_id', '=', [166 , 20, 7, 3]]];
- currency_Rate.query(fields).filter(domain).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Voucher -
- fecthVoucher:function(){
- var self= this;
- var defer = $.Deferred();
- var voucher = new instance.web.Model('account.voucher');
- var field = ['id', 'reference', 'number', 'partner_id', 'payment_rate_currency_id', 'currency_id', 'company_id',' state',' pre_line', 'payment_rate', 'type', 'date', 'name', 'journal_id', 'amount'];
- var domain =[['type', '=', 'payment']];
- voucher.query(field).filter(domain).order_by('id').all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Verificar Valor null
- valorNull:function(dato){
- var valor ="";
- if (dato){
- valor=dato;
- }
- return valor;
- },
- // Join object
- fecthDataVoucher:function(objVoucher,objJournal){
- var self=this;
- var item;
- var journal;
- var voucherLine;
- var voucherItem;//Contenido del voucher
- var sumaAmount; //Guardar la suma de los pagos
- var voucherObject=[];
- var voucherObjectItem=[];
- var cutrrencyRate; //Valor del cambio
- var total=0;
- var sumaAmountTot=0;
- var itemVoucher;
- for (var i = 0; i < objJournal.length; i++) {
- voucherObjectItem=[];
- journal=objJournal[i];
- //Generar la Cabezera con el nombre de la sucursal
- for (var f = 0; f < journal.journal_ids.length; f++) {
- voucherLine = journal.journal_ids[f];
- voucherItem = self.getVoucherjournal(objVoucher,voucherLine)
- if (voucherItem.length > 0){
- sumaAmount=_.reduce(_.map(voucherItem,function(item){return item.amount}), function(memo, num){ return memo + num; },0);
- itemVoucher = voucherItem.shift();
- cutrrencyRate=self.getCutrrencyRate(itemVoucher.currency_id[0]);
- if (!cutrrencyRate){
- cutrrencyRate={};
- cutrrencyRate.rate=1;
- }
- // Guardar item
- voucherObjectItem.push({ journal : " ",
- method :self.valorNull(itemVoucher.journal_id[1]),
- amount : accounting.formatNumber(self.valorNull(sumaAmount),2, ".", ","),
- currency_name : self.valorNull(itemVoucher.currency_id[0]),
- currency_id : self.valorNull(itemVoucher.currency_id[1]),
- rate : cutrrencyRate.rate,
- amountBase : self.valorNull(sumaAmount / cutrrencyRate.rate),
- journal_id: journal.id,
- journal_name: journal.name,
- graficar: false
- })
- }
- }
- if (voucherObjectItem.length > 0){
- var company = _.map(self.companyCurrency, function (map) {
- return map.currency_id[1];
- });
- sumaAmountTot=_.reduce(_.map(voucherObjectItem,function(item){return (item.amountBase)}), function(memo, num){ return memo + num; },0);
- total=total+sumaAmountTot;
- voucherObjectItem.push({journal : " ",
- method :"Total " + company,
- amount : accounting.formatNumber(self.valorNull(sumaAmountTot),2, ".", ","),
- currency_name : "",
- currency_id : "",
- rate : "cutrrencyRate.rate",
- amountBase:"",
- journal_id: journal.id,
- journal_name: journal.name,
- graficar: true
- });
- // Generarl la Cabezera
- voucherObjectItem.unshift({ journal : journal.name, method :"", amount :"", voucherLine_name :"", voucherLine_id :"",rate :"",amountBase :"",journal_id:journal.id, journal_name:journal.name, graficar:false});
- // Generar Objeto Principal
- voucherObject=voucherObject.concat(voucherObjectItem);
- }
- }
- if (voucherObject.length >0){
- voucherObject.push({journal : " Total de Egreso",
- method :"",
- amount : accounting.formatNumber(self.valorNull(total),2, ".", ","),
- currency_name : "",
- currency_id : "",
- rate : "",
- amountBase:"",
- journal_id: journal.id,
- journal_name: journal.name,
- graficar: false
- });
- }
- self.loadTable(voucherObject);
- },
- // Obtener Voucher
- getVoucherjournal:function(objVoucher,journal_id){
- return _.map(_.filter(objVoucher, function (inv){return inv.journal_id[0] === journal_id}),function(item){return item});
- },
- // Obtener Cambio
- getCutrrencyRate: function(currency_id){
- return _.filter(this.currencyRate, function(rate){return rate.currency_id[0] === currency_id}).shift();
- },
- // Generar la tabla
- loadTable:function(rowsTable){
- this.dataVoucher=rowsTable;
- var table = this.$el.find('#table');
- table.bootstrapTable('load' ,rowsTable);
- },
- // Buscar
- fectSearch: function(){
- var self = this;
- var desde =this.$el.find('#from').val();
- var hasta =this.$el.find('#to').val();
- var journal =this.$el.find('#current-journal').val();
- var currency =this.$el.find('#current-currency').val();
- var newJournal= self.accountJournal; //copia del Diario
- var newVoucher= self.accountVoucher; //copia del Vouacher
- if (journal != 9999999){
- var botonChart =this.$el.find('#chart').attr("disabled", true);
- newJournal=_.filter(newJournal, function (inv){ return inv.id == journal});
- }else {
- var botonChart =this.$el.find('#chart').attr("disabled", false);
- }
- if(currency != 999){
- newVoucher=_.filter(newVoucher, function (inv){ return inv.currency_id[0] == currency});
- }
- if (desde){
- var date= desde.split('/')
- newVoucher=_.filter(newVoucher, function (inv){return inv.date >= (date[2]+"-"+date[1]+"-"+date[0])});
- }
- if (hasta){
- var date= hasta.split('/')
- newVoucher=_.filter(newVoucher, function (inv){return inv.date <= (date[2]+"-"+date[1]+"-"+date[0])});
- }
- self.fecthDataVoucher(newVoucher,newJournal);
- },
- // volver
- volver: function(){
- this.$el.find('#volver').empty();
- this.$el.find('#grafico').empty();
- this.$el.find('.bootstrap-table').show({
- effect: 'drop',
- direction: 'down',
- duration: 200,
- });
- this.$el.find('#toolbar').show({
- effect: 'drop',
- direction: 'down',
- duration: 200,
- });
- },
- // Click pdf -Grafic
- clickOnAction: function (e) {
- var action = this.$el.find(e.target).val();
- var self = this;
- var getColumns=[];
- var rows=[];
- var table = this.$el.find("#table");
- var data2 = table.bootstrapTable('getVisibleColumns');
- if (action === 'pdf') {
- var dataNEW = _.map(data2, function (val){ return val.field});
- _.each(this.dataVoucher,function (item){
- rows.push(_.pick(item, dataNEW));
- });
- // Obtener los nombre de la Cabezera
- _.each(_.map(data2,function(val){return val}), function(item){
- getColumns.push([{title: item.title, dataKey: item.field}]);
- });
- // Llamar al pdf
- this.drawPDF(_.flatten(getColumns),rows)
- }
- if (action === 'chart'){
- var self = this;
- var objetChar;
- objetChar = _.filter(self.dataVoucher,function(item){return item.graficar === true});
- self.fectCharFilter(objetChar);
- }
- },
- // pdfDoc
- drawPDF:function(getColumns,rows){
- var self = this;
- var fechaActu= new Date();
- var sucusal = this.sucDescrip = this.$el.find('#current-journal option:selected').text();
- var desde =(this.$el.find('#from').val());
- var hasta =(this.$el.find('#to').val());
- var totalPagesExp = "{total_pages_count_string}";
- var pdfDoc = new window.jsPDF();
- pdfDoc.autoTable(getColumns, rows, {
- styles: { overflow: 'linebreak', fontSize:10 , columnWidth: 'wrap'},
- columnStyles:{ journal: {fontStyle: 'bold'},
- method :{columnWidth: '10px'},
- amount : {halign:'right'},
- },
- margin: { top: 16, horizontal: 7},
- addPageContent: function (data) {
- pdfDoc.setFontSize(12);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text('Resumen de Egreso de '+ sucusal, data.settings.margin.left, 10);
- if(desde.length > 0 || hasta.length > 0){
- var fecha='';
- if(desde){
- fecha=fecha.concat(' Desde '+desde);
- }
- if (hasta){
- fecha=fecha.concat(' Hasta '+hasta);
- }
- pdfDoc.setFontSize(10);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40)
- pdfDoc.text(fecha, data.settings.margin.left,14);
- }
- // FOOTER
- var str = "Pagina " + data.pageCount;
- // Total page number plugin only available in jspdf v1.0+
- if (typeof pdfDoc.putTotalPages === 'function') {
- str = str + " de " + totalPagesExp +"\n Día de Expedición "+fechaActu.getDate()+"/"+fechaActu.getMonth()+"/"+fechaActu.getFullYear();
- }
- pdfDoc.setFontSize(9);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
- }
- });
- if (typeof pdfDoc.putTotalPages === 'function') {
- pdfDoc.putTotalPages(totalPagesExp);
- }
- pdfDoc.save('Resumen de Egreso.pdf');
- },
- // Char filter
- fectCharFilter: function(objetChar){
- var self = this;
- var dataBody=[];
- var dataHeader=[];
- // objetChar
- var canvas="<canvas id='graf_resume'></canvas>";
- this.$el.find('#grafico').append(canvas);
- _.each(objetChar,function(voucher){
- dataHeader.push(voucher.journal_name);
- dataBody.push(parseFloat(((voucher.amount.replace(".","")).replace(",","."))));
- });
- var selector ="<button type='button' class='oe_button oe_form_button oe_highlight' id='volver_btn' name='volver_btn'><span>Atras</span></button>";
- this.$el.find('#volver').append(selector);
- this.$el.find('.bootstrap-table').hide({
- effect: 'drop',
- direction: 'up',
- duration: 200,
- complete: function () {
- self.drawChart(dataHeader,dataBody);
- }
- });
- this.$el.find('#toolbar').hide({
- effect: 'drop',
- direction: 'up',
- duration: 200,
- complete: function () {
- self.drawChart(dataHeader,dataBody);
- }
- });
- },
- //Chart
- drawChart: function (dataHeader,dataBody) {
- var barChart = new Chart(this.$el.find('#graf_resume'), {
- type: 'doughnut',//bar, doughnut
- data: {
- labels: dataHeader,
- datasets: [
- {
- labels: dataHeader,
- backgroundColor: [
- 'rgba(255, 99, 132, 0.2)',
- 'rgba(54, 162, 235, 0.2)',
- 'rgba(255, 206, 86, 0.2)',
- 'rgba(75, 192, 192, 0.2)',
- 'rgba(153, 102, 255, 0.2)',
- ],
- borderColor: [
- 'rgba(255,99,132,1)',
- 'rgba(54, 162, 235, 1)',
- 'rgba(255, 206, 86, 1)',
- 'rgba(75, 192, 192, 1)',
- 'rgba(153, 102, 255, 1)',
- ],
- borderWidth: 1,
- data: dataBody,
- }
- ]
- },
- options: {
- maintainAspectRatio: false,
- layout: {
- padding: 30
- }
- },
- });
- },
- });
- // ResumenIngreso
- local.ReportResumenIngresoWidget = instance.Widget.extend({
- template :'ReportResumenIngreso',
- accountVoucher:[],
- resCurrency:[],
- accountJournal:[],
- dataVoucher:[],
- currencyRate:[],
- resCompany:[],
- modules:[],
- events:{
- 'click #toolbar > button' : 'clickOnAction',
- 'change #current-journal': 'fectSearch',
- 'change #current-currency': 'fectSearch',
- 'change #from' : 'fectSearch',
- 'change #to': 'fectSearch',
- 'click #volver_btn': 'volver',
- },
- init:function(parent){
- this._super(parent);
- },
- start: function(){
- var self = this;
- var table = this.$el.find('#table');
- table.bootstrapTable({data : self.dataVoucher});
- self.fecthFecha();
- self.fecthInitial();
- },
- // Redirecionar
- // renderReport: function () {
- // var self = this;
- //
- // var container = this.$el.closest('.oe_form_sheet.oe_form_sheet_width');
- // this.$el.closest('.report_view').remove();
- // container.find('.report_view').show({
- // effect: 'fade',
- // duration: 200,
- // });
- // },
- // Verificar el modelo
- // checkModel : function(model){
- // var self = this;
- // return _.filter(self.modules,function(item){return item === model});
- // },
- // // Lanzar el mensaje
- // showMensaje : function(modelos){
- // $("#dialog" ).dialog({
- // autoOpen: true,
- // resizable: false,
- // modal: true,
- // title: 'Atención',
- // width: 500,
- // open: function() {
- // $(this).html('Lo sentimos , pero no contás con las configuraciones adecuado para manipular este informe.\nPóngase en contacto con el administrador del sistema (referencia : '+modelos+' )');
- // },
- // show: {
- // effect: "fade",
- // duration: 200
- // },
- // hide: {
- // effect: "fade",
- // duration: 200
- // },
- // buttons: {
- // Aceptar: function() {
- // $(this).dialog('close');
- // }
- // }
- // });
- // return
- // },
- // Fecha
- fecthFecha: function() {
- var to;
- var dateFormat1 = "mm/dd/yy",
- from = $( "#from" ).datepicker({
- dateFormat: "dd/mm/yy",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
- });
- to = $( "#to" ).datepicker({
- dateFormat: "dd/mm/yy",
- defaultDate: "+7d",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- from.datepicker( "option", "maxDate", getDate(this));
- });
- function getDate( element ) {
- var fechaSel =element.value.split('/');
- var date;
- try {
- date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
- } catch( error ) {
- date = null;
- }
- return date;
- }
- },
- // Metodo inicial
- fecthInitial: function(){
- var self = this;
- // self.modules = instance._modules;
- self.fecthJournalStore().then(function(accountJournal){
- self.accountJournal=accountJournal;
- return accountJournal;
- }).then(function(accountJournal){
- self.$el.find('#current-journal').append('<option value="9999999">Todas las SUC.</option>');
- _.each(accountJournal,function(item){
- self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
- });
- return self.fecthCurrency();
- }).then(function(resCurrency){
- self.$el.find('#current-currency').append('<option value="999">Todas las Monedas</option>');
- _.each(resCurrency,function(item){
- self.$el.find('#current-currency').append('<option value="'+item.id+'">'+item.name +' '+item.symbol+'</option>');
- });
- self.resCurrency =resCurrency;
- return self.fecthCurrencyRate();
- }).then(function(currencyRate){
- self.currencyRate =currencyRate;
- return self.fecthVoucher();
- }).then(function(accountVoucher){
- self.accountVoucher =accountVoucher;
- return self.fecthComanyCurrency();
- }).then(function(resCompany){
- self.resCompany = resCompany;
- return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
- });
- // return self.renderReport();
- },
- // company_curency
- fecthComanyCurrency: function(){
- var self = this;
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.company');
- var field=['id', 'currency_id'];
- var domain=[['id','=',1]];
- currency.query(field).filter(domain).all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Journal
- fecthJournalStore: function(){
- var self = this;
- var defer = $.Deferred();
- // var modules = self.checkModel('multi_store');
- //
- // if (modules.length <= 0){
- // self.showMensaje('multi_store');
- // return defer;
- // }
- var journal = new instance.web.Model('res.store');
- var field=['id', 'name','out_invoice_id','journal_ids'];
- journal.query(field).order_by('id').all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Moneda
- fecthCurrency:function(){
- var self = this;
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.currency');
- var field = ['id', 'name', 'symbol'];
- var domain = [['active','=', true]];
- currency.query(field).filter(domain).order_by('id').all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Cambio de la moneda
- fecthCurrencyRate:function(){
- var defer = $.Deferred();
- var currency_Rate = new instance.web.Model('res.currency.rate');
- var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
- var domain = [['currency_id', '=', [166 , 20, 7, 3]]];
- currency_Rate.query(fields).filter(domain).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Voucher -
- fecthVoucher:function(){
- var self= this;
- var defer = $.Deferred();
- var voucher = new instance.web.Model('account.voucher');
- var field = ['id', 'reference', 'number', 'partner_id', 'payment_rate_currency_id', 'currency_id', 'company_id',' state',' pre_line', 'payment_rate', 'type', 'date', 'name', 'journal_id', 'amount'];
- var domain =[['type', '=', 'receipt']];
- voucher.query(field).filter(domain).order_by('id').all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Verificar Valor null
- valorNull:function(dato){
- var valor ="";
- if (dato){
- valor=dato;
- }
- return valor;
- },
- // Join object
- fecthDataVoucher:function(objVoucher,objJournal){
- var self=this;
- var item;
- var journal;
- var voucherLine;
- var voucherItem;//Contenido del voucher
- var sumaAmount; //Guardar la suma de los pagos
- var voucherObject=[];
- var voucherObjectItem=[];
- var cutrrencyRate; //Valor del cambio
- var total=0;
- var sumaAmountTot=0;
- var itemVoucher;
- for (var i = 0; i < objJournal.length; i++) {
- voucherObjectItem=[];
- journal=objJournal[i];
- //Generar la Cabezera con el nombre de la sucursal
- for (var f = 0; f < journal.journal_ids.length; f++) {
- voucherLine = journal.journal_ids[f];
- voucherItem = self.getVoucherjournal(objVoucher,voucherLine)
- if (voucherItem.length > 0){
- sumaAmount=_.reduce(_.map(voucherItem,function(item){return item.amount}), function(memo, num){ return memo + num; },0);
- itemVoucher = voucherItem.shift();
- cutrrencyRate=self.getCutrrencyRate(itemVoucher.currency_id[0]);
- if (!cutrrencyRate){
- cutrrencyRate={};
- cutrrencyRate.rate=1;
- }
- // Guardar item
- voucherObjectItem.push({ journal : " ",
- method :self.valorNull(itemVoucher.journal_id[1]),
- amount : accounting.formatNumber(self.valorNull(sumaAmount),2, ".", ","),
- currency_name : self.valorNull(itemVoucher.currency_id[0]),
- currency_id : self.valorNull(itemVoucher.currency_id[1]),
- rate : cutrrencyRate.rate,
- amountBase : self.valorNull(sumaAmount / cutrrencyRate.rate),
- journal_id: journal.id,
- journal_name: journal.name,
- graficar: false
- })
- }
- }
- var company = _.map(self.resCompany, function (map) {
- return map.currency_id[1];
- });
- if (voucherObjectItem.length > 0){
- sumaAmountTot=_.reduce(_.map(voucherObjectItem,function(item){return (item.amountBase)}), function(memo, num){ return memo + num; },0);
- total=total+sumaAmountTot;
- voucherObjectItem.push({journal : " ",
- method :"Total "+ company,
- amount : accounting.formatNumber(self.valorNull(sumaAmountTot),2, ".", ","),
- currency_name : "",
- currency_id : "",
- rate : "cutrrencyRate.rate",
- amountBase:"",
- journal_id: journal.id,
- journal_name: journal.name,
- graficar: true
- });
- // Generarl la Cabezera
- voucherObjectItem.unshift({ journal : journal.name, method :"", amount :"", voucherLine_name :"", voucherLine_id :"",rate :"",amountBase :"",journal_id:journal.id, journal_name:journal.name, graficar:false});
- // Generar Objeto Principal
- voucherObject=voucherObject.concat(voucherObjectItem);
- }
- }
- if (voucherObject.length > 0){
- voucherObject.push({journal : " Total de Ingreso",
- method :"",
- amount : accounting.formatNumber(self.valorNull(total),2, ".", ","),
- currency_name : "",
- currency_id : "",
- rate : "",
- amountBase:"",
- journal_id: journal.id,
- journal_name: journal.name,
- graficar: false
- });
- }
- self.loadTable(voucherObject);
- },
- // Obtener Voucher
- getVoucherjournal:function(objVoucher,journal_id){
- return _.map(_.filter(objVoucher, function (inv){return inv.journal_id[0] === journal_id}),function(item){return item});
- },
- // Obtener Cambio
- getCutrrencyRate: function(currency_id){
- return _.filter(this.currencyRate, function(rate){return rate.currency_id[0] === currency_id}).shift();
- },
- // Generar la table
- loadTable:function(rowsTable){
- var self = this;
- self.dataVoucher=rowsTable
- var table = this.$el.find('#table');
- table.bootstrapTable('load' ,rowsTable);
- },
- // Buscar
- fectSearch: function(){
- var self = this;
- var desde =this.$el.find('#from').val();
- var hasta =this.$el.find('#to').val();
- var journal =this.$el.find('#current-journal').val();
- var currency =this.$el.find('#current-currency').val();
- var newJournal= self.accountJournal; //copia del Diario
- var newVoucher= self.accountVoucher; //copia del Vouacher
- if (journal != 9999999){
- var botonChart =this.$el.find('#chart').attr("disabled", true);
- newJournal=_.filter(newJournal, function (inv){ return inv.id == journal});
- }else {
- var botonChart =this.$el.find('#chart').attr("disabled", false);
- }
- if(currency != 999){
- newVoucher=_.filter(newVoucher, function (inv){ return inv.currency_id[0] == currency});
- }
- if (desde){
- var date= desde.split('/')
- newVoucher=_.filter(newVoucher, function (inv){return inv.date >= (date[2]+"-"+date[1]+"-"+date[0])});
- }
- if (hasta){
- var date= hasta.split('/')
- newVoucher=_.filter(newVoucher, function (inv){return inv.date <= (date[2]+"-"+date[1]+"-"+date[0])});
- }
- self.fecthDataVoucher(newVoucher,newJournal);
- },
- // volver
- volver: function(){
- this.$el.find('#volver').empty();
- this.$el.find('#grafico').empty();
- this.$el.find('.bootstrap-table').show({
- effect: 'drop',
- direction: 'down',
- duration: 200,
- });
- },
- // Click pdf -Grafic
- clickOnAction: function (e) {
- var action = this.$el.find(e.target).val();
- var self = this;
- var getColumns=[];
- var rows=[];
- var table = this.$el.find("#table");
- var data2 = table.bootstrapTable('getVisibleColumns');
- if (action === 'pdf') {
- var dataNEW = _.map(data2, function (val){ return val.field});
- _.each(this.dataVoucher,function (item){
- rows.push(_.pick(item, dataNEW));
- });
- // Obtener los nombre de la Cabezera
- _.each(_.map(data2,function(val){return val}), function(item){
- getColumns.push([{title: item.title, dataKey: item.field}]);
- });
- // Llamar al pdf
- this.drawPDF(_.flatten(getColumns),rows)
- }
- if (action === 'chart'){
- var self = this;
- var objetChar;
- objetChar = _.filter(self.dataVoucher,function(item){return item.graficar === true});
- self.fectCharFilter(objetChar);
- }
- },
- // pdfDoc
- drawPDF:function(getColumns,rows){
- var self = this;
- var fechaActu= new Date();
- var sucusal = this.sucDescrip = this.$el.find('#current-journal option:selected').text();
- var desde =(this.$el.find('#from').val());
- var hasta =(this.$el.find('#to').val());
- var totalPagesExp = "{total_pages_count_string}";
- var pdfDoc = new window.jsPDF();
- pdfDoc.autoTable(getColumns, rows, {
- styles: { overflow: 'linebreak', fontSize:10 , columnWidth: 'wrap'},
- columnStyles:{ journal: {fontStyle: 'bold'},
- method :{columnWidth: '10px'},
- amount : {halign:'right'},
- },
- margin: {
- top: 16,
- horizontal: 7
- },
- addPageContent: function (data) {
- pdfDoc.setFontSize(12);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text('Resumen de Ingreso de '+ sucusal, data.settings.margin.left, 10);
- if(desde.length > 0 || hasta.length > 0){
- var fecha='';
- if(desde){
- fecha=fecha.concat(' Desde '+desde);
- }
- if (hasta){
- fecha=fecha.concat(' Hasta '+hasta);
- }
- pdfDoc.setFontSize(10);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40)
- pdfDoc.text(fecha, data.settings.margin.left,14);
- }
- // FOOTER
- var str = "Pagina " + data.pageCount;
- // Total page number plugin only available in jspdf v1.0+
- if (typeof pdfDoc.putTotalPages === 'function') {
- str = str + " de " + totalPagesExp +"\n Día de Expedición "+fechaActu.getDate()+"/"+fechaActu.getMonth()+"/"+fechaActu.getFullYear();
- }
- pdfDoc.setFontSize(9);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
- }
- });
- if (typeof pdfDoc.putTotalPages === 'function') {
- pdfDoc.putTotalPages(totalPagesExp);
- }
- pdfDoc.save('Resumen de Ingreso.pdf');
- },
- // Char filter
- fectCharFilter: function(objetChar){
- var self = this;
- var dataBody=[];
- var dataHeader=[];
- // objetChar
- var canvas="<canvas id='graf_resume'></canvas>";
- this.$el.find('#grafico').append(canvas);
- _.each(objetChar,function(voucher){
- dataHeader.push(voucher.journal_name);
- dataBody.push(parseFloat(((voucher.amount.replace(".","")).replace(",","."))));
- });
- var selector ="<button type='button' class='oe_button oe_form_button oe_highlight' id='volver_btn' name='volver_btn'><span>Atras</span></button>";
- this.$el.find('#volver').append(selector);
- this.$el.find('.bootstrap-table').hide({
- effect: 'drop',
- direction: 'up',
- duration: 200,
- complete: function () {
- self.drawChart(dataHeader,dataBody);
- }
- });
- },
- //Chart
- drawChart: function (dataHeader,dataBody) {
- var barChart = new Chart(this.$el.find('#graf_resume'), {
- type: 'doughnut',//bar, doughnut
- data: {
- labels: dataHeader,
- datasets: [
- {
- labels: dataHeader,
- backgroundColor: [
- 'rgba(255, 99, 132, 0.2)',
- 'rgba(54, 162, 235, 0.2)',
- 'rgba(255, 206, 86, 0.2)',
- 'rgba(75, 192, 192, 0.2)',
- 'rgba(153, 102, 255, 0.2)',
- ],
- borderColor: [
- 'rgba(255,99,132,1)',
- 'rgba(54, 162, 235, 1)',
- 'rgba(255, 206, 86, 1)',
- 'rgba(75, 192, 192, 1)',
- 'rgba(153, 102, 255, 1)',
- ],
- borderWidth: 1,
- data: dataBody,
- }
- ]
- },
- options: {
- maintainAspectRatio: false,
- layout: {
- padding: 30
- }
- },
- });
- },
- });
- // StockLocation
- local.ReportStockLocationWidget = instance.Widget.extend({
- template : 'ReportStockLocation',
- stockLocation : [],
- stockQuant : [],
- productProduct : [],
- prodcut:[],
- events : {
- 'click #toolbar > button' : 'clickOnAction',
- 'change #current-location': 'fecthSearch',
- },
- init : function(parent){
- this._super(parent);
- },
- start : function(){
- var self = this;
- var dato=[];
- var table = this.$el.find('#table');
- table.bootstrapTable({data : self.prodcut});
- self.fecthInitial();
- },
- // Consulta Inicial
- fecthInitial: function(){
- var self = this;
- self.fecthLocation().then(function(stockLocation){
- self.stockLocation=stockLocation
- return stockLocation;
- }).then(function(stockLocation){
- self.$el.find('#current-location').append('<option value="9999999">Todas las Ubicación.</option>');
- _.each(stockLocation,function(item){
- self.$el.find('#current-location').append('<option value="' + item.id + '">' + item.location_id[1]+" / "+item.name + '</option>');
- });
- return self.fecthStockQuant();
- }).then(function(stockQuant){
- self.stockQuant = stockQuant;
- return self.fecthProduct(stockQuant);
- }).then(function(productProduct){
- self.productProduct = productProduct;
- return self.fecthProducto(self.stockQuant, self.stockLocation);
- });
- },
- // Ubicacion
- fecthLocation : function(){
- var self = this;
- var defer = $.Deferred();
- var location = new instance.web.Model('stock.location');
- var fields = ['id', 'name', 'company_id', 'location_id'];
- var domain =[['active', '=', true],['usage', '=', 'internal']];
- location.query(fields).filter(domain).order_by('id').all().then(function(results){
- defer.resolve(results);
- })
- return defer;
- },
- // quant
- fecthStockQuant : function(){
- var self = this;
- var defer = $.Deferred();
- var location = _.map(self.stockLocation,function(item){
- return item.id;
- });
- var company_id =(_.map(self.stockLocation, function(item){
- return item.company_id[0];
- })).shift();
- var quant = new instance.web.Model('stock.quant');
- var fields = ['id', 'product_id', 'qty', 'cost','location_id'];
- var domain =[['company_id', '=', company_id],['location_id', '=',location]];
- quant.query(fields).filter(domain).all().then(function(results){
- defer.resolve(results);
- })
- return defer;
- },
- // ProductProduct
- fecthProduct: function(quant){
- var defer = $.Deferred();
- var porductIDS = _.flatten(_.map(quant, function (item) {
- return item.product_id[0];
- }));
- var ProductProdcut = new instance.web.Model('product.product');
- var fields = ['id','name','name_template', 'standard_price','type','attribute_value_ids'];
- ProductProdcut.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
- defer.resolve(results)
- });
- return defer;
- },
- // Union de Modulos
- fecthProducto : function(stockQuant,stockLocation){
- var self = this;
- var stock=[];
- var itemLocation;
- var itemProduct;
- var itemQuant;
- var productProduct;
- var cat = 0;
- var quant;
- for (var i = 0; i < stockLocation.length; i++) {
- itemLocation = stockLocation[i];
- productProduct = self.getProdcutoProduct(self.productProduct,stockQuant, itemLocation.id);
- for (var f = 0; f < productProduct.length; f++) {
- itemProduct = productProduct[f];
- itemQuant = self.getQuantProduct(itemLocation.id, itemProduct.id, stockQuant);
- if (itemQuant.length >0){
- cat = _.reduce(_.map(itemQuant,function(item){
- return item.qty;
- }),function(mamo, num){
- return mamo + num;
- },0);
- quant=itemQuant.shift();
- stock.push({prodcut : quant.product_id[1],
- qty : cat,
- location :(itemLocation.location_id[1]+" / "+itemLocation.name)});
- }
- }
- }
- self.loadTable(stock);
- },
- // Obtener Producto Por quant y locations
- getProdcutoProduct: function(productProduct, stockQuant, location_id){
- var self = this;
- var product_ids= _.flatten(_.map(_.filter(stockQuant, function(item){
- return item.location_id[0] === location_id;
- }),function(map){
- return map.product_id[0];
- }));
- return _.filter(productProduct,function(prod){return _.contains(product_ids, prod.id)});
- },
- // Obtener Qaunt por productos
- getQuantProduct: function(location_id, product_id, quantObjs){
- var self = this;
- var quantProdcut = quantObjs;
- if (location_id){
- quantProdcut = _.filter(quantProdcut, function(item){
- return item.location_id[0] === location_id;
- });
- }
- if (product_id){
- quantProdcut = _.filter(quantProdcut, function(item){
- return item.product_id[0] === product_id;
- });
- }
- return quantProdcut;
- },
- // Buscar
- fecthSearch: function(){
- var self = this;
- var location =this.$el.find('#current-location').val();
- var locationObjs = self.stockLocation;
- var quantObjs = self.stockQuant;
- if (location != 9999999){
- locationObjs=_.filter(locationObjs, function (inv){
- return inv.id == location;
- });
- quantObjs=_.filter(quantObjs, function (inv){
- return inv.location_id[0] == location;
- });
- }
- self.fecthProducto(quantObjs,locationObjs)
- },
- // Generar la table
- loadTable:function(rowsTable){
- var self = this;
- this.prodcut=rowsTable;
- var table = this.$el.find('#table');
- table.bootstrapTable('load' ,rowsTable);
- },
- // Click pdf -Grafic
- clickOnAction: function (e) {
- var self = this;
- var action = self.$el.find(e.target).val();
- var getColumns=[];
- var rows=[];
- var table = self.$el.find("#table");
- var data2 = table.bootstrapTable('getVisibleColumns');
- if (action === 'pdf') {
- var dataNEW = _.map(data2, function (val){
- return val.field;
- });
- _.each(self.prodcut,function (item){
- rows.push(_.pick(item, dataNEW));
- });
- // Obtener los nombre de la Cabezera
- _.each(_.map(data2,function(val){return val}), function(item){
- getColumns.push([{
- title: item.title,
- dataKey: item.field
- }]);
- });
- self.drawPDF(_.flatten(getColumns),rows)
- }
- },
- // pdfDoc
- drawPDF:function(getColumns,rows){
- var self = this;
- var fechaActu= new Date();
- var location = this.sucDescrip = this.$el.find('#current-location option:selected').text();
- var totalPagesExp = "{total_pages_count_string}";
- var pdfDoc = new jsPDF();
- pdfDoc.autoTable(getColumns, rows, {
- styles: { overflow: 'linebreak', fontSize:8 , columnWidth: 'wrap'},
- columnStyles:{
- prodcut :{columnWidth: '8px'},
- location :{columnWidth: '8px'},
- qty : {halign:'center'},
- },
- margin: { top: 16, horizontal: 7},
- addPageContent: function (data) {
- pdfDoc.setFontSize(12);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text('Listado de Stock Por '+ location, data.settings.margin.left, 10);
- // FOOTER
- var str = "Pagina " + data.pageCount;
- if (typeof pdfDoc.putTotalPages === 'function') {
- str = str + " de " + totalPagesExp +"\n Día de Expedición "+fechaActu.getDate()+"/"+fechaActu.getMonth()+"/"+fechaActu.getFullYear();
- }
- pdfDoc.setFontSize(9);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
- }
- });
- if (typeof pdfDoc.putTotalPages === 'function') {
- pdfDoc.putTotalPages(totalPagesExp);
- }
- pdfDoc.save('Listado_de_Stock_Por_Ubicaion.pdf');
- }
- });
- // AllPurchases Listado de Compras
- local.AllPurchasesWidget = instance.Widget.extend({
- template: 'AllPurchases',
- invoice: [],
- Currency:[],
- resCurrency :[],
- resCompany:[],
- accountJournal:[],
- supplier:[],
- newInvoice:[],
- rowsData :[],
- // event
- events:{
- 'click #toolbar > button' : 'clickOnAction',
- 'change #current-journal' : 'factSearch',
- 'change #current-currency' : 'factSearch',
- 'change #from' : 'factSearch',
- 'change #to' : 'factSearch',
- 'click #volver_btn' : 'volver',
- },
- // Initil
- init : function(parent){
- this._super(parent);
- },
- // start
- start: function () {
- var self = this;
- var table = this.$el.find('#table');
- table.bootstrapTable({data : self.rowsData});
- this.fecthFecha();
- this.submitForm();
- },
- // volver
- volver: function(){
- this.$el.find('#volver').empty();
- this.$el.find('.bootstrap-table').show({
- effect: 'drop',
- direction: 'down',
- duration: 200,
- });
- },
- // Consultar
- submitForm: function () {
- var self = this;
- self.fetchResCurency().then(function(resCurrency) {
- return resCurrency;
- }).then(function (resCurrency) {
- self.resCurrency = resCurrency;
- self.$el.find('#current-currency').append('<option value="9999999">Todas las monedas</option>');
- _.each(resCurrency, function (item) {
- self.$el.find('#current-currency').append('<option value="' + item.id + '">' + item.name + '</option>');
- });
- return self.fetchCurency(resCurrency);
- }).then(function(Currency){
- self.Currency = Currency;
- return self.fetchJournal();
- }).then(function (journal) {
- self.accountJournal =journal;
- self.$el.find('#current-journal').append('<option value="9999999">TODAS LAS SUC.</option>');
- _.each(journal, function (item) {
- self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
- });
- return self.fetchInvoiceP2();
- }).then(function (invoice){
- self.invoice = invoice;
- return self.fetchSupplier(invoice);
- }).then(function(supplier){
- self.supplier=supplier;
- return self.fecthComanyCurrency();
- }).then(function(resCompany){
- self.resCompany = resCompany;
- self.inicializarBuscadorsup();
- return self.fect_generar(self.invoice);
- });
- },
- // Fecha
- fecthFecha: function() {
- var to;
- var dateFormat1 = "mm/dd/yy",
- from = $( "#from" )
- .datepicker({
- dateFormat: "dd/mm/yy",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
- });
- to = $( "#to" ).datepicker({
- dateFormat: "dd/mm/yy",
- defaultDate: "+7d",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- from.datepicker( "option", "maxDate", getDate(this));
- });
- function getDate( element ) {
- var fechaSel =element.value.split('/');
- var date;
- try {
- date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
- } catch( error ) {
- date = null;
- }
- return date;
- }
- },
- // Buscar Diario
- fetchJournal: function () {
- var self = this;
- var defer = $.Deferred();
- var Journal = new instance.web.Model('account.journal');
- Journal.query(['id', 'name']).filter([['type', '=', 'purchase']]).all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Buscar Cambio de Monedas USD,PYG,ARG,BRL
- fetchCurency: function (currency) {
- var defer = $.Deferred();
- var currency_id = _.flatten(_.map(currency,function(map){
- return map.id;
- }))
- var currency_Rate = new instance.web.Model('res.currency.rate');
- var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
- var domain = [['currency_id', '=', currency_id]];
- currency_Rate.query(fields).filter(domain).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Moneda
- fetchResCurency: function () {
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.currency');
- var fields = ['id', 'name'];
- var domain = [['active', '=', true]];
- currency.query(fields).filter(domain).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Invoice (FACTURAS)
- fetchInvoiceP2: function () {
- var journal_ids = _.flatten(_.map(this.accountJournal, function (item) {
- return item.id;
- }));
- var filter =[['state', '=',['open','paid']],['type', '=', 'in_invoice'],['origin', '!=', false],['journal_id', '=',journal_ids]];
- var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id'];
- var defer = $.Deferred();
- var Invoice = new instance.web.Model('account.invoice');
- Invoice.query(field).filter(filter).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // company_curency
- fecthComanyCurrency: function(){
- var self = this;
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.company');
- var field=['id', 'currency_id'];
- var domain=[['id','=',1]];
- currency.query(field).filter(domain).all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Partner (Proveeedor)
- fetchSupplier: function() {
- var self = this;
- var defer = $.Deferred();
- var supplier = new instance.web.Model('res.partner');
- supplier.query(['id', 'name', 'ruc', 'active', 'supplier']).filter([['active', '=', true], ['supplier', '=', true]]).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Obtener el Cambio de la Moneda
- getCurrency: function (id){
- return _.find(this.Currency,function (curr) {
- return _.contains(curr.currency_id,id);
- });
- },
- // Verificar si los Valores no son nulos
- valorNull:function(dato){
- var valor ="";
- if (dato){
- valor=dato;
- }
- return valor;
- },
- // Buscador
- inicializarBuscadorsup: function () {
- var self = this;
- var results = self.supplier;
- results = _.map(results, function (item) {
- return {
- label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
- value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
- }
- });
- self.$('#customer').autocomplete({
- source: results,
- minLength:0,
- search: function(event, ui) {
- if (!(self.$('#customer').val())){
- self.factSearch();
- }
- },
- select: function(event, ui) {
- self.factSearch();
- }
- });
- },
- // unir los objetos
- fect_generar: function(invoices){
- var self = this;
- var data = [];
- _.each(invoices, function(invoice){
- data.push({
- number: invoice.number,
- supplier_invoice_number: self.valorNull(invoice.supplier_invoice_number),
- partner: invoice.partner_id[1],
- date: moment(invoice.date_invoice).format("DD/MM/YYYY"),
- date_invoice: invoice.date_invoice,
- user: invoice.user_id[1],
- currency: invoice.currency_id[1],
- amount_total: accounting.formatNumber(invoice.amount_total,2,".",","),
- amount: invoice.amount_total,
- journal_id : invoice.journal_id[0],
- currency_id : invoice.currency_id[0],
- partner_id : invoice.partner_id[0]
- });
- });
- self.newInvoice = data;
- this.loadTable(data);
- },
- // Buscar
- factSearch: function(){
- var self = this;
- var desde =this.$el.find('#from').val();
- var hasta =this.$el.find('#to').val();
- var suc =this.$el.find('#current-journal').val();
- var currency =this.$el.find('#current-currency').val();
- var prov= this.$el.find('#customer').val().split('-');
- var newInvoice = self.newInvoice;
- // Buscar por Sucursales
- if (suc != 9999999){
- newInvoice=_.filter(newInvoice, function (inv){
- return inv.journal_id == suc;
- });
- }
- // Buscar por fecha Desde
- if (desde.length > 0){
- var date= desde.split('/');
- newInvoice = _.filter(newInvoice, function (inv){
- return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
- });
- }
- // Buscar por Fechas Hasta
- if (hasta.length > 0){
- var date= hasta.split('/');
- newInvoice = _.filter(newInvoice, function (inv){
- return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
- });
- }
- // Busacar por moneda
- if(currency != 9999999){
- newInvoice = _.filter(newInvoice,function(inv){
- return inv.currency_id == currency;
- });
- }
- // Busacara por proveedor
- if (prov != ""){
- newInvoice = _.filter(newInvoice, function(inv){
- return inv.partner_id == prov[0];
- });
- }
- self.loadTable(newInvoice)
- },
- // cargara la tabla
- loadTable:function(rowsTable){
- var self = this;
- self.rowsData = rowsTable;
- var table = this.$el.find('#table');
- table.bootstrapTable('load',rowsTable);
- },
- // Obtener Invoice por Monedad
- getInvoice : function(currency_id){
- var self = this;
- return _.filter(self.rowsData, function(item){
- return item.currency_id === currency_id;
- });
- },
- // Crear Objete PDF
- getObjetPdf: function(rowsTable){
- var self = this;
- var rowsPdf=[];
- var rows=[];
- var itemCurrecy;
- var itenRow;
- var item;
- var curreRate;
- var amount_total=0;
- var amount=0;
- var company = _.map(self.resCompany,function(map){return map.currency_id[1]});
- for (var i = 0; i < self.resCurrency.length; i++) {
- itemCurrecy = self.resCurrency[i];
- itenRow = self.getInvoice(itemCurrecy.id);
- rowsPdf=[];
- if (itenRow.length > 0){
- rowsPdf.push({number: itemCurrecy.name, supplier_invoice_number: "", partner: "", date: "", date_invoice: "", user: "", currency: "", amount_total: "", journal_id : "", currency_id : "", partner_id : ""});
- _.each(itenRow, function(item){
- rowsPdf.push({
- number: item.number,
- supplier_invoice_number: self.valorNull(item.supplier_invoice_number),
- partner: item.partner,
- date: moment(item.date_invoice).format("DD/MM/YYYY"),
- date_invoice: item.date_invoice,
- user: item.user,
- currency: item.currency,
- amount_total: accounting.formatNumber((item.amount),2,".",","),
- amount: item.amount,
- journal_id : item.journal_id,
- currency_id : item.currency_id,
- partner_id : item.partner_id
- });
- });
- curreRate = self.getCurrency(itemCurrecy.id);
- if (!curreRate){
- curreRate={};
- curreRate.rate=1;
- }
- amount_total= _.reduce(_.map(itenRow,function(map){
- return(map.amount);
- }),function(memo, num){
- return memo + num;
- },0);
- amount = amount+(amount_total/curreRate.rate);
- rowsPdf.push({
- number: "Sub - Total "+itemCurrecy.name,
- supplier_invoice_number: "",
- partner: "",
- date: "",
- date_invoice: "",
- user: "",
- currency: "",
- amount_total: accounting.formatNumber((amount_total),2,".",","),
- journal_id : "",
- currency_id : "",
- partner_id : ""
- });
- }
- if (rowsPdf.length >0){
- rows = rows.concat(rowsPdf);
- }
- }
- if (rows.length > 0){
- rows.push({
- number: "Total en "+company,
- supplier_invoice_number: "",
- partner: "",
- date: "",
- date_invoice: "",
- user: "",
- currency: "",
- amount_total: accounting.formatNumber((amount),2,".",","),
- journal_id : "",
- currency_id : "",
- partner_id : ""
- });
- }
- return rows;
- },
- // imprimir PDF
- clickOnAction: function (e) {
- var self = this;
- var rowsNew;
- var action = self.$el.find(e.target).val();
- var table = self.$el.find("#table");
- var data2 = table.bootstrapTable('getVisibleColumns');
- var getColumns=[];
- var rows=[];
- rowsNew = self.getObjetPdf();
- if (action === 'pdf') {
- var dataNEW = _.map(data2, function (val){
- return val.field;
- });
- _.each(rowsNew,function (item){
- rows.push(_.pick(item, dataNEW));
- });
- // Obtener los nombre de la Cabezera
- _.each(_.map(data2,function(val){
- return val;
- }), function(item){
- getColumns.push([{
- title: item.title,
- dataKey: item.field
- }]);
- });
- this.drawPDF(_.flatten(getColumns),rows);
- }
- },
- // Generar pdfDoc
- drawPDF: function (getColumns,rows) {
- var self = this;
- var sucusal = this.sucDescrip = this.$el.find('#current-journal option:selected').text();
- var desde =(this.$el.find('#from').val());
- var hasta =(this.$el.find('#to').val());
- var totalPagesExp = "{total_pages_count_string}";
- var pdfDoc = new jsPDF();
- pdfDoc.autoTable(getColumns, rows, {
- styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
- columnStyles: {
- number : {columnWidth: '8px'},
- supplier_invoice_number : {columnWidth: '8px'},
- partner : {columnWidth: '8px'},
- date : {columnWidth: '8px'},
- user : {columnWidth: '8px'},
- currency : {columnWidth: '8px'},
- amount_total: {halign:'right',columnWidth: '8px'},
- },
- margin: { top: 16, horizontal: 7},
- addPageContent: function (data) {
- pdfDoc.setFontSize(12);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text('Listado de Compras '+ sucusal, data.settings.margin.left, 10);
- if(desde.length > 0 || hasta.length > 0){
- var fecha='';
- if(desde){
- fecha=fecha.concat(' Desde '+desde);
- }
- if (hasta){
- fecha=fecha.concat(' Hasta '+hasta);
- }
- pdfDoc.setFontSize(10);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40)
- pdfDoc.text(fecha, data.settings.margin.left,14);
- }
- // FOOTER
- var str = "Pagina " + data.pageCount;
- // Total page number plugin only available in jspdf v1.0+
- if (typeof pdfDoc.putTotalPages === 'function') {
- str = str + " de " + totalPagesExp;
- }
- pdfDoc.setFontSize(9);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
- }
- });
- if (typeof pdfDoc.putTotalPages === 'function') {
- pdfDoc.putTotalPages(totalPagesExp);
- }
- pdfDoc.save('Listado de Compras.pdf')
- },
- });
- // ReposrtExpenses Listado de Gastos
- local.ReposrtExpensesWidget = instance.Widget.extend({
- template: 'ReposrtExpenses',
- invoice: [],
- Currency:[],
- resCurrency :[],
- resCompany:[],
- accountJournal:[],
- supplier:[],
- newInvoice:[],
- rowsData :[],
- // event
- events:{
- 'click #toolbar > button' : 'clickOnAction',
- 'change #current-journal' : 'factSearch',
- 'change #current-currency' : 'factSearch',
- 'change #from' : 'factSearch',
- 'change #to' : 'factSearch',
- 'click #volver_btn' : 'volver',
- },
- // Initil
- init : function(parent){
- this._super(parent);
- },
- // start
- start: function () {
- var self = this;
- var table = this.$el.find('#table');
- table.bootstrapTable({data : self.rowsData});
- this.fecthFecha();
- this.submitForm();
- },
- // volver
- volver: function(){
- this.$el.find('#volver').empty();
- this.$el.find('.bootstrap-table').show({
- effect: 'drop',
- direction: 'down',
- duration: 200,
- });
- },
- // Consultar
- submitForm: function () {
- var self = this;
- self.fetchResCurency().then(function(resCurrency) {
- return resCurrency;
- }).then(function (resCurrency) {
- self.resCurrency = resCurrency;
- self.$el.find('#current-currency').append('<option value="9999999">Todas las monedas</option>');
- _.each(resCurrency, function (item) {
- self.$el.find('#current-currency').append('<option value="' + item.id + '">' + item.name + '</option>');
- });
- return self.fetchCurency(resCurrency);
- }).then(function(Currency){
- self.Currency = Currency;
- return self.fetchJournal();
- }).then(function (journal) {
- self.accountJournal =journal;
- self.$el.find('#current-journal').append('<option value="9999999">TODAS LAS SUC.</option>');
- _.each(journal, function (item) {
- self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
- });
- return self.fetchInvoiceP2();
- }).then(function (invoice){
- self.invoice = invoice;
- return self.fetchSupplier(invoice);
- }).then(function(supplier){
- self.supplier=supplier;
- return self.fecthComanyCurrency();
- }).then(function(resCompany){
- self.resCompany = resCompany;
- self.inicializarBuscadorsup();
- return self.fect_generar(self.invoice);
- });
- },
- // Fecha
- fecthFecha: function() {
- var to;
- var dateFormat1 = "mm/dd/yy",
- from = $( "#from" )
- .datepicker({
- dateFormat: "dd/mm/yy",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
- });
- to = $( "#to" ).datepicker({
- dateFormat: "dd/mm/yy",
- defaultDate: "+7d",
- changeMonth: true,
- numberOfMonths: 1,
- })
- .on( "change", function() {
- from.datepicker( "option", "maxDate", getDate(this));
- });
- function getDate( element ) {
- var fechaSel =element.value.split('/');
- var date;
- try {
- date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
- } catch( error ) {
- date = null;
- }
- return date;
- }
- },
- // Buscar Diario
- fetchJournal: function () {
- var self = this;
- var defer = $.Deferred();
- var Journal = new instance.web.Model('account.journal');
- Journal.query(['id', 'name']).filter([['type', '=', 'purchase']]).all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Buscar Cambio de Monedas USD,PYG,ARG,BRL
- fetchCurency: function (currency) {
- var defer = $.Deferred();
- var currency_id = _.flatten(_.map(currency,function(map){
- return map.id;
- }))
- var currency_Rate = new instance.web.Model('res.currency.rate');
- var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
- var domain = [['currency_id', '=', currency_id]];
- currency_Rate.query(fields).filter(domain).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Moneda
- fetchResCurency: function () {
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.currency');
- var fields = ['id', 'name'];
- var domain = [['active', '=', true]];
- currency.query(fields).filter(domain).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Invoice (FACTURAS)
- fetchInvoiceP2: function () {
- var journal_ids = _.flatten(_.map(this.accountJournal, function (item) {
- return item.id;
- }));
- var filter =[['state', '=',['open','paid']],['type', '=', 'in_invoice'],['origin', '=', false],['journal_id', '=',journal_ids]];
- var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id'];
- var defer = $.Deferred();
- var Invoice = new instance.web.Model('account.invoice');
- Invoice.query(field).filter(filter).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // company_curency
- fecthComanyCurrency: function(){
- var self = this;
- var defer = $.Deferred();
- var currency = new instance.web.Model('res.company');
- var field=['id', 'currency_id'];
- var domain=[['id','=',1]];
- currency.query(field).filter(domain).all().then(function(results){
- defer.resolve(results);
- });
- return defer;
- },
- // Partner (Proveeedor)
- fetchSupplier: function() {
- var self = this;
- var defer = $.Deferred();
- var supplier = new instance.web.Model('res.partner');
- supplier.query(['id', 'name', 'ruc', 'active', 'supplier']).filter([['active', '=', true], ['supplier', '=', true]]).all().then(function (results) {
- defer.resolve(results);
- });
- return defer;
- },
- // Obtener el Cambio de la Moneda
- getCurrency: function (id){
- return _.find(this.Currency,function (curr) {
- return _.contains(curr.currency_id,id);
- });
- },
- // Verificar si los Valores no son nulos
- valorNull:function(dato){
- var valor ="";
- if (dato){
- valor=dato;
- }
- return valor;
- },
- // Buscador
- inicializarBuscadorsup: function () {
- var self = this;
- var results = self.supplier;
- results = _.map(results, function (item) {
- return {
- label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
- value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
- }
- });
- self.$('#customer').autocomplete({
- source: results,
- minLength:0,
- search: function(event, ui) {
- if (!(self.$('#customer').val())){
- self.factSearch();
- }
- },
- select: function(event, ui) {
- self.factSearch();
- }
- });
- },
- // unir los objetos
- fect_generar: function(invoices){
- var self = this;
- var data = [];
- _.each(invoices, function(invoice){
- data.push({
- number: invoice.number,
- supplier_invoice_number: self.valorNull(invoice.supplier_invoice_number),
- partner: invoice.partner_id[1],
- date: moment(invoice.date_invoice).format("DD/MM/YYYY"),
- date_invoice: invoice.date_invoice,
- user: invoice.user_id[1],
- currency: invoice.currency_id[1],
- amount_total: accounting.formatNumber(invoice.amount_total,2,".",","),
- amount: invoice.amount_total,
- journal_id : invoice.journal_id[0],
- currency_id : invoice.currency_id[0],
- partner_id : invoice.partner_id[0]
- });
- });
- self.newInvoice = data;
- this.loadTable(data);
- },
- // Buscar
- factSearch: function(){
- var self = this;
- var desde =this.$el.find('#from').val();
- var hasta =this.$el.find('#to').val();
- var suc =this.$el.find('#current-journal').val();
- var currency =this.$el.find('#current-currency').val();
- var prov= this.$el.find('#customer').val().split('-');
- var newInvoice = self.newInvoice;
- // Buscar por Sucursales
- if (suc != 9999999){
- newInvoice=_.filter(newInvoice, function (inv){
- return inv.journal_id == suc;
- });
- }
- // Buscar por fecha Desde
- if (desde.length > 0){
- var date= desde.split('/');
- newInvoice = _.filter(newInvoice, function (inv){
- return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
- });
- }
- // Buscar por Fechas Hasta
- if (hasta.length > 0){
- var date= hasta.split('/');
- newInvoice = _.filter(newInvoice, function (inv){
- return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
- });
- }
- // Busacar por moneda
- if(currency != 9999999){
- newInvoice = _.filter(newInvoice,function(inv){
- return inv.currency_id == currency;
- });
- }
- // Busacara por proveedor
- if (prov != ""){
- newInvoice = _.filter(newInvoice, function(inv){
- return inv.partner_id == prov[0];
- });
- }
- self.loadTable(newInvoice)
- },
- // cargara la tabla
- loadTable:function(rowsTable){
- var self = this;
- self.rowsData = rowsTable;
- var table = this.$el.find('#table');
- table.bootstrapTable('load',rowsTable);
- },
- // Obtener Invoice por Monedad
- getInvoice : function(currency_id){
- var self = this;
- return _.filter(self.rowsData, function(item){
- return item.currency_id === currency_id;
- });
- },
- // Crear Objete PDF
- getObjetPdf: function(rowsTable){
- var self = this;
- var rowsPdf=[];
- var rows=[];
- var itemCurrecy;
- var itenRow;
- var item;
- var curreRate;
- var amount_total=0;
- var amount=0;
- var company = _.map(self.resCompany,function(map){return map.currency_id[1]});
- for (var i = 0; i < self.resCurrency.length; i++) {
- itemCurrecy = self.resCurrency[i];
- itenRow = self.getInvoice(itemCurrecy.id);
- rowsPdf=[];
- if (itenRow.length > 0){
- rowsPdf.push({number: itemCurrecy.name, supplier_invoice_number: "", partner: "", date: "", date_invoice: "", user: "", currency: "", amount_total: "", journal_id : "", currency_id : "", partner_id : ""});
- _.each(itenRow, function(item){
- rowsPdf.push({
- number: item.number,
- supplier_invoice_number: self.valorNull(item.supplier_invoice_number),
- partner: item.partner,
- date: moment(item.date_invoice).format("DD/MM/YYYY"),
- date_invoice: item.date_invoice,
- user: item.user,
- currency: item.currency,
- amount_total: accounting.formatNumber((item.amount),2,".",","),
- amount: item.amount,
- journal_id : item.journal_id,
- currency_id : item.currency_id,
- partner_id : item.partner_id
- });
- });
- curreRate = self.getCurrency(itemCurrecy.id);
- if (!curreRate){
- curreRate={};
- curreRate.rate=1;
- }
- amount_total= _.reduce(_.map(itenRow,function(map){
- return(map.amount);
- }),function(memo, num){
- return memo + num;
- },0);
- amount = amount+(amount_total/curreRate.rate);
- rowsPdf.push({
- number: "Sub - Total "+itemCurrecy.name,
- supplier_invoice_number: "",
- partner: "",
- date: "",
- date_invoice: "",
- user: "",
- currency: "",
- amount_total: accounting.formatNumber((amount_total),2,".",","),
- journal_id : "",
- currency_id : "",
- partner_id : ""
- });
- }
- if (rowsPdf.length >0){
- rows = rows.concat(rowsPdf);
- }
- }
- if (rows.length > 0){
- rows.push({
- number: "Total en "+company,
- supplier_invoice_number: "",
- partner: "",
- date: "",
- date_invoice: "",
- user: "",
- currency: "",
- amount_total: accounting.formatNumber((amount),2,".",","),
- journal_id : "",
- currency_id : "",
- partner_id : ""
- });
- }
- return rows;
- },
- // imprimir PDF
- clickOnAction: function (e) {
- var self = this;
- var rowsNew;
- var action = self.$el.find(e.target).val();
- var table = self.$el.find("#table");
- var data2 = table.bootstrapTable('getVisibleColumns');
- var getColumns=[];
- var rows=[];
- rowsNew = self.getObjetPdf();
- if (action === 'pdf') {
- var dataNEW = _.map(data2, function (val){
- return val.field;
- });
- _.each(rowsNew,function (item){
- rows.push(_.pick(item, dataNEW));
- });
- // Obtener los nombre de la Cabezera
- _.each(_.map(data2,function(val){
- return val;
- }), function(item){
- getColumns.push([{
- title: item.title,
- dataKey: item.field
- }]);
- });
- this.drawPDF(_.flatten(getColumns),rows);
- }
- },
- // Generar pdfDoc
- drawPDF: function (getColumns,rows) {
- var self = this;
- var sucusal = this.sucDescrip = this.$el.find('#current-journal option:selected').text();
- var desde =(this.$el.find('#from').val());
- var hasta =(this.$el.find('#to').val());
- var totalPagesExp = "{total_pages_count_string}";
- var pdfDoc = new jsPDF();
- pdfDoc.autoTable(getColumns, rows, {
- styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
- columnStyles: {
- number : {columnWidth: '8px'},
- supplier_invoice_number : {columnWidth: '8px'},
- partner : {columnWidth: '8px'},
- date : {columnWidth: '8px'},
- user : {columnWidth: '8px'},
- currency : {columnWidth: '8px'},
- amount_total: {halign:'right',columnWidth: '8px'},
- },
- margin: { top: 16, horizontal: 7},
- addPageContent: function (data) {
- pdfDoc.setFontSize(12);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text('Listado de Compras '+ sucusal, data.settings.margin.left, 10);
- if(desde.length > 0 || hasta.length > 0){
- var fecha='';
- if(desde){
- fecha=fecha.concat(' Desde '+desde);
- }
- if (hasta){
- fecha=fecha.concat(' Hasta '+hasta);
- }
- pdfDoc.setFontSize(10);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40)
- pdfDoc.text(fecha, data.settings.margin.left,14);
- }
- // FOOTER
- var str = "Pagina " + data.pageCount;
- // Total page number plugin only available in jspdf v1.0+
- if (typeof pdfDoc.putTotalPages === 'function') {
- str = str + " de " + totalPagesExp;
- }
- pdfDoc.setFontSize(9);
- pdfDoc.setFontStyle('bold');
- pdfDoc.setTextColor(40);
- pdfDoc.text(str, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
- }
- });
- if (typeof pdfDoc.putTotalPages === 'function') {
- pdfDoc.putTotalPages(totalPagesExp);
- }
- pdfDoc.save('Listado de Gastos.pdf')
- },
- });
- // Proximo Report
- instance.web.client_actions.add('eiru_reporting.action_report', 'instance.eiru_reporting.ReportingWidget');
- }
|