def on_save_button_clicked(self, button): result = {} result['type'] = self.type_index result['total_value'] = self.total_credit_entry.get_float() result['cash_payment'] = self.cash_payment_entry.get_float() result['non_cash_payment'] = self.builder.get_object('non-cash-payment-label').get_text() result['spend_cheque'] = self.builder.get_object('spend-cheque-label').get_text() result['discount'] = self.discount_entry.get_float() result['non-cash-payment-info'] = None # TODO: = non cash payment infos result['spend-cheque-info'] = None # TODO = spent cheque infos result['desc'] = self.builder.get_object('desc').get_text() result['from'] = self.from_id result['to'] = self.to_id dbconf = dbconfig.dbConfig() #Save data in data base for single use if self.liststore == None: type(result['from']) document = class_document.Document() document.add_notebook(result['from'], result['total_value'], unicode(result['desc'])) document.add_notebook(result['to'] , -result['cash_payment'], unicode(result['desc'])) if result['discount'] : document.add_notebook(dbconf.get_int('sell-discount'), -result['discount'], result['desc']) cl_cheque = class_cheque.ClassCheque() for cheque in self.chequeui.new_cheques: if self.mode == 'our': document.add_cheque(dbconf.get_int('our_cheque'), -cheque['amount'], cheque['desc'], cheque['serial']) else: document.add_cheque(dbconf.get_int('other_cheque'), -cheque['amount'], cheque['desc'], cheque['serial']) #spendble cheque for sp_cheque in self.chequeui.spend_cheques: cl_cheque.update_status(sp_cheque['serial'],5) document.add_cheque(dbconf.get_int('other_cheque'), -sp_cheque['amount'] , unicode('kharj shodeh') , sp_cheque['serial']) result = document.save() if result < 0: dialog = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, 'Failed, %s' % document.get_error_message(result)) dialog.run() dialog.destroy() return if self.type_configs[self.type_index][3] == True: # from is subject customer_id = 0 else: # from is customer customer_id = share.config.db.session.query(Customers).select_from(Customers).filter(Customers.custSubj==self.from_id).first().custId for cheque in self.chequeui.new_cheques: notebook_id =document.cheques_result[cheque['serial']] cl_cheque.add_cheque(cheque['amount'], cheque['write_date'], cheque['due_date'], cheque['serial'], cheque['status'], customer_id, cheque['bank_account_id'], result, notebook_id, cheque['desc']) cl_cheque.save() cl_cheque.save_cheque_history(self.current_time) self.on_destroy(self.builder.get_object('general')) share.mainwin.silent_daialog(_('successfully added. Document number : %d') % document.number) # infobar = gtk.InfoBar() # label = gtk.Label(_('successfully added. Document number : %d') % document.number) # infobar.get_content_area().add(label) # width , height = self.main_window_background.window.get_size() # infobar.set_size_request(width, -1) # self.main_window_background.put(infobar ,0 , 0) # infobar.show_all() # # glib.timeout_add_seconds(3, lambda w: w.destroy(), infobar) #Store result in list store for showing in addeditdoc else: mysubject = Subjects() numrows = len(self.liststore) + 1 #document.add_notebook(result['from'], result['total_value'], result['desc']) self.liststore.append ((LN(numrows), LN(self.from_code), self.from_name, LN(0), LN(result['total_value']), result['desc'], None)) #self.liststore.append ((numrows, code, sub.name, debt, credit, desc, None)) #document.add_notebook(result['to'] , -result['cash_payment'], result['desc']) numrows += 1 self.liststore.append ((LN(numrows), LN(self.to_code), self.to_name, LN(result['cash_payment']), LN(0), result['desc'], None)) if result['discount'] : numrows += 1 self.liststore.append ((LN(numrows), LN(mysubject.get_code(dbconf.get_int('sell-discount'))), mysubject.get_name(dbconf.get_int('sell-discount')), LN(result['discount']), LN(0), result['desc'], None)) #cl_cheque = class_cheque.ClassCheque() #or cheque in self.chequeui.new_cheques: # if self.mode == 'our': # document.add_cheque(dbconf.get_int('our_cheque'), -cheque['amount'], cheque['desc'], cheque['serial']) # else: # document.add_cheque(dbconf.get_int('other_cheque'), -cheque['amount'], cheque['desc'], cheque['serial']) #spendble cheque #for sp_cheque in self.chequeui.spend_cheques: # cl_cheque.update_status(sp_cheque['serial'],5) # document.add_cheque(dbconf.get_int('other_cheque'), -sp_cheque['amount'] , unicode('kharj shodeh') , sp_cheque['serial']) #if self.type_configs[self.type_index][3] == True: # from is subject # customer_id = 0 #else: # from is customer # customer_id = config.db.session.query(Customers).select_from(Customers).filter(Customers.custSubj==self.from_id).first().custId #for cheque in self.chequeui.new_cheques: # notebook_id =document.cheques_result[cheque['serial']] # cl_cheque.add_cheque(cheque['amount'], cheque['write_date'], cheque['due_date'], # cheque['serial'], cheque['status'], # customer_id, cheque['bank_account_id'], # result, notebook_id, cheque['desc']) #cl_cheque.save() #cl_cheque.save_cheque_history(self.current_time) self.on_destroy(self.builder.get_object('general'))
def on_spend_cheque_buttun_clicked(self,button): cl_cheque = class_cheque.ClassCheque() self.chequeui.list_cheques(None, 1) cl_cheque.save_cheque_history()
def on_spend_cheque_buttun_clicked(self,button): cl_cheque = class_cheque.ClassCheque() self.spendChequeui. showPayments(self.win)
def on_save_button_clicked(self, button): share.config.db.session.rollback() result = {} result['type'] = self.type_index result['total_value'] = self.total_credit_entry.get_float() result['cash_payment'] = self.cash_payment_entry.get_float() result['non_cash_payment'] = self.builder.get_object('non-cash-payment-label').get_text() result['spend_cheque'] = self.builder.get_object('spend-cheque-label').get_text() result['discount'] = self.discount_entry.get_float() result['non-cash-payment-info'] = None # TODO: = non cash payment infos result['spend-cheque-info'] = None # TODO = spent cheque infos result['desc'] = self.builder.get_object('desc').get_text() result['from'] = self.from_id result['to'] = self.to_id dbconf = dbconfig.dbConfig() #Save data in data base for single use if self.liststore == None: type(result['from']) if self.type_index is not None and self.type_configs[self.type_index][3]: mode = 'our' else: mode = 'other' desc = result['desc'] if desc =="": desc = self.type_names[self.type_index][1] document = class_document.Document() if result['cash_payment'] : document.add_notebook(result['from'], result['cash_payment'], unicode(desc)) document.add_notebook(result['to'] , -result['cash_payment'], unicode(desc )) if result['discount'] : document.add_notebook(dbconf.get_int('sell-discount'), -result['discount'], desc) if self.type_configs[self.type_index][3] == True: # from is subject custSubj = self.to_id else: # from is customer custSubj = self.from_id print custSubj customer_id = share.config.db.session.query(Customers).filter(Customers.custSubj==custSubj).first().custId for cheque in self.addChequeui.chequesList: if mode == 'our': document.add_cheque(dbconf.get_int('our_cheque'),custSubj,(cheque.chqAmount), cheque.chqDesc, cheque.chqId) else: document.add_cheque(dbconf.get_int('other_cheque'),custSubj, -cheque.chqAmount, cheque.chqDesc, cheque.chqId) cl_cheque = class_cheque.ClassCheque() #spendble cheques for sp_cheque in self.spendChequeui.chequesList: cl_cheque.update_status(sp_cheque.chqId,5 , customer_id) document.add_cheque(custSubj, dbconf.get_int('other_cheque'), -sp_cheque.chqAmount , unicode(_('Cheque No. %s spended') % sp_cheque.chqSerial) , sp_cheque.chqId) result = document.save() if result < 0: dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _('Failed, %s') % document.get_error_message(result)) dialog.run() dialog.destroy() return for cheque in self.addChequeui.chequesList: cl_cheque.add_cheque(cheque.chqAmount, cheque.chqWrtDate, cheque.chqDueDate, cheque.chqSerial, cheque.chqStatus, customer_id, cheque.chqAccount, 0, 0, cheque.chqDesc, 0, 0) cl_cheque.save() cl_cheque.save_cheque_history(self.current_time) self.on_destroy(self.builder.get_object('general')) share.mainwin.silent_daialog(_('successfully added. Document number : %d') % document.number) #Store result in list store for showing in addeditdoc else: mysubject = Subjects() numrows = len(self.liststore) + 1 #document.add_notebook(result['from'], result['total_value'], result['desc']) self.liststore.append ((LN(numrows), unicode(self.from_code), unicode(self.from_name), LN(0), LN(result['total_value']), result['desc'], None)) #self.liststore.append ((numrows, code, sub.name, debt, credit, desc, None)) #document.add_notebook(result['to'] , -result['cash_payment'], result['desc']) numrows += 1 self.liststore.append ((LN(numrows), unicode(self.to_code), unicode(self.to_name), LN(result['cash_payment']), LN(0), result['desc'], None)) if result['discount'] : numrows += 1 self.liststore.append ((LN(numrows), unicode(mysubject.get_code(dbconf.get_int('sell-discount'))), mysubject.get_name(dbconf.get_int('sell-discount')), LN(result['discount']), LN(0), result['desc'], None)) self.on_destroy(self.builder.get_object('general'))
def __init__(self, non_cash_label=None, spend_label=None): ## A list contains information about new cheques # # to remove all cheques for reseting form cheques_ui_obj.new_cheques = [] self.cheque_class = class_cheque.ClassCheque() self.new_cheques = [] #self.is_edit is a var that check the form called by add function or edit function ## a list contains informations about selected cheques for spending #self.spend_cheques only keep serial of cheque and values self.spend_cheques = [] self.is_edit = 0 self.non_cash_payment_label = non_cash_label self.spend_label = spend_label self.mode = 'our' self.bank_accounts = class_bankaccounts.BankAccountsClass() # User Interface self.builder = helpers.get_builder('cheque') self.builder.connect_signals(self) self.amount_entry = decimalentry.DecimalEntry() self.write_date = dateentry.DateEntry() self.due_date = dateentry.DateEntry() add_table = self.builder.get_object('add_table') add_table.attach(self.amount_entry, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.SHRINK) add_table.attach(self.write_date, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.SHRINK) add_table.attach(self.due_date, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.SHRINK) self.builder.get_object('list_cheque_window').resize(400, 1) self.builder.get_object('desc_frame').set_size_request(0, 100) model = gtk.ListStore(str, str, str, str, str, str, str) treeview = self.builder.get_object('list_cheque_treeview') treeview.set_model(model) column = gtk.TreeViewColumn(_("Customer"), gtk.CellRendererText(), text=0) treeview.append_column(column) column = gtk.TreeViewColumn(_("Bank Account"), gtk.CellRendererText(), text=1) treeview.append_column(column) column = gtk.TreeViewColumn(_("Bank/Branch"), gtk.CellRendererText(), text=2) treeview.append_column(column) column = gtk.TreeViewColumn(_("Serial"), gtk.CellRendererText(), text=3) treeview.append_column(column) column = gtk.TreeViewColumn(_("Amount"), gtk.CellRendererText(), text=4) treeview.append_column(column) self.new_cheques = [] column = gtk.TreeViewColumn(_("Due Date"), gtk.CellRendererText(), text=5) treeview.append_column(column) model = gtk.ListStore(str, str, str) combo = self.builder.get_object('bank_accounts') combo.set_model(model) cell = gtk.CellRendererText() cell.set_visible(False) combo.pack_start(cell, True) combo.add_attribute(cell, 'text', 0) cell = gtk.CellRendererText() combo.pack_start(cell, True) combo.add_attribute(cell, 'text', 1) cell = gtk.CellRendererText() combo.pack_start(cell, True) combo.add_attribute(cell, 'text', 2)