示例#1
0
 def record_rent(**kwargs):
     transaction = Transaction()
         
     for key in kwargs:
         transaction.__setattr__(key, kwargs[key])
     
     meta.Session.add(transaction)
     meta.Session.commit()
     session.save()
     
     #pulse
     unit = Unit.get_unit(kwargs['unitid'])
     property_name = Property.get_name_by_id(unit.propertyid)
     Pulse.create(
                  unitid = unit.id,
                  propertyid = unit.propertyid,
                  type = 'rent',
                  html = '<div class="unit"><a href="/unit/view/{1}">{3} #{2}</a> has paid ${0} rent for {4}/{5}.</div>'.format(
                             kwargs['amount'],
                             unit.id,
                             unit.label,
                             property_name,
                             kwargs['formonth'],
                             kwargs['foryear']
                             )
                  )
示例#2
0
 def undo_rent(unitId, forMonth, forYear):
     records = meta.Session.query(Transaction).filter(and_(Transaction.unitid==unitId,\
                                                          Transaction.formonth==forMonth,\
                                                          Transaction.foryear==forYear)).all()
     for record in records:
         meta.Session.delete(record)
     meta.Session.commit()
     session.save()
     
     #pulse
     unit = Unit.get_unit(unitId)
     property_name = Property.get_name_by_id(unit.propertyid)
     Pulse.create(
                  unitid = unit.id,
                  propertyid = unit.propertyid,
                  type = 'warning',
                  html = '<div class="unit"><a href="/unit/view/{1}">{3} #{2}</a>\'s rent for {0} has been unmarked.</div>'.format(
                             '{0}/{1}'.format(forMonth, forYear),
                             unit.id,
                             unit.label,
                             property_name
                             )
                  )
示例#3
0
文件: lease.py 项目: weixiyen/Rentfox
 def create(**kwargs):
     lease = Lease()
     
     for key in kwargs:
         lease.__setattr__(key, kwargs[key])
     
     meta.Session.add(lease)
     meta.Session.commit()
     session.save()
     
     unit = Unit.get_unit(kwargs['unitid'])
     property_name = Property.get_name_by_id(unit.propertyid)
     Pulse.create(
                  unitid = unit.id,
                  propertyid = unit.propertyid,
                  type = 'lease',
                  html = '<div class="unit">A new lease will begin on {0} in <a href="/unit/view/{1}">{3} #{2}</a></div>'.format(
                             kwargs['startdate'].strftime('%B %d'),
                             unit.id,
                             unit.label,
                             property_name
                             )
                  )
示例#4
0
文件: lease.py 项目: weixiyen/Rentfox
 def delete(leaseid):
     lease = Lease.get(leaseid)
     
     #pulse
     unit = Unit.get_unit(lease.unitid)
     property_name = Property.get_name_by_id(unit.propertyid)
     lease_start = lease.startdate.strftime("%B %d, %Y")
     unit_label = unit.label
     Pulse.create(
                  unitid = unit.id,
                  propertyid = unit.propertyid,
                  type = 'warning',
                  html = '<div class="unit">Lease starting from {0} for <a href="/unit/view/{1}">{3} #{2}</a>\'s has been deleted.</div>'.format(
                             lease_start,
                             unit.id,
                             unit_label,
                             property_name
                             )
                  )
     
     recycleId = Recycle.create("Lease starting from {0} deleted from {1} #{2}".format(lease_start, property_name, unit_label))
     lease.deleted = recycleId
     meta.Session.commit()
     session.save()