예제 #1
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
 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)
예제 #2
0
 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)
예제 #3
0
    def _new(self):
        results = self.form_result['invoice']
        del (results['item_count'])

        items = results['items']
        results['items'] = []
        c.invoice = Invoice(**results)

        for i in items:
            item = InvoiceItem()
            if i['description'] != "":
                item.description = i['description']
            else:
                product = Product.find_by_id(i['product'].id)
                category = product.category
                item.product = i['product']
                item.description = product.category.name + ' - ' + product.description
            item.cost = i['cost']
            item.qty = i['qty']
            c.invoice.items.append(item)

        c.invoice.manual = True
        c.invoice.void = None
        meta.Session.add(c.invoice)
        meta.Session.commit()

        h.flash("Manual invoice created")
        return redirect_to(action='view', id=c.invoice.id)
예제 #4
0
    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)
예제 #5
0
 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')
예제 #6
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
 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')
예제 #7
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
    def void(self, id):
        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zookeepr_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)
예제 #8
0
    def void(self, id):
        if not h.auth.authorized(
                h.auth.Or(h.auth.is_same_zookeepr_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)
예제 #9
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
    def printable(self, id):
        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zookeepr_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.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')
예제 #10
0
    def printable(self, id):
        if not h.auth.authorized(
                h.auth.Or(h.auth.is_same_zookeepr_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.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')
예제 #11
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
    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')
예제 #12
0
    def pdf(self, id):
        if not h.auth.authorized(
                h.auth.Or(h.auth.is_same_zookeepr_attendee(id),
                          h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        import os, tempfile, libxml2, libxslt

        c.invoice = Invoice.find_by_id(id, True)

        xml_s = render('/invoice/pdf.mako')

        xsl_f = file_paths['zk_root'] + '/zookeepr/templates/invoice/pdf.xsl'
        xsl_s = libxml2.parseFile(xsl_f)
        xsl = libxslt.parseStylesheetDoc(xsl_s)

        xml = libxml2.parseDoc(xml_s)
        svg_s = xsl.applyStylesheet(xml, None)

        (svg_fd, svg) = tempfile.mkstemp('.svg')
        xsl.saveResultToFilename(svg, svg_s, 0)

        xsl.freeStylesheet()
        xml.freeDoc()
        svg_s.freeDoc()

        (pdf_fd, pdf) = tempfile.mkstemp('.pdf')

        os.close(svg_fd)
        os.close(pdf_fd)

        os.system('inkscape -z -f %s -A %s' % (svg, pdf))

        pdf_f = file(pdf)
        res = Response(pdf_f.read())
        pdf_f.close()
        res.headers['Content-type'] = 'application/pdf'
        #res.headers['Content-type']='application/octet-stream'
        #res.headers['Content-type']='text/plain; charset=utf-8'
        filename = lca_info['event_shortname'] + '_' + str(
            c.invoice.id) + '.pdf'
        res.headers['Content-Disposition'] = ('attachment; filename=%s' %
                                              filename)

        # We should really remove the pdf file, shouldn't we.
        return res
예제 #13
0
    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')
예제 #14
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
    def pdf(self, id):
        if not h.auth.authorized(h.auth.Or(h.auth.is_same_zookeepr_attendee(id), h.auth.has_organiser_role, h.auth.has_unique_key())):
            # Raise a no_auth error
            h.auth.no_role()

        import os, tempfile, libxml2, libxslt

        c.invoice = Invoice.find_by_id(id, True)

        xml_s = render('/invoice/pdf.mako')

        xsl_f = file_paths['zk_root'] + '/zookeepr/templates/invoice/pdf.xsl'
        xsl_s = libxml2.parseFile(xsl_f)
        xsl = libxslt.parseStylesheetDoc(xsl_s)

        xml = libxml2.parseDoc(xml_s)
        svg_s = xsl.applyStylesheet(xml, None)

        (svg_fd, svg) = tempfile.mkstemp('.svg')
        xsl.saveResultToFilename(svg, svg_s, 0)

        xsl.freeStylesheet()
        xml.freeDoc()
        svg_s.freeDoc()

        (pdf_fd, pdf) = tempfile.mkstemp('.pdf')

        os.close(svg_fd); os.close(pdf_fd)

        os.system('inkscape -z -f %s -A %s' % (svg, pdf))

        pdf_f = file(pdf)
        res = Response(pdf_f.read())
        pdf_f.close()
        res.headers['Content-type']='application/pdf'
        #res.headers['Content-type']='application/octet-stream'
        #res.headers['Content-type']='text/plain; charset=utf-8'
        filename = lca_info['event_shortname'] + '_' + str(c.invoice.id) + '.pdf'
        res.headers['Content-Disposition']=( 'attachment; filename=%s' % filename )

        # We should really remove the pdf file, shouldn't we.
        return res
예제 #15
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
    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_zookeepr_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()
        return render("/invoice/payment.mako")
예제 #16
0
    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_zookeepr_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()
        return render("/invoice/payment.mako")
예제 #17
0
 def _to_python(self, value, state):
     invoice = Invoice.find_by_id(int(value), False)
     if invoice is None:
         raise Invalid("Unknown invoice ID.", value, state)
     else:
         return invoice
예제 #18
0
    def index(self):
        c.can_edit = True
        c.invoice_collection = Invoice.find_all()

        return render('/invoice/list.mako')
예제 #19
0
 def remind(self):
     c.invoice_collection = Invoice.find_all()
     c.invoice = c.invoice_collection[0]
     c.recipient = c.invoice.person
     return render('/invoice/remind.mako')
예제 #20
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
 def _to_python(self, value, state):
     invoice = Invoice.find_by_id(int(value), False)
     if invoice is None:
         raise Invalid("Unknown invoice ID.", value, state)
     else:
         return invoice
예제 #21
0
파일: invoice.py 프로젝트: cafuego/zookeepr
 def remind(self):
     c.invoice_collection = Invoice.find_all()
     c.invoice = c.invoice_collection[0]
     c.recipient = c.invoice.person
     return render('/invoice/remind.mako')
예제 #22
0
파일: invoice.py 프로젝트: CarlFK/zookeepr
    def index(self):
        c.can_edit = True
        c.invoice_collection = Invoice.find_all()

        return render('/invoice/list.mako')