Exemplo n.º 1
0
 def set_data_for(self):
     self.data = [(rap.type_, rap.store.name, rap.product,
                   formatted_number(rap.qty_use),
                   formatted_number(rap.remaining),
                   show_date(rap.date))
                  for rap in Reports.select().where(
         Reports.date < date_on_or_end(self.today, on=False),
         Reports.date > date_on_or_end(self.today)
     ).order_by(Reports.id.desc())]
Exemplo n.º 2
0
 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()
Exemplo n.º 3
0
    def set_data_for(self, on, end):
        reports = []
        if end:
            # self.parent.current_period.setText(self.parent.format_period(on,
            # end))
            reports = Report.filter(date__gte=date_on_or_end(on),
                                    date__lte=date_on_or_end(end, on=False)).order_by(Report.date.desc())

        self.data = [(rap.product, rap.remaining, rap.selling_price,
                      rap.remaining * rap.selling_price,
                      rap.qty * (rap.selling_price - rap.selling_price))
                     for rap in reports]
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
    def set_data_for(self, on, end):
        reports = []
        if end:
            # self.parent.current_period.setText(self.parent.format_period(on,
            # end))
            reports = Report.filter(date__gte=date_on_or_end(on),
                                    date__lte=date_on_or_end(
                                        end,
                                        on=False)).order_by(Report.date.desc())

        self.data = [(rap.product, rap.remaining, rap.selling_price,
                      rap.remaining * rap.selling_price,
                      rap.qty * (rap.selling_price - rap.selling_price))
                     for rap in reports]
Exemplo n.º 6
0
    def extend_rows(self):

        self.parent.btt_export.setEnabled(True)
        nb_rows = self.rowCount()
        date = self.parent.date_.text()

        self.setRowCount(nb_rows + 4)

        self.amount_ht = 0
        for row_num in xrange(0, self.data.__len__()):
            mtt = is_int(self.item(row_num, 3).text())
            self.amount_ht += mtt

        row_num += 1
        self.setItem(row_num, 2, TotalsWidget(u"Total vente : "))
        self.amount_apricot = self.amount_ht
        self.setItem(
            row_num, 3,
            TotalsWidget(formatted_number(formatted_number(self.amount_ht))))
        row_num += 1
        self.setItem(row_num, 2, TotalsWidget(u"Dette du jour : "))
        self.total_debt = Refund.select(fn.SUM(Refund.amount)).where(
            Refund.type_ == Refund.DT,
            Refund.date < date_on_or_end(date, on=False),
            Refund.date > date_on_or_end(date)).scalar() or 0
        if self.total_debt:
            self.amount_apricot -= self.total_debt
        self.setItem(
            row_num, 3,
            TotalsWidget(formatted_number(formatted_number(self.total_debt))))
        row_num += 1
        self.setItem(row_num, 2, TotalsWidget(u"Dette reglée : "))
        self.total_refund = Refund.select(fn.SUM(Refund.amount)).where(
            Refund.type_ == Refund.RB,
            Refund.date < date_on_or_end(date, on=False),
            Refund.date > date_on_or_end(date)).scalar() or 0
        if self.total_refund:
            self.amount_apricot += self.total_refund
        self.setItem(
            row_num, 3,
            TotalsWidget(formatted_number(formatted_number(
                self.total_refund))))
        row_num += 1
        self.setItem(row_num, 2, TotalsWidget(u"Caise : "))
        self.setItem(
            row_num, 3,
            TotalsWidget(
                formatted_number(formatted_number(self.amount_apricot))))
        self.setSpan(nb_rows, 0, 4, 2)
