def get_object(self): orga = organization_manager.get_selected_organization(self.request) try: settings = self.model.objects.get(organization=orga) except self.model.DoesNotExist: settings = self.model.objects.create(organization=orga) return settings
def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) orga = organization_manager.get_selected_organization(self.request) report = TaxReport(orga, start=self.period.start, end=self.period.end) report.generate() ctx['tax_summaries'] = report.tax_summaries.values() return ctx
def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) orga = organization_manager.get_selected_organization(self.request) report = InvoiceDetailsReport(orga, start=self.period.start, end=self.period.end) report.generate() ctx['invoices'] = report.invoices ctx['tax_rates'] = report.tax_rates ctx['payrun_settings'] = orga.payrun_settings return ctx
def check_completion(self, request): orga = organization_manager.get_selected_organization(request) if orga is None: return False try: settings = orga.payrun_settings settings.full_clean() except PayRunSettings.DoesNotExist: return False except ValidationError: return False return True
def get_context_data(self, **kwargs): ctx = super().get_context_data(**kwargs) orga = organization_manager.get_selected_organization(self.request) # currrent quarter now = timezone.now() start = date(year=now.year, month=(now.month - ((now.month - 1) % 3)), day=1) end = start + relativedelta(months=3) report = ProfitAndLossReport(orga, start=start, end=end) report.generate() ctx['summaries'] = report.summaries ctx['total_summary'] = report.total_summary return ctx
def check_completion(self, request): orga = organization_manager.get_selected_organization(request) if orga is None: return False count = orga.tax_rates.all().count() return count > 0