Exemple #1
0
 def insert(self, name):
     if not self.exists(name):
         sql = "INSERT INTO accounts SET name ='%s'"
         pass
         self.Close()
     else:
         fetch.msg("Account name exists, please try another")
Exemple #2
0
    def OnSave(self, evt):
        #rint'save then destroy'

            
        for item in deletedDebits:
            sql = "DELETE FROM WHERE id = %d" % item
            #rintsql
   
        for item in addedDebits:
            iid, val = item
            sql = "INSERT INTO VALUES ('%s', %d)" % (iid, val)
            #rintsql
            
        # fem

        
        # how to signal update or cancel
 
        saved = True
        
        if saved:
            self.Destroy()
        else:
            fetch.msg('file not saved - please check ')
    
        self.EndModal(wx.ID_OK)
Exemple #3
0
 def deleteRow(self, grid):
     rows = grid.GetSelectedRows()
     #rint'GetSelectedRows', rows
     if len(rows)==1:
         grid.deleteRow(rows[0])
         grid.calcTotal()
     else:
         fetch.msg('select one row only')
Exemple #4
0
 def displayData(self):
     res = fetch.courses_levels_all_DATA()
     #rintres
     if not res:
         msg = "No courses levels found"
         
         fetch.msg(msg)
     else:
         self.list_ctrl_course_levels.SetItemMap(res)
         
     self.list_ctrl_course_levels.SortListItems(1)
Exemple #5
0
    def OnAdd(self, evt):
        #rint'OnAdd'
        product_id = fetch.cmbID(self.choice_products)
        #rint'product_id.GetSelection():', product_id
        if not product_id or self.grid_product.inGrid(product_id):
            return
        
        description     = fetch.cmbValue(self.choice_products)
        price           = fetch.product_price(product_id)
        qnty            = 1
        total           = qnty*price
        product_type_id = fetch.get_product_type_id(product_id)
        
        if product_type_id == 1: # school fee
            #rint' append fee '
            month_no = fetch.month_last_paid(student_id, gVar.schYr, 9)+1
            if month_no > 12:
                self.panel_fees.Hide()
                fetch.msg('month 12 already paid for')
                return
            else:
                self.panel_fees.Show()
            month = fetch.monthName(month_no)
            description = 'Schoolfee for %s' % month
            
            
        elif product_type_id == 9: # bus fee
            #rint' append bus '

            # last paid for month
            # if last month == 12 : return
            month_no = fetch.month_last_paid(student_id, gVar.schYr, 9)+1
            
            if month_no > 12:
                fetch.msg('month 12 already paid for')
                # what we really need to know is if all months have been paid for
                return
            else:
                self.panel_bus.Show()
            self.Layout()
            month = fetch.monthName(month_no)
            description = 'Bus fee for %s' % month

        
        data  = {'product_id':product_id,
                'qnty':qnty,
                'description':description,
                'price':price,
                'total':total}
        self.grid_product.appendItem(data)
        
        r = self.grid_product.GetNumberRows()
        self.grid_product.setCellReadOnly(r, 0)
Exemple #6
0
    def displayData(self, course_id=0):
        self.course_id = course_id
        if course_id:
            self.editMode = 'update'
            txt = "no details found for course_id %d" % course_id
            if not self.displayCourseDetails():
                fetch.msg(txt)
                self.editMode = 'new'

        else:
            self.editMode = 'new'
            
        txt = self.editMode + ' course for school year ' + str(gVar.schYr)
        self.SetTitle(txt)
