def __set_properties(self): # begin wxGlade: MainFrame.__set_properties self.SetTitle("Pydra GUI") self.SetSize((568, 507)) self.text_output.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, 0, "Consolas")) # end wxGlade self.label_period.SetLabel(period.yyyymm())
def process_pos(inserts): # Retrieve the relevant info from the database #p = period.g_period #from_date = p.first() #to_date = p.last() fmt = "SELECT Code, Cost FROM qryPO WHERE BillingPeriod='%s'" sql = fmt % (period.yyyymm()) costs = {} for rec in db.fetch_all(sql): costs[str(rec[0])] = rec[1] # Add PO costs to database for jcode in costs: cost = costs[jcode] if not inserts.has_key(jcode): continue # can happen with '3. Sundry' for example # inserts[jcode] = create_insertion(jcode) inserts[jcode]['InvPODatabaseCosts'] = cost
def click_all_stages(self, event): # wxGlade: MainFrame.<event_handler> # main process loop question = 'Process period {0}?'.format(period.yyyymm()) if not long_calc(self, question): return self.text_output.SetValue("") self.text_output.Refresh() princ('Started: ' + str(datetime.datetime.now())) wx.SetCursor ( wx.StockCursor ( wx.CURSOR_WAIT ) ) try: self.cache = pydra.main() princ('Finished: ' + str(datetime.datetime.now())) finally: #princ('Entered finally') wx.SetCursor ( wx.StockCursor ( wx.CURSOR_ARROW ) ) wx.MessageBox('Finished', 'Info')
def btn_calculate_clicked(self, event): # wxGlade: TimegridFrame.<event_handler> grid = self.grid_time common.empty_wxgrid(grid) #p = period.g_period self.label_period.SetLabel(period.yyyymm()) dim = period.dim() #maybe delete some columns DATE_COL0 = 4 common.rectify_num_grid_columns(grid, dim + DATE_COL0) #number the columns for c in range(0, dim): grid.SetColLabelValue(c + DATE_COL0 , str(c + 1)) grid.SetColSize(c+DATE_COL0, 30) grid.ForceRefresh() employees = db.GetEmployees() data_rows = {} for initials in sorted(employees.keys()): if employees[initials]['Active'] == 0: continue #print initials data_rows[initials] = DataRow(initials, employees[initials]['PersonNAME'], dim) #print data_rows # accumulate time items by person and date timeItems = db.GetTimeitems() for timeItem in timeItems: initials = timeItem['Person'] dstamp = timeItem['DateVal'] #print str(dstamp) day = dstamp.day #int(str(dstamp[-2:])) #print day qty = timeItem['TimeVal'] if not data_rows.has_key(initials): data_rows[initials] = DataRow(initials, '???', dim) data_rows[initials].times[day-1] += qty # output the results in a grid row_num = -1 for initials in sorted(data_rows): row_num += 1 data_row = data_rows[initials] grid.AppendRows(1) grid.SetCellValue(row_num,0, initials) grid.SetCellValue(row_num,1, data_row.name) staff = "yes" if employees[initials]['IsStaff'] else "" grid.SetCellValue(row_num, 2, staff) grid.SetCellValue(row_num, 3, str(sum(data_row.times))) for c in range(0, dim): v = data_row.times[c] if v == 0: v = '' v = str(v) #v = 'foo' grid.SetCellValue(row_num,c+DATE_COL0,v) # colour the cell according to whether it is a week day or end if period.is_weekend(c+1): bcolour = wx.LIGHT_GREY else: bcolour = wx.WHITE grid.SetCellBackgroundColour(row_num,c+DATE_COL0, bcolour) # self.Refresh() grid.SetFocus()
def camelxls(): return r"M:\Finance\pypms\{0}\summary-{0}.xls".format(period.yyyymm())
def change_period(self, num_months): period.inc(num_months) self.label_period.SetLabel(period.yyyymm())