← Back to team overview

clearcorp team mailing list archive

lp:~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_account_financial_report_webkit into lp:openerp-costa-rica/6.1

 

Armando Soto Rodríguez has proposed merging lp:~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_account_financial_report_webkit into lp:openerp-costa-rica/6.1.

Requested reviews:
  CLEARCORP drivers (clearcorp-drivers)

For more details, see:
https://code.launchpad.net/~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_account_financial_report_webkit/+merge/109425

[ADD] Added l10n_cr_partner_balance report
-- 
https://code.launchpad.net/~as.clearcorp/openerp-costa-rica/6.1-l10n_cr_account_financial_report_webkit/+merge/109425
Your team CLEARCORP development team is subscribed to branch lp:openerp-costa-rica/6.1.
=== modified file 'l10n_cr_account_financial_report_webkit/report/__init__.py'
--- l10n_cr_account_financial_report_webkit/report/__init__.py	2012-06-05 19:51:03 +0000
+++ l10n_cr_account_financial_report_webkit/report/__init__.py	2012-06-08 19:58:18 +0000
@@ -1,2 +1,3 @@
 from . import l10n_cr_partners_ledger
 from . import l10n_cr_open_invoices
+from . import l10n_cr_partner_balance

=== added file 'l10n_cr_account_financial_report_webkit/report/l10n_cr_account_report_partner_balance.mako'
--- l10n_cr_account_financial_report_webkit/report/l10n_cr_account_report_partner_balance.mako	1970-01-01 00:00:00 +0000
+++ l10n_cr_account_financial_report_webkit/report/l10n_cr_account_report_partner_balance.mako	2012-06-08 19:58:18 +0000
@@ -0,0 +1,157 @@
+<html>
+    <head>
+        <style type="text/css">
+            ${css}
+
+            .list_table .act_as_row {
+                margin-top: 10px;
+                margin-bottom: 10px;
+                font-size:10px;
+            }
+
+            .account_line {
+                font-weight: bold;
+                font-size: 15px;
+                background-color:#F0F0F0;
+            }
+            
+            .account_line .act_as_cell {
+                height: 30px;
+                vertical-align: bottom;
+            }
+
+        </style>
+    </head>
+<body class = "data">
+	%for partner in objects :
+	<%
+	part_by_curr = get_partners_by_curr(cr, uid, partner)
+	%>
+	<%setLang(user.context_lang)%>
+		<%
+		total_balance = 0.0
+		%>
+		<div style="font-size: 20px; font-weight: bold; text-align: center;"> ${company.partner_id.name | entity} - ${company.currency_id.name | entity}</div>
+		<div style="font-size: 25px; font-weight: bold; text-align: center;"> Estado de Cuenta</div>
+		<div style="font-size: 20px; font-weight: bold; text-align: center;"> ${partner.name}</div>
+		 </br></br>
+		%for currency in part_by_curr:
+		    <%
+		    total_debit_curr = 0.0
+		    total_credit_curr = 0.0
+		    total_balance_curr = 0.0
+		    balance_curr = 0.0
+		    %>
+		    %if currency[0] != None:
+                <div class="account_title bg" style="margin-top: 20px; font-size: 12px; width: 1080px;">${_('Estado de Cuenta en ')} ${currency[0]}</div>
+		    %else:
+                <div class="account_title bg" style="margin-top: 20px; font-size: 12px; width: 1080px;">${_('Estado de Cuenta en ')} ${company.currency_id.name}</div>
+		    %endif
+		    <div class="act_as_table list_table">
+		    <div class="act_as_thead">
+			<div class="act_as_row labels" style="font-weight: bold; font-size: 11x;">
+			    <div class="act_as_cell first_column" style="vertical-align: middle">${_('Fecha')}</div>
+			    <div class="act_as_cell" style="width: 250px;  vertical-align: middle">${_('Detalle')}</div>
+			    <div class="act_as_cell">${_('Fecha de Vencimiento')}</div>
+			    <div class="act_as_cell amount">${_('Cobros')}</div>
+			    <div class="act_as_cell amount">${_('Pagos')}</div>
+			</div>
+		    </div>
+			
+			    <div class="act_as_tbody">       
+                %for move_line in sorted(currency[1], key=lambda currency: currency.date):
+			    <div class="act_as_row lines">           
+                              ## Fecha
+                              <div class="act_as_cell first_column">${move_line.date or '0'}</div>
+                              ## Detalle
+                              <div class="act_as_cell">${move_line.name or '-'}</div>
+                              ## Fecha de Vencimiento
+                              <div class="act_as_cell">${move_line.date_maturity or '-'}</div>
+				%if currency[0] != None:
+				    %if move_line.amount_currency > 0: 
+                        ## Cobros
+                        <div class="act_as_cell amount">${formatLang(move_line.amount_currency) or '0'}</div>
+                        ## Pagos
+                        <div class="act_as_cell amount">${'0.00'}</div>
+                        <%total_debit_curr += move_line.amount_currency%>
+				    %else:
+                        ## Cobros
+                        <div class="act_as_cell amount">${'0.00'}</div>
+                        ## Pagos
+                        <div class="act_as_cell amount">${formatLang(move_line.amount_currency*-1) or '0'}</div>
+                        <%total_credit_curr += move_line.amount_currency*-1%>
+				    %endif
+				%else:
+				    ## Pagos
+				    <div class="act_as_cell amount">${formatLang(move_line.debit) or '0'}</div>
+				    ## Cobros
+				    <div class="act_as_cell amount">${formatLang(move_line.credit) or '0'}</div>
+				    <%
+					## Totales por Moneda
+					total_debit_curr += move_line.debit
+					total_credit_curr += move_line.credit 
+				    %>
+				%endif
+                    </div>
+                %endfor
+		</div>
+		<%
+		    ## Totales
+		    total_balance_curr = total_debit_curr - total_credit_curr
+		    if currency[0] != None:
+                balance_curr = currency_convert(cr, uid, move_line.currency_id.id, company.currency_id.id, total_balance_curr)
+		    else:
+                balance_curr = total_balance_curr
+		    endif
+
+		    total_balance += balance_curr
+		%>
+		<div class="act_as_tfoot">
+		<div class="act_as_row labels"  style="font-weight: bold; font-size: 11px;" >
+		    <div class="act_as_cell first_column" style="vertical-align: middle">${_('SALDO')}</div>
+		    %if currency[0] != None:
+                <div class="act_as_cell" style="width: 250px;  vertical-align: middle">${move_line.currency_id.symbol} ${formatLang(total_balance_curr)}</div>
+                <div class="act_as_cell">${_('')}</div>
+                <div class="act_as_cell amount">${move_line.currency_id.symbol} ${formatLang(total_debit_curr)}</div>
+                <div class="act_as_cell amount">${move_line.currency_id.symbol} ${formatLang(total_credit_curr)}</div>
+		    %else:
+                <div class="act_as_cell" style="width: 250px;  vertical-align: middle">${company.currency_id.symbol} ${formatLang(total_balance_curr)}</div>
+                <div class="act_as_cell">${_('')}</div>
+                <div class="act_as_cell amount">${company.currency_id.symbol} ${formatLang(total_debit_curr)}</div>
+                <div class="act_as_cell amount">${company.currency_id.symbol} ${formatLang(total_credit_curr)}</div>
+		    %endif
+		    
+		</div>
+            </div>
+            </div>
+                           
+         %endfor
+
+	<div class="act_as_table list_table " style="margin-top: 20px;">
+	    <div class="act_as_tfoot">
+		<div class="act_as_row labels"  style="font-weight: bold; font-size: 11px;">
+		    <div class="act_as_cell first_column" style="width: 205px; font-size: 12px; text-align: left">${_('SAlDO TOTAL en ')} ${company.currency_id.name}</div>
+		    <div class="act_as_cell" style="text-align: left">${company.currency_id.symbol} ${formatLang(total_balance)}</div>
+		</div>
+	    </div>
+	</div>
+	<div>
+        <%
+            today = get_time_today()
+            if currency[0] != None:
+                conversion_rate = get_conversion_rate(cr, uid, move_line.currency_id, company.currency_id)
+            else:
+                from_currency = get_currency(cr, uid, 2)
+                conversion_rate = get_conversion_rate(cr, uid, from_currency, company.currency_id)
+            endif
+        %>
+	    <div style="font-family: Helvetica, Arial; font-size: 13px; font-weight: bold; margin-top: 20px;"> ${_('Nota: ')} </div>
+        <div style="font-family: Helvetica, Arial; font-size: 12px;"> ${_('En el caso de que hayan monedas extranjeras el Saldo Total se calculó según el cambio de moneda del día ')} ${formatLang( today, date=True)} (${company.currency_id.symbol} ${conversion_rate})</div>
+	</div>
+	<p style="page-break-after:always"></p>
+	
+	%endfor
+	
+
+</body>
+</html>