Exemple #7
0
 def OnSave(self, evt):
     print
     #rint'OnSave--------------'
     
     division_id  = fetch.cmbID(self.choice_divisioan)
     date         = self.datepicker_ctrl_1.GetDbReadyValue()
     description  = self.text_ctrl_description.GetValue()
     ckRef        = self.text_ctrl_ckrefno.GetValue()
     supplierRef  = self.text_ctrl_supplierrefno.GetValue()
     
     supplier_id = fetch.cmbID(self.choice_supplier)
     
     pettycash = self.checkbox_pettycash.GetValue()
     
     debit_items_count  = self.grid_debits.getItemCount()
     credit_items_count = self.grid_credits.getItemCount()
     msg = ''
     
     if not division_id:
         msg += '- division\n'
         
     if not tran_description:
         msg += '-transaction description\n'
         
     if not supplier_id:
          msg += '-supplier\n'
     
     if not date:
         msg += '-transaction date\n'
     
     if not ckRef:
         msg += '-ck ref missing\n'
     
     if debit_items_count + credit_items_count == 0:
         msg += '-credit or debit entries\n'
         
     if msg:
         msg = 'Missing Items:\n' + msg
         fetch.msg(msg)
         return
     
     if self.debit_total != self.credit_total:
         fetch.msg('transaction totals do not match')
     
     data = (supplier_id, date, description,  ckRef, supplier_id, supplierRef, pettycash)
     if self.journal_id:
         self.updateEntries(data)
     else:
         self.newEntry(data)
Exemple #8
0
   def OnAddCredit(self, evt):
       #rint'Add credit'
       gVar.listCtrl = 'c'
       account_id=fetch.cmbID(self.choice_credits)
 
       if self.id_in_grid(account_id, self.grid_credits): return
       
       if self.id_in_grid(account_id, self.grid_debits):
           fetch.msg('can add this account, already in debits')
       
       account = fetch.cmbValue(self.choice_credits)
       #rint'OnAddCredit', account
       
       self.grid_credits.appendItem((account_id, account, 0))
       self.grid_credits.calcTotal()
Exemple #9
0
 def OnEnter(self, event):
     self.course_name  = '"%s"' % self.text_ctrl_course_name.GetValue()
     self.code         = '"%s"' % self.text_ctrl_short_name.GetValue()
     self.course_level = fetch.cmbID(self.choice_levels)
     self.school_id    = fetch.cmbID(self.choice_schools)
     
     if not self.course_title or not self.course_level:
         txt = "Must have course title  and a course level"
         fetch.msg(txt)
         return
     
     elif self.courseNameAvailable(self.course_title):
         if self.editMode == 'update':
               self.updateCourse()
         else: self.insertNewCourse()
         self.EndModal(wx.ID_OK)
Exemple #10
0
 def courseNameAvailable(self, course_name):
     sql = 'SELECT id \
              FROM courses \
             WHERE name = %s \
               AND schYr =%d' % (course_name, gVar.schYr)
     
     if self.editMode:
         sql += " AND NOT id = %d" % self.course_id
     
     #rint sql
     if fetch.getDig(sql):
         fetch.msg("Duplicate course name for this year, please try another")
         return False
         
     else:       
         return True
Exemple #11
0
 def onSave(self, evt):
     description = self.text_ctrl_description.GetValue()
     price       = int(self.text_ctrl_price.GetValue())
     
     if not description or not price:
         fetch.msg("Price or description missing ")
 
     elif fetch.is_unique_product(sql):
         fetch.msg('description not unique')
     
     else:
         sql = "INSERT INTO acc_products \
                           (description, price)  \
                    VALUES ('%s', %d)" % (
                           description, price)
         #rintsql
         fetch.updateDB(sql)
         self.Destroy()
Exemple #12
0
 def OnNewDivision(self, evt):
     dlg = wx.TextEntryDialog(self, 'division name', 'New division name', '')
     if dlg.ShowModal() == wx.ID_OK:
         new_name = dlg.GetValue().strip()
         if new_name:
             sql = "SELECT name \
                      FROM acc_divisions \
                     WHERE name = '%s'" % new_name
             if fetch.getCount(sql):
                 msg = "Sorry division '%s' already exists" % new_name
                 fetch.msg(msg)
             else:
                 sql = "INSERT INTO acc_divisions \
                                    (name) \
                             VALUES ('%s')" % (new_name)
                 #rintsql
                 fetch.updateDB(sql)
                 self.loadDivisions()
                 loadCmb.restore_str(self.choice_division, new_name)
     dlg.Destroy()
