Пример #1
0
    def __init__(self, filename, branch, daterange, data_object):
        self.branch = branch
        self.start_date = daterange[0]
        self.end_date = daterange[1]
        self.sales = data_object.sales
        self.lonely_in_payments = data_object.lonely_in_payments
        self.purchases = data_object.purchases
        self.lonely_out_payments = data_object.lonely_out_payments
        self.return_sales = data_object.return_sales
        self.till_supplies = data_object.till_supplies
        self.till_removals = data_object.till_removals
        self.method_summary = data_object.method_summary
        self.card_summary = data_object.card_summary

        HTMLReport.__init__(self, filename)
Пример #2
0
Файл: till.py Проект: stoq/stoq
    def __init__(self, filename, store, branch, daterange, data_object):
        self.branch = branch
        self.start_date = daterange[0]
        self.end_date = daterange[1]
        self.sales = data_object.sales
        self.lonely_in_payments = data_object.lonely_in_payments
        self.purchases = data_object.purchases
        self.lonely_out_payments = data_object.lonely_out_payments
        self.return_sales = data_object.return_sales
        self.till_supplies = data_object.till_supplies
        self.till_removals = data_object.till_removals
        self.method_summary = data_object.method_summary
        self.card_summary = data_object.card_summary

        queries = [TillClosedView.opening_date >= self.start_date, TillClosedView.opening_date <= self.end_date]
        if branch:
            queries.append(TillClosedView.branch_id == branch.id)
        self.tills = store.find(TillClosedView, And(queries))

        HTMLReport.__init__(self, filename)
Пример #3
0
    def __init__(self, filename, store, branch, daterange, data_object):
        self.branch = branch
        self.start_date = daterange[0]
        self.end_date = daterange[1]
        self.sales = data_object.sales
        self.lonely_in_payments = data_object.lonely_in_payments
        self.purchases = data_object.purchases
        self.lonely_out_payments = data_object.lonely_out_payments
        self.return_sales = data_object.return_sales
        self.till_supplies = data_object.till_supplies
        self.till_removals = data_object.till_removals
        self.method_summary = data_object.method_summary
        self.card_summary = data_object.card_summary

        queries = [
            TillClosedView.opening_date >= self.start_date,
            TillClosedView.opening_date <= self.end_date
        ]
        if branch:
            queries.append(TillClosedView.branch_id == branch.id)
        self.tills = store.find(TillClosedView, And(queries))

        HTMLReport.__init__(self, filename)
Пример #4
0
 def __init__(self, filename, order):
     self.order = order
     self.receiving_orders = list(order.get_receiving_orders())
     HTMLReport.__init__(self, filename)
Пример #5
0
 def __init__(self, filename, payments):
     self.booklets_data = list(self._get_booklets_data(payments))
     HTMLReport.__init__(self, filename)
Пример #6
0
 def __init__(self, filename, order):
     self.order = order
     self.payments = api.sysparam.get_bool(
         "CREATE_PAYMENTS_ON_STOCK_DECREASE")
     HTMLReport.__init__(self, filename)
Пример #7
0
 def __init__(self, filename, pending_return):
     self.pending_return = pending_return
     HTMLReport.__init__(self, filename)
Пример #8
0
 def __init__(self, filename, order):
     self.order = order
     self.payments = api.sysparam.get_bool("CREATE_PAYMENTS_ON_STOCK_DECREASE")
     HTMLReport.__init__(self, filename)
Пример #9
0
Файл: sale.py Проект: relsi/stoq
 def __init__(self, filename, order):
     self.order = order
     HTMLReport.__init__(self, filename)
Пример #10
0
 def __init__(self, filename, payment, order, date, *args, **kwargs):
     self.payment = payment
     self.order = order
     self.receipt_date = date
     HTMLReport.__init__(self, filename, *args, **kwargs)
Пример #11
0
 def __init__(self, filename, client):
     self.client = client
     HTMLReport.__init__(self, filename)
Пример #12
0
 def __init__(self, filename, payment, order, date, *args, **kwargs):
     self.payment = payment
     self.order = order
     self.receipt_date = date
     HTMLReport.__init__(self, filename, *args, **kwargs)
