Changeset - 16a6c7c3c071
[Not reviewed]
0 2 0
Lance Edgar - 10 years ago 2015-02-27 18:49:50
ledgar@sacfoodcoop.com
Add `GPC.pretty()` method.
2 files changed with 9 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rattail/db/model/products.py
Show inline comments
 
@@ -216,13 +216,13 @@ associates, if any.
 
    def pretty_upc(self):
 
        """
 
        Product's UPC as a somewhat human-readable string.
 
        """
 
        if self.upc is None:
 
            return None
 
        return "{0}-{1}".format(unicode(self.upc)[:-1], unicode(self.upc)[-1])
 
        return self.upc.pretty()
 

	
 
    def cost_for_vendor(self, vendor):
 
        """
 
        Of the product's cost records, return the first one associated with the
 
        given vendor.
 
        """
rattail/gpc.py
Show inline comments
 
@@ -96,6 +96,14 @@ class GPC(object):
 

	
 
    def __str__(self):
 
        return str(unicode(self))
 

	
 
    def __unicode__(self):
 
        return u'%014d' % self.value
 

	
 
    def pretty(self):
 
        """
 
        Returns the UPC as a somewhat more human-readable string.  Basically
 
        that just means the check digit is distinguished by a hyphen.
 
        """
 
        upc = unicode(self)
 
        return "{0}-{1}".format(upc[:-1], upc[-1])
0 comments (0 inline, 0 general)