Beispiel #1
0
 def total_sellings(self,
                    year=None,
                    branch=None,
                    start_date=None,
                    end_date=None):
     helper = TimeSliceHelper(self.model)
     ventes = helper.get_objects(year=year,
                                 branch=branch,
                                 start_date=start_date,
                                 end_date=end_date)
     total = sum(v.montant for v in ventes if v.reglement_termine)
     return total
Beispiel #2
0
 def total_costs(self,
                 year=None,
                 branch=None,
                 start_date=None,
                 end_date=None):
     helper = TimeSliceHelper(self.model)
     costs = helper.get_objects(year=year,
                                branch=branch,
                                start_date=start_date,
                                end_date=end_date)
     total = sum(c.amount for c in costs)
     return total
Beispiel #3
0
 def total_quantity(self,
                    branch=None,
                    year=None,
                    start_date=None,
                    end_date=None):
     helper = TimeSliceHelper(Losses)
     losses = helper.get_objects(branch=branch,
                                 year=year,
                                 start_date=start_date,
                                 end_date=end_date)
     total = sum(a.losses for a in losses)
     return total
Beispiel #4
0
 def total_costs(self,
                 branch=None,
                 year=None,
                 start_date=None,
                 end_date=None):
     """Return how much money was lost because broken articles or other cause."""
     helper = TimeSliceHelper(Losses)
     losses = helper.get_objects(branch=branch,
                                 year=year,
                                 start_date=start_date,
                                 end_date=end_date)
     total = sum(a.amount_losses for a in losses)
     return total
Beispiel #5
0
 def total_purchasing_price(self,
                            branch=None,
                            year=None,
                            start_date=None,
                            end_date=None):
     total = 0
     helper = TimeSliceHelper(Article)
     articles = helper.get_objects(year=year,
                                   branch=branch,
                                   start_date=start_date,
                                   end_date=end_date)
     total = sum(a.purchasing_price for a in articles)
     return total
Beispiel #6
0
 def grand_total(self,
                 branch=None,
                 year=None,
                 start_date=None,
                 end_date=None):
     """Sum of costs + sum of Articles' purchasing price.
     """
     helper = TimeSliceHelper(Article)
     articles = helper.get_objects(year=year,
                                   branch=branch,
                                   start_date=start_date,
                                   end_date=end_date)
     purchasing_price = sum(a.purchasing_price for a in articles)
     return purchasing_price + self.total_costs(
         branch=branch, year=year, start_date=start_date, end_date=end_date)