def on_print_again(self, event): bill_ids = [ id for i, id in enumerate(self.data) if self.payments.IsSelected(i) ] if bill_ids: bills = [Bill.load(self.cursor, id_bill) for id_bill in bill_ids] consults = [b for b in bills if b.type == BILL_TYPE_CONSULTATION] if consults: filename_consult = normalize_filename( datetime.datetime.now().strftime( 'consultations_%F_%Hh%Mm%Ss.pdf')) pdf_bills.consultations(filename_consult, consults) cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf', 'view', filename_consult) os.system(cmd + '&') manuals = [b for b in bills if b.type == BILL_TYPE_MANUAL] if manuals: filename_manual = normalize_filename( datetime.datetime.now().strftime( 'fact_manuelles_%F_%Hh%Mm%Ss.pdf')) pdf_bills.manuals(filename_manual, manuals) cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf', 'view', filename_manual) os.system(cmd + '&')
def on_generate(self, event): today = datetime.date.today() bills = [] item = -1 while True: item = self.reminders.GetNextSelected(item) if item == -1: break id_bill = self.data[item][0] self.cursor.execute( """INSERT INTO reminders (id_bill, amount_cts, reminder_date) VALUES (%s, %s, %s)""", [id_bill, custo.MONTANT_RAPPEL_CTS, today]) bills.append(Bill.load(self.cursor, id_bill)) consults = [b for b in bills if b.type == BILL_TYPE_CONSULTATION] if consults: filename = normalize_filename(datetime.datetime.now().strftime( 'rappels_consultations_%F_%Hh%Mm%Ss.pdf')) pdf_bills.consultations(filename, consults) cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf', 'view', filename) os.system(cmd) manuals = [b for b in bills if b.type == BILL_TYPE_MANUAL] if manuals: filename = normalize_filename(datetime.datetime.now().strftime( 'rappels_factures_manuelles_%F_%Hh%Mm%Ss.pdf')) pdf_bills.manuals(filename, manuals) cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf', 'view', filename) os.system(cmd) self.Close()
def on_validate(self, event): if self.payment_method.StringSelection == 'BVR': bill = self.data[self.selected_idx] if bill.status == STATUS_OPENED: filename_consult = normalize_filename(datetime.datetime.now().strftime('consultation_%F_%Hh%Mm%Ss.pdf')) bills.consultations(filename_consult, [bill]) cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf', 'view', filename_consult) os.system(cmd + '&') self.real_validate() self.on_refresh(None)
def on_change_payment(self, event): bill = self.data[self.selected_idx] if self.payment_method.StringSelection == 'BVR': if not askyesno(windows_title.confirm_change, labels_text.ask_confirm_payment_method_change_to_BVR): return bill.bv_ref = gen_bvr_ref(self.cursor, bill.firstname, bill.lastname, bill.timestamp) else: bill.bv_ref = None bill.payment_method = self.payment_method.StringSelection bill.save(self.cursor) filename_consult = normalize_filename(datetime.datetime.now().strftime('consultation_%F_%Hh%Mm%Ss.pdf')) bills.consultations(filename_consult, [bill]) cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf', 'view', filename_consult) os.system(cmd + '&') self.real_validate() self.on_refresh(None)
def on_change_payment(self, event): bill = self.data[self.selected_idx] if self.payment_method.StringSelection == 'BVR': if not askyesno( "Confirmer le changement", "Voulez-vous vraiment changer la méthode de paiement vers BVR ?" ): return bill.bv_ref = gen_bvr_ref(self.cursor, bill.firstname, bill.lastname, bill.timestamp) else: bill.bv_ref = None bill.payment_method = self.payment_method.StringSelection bill.save(self.cursor) filename_consult = normalize_filename( datetime.datetime.now().strftime('consultation_%F_%Hh%Mm%Ss.pdf')) bills.consultations(filename_consult, [bill]) cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf', 'view', filename_consult) os.system(cmd + '&') self.real_validate() self.on_refresh(None)