def run(self): crm = get_crm_module(self.settings) server = Server(self.settings.couchdb_uri) db = server.get_db(self.settings.couchdb_db) invoice_cycle = InvoiceCycle(self.settings.invoice_nr) clients = db.view( self._cmd("client_is_billable"), include_docs=True ) counter = 0 for client in clients: if not self.settings.limit_client_id or client['id'] == self.settings.limit_client_id: # print(client['doc']['name']) invoice = Invoice( self.settings, crm=crm, client_doc=client['doc'], invoice_cycle=invoice_cycle ) invoice_start_date = min( [d['start_date'] for d in invoice.doc['services'].itervalues()] ) if invoice_start_date < invoice_cycle.doc['end_date']: invoice.render_pdf() invoice_cycle.add_invoice(invoice) counter += 1 print(".", end="") if self.settings.max != 0 and counter >= self.settings.max: break print("\n", "total", invoice_cycle.get_total())
def __init__(self, settings): self.clients_extcrm_ids = {} self.settings = settings self.server = Server(self.settings.couchdb_uri) self.db = self.server.get_db(self.settings.couchdb_db) self.crm = get_crm_module(self.settings)
def run(self): self.todoyu = get_crm_module(self.settings) services = ImportServices(self.settings) services.create_files()