コード例 #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]