Exemplo n.º 7
0
    def extend_rows(self):
        nb_rows = self.rowCount()
        date = self.parent.date_.text()

        self.setRowCount(nb_rows + 4)

        self.amount_ht = 0
        for row_num in xrange(0, self.data.__len__()):
            mtt = is_int(self.item(row_num, 3).text())
            self.amount_ht += mtt

        row_num += 1
        self.setItem(row_num, 2, TotalsWidget(u"Total vente : "))
        self.amount_apricot = self.amount_ht
        self.setItem(row_num, 3, TotalsWidget(
            formatted_number(formatted_number(self.amount_ht))))
        row_num += 1
        self.setItem(row_num, 2, TotalsWidget(u"Dette du jour : "))
        self.total_debt = Refund.select(fn.SUM(Refund.amount)).where(
            Refund.type_ == Refund.DT, Refund.date < date_on_or_end(
                date, on=False),  Refund.date > date_on_or_end(date)).scalar() or 0
        if self.total_debt:
            self.amount_apricot -= self.total_debt
        self.setItem(row_num, 3, TotalsWidget(
            formatted_number(formatted_number(self.total_debt))))
        row_num += 1
        self.setItem(row_num, 2, TotalsWidget(u"Dette reglée : "))
        self.total_refund = Refund.select(fn.SUM(Refund.amount)).where(
            Refund.type_ == Refund.RB, Refund.date < date_on_or_end(
                date, on=False),  Refund.date > date_on_or_end(date)).scalar() or 0
        if self.total_refund:
            self.amount_apricot += self.total_refund
        self.setItem(row_num, 3, TotalsWidget(
            formatted_number(formatted_number(self.total_refund))))
        row_num += 1
        self.setItem(row_num, 2, TotalsWidget(u"Caise : "))
        self.setItem(row_num, 3, TotalsWidget(
            formatted_number(formatted_number(self.amount_apricot))))
        self.setSpan(nb_rows, 0, 4, 2)
Exemplo n.º 8
0
    def changed_value(self, refresh=False):
        """ Calcule les Resultat """
        current_store = self.parent.liste_store[
            self.parent.box_store.currentIndex()]

        for row_num in xrange(0, self.data.__len__()):
            self.isvalid = True
            try:
                last_report = Reports.filter(store=current_store,
                                             product__name=str(self.item(row_num, 1)
                                                               .text())).order_by(Reports.date.desc()).get()
                qtremaining = last_report.remaining

                date_out = str(self.parent.date_out.text())
                if last_report.date > date_on_or_end(date_out, on=False):
                    self.parent.date_out.setStyleSheet("font-size:15px;"
                                                       "color:red")
                    self.parent.date_out.setToolTip(u"Cette date est "
                                                    u"Inférieure à la date "
                                                    u"de la dernière rapport"
                                                    u" (%s) " %
                                                    last_report.date)
                    self.isvalid = False
                    return False

            except Exception as e:
                print(e)
                qtremaining = 0

            qtsaisi = is_int(self.cellWidget(row_num, 0).text())

            self._update_data(row_num, [qtsaisi])
            viderreur_qtsaisi = ""
            stylerreur = "background-color: rgb(255, 235, 235);" + \
                         "border: 3px double SeaGreen"
            if qtsaisi == 0:
                viderreur_qtsaisi = stylerreur
                self.cellWidget(row_num, 0).setToolTip(u"obligatoire")
                self.isvalid = False

            self.cellWidget(row_num, 0).setStyleSheet(viderreur_qtsaisi)

            self.cellWidget(row_num, 0).setToolTip("")
            if qtremaining < qtsaisi:
                self.cellWidget(row_num, 0).setStyleSheet("font-size:20px;"
                                                          " color: red")
                self.cellWidget(row_num, 0).setToolTip(u"%s est > %s (stock"
                                                       u" remaining)" % (qtsaisi,
                                                                         qtremaining))
                self.isvalid = False
                return False
Exemplo n.º 9
0
 def format_period(self, on, end):
     return u"<h3>Rapport: <i style='color:LimeGreen'>%s</i>" \
            u" Au <i style='color:LimeGreen'>%s</i><h3>" \
         % (date_on_or_end(on).strftime(u"%A le %d/%m/%Y"),
            date_on_or_end(end, on=False).strftime(u"%A le %d/%m/%Y"))
Exemplo n.º 10
0
 def format_period(self, on, end):
     return u"<h3>Rapport: <i style='color:LimeGreen'>%s</i>" \
            u" Au <i style='color:LimeGreen'>%s</i><h3>" \
         % (date_on_or_end(on).strftime(u"%A le %d/%m/%Y"),
            date_on_or_end(end, on=False).strftime(u"%A le %d/%m/%Y"))
Exemplo n.º 11
0
 def rapport_filter(self):
     self.btt_export.setEnabled(True)
     self.invent_table.refresh_(on=date_on_or_end(self.on_date.text()),
                                end=date_on_or_end(self.end_date.text(), on=False))
Exemplo n.º 12
0
    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]
Exemplo n.º 13
0
 def report_filter(self):
     self.table_op.refresh_(on=date_on_or_end(self.on_date.text()),
                            end=date_on_or_end(self.end_date.text(), on=False))
Exemplo n.º 14
0
    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]