# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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/>.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from report import report_sxw
-
class pos_details_summary(report_sxw.rml_parse):
+ def __init__(self, cr, uid, name, context):
+ super(pos_details_summary, self).__init__(cr, uid, name, context=context)
+ self.total = 0.0
+ self.localcontext.update({
+ 'time': time,
+ 'strip_name': self._strip_name,
+ 'getpayments': self._get_payments,
+ 'getqtytotal': self._get_qty_total,
+ 'getsumdisc': self._get_sum_discount,
+ 'getpaidtotal': self._paid_total,
+ 'gettotalofthaday': self._total_of_the_day,
+ 'getsuminvoice': self._sum_invoice,
+ 'gettaxamount': self._get_tax_amount,
+ 'getsalestotal': self._get_sales_total,
+ 'getstartperiod': self._get_start_period,
+ 'getendperiod': self._get_end_period,
+ 'getcompany':self.get_company
+ })
+
+ def get_company(self,objects):
+ comp=[obj.company_id.name for obj in objects]
+ return '%s' % (comp[0])
def _get_qty_total(self, objects):
#code for the sum of qty_total
objects,
0.0 )
- def _get_payments(self, objects, ignore_gift=False):
- gift_journal_id = None
- if ignore_gift:
- config_journal_ids = self.pool.get("pos.config.journal").search(self.cr, self.uid, [('code', '=', 'GIFT')])
- if len(config_journal_ids):
- config_journal = self.pool.get("pos.config.journal").browse(self.cr, self.uid, config_journal_ids, {})[0]
- gift_journal_id = config_journal.journal_id.id
+ def _get_payments(self, objects):
+# gift_journal_id = None
+# if ignore_gift:
+# config_journal_ids = self.pool.get("pos.config.journal").search(self.cr, self.uid, [('code', '=', 'GIFT')])
+# if len(config_journal_ids):
+# config_journal = self.pool.get("pos.config.journal").browse(self.cr, self.uid, config_journal_ids, {})[0]
+# gift_journal_id = config_journal.journal_id.id
result = {}
for obj in objects:
- for payment in obj.payments:
- if gift_journal_id and gift_journal_id == payment.journal_id.id:
- continue
- result[payment.journal_id.name] = result.get(payment.journal_id.name, 0.0) + payment.amount
+ for statement in obj.statement_ids:
+ if statement.journal_id:
+ result[statement.journal_id] = result.get(statement.journal_id, 0.0) + statement.amount
return result
def _paid_total(self, objects):
- return sum(self._get_payments(objects, True).values(), 0.0)
+ return sum(self._get_payments(objects).values(), 0.0)
def _total_of_the_day(self, objects):
- total_paid = sum(self._get_payments(objects, True).values(), 0.0)
+ total_paid = self._paid_total(objects)
total_invoiced = self._sum_invoice(objects)
return total_paid - total_invoiced
def _get_sales_total(self, objects):
return reduce(lambda x, o: x + len(o.lines), objects, 0)
- def _get_period(self, objects):
- date_orders = [obj.date_order for obj in objects]
- min_date = min(date_orders)
- max_date = max(date_orders)
- if min_date == max_date:
- return '%s' % min_date
- else:
- return '%s - %s' % (min_date, max_date)
+ def _get_start_period(self, objects):
+ date_orders = sorted([obj.date_order for obj in objects])
+ min_date = date_orders[0]
+ return '%s' % min_date
+
+
+ def _get_end_period(self, objects):
+ date_orders = sorted([obj.date_order for obj in objects])
+ max_date = date_orders[-1]
+ return '%s' % max_date
- def __init__(self, cr, uid, name, context):
- super(pos_details_summary, self).__init__(cr, uid, name, context)
- self.total = 0.0
- self.localcontext.update({
- 'time': time,
- 'strip_name': self._strip_name,
- 'getpayments': self._get_payments,
- 'getqtytotal': self._get_qty_total,
- 'getsumdisc': self._get_sum_discount,
- 'getpaidtotal': self._paid_total,
- 'gettotalofthaday': self._total_of_the_day,
- 'getsuminvoice': self._sum_invoice,
- 'gettaxamount': self._get_tax_amount,
- 'getsalestotal': self._get_sales_total,
- 'getperiod': self._get_period,
- })
report_sxw.report_sxw('report.pos.details_summary',
'pos.order',
'addons/point_of_sale/report/pos_details_summary.rml',
parser=pos_details_summary,
- header=None)
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ header='internal')
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file