Пример #13
0
    def __init__(self, filename, store, start_date, end_date=None):
        self.start_date = start_date
        self.end_date = end_date

        query = And(Payment.status == Payment.STATUS_PAID,
                    Date(Payment.paid_date) == Date(start_date))

        # Keys are the sale objects, and values are lists with all payments
        self.sales = {}

        # Keys are the returned sale objects, and values are lists with all payments
        self.return_sales = {}
        self.purchases = {}

        # lonely input and output payments
        self.lonely_in_payments = []
        self.lonely_out_payments = []

        # values are lists with the first element the summary of the input, and
        # the second the summary of the output
        method_summary = {}
        self.card_summary = {}

        for p in store.find(InPaymentView, query).order_by(Payment.identifier):
            if p.sale:
                sale_payments = self.sales.setdefault(p.sale, [])
                sale_payments.append(p)
            else:
                self.lonely_in_payments.append(p)

            method_summary.setdefault(p.method, [0, 0])
            method_summary[p.method][0] += p.value
            if p.card_data:
                type_desc = p.card_data.short_desc[p.card_data.card_type]
                key = (p.card_data.provider.short_name, type_desc)
                self.card_summary.setdefault(key, 0)
                self.card_summary[key] += p.value

        for p in store.find(OutPaymentView, query).order_by(Payment.identifier):
            if p.purchase:
                purchase_payments = self.purchases.setdefault(p.purchase, [])
                purchase_payments.append(p)
            elif p.sale:
                return_sales_payment = self.return_sales.setdefault(p.sale, [])
                return_sales_payment.append(p)
            else:
                self.lonely_out_payments.append(p)

            method_summary.setdefault(p.method, [0, 0])
            method_summary[p.method][1] += p.value

        self.method_summary = []
        for method, (in_value, out_value) in method_summary.items():
            self.method_summary.append((N_(method.description),
                                        in_value,
                                        out_value))
        self.method_summary.sort()

        # Till removals
        query = And(Eq(TillEntry.payment_id, None),
                    Date(TillEntry.date) == Date(start_date),
                    TillEntry.value < 0)
        self.till_removals = store.find(TillEntry, query)

        # Till supply
        query = And(Eq(TillEntry.payment_id, None),
                    Date(TillEntry.date) == Date(start_date),
                    TillEntry.value > 0)
        self.till_supplies = store.find(TillEntry, query)

        HTMLReport.__init__(self, filename)
Пример #14
0
    def __init__(self, filename, store, start_date, end_date=None):
        self.start_date = start_date
        self.end_date = end_date

        query = And(Payment.status == Payment.STATUS_PAID,
                    Date(Payment.paid_date) == Date(start_date))

        # Keys are the sale objects, and values are lists with all payments
        self.sales = {}

        # Keys are the returned sale objects, and values are lists with all payments
        self.return_sales = {}
        self.purchases = {}

        # lonely input and output payments
        self.lonely_in_payments = []
        self.lonely_out_payments = []

        # values are lists with the first element the summary of the input, and
        # the second the summary of the output
        self.method_summary = {}
        self.card_summary = {}

        for p in store.find(InPaymentView, query).order_by(Payment.identifier):
            if p.sale:
                sale_payments = self.sales.setdefault(p.sale, [])
                sale_payments.append(p)
            else:
                self.lonely_in_payments.append(p)

            self.method_summary.setdefault(p.method, [0, 0])
            self.method_summary[p.method][0] += p.value
            if p.card_data:
                type_desc = p.card_data.short_desc[p.card_data.card_type]
                key = (p.card_data.provider.short_name, type_desc)
                self.card_summary.setdefault(key, 0)
                self.card_summary[key] += p.value

        for p in store.find(OutPaymentView,
                            query).order_by(Payment.identifier):
            if p.purchase:
                purchase_payments = self.purchases.setdefault(p.purchase, [])
                purchase_payments.append(p)
            elif p.sale:
                return_sales_payment = self.return_sales.setdefault(p.sale, [])
                return_sales_payment.append(p)
            else:
                self.lonely_out_payments.append(p)

            self.method_summary.setdefault(p.method, [0, 0])
            self.method_summary[p.method][1] += p.value

        # Till removals
        query = And(Eq(TillEntry.payment_id, None),
                    Date(TillEntry.date) == Date(start_date),
                    TillEntry.value < 0)
        self.till_removals = store.find(TillEntry, query)

        # Till supply
        query = And(Eq(TillEntry.payment_id, None),
                    Date(TillEntry.date) == Date(start_date),
                    TillEntry.value > 0)
        self.till_supplies = store.find(TillEntry, query)

        HTMLReport.__init__(self, filename)
