示例#1
0
    def print_time_sheet(self):
        from py3o.template import Template  #import for every invoice or there is
        #an error about invalid magic header numbers

        self.time_card_name = "/tmp/time_card_" + self.name.split()[0]
        self.time_card_odt = self.time_card_name + ".odt"
        self.time_card_pdf = self.time_card_name + ".pdf"

        #self.tmp_timecard_file = "/tmp/" + self.document_odt
        t = Template("./templates/time_card_template.odt", self.time_card_odt,
                     True)
        t.render(
            self.data
        )  #the self.data holds all the info to be passed to the template

        subprocess.call("odt2pdf " + self.time_card_odt, shell=True)
        p = printing.Operation(settings_file='time_card',
                               file_to_print=self.time_card_pdf,
                               parent=self.window)
        if self.print_directly == False:
            result = p.print_dialog()
        else:
            result = p.print_directly()

        f = open(self.time_card_pdf, 'rb')
        dat = f.read()
        f.close()
        self.cursor.execute(
            "UPDATE payroll.pay_stubs SET timecard_pdf = %s WHERE id = %s",
            (dat, self.paystubs_id))
示例#2
0
	def print_dialog(self, window):
		from py3o.template import Template 
		purchase_order_file = "/tmp/" + self.document_odt
		t = Template(template_dir+"/document_template.odt", purchase_order_file , True)
		t.render(self.data)  #the self.data holds all the info of the purchase_order
		subprocess.call("odt2pdf " + purchase_order_file, shell = True)
		p = printing.Operation(settings_file = "document")
		p.set_parent(window)
		p.set_file_to_print ("/tmp/" + self.document_pdf)
		p.print_dialog ()
示例#3
0
 def print_pdf_clicked(self, button):
     import printing
     print_op = printing.Operation()
     print_op.set_parent(self.window)
     pdf_data = Gio.MemoryInputStream.new_from_bytes(GLib.Bytes(self.bytes))
     print_op.set_bytes_to_print(pdf_data)
     if self.landscape:
         setup = Gtk.PageSetup()
         setup.set_orientation(Gtk.PageOrientation.LANDSCAPE)
         print_op.set_default_page_setup(setup)
     print_op.print_dialog()
示例#4
0
 def print_directly(self, window):
     subprocess.call("odt2pdf " + self.invoice_file, shell=True)
     p = printing.Operation(settings_file="invoice")
     p.set_parent(window)
     p.set_file_to_print("/tmp/" + self.document_pdf)
     result = p.print_directly()
     cursor = DB.cursor()
     if result == Gtk.PrintOperationResult.APPLY:
         cursor.execute(
             "UPDATE invoices SET date_printed = "
             "CURRENT_DATE WHERE id = %s", (self.invoice_id, ))
     cursor.close()
示例#5
0
	def print_and_post_clicked (self, button):
		total = Decimal(self.get_object('spinbutton1').get_text())
		check_number = self.get_object('entry7').get_text()
		bank_account = self.get_object('combobox2').get_active_id()
		self.cursor.execute("SELECT "
								"name, "
								"checks_payable_to, "
								"address, "
								"city, "
								"state, "
								"zip, "
								"phone "
							"FROM contacts WHERE id = %s",(self.provider_id,))
		provider = Item()
		for line in self.cursor.fetchall():
			provider.name = line[0]
			provider.pay_to = line[1]
			provider.street = line[2]
			provider.city = line[3]
			provider.state = line[4]
			provider.zip = line[5]
			provider.phone = line[6]
			pay_to = line[1].split()[0]
		items = list()
		'''for row in self.provider_invoice_store:
			if row[3] == True:'''
				
		item = Item()
		item.po_number = ''#row[0] 
		item.amount = ''#row[2]
		item.date = ''#row[4]
		items.append(item)
		check = Item()
		check.check_number = check_number
		check.checking_account = bank_account
		check.date = self.date
		check.amount = total 
		check.amount_text = get_written_check_amount_text (total)
		from py3o.template import Template
		data = dict(contact = provider, check = check, items = items )#- kept this
		#in case we ever wish to list the accountbreakdown on the check stubs
		self.tmp_file = "/tmp/check" + pay_to +".odt"
		self.tmp_file_pdf = "/tmp/check" + pay_to + ".pdf"
		t = Template(template_dir+"/vendor_check_template.odt", self.tmp_file, True)
		t.render(data)
		subprocess.call(["odt2pdf", self.tmp_file])
		p = printing.Operation(settings_file = 'Vendor_check')
		p.set_file_to_print(self.tmp_file_pdf)
		p.set_parent(self.window)
		result = p.print_dialog()
		if result != "user canceled":
			self.perform_payment()
