def update_ui(self): args = self.get_input() self.tmp_invoice = corp.Invoice(**args, prev_invoices=self.prev_invoices) # """ update the values of the labels """# self.set_labels( amount_w_VAT=self.tmp_invoice.amount_w_VAT, amount_VAT_amount=self.tmp_invoice.amount_VAT_amount, verified_amount_w_VAT=self.tmp_invoice.verified_amount_w_VAT, verified_amount_VAT_amount=self.tmp_invoice. verified_amount_VAT_amount, prev_invoices_count=str(len(self.prev_invoices)), prev_invoices_amount=self.tmp_invoice.prev_invoices_amount, rebate_amount=self.tmp_invoice.rebate_amount, reduction_insurance_costs_amount=self.tmp_invoice. reduction_insurance_costs_amount, reduction_usage_costs_amount=self.tmp_invoice. reduction_usage_costs_amount, amount_a_reductions_amount=self.tmp_invoice. amount_a_reductions_amount, amount_a_reductions_amount_w_VAT=self.tmp_invoice. amount_a_reductions_amount_w_VAT, amount_a_reductions_amount_VAT_amount=self.tmp_invoice. amount_a_reductions_amount_VAT_amount, safety_deposit_amount=self.tmp_invoice.safety_deposit_amount, approved_amount=self.tmp_invoice.approved_amount, discount_amount=self.tmp_invoice.discount_amount, approved_amount_a_discount_amount=self.tmp_invoice. approved_amount_a_discount_amount, ) self.activate_ok_button()
def __init__(self, *, app_data, sel_job=None, loaded_invoice=None): super().__init__() """ create local variables """ self.app_data = app_data self.default_vat = app_data.project.config["default_vat"] self.currency = app_data.project.config["currency"] self.prev_invoices = list() self.tmp_invoice = corp.Invoice() self.loaded_invoice = loaded_invoice self.initialize_ui() """ set title """ dialog_title = (f"Rechnung ({loaded_invoice.id}) bearbeiten..." if loaded_invoice else "Neue Rechnung") self.setWindowTitle(dialog_title) """ fixed window size """ # self.setFixedSize(self.size()) """ activate UI """ self.setup_combo_boxes() self.set_button_actions() self.set_check_box_actions() self.set_spin_box_actions() self.set_combo_box_actions() self.set_date_edit_actions() self.set_event_handler() self.set_validators() self.set_date_today() self.uncheck_boxes() self.set_default_labels() # no idea, why this line is needed, but it is on this dialog self.lineEdit_id.setFocus() if self.loaded_invoice: """activate delete button""" self.pushButton_delete.setEnabled(True) """ load invoice data to input """ loaded_args = vars(self.loaded_invoice).copy() self.prev_invoices = self.loaded_invoice.prev_invoices self.set_input(**loaded_args) elif sel_job: self.set_company_to(sel_job.company) self.setup_combo_box_jobs() self.set_job_to(sel_job) self.update_prev_invoices() self.update_ui()
def create_objects(self): """Create the ojects from the imported args.""" for trade_args in self.trades_args: trade = arch.Trade(**trade_args) self.trades.append(trade) for company_args in self.companies_args: company = corp.Company(**company_args) self.companies.append(company) for job_args in self.jobs_args: job = arch.ArchJob(**job_args) self.jobs.append(job) for invoice_args in self.invoices_args: invoice = corp.Invoice(**invoice_args) self.invoices.append(invoice)
def input_new_invoice(self, invoice_args): new_invoice = corp.Invoice(**invoice_args) self.add_invoice(new_invoice) return new_invoice
def dict_to_object(self, dct): """Check the object type and decodes JSON to the original object. Args: dct (dict): JSON formatted input Returns: corp.Invoice: Restored object """ if "Invoice" in dct: args = { "uid": UIDDecoder().object_hook(dct["uid"]), "deleted": dct["deleted"], "id": dct["id"], "company_ref": { "uid": UIDDecoder().object_hook(dct["company_ref"]["uid"]), "name": dct["company_ref"]["name"], } if dct["company_ref"] else None, "job_ref": { "uid": UIDDecoder().object_hook(dct["job_ref"]["uid"]), "id": dct["job_ref"]["id"], "company.name": dct["job_ref"]["company.name"], } if dct["job_ref"] else None, "cumulative": dct["cumulative"], "invoice_date": QDate.fromString(dct["invoice_date"]) if dct["invoice_date"] else None, "inbox_date": QDate.fromString(dct["inbox_date"]) if dct["inbox_date"] else None, "checked_date": QDate.fromString(dct["checked_date"]) if dct["checked_date"] else None, "amount": dct["amount"], "verified_amount": dct["verified_amount"], "rebate": dct["rebate"], "reduction_insurance_costs": dct["reduction_insurance_costs"], "reduction_usage_costs": dct["reduction_usage_costs"], "reduce_prev_invoices": dct["reduce_prev_invoices"], "prev_invoices_uids": [ UIDDecoder().object_hook(uid) for uid in dct["prev_invoices_uids"] ] if dct["prev_invoices_uids"] else None, "prev_invoices_amount": dct["prev_invoices_amount"], "VAT": dct["VAT"], "safety_deposit": dct["safety_deposit"], "safety_deposit_amount": dct["safety_deposit_amount"] if dct["safety_deposit_amount"] else None, "discount": dct["discount"], "due_date": QDate.fromString(dct["due_date"]) if dct["due_date"] else None, "due_date_discount": QDate.fromString(dct["due_date_discount"]) if dct["due_date_discount"] else None, } return corp.Invoice(**args) return dct