Пример #15
0
    def __init__(self, filename, store, start_date, end_date=None):
        self.start_date = start_date
        self.end_date = end_date
        self.branch = api.get_current_branch(store)

        query = And(Payment.status == Payment.STATUS_PAID,
                    Payment.branch_id == self.branch.id,
                    self._get_date_interval_query(Payment.paid_date))

        # Keys are the sale objects, and values are lists with all payments
        self.sales = {}

        # Keys are the returned sale objects, and values are lists with all payments
        self.return_sales = {}
        self.purchases = {}

        # lonely input and output payments
        self.lonely_in_payments = []
        self.lonely_out_payments = []

        # values are lists with the first element the summary of the input, and
        # the second the summary of the output
        method_summary = {}
        self.card_summary = {}

        for p in store.find(InPaymentView, query).order_by(Sale.identifier, Payment.identifier):
            if p.sale:
                if p.sale.status == Sale.STATUS_RETURNED:
                    continue
                sale_payments = self.sales.setdefault(p.sale, {})
                details = ''
                method_desc = p.method.get_description()
                if p.card_data:
                    if p.card_data.card_type == CreditCardData.TYPE_DEBIT:
                        method_desc += ' ' + _('Debit')
                    else:
                        method_desc += ' ' + _(u'Credit')
                    details = '%s - %s - %s' % (p.card_data.auth,
                                                p.card_data.provider.short_name or '',
                                                p.card_data.device.description or '')

                key = (method_desc, details)
                item = sale_payments.setdefault(key, [0, 0])
                item[0] += p.value
                item[1] += 1

            else:
                self.lonely_in_payments.append(p)

            method_summary.setdefault(p.method, [0, 0])
            method_summary[p.method][0] += p.value
            if p.card_data:
                type_desc = p.card_data.short_desc[p.card_data.card_type]
                key = (p.card_data.provider.short_name, type_desc)
                self.card_summary.setdefault(key, 0)
                self.card_summary[key] += p.value

        for p in store.find(OutPaymentView, query).order_by(Payment.identifier):
            if p.purchase:
                purchase_payments = self.purchases.setdefault(p.purchase, [])
                purchase_payments.append(p)
            elif p.sale:
                return_sales_payment = self.return_sales.setdefault(p.sale, [])
                return_sales_payment.append(p)
            else:
                self.lonely_out_payments.append(p)

            method_summary.setdefault(p.method, [0, 0])
            method_summary[p.method][1] += p.value

        self.method_summary = []
        for method, (in_value, out_value) in method_summary.items():
            self.method_summary.append((N_(method.description),
                                        in_value,
                                        out_value))
        self.method_summary.sort()

        # Till removals
        query = And(Eq(TillEntry.payment_id, None),
                    TillEntry.branch_id == self.branch.id,
                    self._get_date_interval_query(TillEntry.date),
                    TillEntry.value < 0)
        self.till_removals = store.find(TillEntry, query)

        # Till supply
        query = And(Eq(TillEntry.payment_id, None),
                    TillEntry.branch_id == self.branch.id,
                    self._get_date_interval_query(TillEntry.date),
                    TillEntry.value > 0)
        self.till_supplies = store.find(TillEntry, query)

        HTMLReport.__init__(self, filename)
Пример #16
0
 def __init__(self, filename, order):
     self.order = order
     self.receiving_orders = list(order.get_receiving_orders())
     HTMLReport.__init__(self, filename)
Пример #17
0
 def __init__(self, filename, payment_histories):
     self.payment_histories = payment_histories
     HTMLReport.__init__(self, filename)
Пример #18
0
 def __init__(self, filename, payments):
     self.booklets_data = list(self._get_booklets_data(payments))
     HTMLReport.__init__(self, filename)
Пример #19
0
 def __init__(self, filename, client):
     self.client = client
     HTMLReport.__init__(self, filename)
Пример #20
0
 def __init__(self, filename, order):
     self.order = order
     HTMLReport.__init__(self, filename)
Пример #21
0
 def __init__(self, filename, store, client, returned_sale, returned_sale_items):
     self.client = client
     self.returned_sale = returned_sale
     self.returned_items = returned_sale_items
     HTMLReport.__init__(self, filename)