=== added file 'l10n_cr_account_financial_report_webkit/report/l10n_cr_partner_balance.py'
--- l10n_cr_account_financial_report_webkit/report/l10n_cr_partner_balance.py	1970-01-01 00:00:00 +0000
+++ l10n_cr_account_financial_report_webkit/report/l10n_cr_partner_balance.py	2012-06-08 19:58:18 +0000
@@ -0,0 +1,76 @@
+import time
+import pooler
+from report import report_sxw
+import locale
+from datetime import date
+
+class l10n_cr_partner_balance(report_sxw.rml_parse):
+    def __init__(self, cr, uid, name, context):
+        super(l10n_cr_partner_balance, self).__init__(cr, uid, name, context=context)
+        self.localcontext.update({
+            'time': time,
+            'cr' : cr,
+            'uid': uid,
+            'get_partners_by_curr':self.get_partners_by_curr,
+            'currency_convert':self.currency_convert,
+            'get_time_today':self.get_time_today,
+            'get_conversion_rate':self.get_conversion_rate,
+            'get_currency':self.get_currency,
+        })
+    
+
+    def get_partners_by_curr(self, cr, uid, partner):
+        currency_names_list = []
+        partners_curr_list = []
+        partners_by_curr = []
+
+        obj_move = self.pool.get('account.move.line')
+        obj_search = obj_move.search(cr, uid, [('partner_id','=',partner.id),'&',('reconcile_id','=',False),'|',('account_id.type','=','payable'),('account_id.type','=','receivable')])
+        move_lines = obj_move.browse(cr, uid, obj_search)
+
+        for move_line in move_lines:
+            currency_name = move_line.currency_id.name
+            if currency_name not in currency_names_list:
+                currency_names_list.append(currency_name)
+
+        for currency_name in currency_names_list:
+            move_lines_by_curr = []
+            for move_line in move_lines:
+                if move_line.currency_id.name == currency_name:
+                    move_lines_by_curr.append(move_line)
+            partners_curr_list.append(move_lines_by_curr)
+
+        i = 0
+        for currency_name in currency_names_list:
+            temp_tup = (currency_name, partners_curr_list[i])
+            partners_by_curr.append(temp_tup)
+            i += 1
+            
+        return partners_by_curr
+    
+
+    def currency_convert(self, cr, uid, from_currency, to_currency, amount):
+        res = self.pool.get('res.currency').compute(cr, uid, from_currency, to_currency, amount)
+
+        return res
+
+    def get_time_today(self):
+        today = str(date.today())
+
+        return today
+
+    def get_conversion_rate(self, cr, uid, from_currency, to_currency):
+        res = self.pool.get('res.currency')._get_conversion_rate(cr, uid, from_currency, to_currency)
+
+        return res
+
+    def get_currency(self, cr, uid, currency_id):
+        currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
+
+        return currency
+        
+report_sxw.report_sxw(
+    'report.l10n.cr.partner.balance.layout_ccorp',
+    'res.partner',
+    'addons/l10n_cr_account_financial_report_webkit/report/l10n_cr_account_report_partner_balance.mako',
+    parser=l10n_cr_partner_balance)

=== modified file 'l10n_cr_account_financial_report_webkit/report/report.xml'
--- l10n_cr_account_financial_report_webkit/report/report.xml	2012-06-05 19:51:03 +0000
+++ l10n_cr_account_financial_report_webkit/report/report.xml	2012-06-08 19:58:18 +0000
@@ -34,5 +34,8 @@
              <field name="webkit_header" ref="financial_landscape_header"/>
          </record>
 
+	<report auto="False" id="l10n_cr_partner_balance" model="res.partner" 
+		name="l10n.cr.partner.balance.layout_ccorp"  file="l10n_cr_account_financial_report_webkit/report/l10n_cr_account_report_partner_balance.mako" string="Estado de Cuenta" report_type="webkit"/>
+
     </data>
 </openerp>


Follow ups