[POS-commit] r54 - Stoq2/lib/domain

Henrique Romano henrique at async.com.br
Wed Mar 2 17:51:52 BRT 2005


Author: henrique
Date: 2005-03-02 17:51:51 -0300 (Wed, 02 Mar 2005)
New Revision: 54

Added:
   Stoq2/lib/domain/sellable.py
Log:
Fix for bug 1820: Sellable module implementation

Initial implementation of sellable module.

r=evandro


Added: Stoq2/lib/domain/sellable.py
===================================================================
--- Stoq2/lib/domain/sellable.py	2005-03-02 20:50:49 UTC (rev 53)
+++ Stoq2/lib/domain/sellable.py	2005-03-02 20:51:51 UTC (rev 54)
@@ -0,0 +1,75 @@
+# -*- Mode: Python; coding: iso-8859-1 -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+##
+## Copyright (C) 2004 Async Open Source <http://www.async.com.br>
+## All rights reserved
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 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 General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+## USA.
+##
+"""
+lib/domain/sellable.py:
+
+   This module implements base classes to "sellable objects", such a product
+   or a service, implemented in your own modules.
+"""
+
+from domain import Model, attr
+
+#
+# Objects
+#
+
+class SellableGroup(Model):
+    _ic_options = [attr('description', str),
+                   attr('markup', float, default=0.0, lazy_numbers=True)]
+
+    _required_attrs = ['description']
+
+class SellableSubgroup(SellableGroup):
+    _ic_options = [attr('group', SellableGroup)]
+
+    _required_attrs = ['group']
+    
+class Sellable(Model):
+    """ A sellable (a product or a service, for instance). """
+
+    _ic_options = [attr('id', int, unique=True),
+                   attr('subgroup', SellableSubgroup, default=None),
+                   attr('description', str, default=""),
+                   attr('real_markup', float, default=0.0, lazy_numbers=True),
+                   attr('price', float, default=0.0, lazy_numbers=True),
+                   attr('cost', float, default=0.0, lazy_numbers=True),
+                   attr('markup', float, default=0.0, lazy_numbers=True),
+                   attr('max_discount', float, default=0.0, lazy_numbers=True),
+                   attr('comission', float, default=0.0, lazy_numbers=True),
+                   attr('promotions', list)]
+
+    _required_attrs = ['id', 'description', 'price', 'subgroup', 'markup',
+                       'real_markup']
+
+    def __init__(self, id): 
+        Model.__init__(self)
+        self.id = id
+
+class SellableItem(Model):
+    _ic_options = [attr('item', Sellable),
+                   attr('quantity', float, default=0.0),
+                   attr('price', float, default=0.0),
+                   attr('real_price', float, default=0.0)]
+
+    _required_attrs = ['item', 'quantity', 'price', 'real_price']
+



More information about the POS-commit mailing list