예제 #1
0
    def handle(self, pi, id):
        from applications.good.service import GoodService
        inventory = InventoryService.get_by_id(id)

        su = sum(map(
            lambda it: GoodService.get_price(
                it.good_id).price_retail * it.count_after, inventory.items))

        pi.set_cells(0, 0, [('number', 2)])
        pi.set_cells(0, 2, ['a', 'date', 'c', 'c', 'c', 'sum'])
        pi.set_cells(0, 3, ['a', 'pointsale'])
        pi.set_cells(0, 6, [('name', 5), 'price', 'a', 'count', 'b', 'c', 'd'])

        pi.write(0, 0, 0, [{'number': inventory.number}])
        pi.write(0, 2, 1, [{'date': inventory.datetimenew.strftime(
            "%d.%m.%Y - %H:%M:%S"), 'sum': su}])
        pi.write(0, 3, 0, [{'pointsale': inventory.location.name}])

        items = [
            {'name': it.good.full_name, 'count': it.count_after or "",
             'price': GoodService.get_price(it.good_id).price_retail,
             'a': '',
             'b': '',
             'c': '',
             'd': ''} for it in inventory.items]
        pi.write(0, 6, 2, items)