Exemple #13
0
    def OnNewSupplier(self, evt):
        #rint"open dlgTextEntry 'new supplier' "
        dlg = wx.TextEntryDialog(self, 'Supplier Name', 'New Supplier Name', '')
 
        if dlg.ShowModal() == wx.ID_OK:
            new_name = dlg.GetValue().strip()
            if new_name:
                sql = "SELECT name \
                         FROM acc_suppliers \
                        WHERE name = '%s'" % new_name
                if fetch.getCount(sql):
                    msg = "Sorry supplier '%s' already exists" % new_name
                    fetch.msg(msg)
                else:
                    sql = "INSERT INTO acc_suppliers \
                                       (name) \
                                VALUES ('%s')" % new_name
                    fetch.updateDB(sql)
                    self.loadSuppliers()
                    loadCmb.restore_str(self.choice_supplier, new_name)
Exemple #14
0
 def __do_main(self, ):
     columns = (('id', 0),('Course Pool', 120), ('Level',70))
     self.list_ctrl_all_courses.SetColumns(columns)
     
     res = fetch.courses_DATA()
     if not res:
         msg = "No courses for found"
         fetch.msg(msg)
     else:
         self.list_ctrl_all_courses.SetItemMap(res)
         
         
     x = 'Courses for %d' % gVar.schYr
     columns = (('id', 0), (x, 120), ('Level',70))
     self.list_ctrl_course_by_year.SetColumns(columns)
     
     res = fetch.courses_for_year_DATA(gVar.schYr)
     if not res:
         msg = "No courses for found"
         fetch.msg(msg)
     else:
         self.list_ctrl_course_by_year.SetItemMap(res)
Exemple #15
0
 def updateEntries(self, data):
     supplier_id, date, tran_description, ckRef, supplier_id, supplierRef, pettycash = data
     
     debit_items  = self.grid_debits.getItemCount()
     credit_items = self.grid_credits.getItemCount()
     
     print
     #rint'updateEntries'
     
     print
     #rint'remove existing entries'
     sql = "DELETE FROM acc_journal_items \
                  WHERE journal_id = %d" % self.journal_id
     #rintsql
         
     sql = "DELETE FROM acc_journal_items \
                  WHERE journal_id = %d" % self.journal_id
     #rint"remove all credit & debit items", sql
     
     if not (debit_items + credit_items)> 0:
         sql1 = "DELETE FROM acc_journal \
                       WHERE id = %d" % self.journal_id
         msg =  'No debit items or credit items. Please edit'
         fetch.msg(msg)
         return
         
     else:
         # update jurnal details
         sql = "UPDATE acc_journal \
                   SET supplier_id = %d, date = '%s', name = '%s', \
                       details='%s', ck_ref='%s', supplier_ref = '%s', petty_cash = %s \
                 WHERE id = %d" % (
                       supplier_id, date, tran_description,
                       tran_description[255:], ckRef, supplierRef, pettycash, 
                       self.journal_id)
         #rint'\nUpdate jurnal details'
         #rintsql
         
         # 'insert each debit item'
         if debit_items: #rint'insert each debit item'
         for x in range(0, debit_items):
             account_id = int(self.grid_debits.GetCellValue(x, 0))
             amount = self.grid_debits.GetCellValue(x, 2)
             amount = float(amount.replace(',',''))
             sql = "INSERT INTO acc_journal_items \
                       SET (journal_id, account_id, debit, amount) \
                    VALUES (%d, %d, %d, %d)" % (self.journal_id, account_id, True, amount)
             
             #rintsql
         
         # 'insert each debit item'
         if credit_items: #rint'insert each debit item'
         for x in range(0, credit_items):
             account_id = int(self.grid_credits.GetCellValue(x, 0))
             amount = self.grid_credits.GetCellValue(x, 2)
             amount = float(amount.replace(',',''))
             sql = "INSERT INTO acc_journal_items \
                       SET (journal_id, account_id, debit, amount) \
                    VALUES (%d, %d, %d, %d)" % (self.journal_id, account_id, False, amount)
             
             #rintsql
     
     self.EndModal(wx.ID_OK)
     
 def getDebitItems(self, ):
     pass
 
      
 def OnClose(self, evt):
     self.EndModal(0)