Explorar o código

Modulo analisis_accountvoucher

sebas %!s(int64=8) %!d(string=hai) anos
achega
15c073f4bb

+ 29 - 0
__init__.py

@@ -0,0 +1,29 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_brand for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    This program is free software: you can redistribute it and/or modify       #
+#    it under the terms of the GNU Affero General Public License as             #
+#    published by the Free Software Foundation, either version 3 of the         #
+#    License, or (at your option) any later version.                            #
+#                                                                               #
+#    This program is distributed in the hope that it will be useful,            #
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
+#    GNU Affero General Public License for more details.                        #
+#                                                                               #
+#    You should have received a copy of the GNU Affero General Public License   #
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product Brand is an Openobject module wich enable Brand management for products #
+###################################################################################
+
+from . import analisis_accountvoucher
+import math

BIN=BIN
__init__.pyc


+ 49 - 0
__openerp__.py

@@ -0,0 +1,49 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_features for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    This program is free software: you can redistribute it and/or modify       #
+#    it under the terms of the GNU Affero General Public License as             #
+#    published by the Free Software Foundation, either version 3 of the         #
+#    License, or (at your option) any later version.                            #
+#                                                                               #
+#    This program is distributed in the hope that it will be useful,            #
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
+#    GNU Affero General Public License for more details.                        #
+#                                                                               #
+#    You should have received a copy of the GNU Affero General Public License   #
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product features is an Openobject module wich enable features management for products #
+###################################################################################
+{
+    'name': 'Analisis de Entrada y Salida sobre Diario de Cuentas',
+    'version': '2.0',
+    'category': 'Product',
+    'description': """
+Analisis de Entrada y Salida sobre Account Voucher
+====================================================
+
+Analisis de Entrada y Salida sobre Account Voucher
+- Cuenta con varios filtros y muestra los siguientes datos: fecha, partner, referencia, monto, fecha
+
+
+    """,
+    'author': 'Eiru/Sebastian Penayo - Rodney Enciso Arias',
+    'website': '',
+	'depends': ['account', 'report'],
+    'data': [
+		'analisis_accountvoucher_filter_view.xml',
+        'informe_analisis_accountvoucher_fecha.xml',
+        'informe_analisis_accountvoucher_view.xml',
+    ],
+    'installable': True,
+}

+ 75 - 0
analisis_accountvoucher.py

@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.                            if(l.type='receipt','l.amount','0') AS amount_entrada,
+#                                     r.employee_id as         'amount_salida': fields.float('Total Salida', readonly=True),
+#            GROUP BY p.id ,l.partner_id,l.journal_id,l.create_date,l.amount_total,s.total
+
+##############################################################################
+
+from openerp import tools
+from openerp.osv import fields, osv
+from openerp.tools.translate import _
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
+
+
+class diarioacc_voucher(osv.osv):
+    _name = "diarioacc.voucher"
+    _description = "Analisis de Entrada y Salida sobre Diario de Cuentas"
+    _auto = False
+
+    _columns = {
+        'partner_id': fields.many2one('res.partner', 'Cliente / Proveedor', readonly=True),
+        'invoice_id': fields.many2one('account.invoice', 'N° Factura', readonly=True),
+        'reference': fields.char('Ref.', readonly=True),
+        'type': fields.char('Tipo', readonly=True),
+        'currency_id': fields.many2one('res.currency', 'Moneda', required=True,readonly=True),
+        'amount_entrada': fields.float('Total Entrada', readonly=True),
+        'amount_salida': fields.float('Total Salida', readonly=True),
+        'saldo': fields.float('Saldo', readonly=True),
+        'date_x': fields.date('Date Order', readonly=True),
+        'company_id': fields.many2one('res.company', 'Company', invisible=True, readonly=True)
+    }
+    _order = 'date_x desc'
+
+
+    def init(self, cr):
+            tools.sql.drop_view_if_exists(cr,'diarioacc_voucher')
+            cr.execute("""
+                CREATE OR REPLACE VIEW diarioacc_voucher AS (
+
+                   SELECT row_number() over (ORDER BY t.id)as id,
+                           t.id as invoice_id,
+                           r.name as xname,
+                           l.partner_id as partner_id,
+                           l.company_id as company_id,
+                           l.reference as reference,
+                           l.type as type,
+                           l.payment_rate_currency_id as currency_id,
+                           (case when l.type = 'receipt' and l.amount>0 then l.amount else 0 end) as amount_entrada,
+                           (case when l.type = 'payment' then l.amount else 0 end) as amount_salida,
+                           ((case when l.type = 'receipt' and l.amount>0 then l.amount else 0 end)-(case when l.type = 'payment' then l.amount else 0 end)) as saldo,
+                           l.date as date_x
+                    FROM account_move r
+                    left join account_invoice t on (r.ref=t.number)
+                    left join account_voucher l on (r.id=l.move_id)
+                    WHERE l.state='posted'
+                    GROUP BY r.name,t.id,l.partner_id,l.reference,l.type,l.amount,l.payment_rate_currency_id ,l.date, l.company_id
+
+                )
+             """)
+diarioacc_voucher()

