예제 #1
0
파일: buy_show.py 프로젝트: Ciwara/GCiss
    def cancellation(self):

        buy = self.buy
        reports = Report.select().where(Report.buy == buy)
        list_error = [(check_befor_update_data(report)) for report in reports]
        if list_error == [] or list_error == [[]]:
            reply = QMessageBox.question(
                self,
                "Confirmation",
                "<h3 style='color:red;'>Voulez vous" " vraiment annuler ce rapport" " d'achat?</h3>",
                QMessageBox.Yes | QMessageBox.No,
                QMessageBox.No,
            )

            if reply == QMessageBox.Yes:
                from ui.dashboard import DashbordViewWidget

                buy.deletes_data()
                self.change_main_context(DashbordViewWidget)
        else:
            QMessageBox.about(
                self,
                "Alerte",
                "<h3>Vous ne pousez pas supprimer ce rapport car:</h3>"
                "<ul><li></li>"
                " %(err)s"
                "<li>Après la suppression</li></ul>" % {"err": list_error},
            )
예제 #2
0
파일: invoice.py 프로젝트: Ciwara/GCiss
 def set_data_for(self, value=None):
     products = [(Product.get(id=rpt.product_id).name) for rpt in
                 Report.select(fn.Distinct(Report.product))]
     if value:
         products = [(prod.name) for prod in Product.select().where(Product.name.contains(value))
                     .where(Product.name << products).order_by(Product.name.desc())]
     self.data = [(prd, "") for prd in products]
예제 #3
0
 def set_data_for(self, value=None):
     products = [(Product.get(id=rpt.product_id).name)
                 for rpt in Report.select(fn.Distinct(Report.product))]
     if value:
         products = [(prod.name) for prod in Product.select().where(
             Product.name.contains(value)).where(
                 Product.name << products).order_by(Product.name.desc())]
     self.data = [(prd, "") for prd in products]
예제 #4
0
파일: api.py 프로젝트: ccp0101/xssreport
 def get_query(self):
     if request.args.get('method', '') == "listURI":
         # monkey patch fields
         self._fields = {self.model: ['latest', 'count', 'uri']}
         return Report.select(Report.uri, fn.Count(Report.id).alias(
             'count'), fn.Max(Report.created).alias('latest')).group_by(
             Report.uri).order_by(fn.Max(Report.created).desc())
     else:
         self._fields = {self.model: self.model._meta.get_field_names()}
         return SessionAuthResource.get_query(self)
예제 #5
0
파일: apricot.py 프로젝트: Ciwara/GCiss
 def set_data_for(self):
     date = self.parent.date_.text()
     self.data = [
         (rap.product.name, formatted_number(rap.qty),
          formatted_number(rap.selling_price), rap.qty * rap.selling_price)
         for rap in Report.select().where(
             Report.type_ == Report.S,
             Report.date < date_on_or_end(date, on=False),
             Report.date > date_on_or_end(date)).order_by(Report.id.desc())
     ]
     self.refresh()
예제 #6
0
파일: api.py 프로젝트: changpingc/xssreport
 def get_query(self):
     if request.args.get('method', '') == "listURI":
         # monkey patch fields
         self._fields = {self.model: ['latest', 'count', 'uri']}
         return Report.select(
             Report.uri,
             fn.Count(Report.id).alias('count'),
             fn.Max(Report.created).alias('latest')).group_by(
                 Report.uri).order_by(fn.Max(Report.created).desc())
     else:
         self._fields = {self.model: self.model._meta.get_field_names()}
         return SessionAuthResource.get_query(self)
예제 #7
0
파일: apricot.py 프로젝트: Ciwara/GCiss
 def set_data_for(self):
     date = self.parent.date_.text()
     self.data = [(rap.product.name,
                   formatted_number(rap.qty),
                   formatted_number(rap.selling_price),
                   rap.qty * rap.selling_price)
                  for rap in Report.select().where(
         Report.type_ == Report.S,
         Report.date < date_on_or_end(date, on=False),
         Report.date > date_on_or_end(date)
     ).order_by(Report.id.desc())]
     self.refresh()
예제 #8
0
    def cancellation(self):

        buy = self.buy
        reports = Report.select().where(Report.buy == buy)
        rpt, remaining = check_befor_update_data(reports)
        if not rpt:
            reply = QMessageBox.question(
                self, 'Confirmation', u"<h3 style='color:red;'>Voulez vous"
                u" vraiment annuler ce rapport"
                u" d'achat?</h3>", QMessageBox.Yes | QMessageBox.No,
                QMessageBox.No)

            if reply == QMessageBox.Yes:
                buy.deletes_data()
                self.close()
                self.table_p.refresh_()
        else:
            QMessageBox.about(
                self, u"Alerte", u"""
                <h3>Vous ne pousez pas supprimer ce rapport car:</h3> <b>%(prod_name)s </b> aura comme restant : %(remaining)s Après la suppression</li></ul>"""
                % {
                    "prod_name": rpt.product.name,
                    "remaining": remaining
                })
