Ejemplo n.º 1
0
    def add_permit_lines(self):
        from regional.restrictions import GetMatchingPRsByZip

        if not self.agreement.system_address.zip:
            return

        property_type = 'commercial' if self.agreement.floorplan == 'Business' else 'residential'

        prs = GetMatchingPRsByZip(self.agreement.system_address.zip,
                                  property_type,
                                  asof=datetime.now())
        print "PRs found: %r" % prs
        permits = [pr for pr in prs if pr.permit_fee or pr.addendum_fee]

        # These are the lines we need permits for.  We're going to cheat
        # our faces off and use the note column for this.

        for pr in permits:
            # reclaim or create a permit line.
            pnote = ';'.join([
                pr.override_type or pr.region_type,
                ', '.join(pr.override_name or pr.region_name)
            ])
            pline = self.reclaim_line(code='PERMIT',
                                      line_type='PERMIT',
                                      note=pnote)
            if not pline:
                pline = InvoiceLine(agreement=self.agreement,
                                    line_type='PERMIT')

            pline.update_permit(pr, permit_product=self.products['PERMIT'])
            pline.save()

            # Put the permit line onto the final part.
            self.final_lines.append(pline)
Ejemplo n.º 2
0
    def add_permit_lines(self):
        from regional.restrictions import GetMatchingPRsByZip

        if not self.agreement.system_address.zip:
            return

        property_type = 'commercial' if self.agreement.floorplan == 'Business' else 'residential'

        prs = GetMatchingPRsByZip(self.agreement.system_address.zip, property_type, asof=datetime.now())
        print "PRs found: %r" % prs
        permits = [pr for pr in prs if pr.permit_fee or pr.addendum_fee]

        # These are the lines we need permits for.  We're going to cheat
        # our faces off and use the note column for this.

        for pr in permits:
            # reclaim or create a permit line.
            pnote = ';'.join([pr.override_type or pr.region_type, ', '.join(pr.override_name or pr.region_name)])
            pline = self.reclaim_line(code='PERMIT', line_type='PERMIT', note=pnote)
            if not pline:
                pline = InvoiceLine(agreement=self.agreement, line_type='PERMIT')

            pline.update_permit(pr, permit_product=self.products['PERMIT'])
            pline.save()

            # Put the permit line onto the final part.
            self.final_lines.append(pline)