BIN=BIN
analisis_accountvoucher.pyc


+ 70 - 0
analisis_accountvoucher_filter_view.xml

@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+
+
+    <!-- Custom reports (aka filters) -->
+
+   <record id="filter_analisis_diariocta_voucher1" model="ir.filters">
+        <field name="name">Por Mes</field>
+        <field name="model_id">diarioacc.voucher</field>
+        <field name="journal_id" eval="False"/>
+        <field name="context">{'group_by': ['date_x:month']}</field>
+    </record>
+
+    <record id="filter_analisis_diarioacc_voucher" model="ir.filters">
+         <field name="name">Por Moneda/Mes</field>
+         <field name="model_id">diarioacc.voucher</field>
+         <field name="journal_id" eval="False"/>
+         <field name="context">{'group_by': ['date_x:month', 'currency_id']}</field>
+     </record>
+
+     <record id="filter_analisis_diariocta_vouchermes" model="ir.filters">
+          <field name="name">Por Diario</field>
+          <field name="model_id">diarioacc.voucher</field>
+          <field name="journal_id" eval="False"/>
+          <field name="context">{'group_by': ['currency_id']}</field>
+      </record>
+
+      <record id="filter_analisis_cliente_voucher2" model="ir.filters">
+           <field name="name">Por Cliente</field>
+           <field name="model_id">diarioacc.voucher</field>
+           <field name="journal_id" eval="False"/>
+           <field name="context">{'group_by': ['partner_id']}</field>
+       </record>
+
+    <record id="view_order_diariovoucher_search2" model="ir.ui.view">
+        <field name="name">diarioacc.analisis.search</field>
+        <field name="model">diarioacc.voucher</field>
+        <field name="arch" type="xml">
+            <search string="Analisis de Entrada">
+              <filter string="Este año" name="year" domain="[('date_x','&lt;=', time.strftime('%%Y-12-31')),('date_x','&gt;=',time.strftime('%%Y-01-01'))]"/>
+              <filter string="Año pasado  " domain="[('date_x','&gt;=',(context_today()-relativedelta(years=1)).strftime('%%Y-01-01')),('date_x','&lt;=', time.strftime('%%Y-01-01'))]"/>
+              <filter string="Mes actual" domain="[('date_x','&lt;',(context_today()+relativedelta(months=1)).strftime('%%Y-%%m-01')), ('date_x','&gt;=',time.strftime('%%Y-%%m-01'))]"/>
+              <filter string="Mes pasado" domain="[('date_x','&gt;=',(context_today()-relativedelta(months=1)).strftime('%%Y-%%m-01')),('date_x','&lt;',time.strftime('%%Y-%%m-01'))]"/>
+              <filter string="Hoy" domain="[('date_x', '&gt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),('date_x', '&lt;=',datetime.datetime.now().strftime('%Y-%m-%d 23:23:59'))]"/>
+              <filter string=" Ayer " domain="[('date_x','&lt;=', (datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d')),('date_x','&gt;=',(datetime.date.today()-relativedelta(days=1)).strftime('%%Y-%%m-%%d'))]"/>
+              <filter string="Semana anterior" domain="[('date_x', '&gt;=', ((context_today()+relativedelta(weeks=-2, days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),('date_x', '&lt;=', ((context_today()+relativedelta(weeks=-1, weekday=6)).strftime('%%Y-%%m-%%d')))]"/>
+              <filter string="Esta semana" domain="[('date_x', '&gt;=', ((context_today()+relativedelta(weeks=-1, days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),('date_x', '&lt;=', ((context_today()+relativedelta(weeks=0, weekday=6)).strftime('%%Y-%%m-%%d')))]"/>
+                <separator/>
+                <group expand="0" string="Filtros Extendidos">
+                    <filter string="Moneda" name="currency_id"/>
+                    <filter string="Guarani" name="currency_id" domain="[('currency_id','=','PYG')]"/>
+                    <filter string="Dolar" name="currency_id" domain="[('currency_id','=','USD')]"/>
+                    <filter string="Entrada" name="type" domain="[('type','=','payment')]"/>
+                    <filter string="Salida" name="type" domain="[('type','=','receipt')]"/>
+                    <filter string="Cliente" name="partner_id"/>
+                </group>
+                <group expand="1" string="Agrupado por">
+                    <filter string="Mes" context="{'group_by':'date_x:month'}"/>
+                    <filter string="Por dia" context="{'group_by':'date_x:day'}"/>
+                </group>
+            </search>
+        </field>
+    </record>
+
+
+
+</data>
+</openerp>

