예제 #1
0
    def do_page(self, fname="invoice.html"):
        harvest_date = self.request.get('weekof')
        harvest_date = self.get_harvest_date(harvest_date)

        inv_query = InventoryList.all()
        inv_query.filter('date = ', harvest_date)
        inv = inv_query.fetch(1000)
        locked_or_not = "unlocked"
        if inv != None and len(inv) > 0 and inv[0].locked == 1:
            locked_or_not = "locked"

        item_query = Item.all()
        item_query.filter('date = ', harvest_date)
        item_query.order('name')
        items = item_query.fetch(1000)
        totals = []
        for i in items:
            totals.append(0)

        user_purchase_orders = []
        users = self.get_all_users()
        for user in users:
            user_po = UserPO(user, harvest_date, items)
            if user_po.sub_total_charge > 0:
                user_purchase_orders.append(user_po)
                user_po.add_quants(totals)

        harvest_date_str = harvest_date.strftime("%Y-%m-%d")
        template_values = {
            'harvest_date': harvest_date_str,
            'user_pos': user_purchase_orders,
            'logout_url': self.url,
            'url_linktext': self.url_linktext,
          }
        path = os.path.join(os.path.dirname(__file__), fname)
        self.response.out.write(template.render(path, template_values))
예제 #2
0
    def do_page(self, fname="invoice.html"):
        harvest_date = self.request.get('weekof')
        harvest_date = self.get_harvest_date(harvest_date)

        inv_query = InventoryList.all()
        inv_query.filter('date = ', harvest_date)
        inv = inv_query.fetch(1000)
        locked_or_not = "unlocked"
        if inv != None and len(inv) > 0 and inv[0].locked == 1:
            locked_or_not = "locked"

        item_query = Item.all()
        item_query.filter('date = ', harvest_date)
        item_query.order('name')
        items = item_query.fetch(1000)
        totals = []
        for i in items:
            totals.append(0)

        user_purchase_orders = []
        users = self.get_all_users()
        for user in users:
            user_po = UserPO(user, harvest_date, items)
            if user_po.sub_total_charge > 0:
                user_purchase_orders.append(user_po)
                user_po.add_quants(totals)

        harvest_date_str = harvest_date.strftime("%Y-%m-%d")
        template_values = {
            'harvest_date': harvest_date_str,
            'user_pos': user_purchase_orders,
            'logout_url': self.url,
            'url_linktext': self.url_linktext,
        }
        path = os.path.join(os.path.dirname(__file__), fname)
        self.response.out.write(template.render(path, template_values))
예제 #3
0
    def do_page(self, fname='harvest.html'):
        harvest_date = self.request.get('weekof')
        harvest_date = self.get_harvest_date(harvest_date)

        inv_query = InventoryList.all()
        inv_query.filter('date = ', harvest_date)
        inv = inv_query.fetch(1000)
        locked_or_not = "unlocked"
        if inv != None and len(inv) > 0 and inv[0].locked == 1:
            locked_or_not = "locked"

        item_query = Item.all()
        item_query.filter('date = ', harvest_date)
        item_query.order('name')
        items = item_query.fetch(1000)
        totals = []
        for i in items:
            totals.append(0)

        total_collect = 0.0
        user_purchase_orders = []
        users = self.get_all_users()
        for user in users:
            user_po = UserPO(user, harvest_date, items)
            if user_po.sub_total_charge > 0:
                user_purchase_orders.append(user_po)
                user_po.add_quants(totals)
                total_collect = total_collect + user_po.total_charge

        # trim out items that no one wanted
        # ---- find all the 0 index
        zero_ndxs = []
        for j in range(0, len(items)):
            i = len(items) - j - 1
            total = 0
            for po in user_purchase_orders:
                if len(items) != len(po.quat_list):
                    raise Exception("trouble")
                total = total + po.quat_list[i]
            if total == 0:
                logging.info("removing index %d" %(i))
                zero_ndxs.append(i)
        # ---- remove all of the xero indexs
        for i in zero_ndxs:
            items.pop(i)
            totals.pop(i)
            for po in user_purchase_orders:
                po.quat_list.pop(i)

        harvest_date_str = harvest_date.strftime("%Y-%m-%d")
        template_values = {
            'harvest_date': harvest_date_str,
            'list_header': items,
            'locked_or_not': locked_or_not,
            'user_pos': user_purchase_orders,
            'logout_url': self.url,
            'totals': totals,
            'total_collect':total_collect,
            'url_linktext': self.url_linktext,
          }
        path = os.path.join(os.path.dirname(__file__), fname)
        self.response.out.write(template.render(path, template_values))
예제 #4
0
    def do_page(self, fname='harvest.html'):
        harvest_date = self.request.get('weekof')
        harvest_date = self.get_harvest_date(harvest_date)

        inv_query = InventoryList.all()
        inv_query.filter('date = ', harvest_date)
        inv = inv_query.fetch(1000)
        locked_or_not = "unlocked"
        if inv != None and len(inv) > 0 and inv[0].locked == 1:
            locked_or_not = "locked"

        item_query = Item.all()
        item_query.filter('date = ', harvest_date)
        item_query.order('name')
        items = item_query.fetch(1000)
        totals = []
        for i in items:
            totals.append(0)

        total_collect = 0.0
        user_purchase_orders = []
        users = self.get_all_users()
        for user in users:
            user_po = UserPO(user, harvest_date, items)
            if user_po.sub_total_charge > 0:
                user_purchase_orders.append(user_po)
                user_po.add_quants(totals)
                total_collect = total_collect + user_po.total_charge

        # trim out items that no one wanted
        # ---- find all the 0 index
        zero_ndxs = []
        for j in range(0, len(items)):
            i = len(items) - j - 1
            total = 0
            for po in user_purchase_orders:
                if len(items) != len(po.quat_list):
                    raise Exception("trouble")
                total = total + po.quat_list[i]
            if total == 0:
                logging.info("removing index %d" % (i))
                zero_ndxs.append(i)
        # ---- remove all of the xero indexs
        for i in zero_ndxs:
            items.pop(i)
            totals.pop(i)
            for po in user_purchase_orders:
                po.quat_list.pop(i)

        harvest_date_str = harvest_date.strftime("%Y-%m-%d")
        template_values = {
            'harvest_date': harvest_date_str,
            'list_header': items,
            'locked_or_not': locked_or_not,
            'user_pos': user_purchase_orders,
            'logout_url': self.url,
            'totals': totals,
            'total_collect': total_collect,
            'url_linktext': self.url_linktext,
        }
        path = os.path.join(os.path.dirname(__file__), fname)
        self.response.out.write(template.render(path, template_values))