当前位置: 首页>>代码示例>>Python>>正文


Python model.Invoice类代码示例

本文整理汇总了Python中zkpylons.model.Invoice的典型用法代码示例。如果您正苦于以下问题:Python Invoice类的具体用法?Python Invoice怎么用?Python Invoice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Invoice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: refund

    def refund(self, id):
        invoice = Invoice.find_by_id(id)
        try:
            c.invoice_person = invoice.person.id
        except:
            c.invoice_person = ''

        c.due_date = datetime.date.today().strftime("%d/%m/%Y")

        c.product_categories = ProductCategory.find_all()
        # The form adds one to the count by default, so we need to decrement it
        c.item_count = len(invoice.items) - 1

        defaults = dict()
        defaults['invoice.person' ] = c.invoice_person
        defaults['invoice.due_date'] = c.due_date
        for i in range(len(invoice.items)):
            item = invoice.items[i]
            if item.product:
                defaults['invoice.items-' + str(i) + '.product'] = item.product.id
            else:
                defaults['invoice.items-' + str(i) + '.description'] = item.description
            defaults['invoice.items-' + str(i) + '.qty'] = -item.qty
            defaults['invoice.items-' + str(i) + '.cost'] = item.cost
        form = render("/invoice/new.mako")
        return htmlfill.render(form, defaults, use_all_keys=True)
开发者ID:n6151h,项目名称:pyconau2016,代码行数:26,代码来源:invoice.py

示例2: pay

    def pay(self, id):
        """Request confirmation from user
        """
        invoice = Invoice.find_by_id(id, True)
        person = invoice.person

        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(person.id), h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        #return render('/registration/really_closed.mako')

        error = self._check_invoice(person, invoice)
        if error is not None:
            return error

        c.payment = Payment()
        c.payment.amount = invoice.total
        c.payment.invoice = invoice

        meta.Session.commit()
        if c.payment.gateway == 'securepay':
            return render("/invoice/securepay.mako")
        else:
            return render("/invoice/payment.mako")
开发者ID:noisymime,项目名称:zookeepr,代码行数:25,代码来源:invoice.py

示例3: unvoid

 def unvoid(self, id):
     c.invoice = Invoice.find_by_id(id, True)
     c.invoice.void = None
     c.invoice.manual = True
     meta.Session.commit()
     h.flash("Invoice was un-voided.")
     return redirect_to(action='view', id=c.invoice.id)
开发者ID:n6151h,项目名称:pyconau2016,代码行数:7,代码来源:invoice.py

示例4: check

    def check(self, app, environ, start_response):

        if not environ.get('REMOTE_USER'):
            set_redirect()
            raise NotAuthenticatedError('Not Authenticated')

        person = Person.find_by_email(environ['REMOTE_USER'])
        if person is None:
            environ['auth_failure'] = 'NO_USER'
            raise NotAuthorizedError(
                'You are not one of the users allowed to access this resource.'
            )

        invoice = Invoice.find_by_id(self.invoice_id)
        if invoice is None:
            raise NotAuthorizedError(
                "Invoice doesn't exist"
            )

        if person.id <> invoice.person_id:
            set_role("Invoice is not for this user")
            raise NotAuthorizedError(
                "Invoice is not for this user"
            )

        return app(environ, start_response)
开发者ID:Ivoz,项目名称:zookeepr,代码行数:26,代码来源:auth.py

示例5: void

    def void(self, id):
        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role)):
            # Raise a no_auth error
            h.auth.no_role()

        c.invoice = Invoice.find_by_id(id, True)
        if c.invoice.is_void():
            h.flash("Invoice was already voided.")
            return redirect_to(action='view', id=c.invoice.id)

        if h.auth.authorized(h.auth.has_organiser_role):
            c.invoice.void = "Administration Change"
            meta.Session.commit()
            h.flash("Invoice was voided.")
            return redirect_to(action='view', id=c.invoice.id)
        else:
            if c.invoice.paid():
                h.flash("Cannot void a paid invoice.")
                return redirect_to(action='view', id=c.invoice.id)
            c.invoice.void = "User cancellation"
            c.person = c.invoice.person
            meta.Session.commit()
            email(lca_info['contact_email'], render('/invoice/user_voided.mako'))
            h.flash("Previous invoice was voided.")
            return redirect_to(controller='registration', action='pay', id=c.person.registration.id)
开发者ID:PaulWay,项目名称:zookeepr,代码行数:25,代码来源:invoice.py

示例6: remind

 def remind(self):
     c.invoice_collection = Invoice.find_all()
     #c.invoice = c.invoice_collection[0]
     #c.recipient = c.invoice.person
     # create dummy person for example:
     c.recipient = FakePerson()
     return render('/invoice/remind.mako')
开发者ID:PaulWay,项目名称:zookeepr,代码行数:7,代码来源:invoice.py

示例7: void

    def void(self, id):
        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role)):
            # Raise a no_auth error
            h.auth.no_role()

        c.invoice = Invoice.find_by_id(id, True)
        if c.invoice.is_void:
            h.flash("Invoice was already voided.")
            return redirect_to(action='view', id=c.invoice.id)
        elif len(c.invoice.payment_received) and h.auth.authorized(h.auth.has_organiser_role):
            h.flash("Invoice has a payment applied to it, do you want to " + h.link_to('Refund', h.url_for(action='refund')) + " instead?")
            return redirect_to(action='view', id=c.invoice.id)
        elif len(c.invoice.payment_received):
            h.flash("Cannot void a paid invoice.")
            return redirect_to(action='view', id=c.invoice.id)
        elif h.auth.authorized(h.auth.has_organiser_role):
            c.invoice.void = "Administration Change"
            meta.Session.commit()
            h.flash("Invoice was voided.")
            return redirect_to(action='view', id=c.invoice.id)
        else:
            c.invoice.void = "User cancellation"
            c.person = c.invoice.person
            meta.Session.commit()
            email(Config.get('contact_email'), render('/invoice/user_voided.mako'))
            h.flash("Previous invoice was voided.")
            return redirect_to(controller='registration', action='pay', id=c.person.registration.id)