+ 80 - 0
informe_analisis_accountvoucher_fecha.xml

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<report id="report_diarioacc3"
+            model="diarioacc.voucher"
+            string="Balance de Ingreso y Egreso"
+            report_type="qweb-pdf"
+            name="analisis_accountvoucher.informe_diarioacc_por_fecha"
+            file="analisis_accountvoucher.informe_diarioacc_por_fecha"
+	    />
+		<template id="informe_diarioacc_por_fecha">
+			<t t-call="report.html_container">
+				<t t-call="report.external_layout">
+					<div class="page">
+						<div class="row">
+							<div class="col-xs-12 col-sm-12">
+								<div class="panel panel-info">
+									<div class="panel-heading text-center">
+										<h4>Balance</h4>
+									</div>
+									<table class="table table-condenced table-bordered">
+										<thead>
+											<th>Factura</th>
+											<th>Cliente/Proveedor</th>
+											<th>Fecha</th>
+											<th>Ingreso</th>
+											<th>Egreso</th>
+										</thead>
+										<tbody>
+											<t t-foreach="docs" t-as="o">
+												<tr>
+													<td><span t-esc="o.reference"/></td>
+													<td><span t-field="o.partner_id"/></td>
+													<td><span t-field="o.date_x"/></td>
+
+													<td class="text-right success"><span t-esc="'{0:,.0f}'.format(round(float(o.amount_entrada), 0))"/></td>
+											<!--		t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/> <td class="text-right success"><span t-esc='"%0.0f" % o.amount_entrada'/></td> -->
+													<td class="text-right danger"><span t-esc="'{0:,.0f}'.format(round(float(o.amount_salida), 0))"/></td>
+												</tr>
+											</t>
+											<tr>
+												<td><strong>Total : </strong></td>
+												<td></td>
+												<td></td>
+												<td class="text-right success">
+													<strong>
+														<t t-set="totalent" t-value="sum([x.amount_entrada for x in docs])"/>
+														<span t-esc="'{0:,.0f}'.format(round(float(totalent), 0))"/>
+													</strong>
+												</td>
+												<td class="text-right danger">
+													<strong>
+														<t t-set="totalsal" t-value="sum([x.amount_salida for x in docs])"/>
+														<span t-esc="'{0:,.0f}'.format(round(float(totalsal), 0))"/>
+													</strong>
+												</td>
+											</tr>
+										</tbody>
+									</table>
+									<div class="panel-footer text-right">
+										<strong>Saldo : <t t-set="tsaldo" t-value="sum([x.saldo for x in docs])"/>
+										<span t-esc="'{0:,.0f}'.format(round(float(tsaldo), 0))"/>
+										</strong>
+									</div>
+								</div>
+							</div>
+						</div>
+					</div>
+				</t>
+			</t>
+		</template>
+		<!-- <record id="paperformat_analisis_accountvoucher" model="report.paperformat">
+			<field name="name">Balance</field>
+			<field name="orientation">Landscape</field>
+		</record>
+		<record id="report_diarioacc3" model="ir.actions.report.xml">
+			<field name="paperformat_id" ref="paperformat_analisis_accountvoucher"></field>
+		</record> -->
+	</data>
+</openerp>

