class CurrencyManagement: """Provices currency related methods. """ implements(ICurrencyManagement) adapts(Interface) def __init__(self, context): """ """ self.shop = IShopManagement(context).getShop() def getLongName(self): """ """ currency = self.shop.getCurrency() return CURRENCIES[currency]["long"] def getShortName(self): """ """ currency = self.shop.getCurrency() return CURRENCIES[currency]["short"] def getSymbol(self): """ """ currency = self.shop.getCurrency() return CURRENCIES[currency]["symbol"] def priceToString(self, price, symbol="symbol", position="before"): """ """ price = "%.2f" % price string = price.replace(".", ",") if symbol == "short": currency = self.getShortName() elif symbol == "long": currency = self.getLongName() else: currency = self.getSymbol() if position == "before": string = "%s %s" % (currency, string) else: string = "%s %s" % (string, currency) return string
def getOrders(self): """ """ om = IOrderManagement(IShopManagement(self.context).getShop()) result = [] for order in om.getOrders(): # omit closed orders wftool = getToolByName(self.context, "portal_workflow") if wftool.getInfoFor(order, "review_state") == "closed": continue customer = order.getCustomer() # am = IAddressManagement(customer) # shipping_address = am.getShippingAddress() im = IItemManagement(order) for item in im.getItems(): product = item.getProduct() row = ( order.getId(), customer.getId(), # shipping_address.getFirstname() + " " + shipping_address.getLastname(), product.getArticle_id(), product.Title(), "%s" % item.getProductQuantity(), "%.2f" % item.getProductPriceGross(), "%.2f" % item.getProductPriceNet(), "%.2f" % item.getProductTax(), "%.2f" % item.getTax(), "%.2f" % item.getTaxRate(), "%.2f" % item.getPriceGross(), "%.2f" % item.getPriceNet(), ) # row = ['"%s"' % field for field in row] row = ";".join(row) result.append(row) self.request.response.setHeader('Content-type', 'text/plain') self.request.response.setHeader( 'Content-disposition', 'attachment; filename=%s' % "orders.csv") return "\n".join(result)
def isValid(self, product=None): """Returns true if the corresponding payment validator is not False and all contained criteria are True. """ # First we check the general validity. For that we try to get the # corresponding payment validator. type = IType(self.context).getType() pm = IPaymentManagement(IShopManagement(self.context).getShop()) method = pm.getPaymentMethod(type) # Only if we find one, we check validity. If we didn't find one, we # consider the general validity as fulfilled. if method and IValidity(method).isValid() == False: return False # If the non-validity isn't proved we check the criteria of context # (a customer payment method) return super(CustomerPaymentValidityManagement, self).isValid(product)
def showAddQuantity(self): """ """ shop = IShopManagement(self.context).getShop() return shop.getShowAddQuantity()
def __init__(self, context): """ """ self.shop = IShopManagement(context).getShop()
def getShopURL(self): """ """ return IShopManagement(self.context).getShop().absolute_url()