예제 #9
0
파일: stats.py 프로젝트: Ciwara/GCiss
    def set_data_for(self, main_date):

        reports = []
        self.totals = 0
        self.total_sum_d1 = 0
        self.total_sum_d2 = 0
        self.total_sum_d3 = 0
        self.total_sum_d4 = 0
        self.total_sum_d5 = 0
        self.total_sum_d6 = 0
        try:
            self.date_on, self.date_end = main_date.current.current
        except Exception as e:
            self.date_on, self.date_end = main_date.current
        products = [(Product.get(id=rpt.product_id).name) for rpt in
                    Report.select(fn.Distinct(Report.product)).where(
            Report.date >= self.date_on, Report.date <= self.date_end,
            Report.type_ == Report.S)]

        products = [(prod.name) for prod in Product.select().where(
            Product.name << products).order_by(Product.name.desc())]
        for prod_name in products:
            on = date_on_or_end(self.date_on)
            end = date_on_or_end(self.date_end, on=False)
            dict_store = {}
            repts = Report.select().where(Report.type_ == Report.S,
                                          Report.product == Product.get(
                                              name=prod_name))
            dict_store["product"] = prod_name

            dict_store["sum_week"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0

            self.totals += (dict_store["sum_week"])
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d1"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d1 += dict_store["sum_d1"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d2"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d2 += dict_store["sum_d2"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d3"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d3 += dict_store["sum_d3"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d4"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d4 += dict_store["sum_d4"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d5"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d5 += dict_store["sum_d5"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d6"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d6 += dict_store["sum_d6"]
            reports.append(dict_store)

        self.data = [(rep.get('product'), rep.get('sum_d1'),
                      rep.get('sum_d2'), rep.get('sum_d3'), rep.get('sum_d4'),
                      rep.get('sum_d5'), rep.get('sum_d6'),
                      rep.get('sum_week'), "") for rep in reports]
예제 #10
0
파일: stats.py 프로젝트: Ciwara/GCiss
    def set_data_for(self, main_date):

        reports = []
        self.totals = 0
        self.total_sum_d1 = 0
        self.total_sum_d2 = 0
        self.total_sum_d3 = 0
        self.total_sum_d4 = 0
        self.total_sum_d5 = 0
        self.total_sum_d6 = 0
        try:
            self.date_on, self.date_end = main_date.current.current
        except Exception as e:
            self.date_on, self.date_end = main_date.current
        products = [(Product.get(id=rpt.product_id).name) for rpt in
                    Report.select(fn.Distinct(Report.product)).where(
            Report.date >= self.date_on, Report.date <= self.date_end,
            Report.type_ == Report.S)]

        products_ = [(prod.name) for prod in Product.select().where(
            Product.name << products).order_by(Product.name.desc())]
        for prod_name in products_:
            on = date_on_or_end(self.date_on)
            end = date_on_or_end(self.date_end, on=False)
            dict_store = {}
            repts = Report.select().where(Report.type_ == Report.S,
                                          Report.product == Product.get(
                                              name=prod_name))
            dict_store["product"] = prod_name

            dict_store["sum_week"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(
                Report.date >= on, Report.date <= end).scalar() or 0

            self.totals += (dict_store["sum_week"])
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d1"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(
                Report.date >= on, Report.date <= end).scalar() or 0
            self.total_sum_d1 += dict_store["sum_d1"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d2"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(
                Report.date >= on, Report.date <= end).scalar() or 0
            self.total_sum_d2 += dict_store["sum_d2"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d3"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(
                Report.date >= on, Report.date <= end).scalar() or 0
            self.total_sum_d3 += dict_store["sum_d3"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d4"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(
                Report.date >= on, Report.date <= end).scalar() or 0
            self.total_sum_d4 += dict_store["sum_d4"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d5"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(
                Report.date >= on, Report.date <= end).scalar() or 0
            self.total_sum_d5 += dict_store["sum_d5"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d6"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(
                Report.date >= on, Report.date <= end).scalar() or 0
            self.total_sum_d6 += dict_store["sum_d6"]
            reports.append(dict_store)

        self.data = [(
            rep.get('product'), rep.get('sum_d1'), rep.get('sum_d2'),
            rep.get('sum_d3'), rep.get('sum_d4'), rep.get('sum_d5'),
            rep.get('sum_d6'), rep.get('sum_week')) for rep in reports]