+ 53 - 0
informe_analisis_accountvoucher_view.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="diarioacc_voucher_tree_view" model="ir.ui.view">
+            <field name="name">diarioacc.analisis.tree.view</field>
+            <field name="model">diarioacc.voucher</field>
+            <field name="priority" eval="20"/>
+            <field name="arch" type="xml">
+            <tree string="Analisis de Entrada sobre Diario de Cuentas" create="false">
+            <field name="id" invisible="1"/>
+            <field name="partner_id"/>
+            <field name="reference" on_change="onchange_ref_id(reference)"/>
+            <field name="invoice_id" invisible="1"/>
+            <field name="currency_id" string="Moneda"/>
+            <field name="amount_entrada" sum="totalent" string="Total Entrada"/>
+            <field name="amount_salida" sum="totalsal" string="Total Salida"/>
+            <field name="saldo" sum="totalsaldo" string="Total Saldo" invisible="1"/>
+            <field name="date_x" string="Fecha"/>
+				</tree>
+            </field>
+        </record>
+
+
+        <record model="ir.ui.view" id="facturaventa_analisis_form">
+                <field name="name">Ingreso y Egreso</field>
+                <field name="model">diarioacc.voucher</field>
+                <field name="view_type">form</field>
+                <field eval="20" name="priority"/>
+                <field name="arch" type="xml">
+                    <form string="Ingreso y Egreso" create="false" edit="false">
+                        <group>
+                            <field name="date_x"/>
+                            <field name="partner_id"/>
+                            <field name="invoice_id"/>
+                        </group>
+                    </form>
+                </field>
+      </record>
+
+		<record id="action_diarioacc_voucher_tree_view" model="ir.actions.act_window">
+            <field name="name"> Ingreso y Egreso</field>
+            <field name="res_model">diarioacc.voucher</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+
+
+
+		<menuitem name="Balance" sequence="1" id="menu_analisisdiarioacc_gral" parent="base.menu_reporting"/>
+		<menuitem id="diarioacc_analisis_menu" name="Ingreso y Egreso" parent="menu_analisisdiarioacc_gral" action="action_diarioacc_voucher_tree_view"/>
+
+	</data>
+</openerp>

+ 94 - 0
modelo.xml

@@ -0,0 +1,94 @@
+<template id="informe_diarioacc_por_fecha">
+		<t t-call="report.html_container">
+			<t t-call="report.internal_layout">
+				<div class="page">
+					<h2 class="text-center text-info">Balance</h2>
+					<br/>
+					<div class="row">
+						<div class="col-xs-6 col-sm-5 col-md-5">
+							<div class="panel panel-success">
+								<div class="panel-heading">
+									Ingreso
+								</div>
+								<table class="table table-condenced table-bordered">
+									<thead>
+										<th>Factura</th>
+										<th>Cliente</th>
+										<th>Fecha</th>
+										<th>Ingreso</th>
+									</thead>
+									<tbody>
+										<t t-foreach="docs" t-as="o">
+											<t t-if="o.type == 'receipt' ">
+												<tr>
+													<td><span t-esc="o.reference"/></td>
+													<td><span t-field="o.partner_id"/></td>
+													<td><span t-field="o.date_x"/></td>
+													<td class="text-right"><span t-field="o.amount_entrada"/></td>
+												</tr>
+											</t>
+										</t>
+									</tbody>
+								</table>
+							</div>
+						</div>
+						<div class="col-xs-6 col-sm-5 col-sm-5">
+							<div class="panel panel-danger">
+								<div class="panel-heading">
+									Egreso
+								</div>
+								<table class="table table-condenced table-bordered">
+									<thead>
+										<th>Factura</th>
+										<th>Proveedor</th>
+										<th>Fecha</th>
+										<th>Egreso</th>
+									</thead>
+									<tbody>
+										<t t-foreach="docs" t-as="o">
+											<t t-if="o.type == 'payment' ">
+												<tr>
+													<td><span t-esc="o.reference"/></td>
+													<td><span t-field="o.partner_id"/></td>
+													<td><span t-field="o.date_x"/></td>
+													<td class="text-right"><span t-field="o.amount_salida"/></td>
+												</tr>
+											</t>
+
+										</t>
+									</tbody>
+								</table>
+							</div>
+						</div>
+					</div>
+					<div class="row">
+						<div class="col-xs-12 col-sm-12 col-sm-12">
+							<div class="panel panel-info">
+								<div class="panel-heading">
+									Saldo
+								</div>
+								<table class="table table-condenced table-bordered">
+									<thead>
+										<th>Total Ingreso: </th>
+										<th class="text-right">
+											<t t-set="totalent" t-value="sum([x.amount_entrada for x in docs])"/>
+											<span t-esc="totalent" t-esc-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
+										</th>
+										<th>Total Egreso: </th>
+										<th class="text-right">
+											<t t-set="totalsal" t-value="sum([x.amount_salida for x in docs])"/>
+											<span t-esc="totalsal" t-esc-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
+										</th>
+									</thead>
+								</table>
+								<div class="panel-footer text-right">
+									<t t-set="tsaldo" t-value="sum([x.saldo for x in docs])"/>
+									<span t-esc="tsaldo" t-esc-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/>
+								</div>
+							</div>
+						</div>
+					</div>
+				</div>
+			</t>
+		</t>
+	</template>

+ 12 - 0
report_accountvoucher.py

@@ -0,0 +1,12 @@
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp  import models, fields, api
+
+
+
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN=BIN
report_accountvoucher.pyc


BIN=BIN
static/description/icon.png