def OnNewButton(self, event): event.Skip() def_c = currency.get_default() t = Ticket() t.update(discount=0, user=user.current, currency=def_c) self.ticketChoice.updateList() self.setCurrentTicket(t)
def _init_content(self): session = pos.database.session() ps = session.query(Product).filter(Product.in_stock).all() total = 0 def_c = currency.get_default() headers = ('Reference', 'Name', 'Price', 'Quantity', 'Total') data = [] marked = [] for p in ps: pc = p.currency p_total = p.quantity*p.price data.append([p.reference, p.name, pc.format(p.price), 'x%d' % (p.quantity,), pc.format(p_total)]) if p.quantity<=0: marked.append(len(data)) total += currency.convert(p_total, pc, def_c) table = self.doTable(data=data, header=headers, marked_rows=marked) total_para = Paragraph('Total: %s' % (def_c.format(total),), stylesheet['Heading3Right']) self.elements.append(Spacer(36,36)) self.elements.append(total_para)
def _init_content(self): session = pos.database.session() ps = session.query(Product).filter(Product.in_stock).all() total = 0 def_c = currency.get_default() headers = ('Reference', 'Name', 'Price', 'Quantity', 'Total') data = [] marked = [] for p in ps: pc = p.currency p_total = p.quantity * p.price data.append([ p.reference, p.name, pc.format(p.price), 'x%d' % (p.quantity, ), pc.format(p_total) ]) if p.quantity <= 0: marked.append(len(data)) total += currency.convert(p_total, pc, def_c) table = self.doTable(data=data, header=headers, marked_rows=marked) total_para = Paragraph('Total: %s' % (def_c.format(total), ), stylesheet['Heading3Right']) self.elements.append(Spacer(36, 36)) self.elements.append(total_para)
def _init_content(self): period_total = 0 def_c = currency.get_default() headers = ('Description', 'Price', 'Amount', 'Total') for t in self.tickets: row = [Paragraph('Ticket #%.3d (%s)%s' % (t.id, t.payment_method, \ ' [not paid]' if not t.paid else ''), stylesheet['Heading3']), Paragraph(str(t.date_close), stylesheet['Heading3Right'])] info_table = self.doTable(data=[row]) #[doc.width/2.0]*2 data = [] tc = t.currency tls = t.ticketlines for tl in tls: # TODO add discount data.append([tl.description, tc.format(tl.sell_price), 'x%d' % (tl.amount,), tc.format(tl.amount*tl.sell_price)]) total = t.total footer = ['', '', 'Sub Total', tc.format(total)] period_total += currency.convert(total, tc, def_c) #colwidths = ['*']+['17%']*3 table = self.doTable(data=data, header=headers, footer=footer) total_para = Paragraph('Total: %s' % (def_c.format(period_total),), stylesheet['Heading3Right']) self.elements.append(Spacer(36,36)) self.elements.append(total_para)
def _init_content(self): period_total = 0 def_c = currency.get_default() headers = ('Description', 'Price', 'Amount', 'Total') for t in self.tickets: row = [Paragraph('Ticket #%.3d (%s)%s' % (t.id, t.payment_method, \ ' [not paid]' if not t.paid else ''), stylesheet['Heading3']), Paragraph(str(t.date_close), stylesheet['Heading3Right'])] info_table = self.doTable(data=[row]) #[doc.width/2.0]*2 data = [] tc = t.currency tls = t.ticketlines for tl in tls: # TODO add discount data.append([ tl.description, tc.format(tl.sell_price), 'x%d' % (tl.amount, ), tc.format(tl.amount * tl.sell_price) ]) total = t.total footer = ['', '', 'Sub Total', tc.format(total)] period_total += currency.convert(total, tc, def_c) #colwidths = ['*']+['17%']*3 table = self.doTable(data=data, header=headers, footer=footer) total_para = Paragraph('Total: %s' % (def_c.format(period_total), ), stylesheet['Heading3Right']) self.elements.append(Spacer(36, 36)) self.elements.append(total_para)
def __init__(self, parent): ManagePanel.__init__(self, parent, -1, 'Products', Product, DataValidator) self.createField('Name', wx.TextCtrl, 'name', '', formatter=TextFormatter(required=True)) self.createField('Description', wx.TextCtrl, 'description', '', formatter=TextFormatter(required=False)) self.createField('Reference', wx.TextCtrl, 'reference', '', formatter=AlphaNumericFormatter(required=False)) self.createField('Code', wx.TextCtrl, 'code', '', formatter=AlphaNumericFormatter(required=False)) self.createField('Price', wx.TextCtrl, 'price', '', formatter=FloatFormatter(required=True)) self.createField('Currency', wx.Choice, 'currency', currency.get_default()) self.createField('Quantity', wx.SpinCtrl, 'quantity', 0, value='0', min=0, max=sys.maxint, style=wx.SP_ARROW_KEYS) self.createField('In Stock', wx.CheckBox, 'in_stock', True) self.getField('in_stock').Bind(wx.EVT_CHECKBOX, self.OnInStockCheckBox) self.createField('Category', wx.Choice, 'category', None) self._init_fields()
def __init__(self, parent): ManagePanel.__init__(self, parent, -1, 'Customers', Customer, DataValidator) self.createField('Name', wx.TextCtrl, 'name', '', formatter=TextFormatter(required=True)) self.createField('Code', wx.TextCtrl, 'code', None, formatter=AlphaNumericFormatter(required=False)) self.createField('First Name', wx.TextCtrl, 'first_name', None, formatter=TextFormatter(required=False)) self.createField('Last Name', wx.TextCtrl, 'last_name', None, formatter=TextFormatter(required=False)) self.createField('General Discount', wx.SpinCtrl, 'discount', 0, formatter=FloatFormatter(required=True), min=0, max=100) self.createField('Max Debt', wx.TextCtrl, 'max_debt', None, formatter=FloatFormatter(required=False)) self.createField('Preferred Currency', wx.Choice, 'currency', currency.get_default()) self.createField('Groups', wx.CheckListBox, 'groups', []) self.createField('Comment', wx.TextCtrl, 'comment', '', style=wx.TE_MULTILINE) self.createField('Contact', ContactCtrl, 'contacts', []) self.createField('Address', AddressCtrl, 'addresses', []) self._init_fields()
def updateTicketInfo(self): if self.ticket is None: def_c = currency.get_default() self.currencyChoice.SetStringSelection(def_c.symbol) self.customerTxt.SetValue('[None]') self.discountSpin.SetValue(0) self.totalTxt.SetValue(def_c.format(0)) else: tc = self.ticket.currency self.currencyChoice.SetStringSelection(tc.symbol) c = self.ticket.customer if c is None: self.customerTxt.SetValue('[None]') else: self.customerTxt.SetValue(c.name) self.discountSpin.SetValue(self.ticket.discount * 100.0) self.totalTxt.SetValue(tc.format(self.ticket.total))
def updateTicketInfo(self): if self.ticket is None: def_c = currency.get_default() self.currencyChoice.SetStringSelection(def_c.symbol) self.customerTxt.SetValue('[None]') self.discountSpin.SetValue(0) self.totalTxt.SetValue(def_c.format(0)) else: tc = self.ticket.currency self.currencyChoice.SetStringSelection(tc.symbol) c = self.ticket.customer if c is None: self.customerTxt.SetValue('[None]') else: self.customerTxt.SetValue(c.name) self.discountSpin.SetValue(self.ticket.discount*100.0) self.totalTxt.SetValue(tc.format(self.ticket.total))