示例#6
0
 def print_check_clicked(self, button):
     check_number = self.builder.get_object('entry2').get_text()
     combo = self.builder.get_object('comboboxtext3')
     checking_account_number = combo.get_active_id()
     self.cursor.execute(
         "SELECT "
         "name, "
         "checks_payable_to, "
         "address, "
         "city, "
         "state, "
         "zip, "
         "phone "
         "FROM contacts WHERE id = %s", (self.vendor_id, ))
     vendor = Item()
     for line in self.cursor.fetchall():
         vendor.name = line[0]
         vendor.pay_to = line[1]
         vendor.street = line[2]
         vendor.city = line[3]
         vendor.state = line[4]
         vendor.zip = line[5]
         vendor.phone = line[6]
         pay_to = line[1].split()[0]
     items = list()
     for row in self.vendor_invoice_store:
         if row[3] == True:
             item = Item()
             item.po_number = row[0]
             item.amount = row[2]
             item.date = row[4]
             items.append(item)
     check = Item()
     check.check_number = check_number
     check.checking_account = checking_account_number
     check.date = self.date
     check.amount = self.amount
     check.amount_text = self.amount_text
     from py3o.template import Template
     data = dict(contact=vendor, check=check, items=items)
     self.tmp_file = "/tmp/check" + pay_to + ".odt"
     self.tmp_file_pdf = "/tmp/check" + pay_to + ".pdf"
     t = Template(template_dir + "/vendor_check_template.odt",
                  self.tmp_file, True)
     t.render(data)
     subprocess.call(["odt2pdf", self.tmp_file])
     p = printing.Operation(settings_file='Vendor_check')
     p.set_file_to_print(self.tmp_file_pdf)
     p.set_parent(self.window)
     result = p.print_dialog()
     if result != "user canceled":
         self.post_check()
示例#7
0
 def print_pdf(self, window):
     cursor = DB.cursor()
     subprocess.call(["odt2pdf", self.credit_memo_file])
     p = printing.Operation(settings_file="credit_memo")
     p.set_parent(window)
     p.set_file_to_print("/tmp/" + self.document_pdf)
     result = p.print_dialog()
     if result == Gtk.PrintOperationResult.APPLY:
         cursor.execute(
             "UPDATE credit_memos SET date_printed = "
             "CURRENT_DATE WHERE id = %s", (self.credit_memo_id, ))
     cursor.close()
     return result
示例#8
0
 def print_directly(self):
     cursor = DB.cursor()
     from py3o.template import Template
     purchase_order_file = "/tmp/" + self.document_odt
     t = Template(template_dir + "/purchase_order_template.odt",
                  purchase_order_file, True)
     t.render(self.data)
     subprocess.call("odt2pdf " + purchase_order_file, shell=True)
     p = printing.Operation(settings_file='purchase_order')
     p.set_parent(window)
     p.set_file_to_print("/tmp/" + self.document_pdf)
     result = p.print_direct()
     if result == Gtk.PrintOperationResult.APPLY:
         cursor.execute(
             "UPDATE purchase_orders SET date_printed = "
             "CURRENT_DATE WHERE id = %s", (self.purchase_order_id, ))
     cursor.close()
     return result
示例#9
0
	def print_dialog (self, window):
		cursor = DB.cursor()
		p = printing.Operation(settings_file = 'statement')
		p.set_parent(window)
		p.set_file_to_print("/tmp/" + self.document_pdf)
		result = p.print_dialog()
		if result == Gtk.PrintOperationResult.APPLY:
			cursor.execute("UPDATE statements SET print_date = "
								"CURRENT_DATE WHERE id = %s", 
								(self.statement_id,))
		document = "/tmp/" + self.document_pdf
		with open(document,'rb') as f:
			data = f.read()
			document_name = 'Balance forward on ' + self.document_name
			cursor.execute("UPDATE statements "
							"SET (name, pdf, printed, amount) = "
							"(%s, %s, True, %s) "
							"WHERE id = %s", 
							(document_name, data, self.total, 
							self.statement_id))
		self.close_invoices_and_payments ()
		cursor.close()
示例#10
0
 def print_pay_check(self):
     from py3o.template import Template  #import for every invoice or
     #there is an error about invalid magic header numbers
     self.check_name = "/tmp/pay_check" + self.name.split()[0]
     self.check_file_odt = self.check_name + ".odt"
     self.check_file_pdf = self.check_name + ".pdf"
     t = Template("./templates/pay_check.odt", self.check_file_odt, True)
     t.render(
         self.data
     )  #the self.data holds all the info to be passed to the template
     subprocess.call("odt2pdf " + self.check_file_odt, shell=True)
     p = printing.Operation(settings_file='pay_check',
                            file_to_print=self.check_file_pdf,
                            parent=self.window)
     if self.print_directly == False:
         result = p.print_dialog()
     else:
         result = p.print_directly()
     f = open(self.check_file_pdf, 'rb')
     dat = f.read()
     f.close()
     self.cursor.execute(
         "UPDATE payroll.emp_payments SET check_pdf = %s WHERE id = %s",
         (dat, self.emp_payments_id))