开发者ID:n6151h,项目名称:pyconau2016,代码行数:27,代码来源:invoice.py

示例8: extend

 def extend(self, id):
     c.invoice = Invoice.find_by_id(id, True)
     if c.invoice.is_overdue:
         c.invoice.due_date = datetime.datetime.now() + datetime.timedelta(days=1)
     else:
         c.invoice.due_date = c.invoice.due_date + ((c.invoice.due_date - datetime.datetime.now()) * 2)
     meta.Session.commit()
     return redirect_to(action='view')
开发者ID:n6151h,项目名称:pyconau2016,代码行数:8,代码来源:invoice.py

示例9: pdf

    def pdf(self, id):
        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        c.invoice = Invoice.find_by_id(id, True)
        xml_s = render('/invoice/pdf.mako')

        xsl_f = get_path('zk_root') + '/zkpylons/templates/invoice/pdf.xsl'
        pdf_data = pdfgen.generate_pdf(xml_s, xsl_f)

        filename = Config.get('event_shortname') + '_' + str(c.invoice.id) + '.pdf'
        return pdfgen.wrap_pdf_response(pdf_data, filename)
开发者ID:n6151h,项目名称:pyconau2016,代码行数:13,代码来源:invoice.py

示例10: printable

    def printable(self, id):
        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        c.printable = True
        c.invoice = Invoice.find_by_id(id, True)
        c.payment_received = None
        c.payment = None
        if c.invoice.is_paid and c.invoice.total > 0:
            c.payment_received = c.invoice.good_payments[0]
            c.payment = c.payment_received.payment
        return render('/invoice/view_printable.mako')
开发者ID:n6151h,项目名称:pyconau2016,代码行数:13,代码来源:invoice.py

示例11: pdf

    def pdf(self, id):
        if not h.auth.authorized(
            h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())
        ):
            # Raise a no_auth error
            h.auth.no_role()

        c.invoice = Invoice.find_by_id(id, True)
        xml_s = render("/invoice/pdf.mako")

        xsl_f = file_paths["zk_root"] + "/zkpylons/templates/invoice/pdf.xsl"
        pdf_data = pdfgen.generate_pdf(xml_s, xsl_f)

        filename = lca_info["event_shortname"] + "_" + str(c.invoice.id) + ".pdf"
        return pdfgen.wrap_pdf_response(pdf_data, filename)
开发者ID:gracz120,项目名称:zookeepr,代码行数:15,代码来源:invoice.py

示例12: pay_manual

    def pay_manual(self, id):
        """Request confirmation from user
        """
        invoice = Invoice.find_by_id(id, True)
        person = invoice.person

        error = self._check_invoice(person, invoice, ignore_overdue=True)
        if error is not None:
            return error

        c.payment = Payment()
        c.payment.amount = invoice.total
        c.payment.invoice = invoice

        meta.Session.commit()
        return redirect_to(controller='payment', id=c.payment.id, action='new_manual')
开发者ID:n6151h,项目名称:pyconau2016,代码行数:16,代码来源:invoice.py

示例13: pdf

    def pdf(self, id):
        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        c.invoice = Invoice.find_by_id(id, True)
        xml_s = render('/invoice/pdf.mako')

        template_path = file_paths['theme_templates'] + '/invoice/pdf.xsl'
        if(os.path.isfile(template_path)):
            xsl_f = template_path
        else:
            xsl_f = file_paths['zk_root'] + '/zkpylons/templates/invoice/pdf.xsl'
        pdf_data = pdfgen.generate_pdf(xml_s, xsl_f)

        filename = lca_info['event_shortname'] + '_' + str(c.invoice.id) + '.pdf'
        return pdfgen.wrap_pdf_response(pdf_data, filename)
开发者ID:noisymime,项目名称:zookeepr,代码行数:17,代码来源:invoice.py

示例14: get_invoice

 def get_invoice(self, id):
     """
     Returns a JSON representation of an existing invoice
     """
     invoice = Invoice.find_by_id(id, True)
     obj = {
         "id": invoice.id,
         "person_id": invoice.person_id,
         "manual": invoice.manual,
         "void": invoice.void,
         "issue_date": invoice.issue_date.strftime("%d/%m/%Y"),
         "due_date": invoice.due_date.strftime("%d/%m/%Y"),
         "items": [
             {"product_id": item.product_id, "description": item.description, "qty": item.qty, "cost": item.cost}
             for item in invoice.items
         ],
     }
     return dict(r=dict(invoice=obj))
开发者ID:gracz120,项目名称:zookeepr,代码行数:18,代码来源:invoice.py

示例15: get_invoice

 def get_invoice(self, id):
     """
     Returns a JSON representation of an existing invoice
     """
     invoice = Invoice.find_by_id(id, True)
     obj = {
         'id': invoice.id,
         'person_id': invoice.person_id,
         'manual': invoice.manual,
         'void': invoice.void,
         'issue_date': invoice.issue_date.strftime('%d/%m/%Y'),
         'due_date': invoice.due_date.strftime('%d/%m/%Y'),
         'items': [
             {
             'product_id': item.product_id,
             'description': item.description,
             'qty': item.qty,
             'cost': item.cost,
             } for item in invoice.items],
     }
     return dict(r=dict(invoice=obj))
开发者ID:n6151h,项目名称:pyconau2016,代码行数:21,代码来源:invoice.py


注:本文中的zkpylons.model.Invoice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。