Example #1
0
class HomeView(LoginRequiredMixin, TemplateView):
    context = {}
    Add_Data(context)
    date_now = datetime.now()
    print(date_now.year)
    context['year'] = date_now.year
    context['week'] = date_now.isocalendar()[
        1]  #Semana empieza desde el dia Lunes y Termina el dia Domingo
    context['TotalSales'] = Invoice.objects.filter(
        StatusInvoice=3, DateInvoice=date_now).count()

    revenue = Invoice.objects.filter(StatusInvoice=3,
                                     DateInvoice=date_now).aggregate(
                                         Sum('TotalPay'))['TotalPay__sum']

    context['Revenue'] = round(revenue, 2) if revenue else 0.00

    expenses = Order.objects.filter(
        #StatusInvoice=3,
        DateOrder__year=date_now.year).aggregate(
            Sum('TotalPay'))['TotalPay__sum']

    context['Expenses'] = round(expenses, 2) if expenses else 0.00
    context['TotalOrders'] = Order.objects.filter(DateOrder=date_now).count()
    totalu = DetailInvoice.objects.filter(
        InvoiceId__DateInvoice=date_now, ).aggregate(
            Sum('Utility'))['Utility__sum']
    context['TotalUtility'] = round(totalu, 2) if totalu else 0.00
    #context['TopSales']=Invoice.objects.all()[10].order_by('-created_at')
    extra_context = context

    template_name = 'auth/home.html'
Example #2
0
    def get_context_data(self, **kwargs):
        context = super(Create, self).get_context_data(**kwargs)
        Add_Data(context)
        context['old_provider'] = self.post_old_data('ProviderId')
        context['providers'] = Provider.objects.filter(status=True)
        context['products'] = Product.objects.filter(status=True)

        return self.post_all_olds_datas(context=context,
                                        attributes=self.attributes)
Example #3
0
    def get_context_data(self, **kwargs):
        context = super(Create,self).get_context_data(**kwargs)
        Add_Data(context)
        context['old_category']= self.post_old_data('CategoryId')
        context['categories']= Category.objects.filter(status=True)
        context['old_mark']= self.post_old_data('MarkId')
        context['marks']= Mark.objects.filter(status=True)
        context['products'] = Product.objects.filter(status=True)

        return  self.get_all_olds_datas(context=context,attributes=self.attributes)
Example #4
0
 def get_context_data(self, **kwargs):
     context = super(Update, self).get_context_data(**kwargs)
     Add_Data(context)
     context['old_provider'] = self.post_old_data(
         'ProviderId',
         self.get_object().ProviderId.pk)
     context['providers'] = Provider.objects.filter(status=True)
     context['products'] = Product.objects.filter(status=True)
     context['DetailsOrder'] = DetailOrder.objects.filter(
         OrderId=self.get_object().pk)
     context['TotalPay'] = self.get_object().TotalPay
     return self.post_all_olds_datas(context=context,
                                     attributes=self.get_attributes())
Example #5
0
    def get_context_data(self, **kwargs):
        context = super(Update, self).get_context_data(**kwargs)
        Add_Data(context)
        context['old_client'] = self.post_old_data(
            'ClientId',
            self.get_object().ClientId.pk)
        context['clients'] = Client.objects.filter(status=True)
        context['old_seller'] = self.post_old_data(
            'SellerId',
            self.get_object().SellerId.pk)
        context['sellers'] = Seller.objects.filter(status=True)
        context['DetailsInvoice'] = DetailInvoice.objects.filter(
            InvoiceId=self.get_object().pk)
        context['products'] = Product.objects.filter(status=True)
        context['TotalPay'] = self.object.get_object().TotalPay

        return self.post_all_olds_datas(context=context,
                                        attributes=self.get_attributes())
Example #6
0
 def get_context_data(self, **kwargs):
     print(**kwargs)
     context = super(Update, self).get_context_data(**kwargs)
     Add_Data(context)
     return self.post_all_olds_datas(context=context,
                                     attributes=self.get_attributes())
Example #7
0
 def get_context_data(self, **kwargs):
     context = super(Create, self).get_context_data(**kwargs)
     Add_Data(context)
     return self.get_all_olds_datas(context=context,
                                    attributes=self.attributes)
Example #8
0
 def get_context_data(self, *, object_list=None, **kwargs):
     context = super(Index, self).get_context_data(**kwargs)
     Add_Data(context)
     return self.get_all_olds_datas(context=context,
                                    attributes=self.attributes)
Example #9
0
class ProfileView(LoginRequiredMixin, TemplateView):
    context = {}
    Add_Data(context)
    date_now = datetime.now()
    extra_context = context
    template_name = 'auth/profile.html'