def rights_per_share(self, cursor, uid,
         nshares, firstDate, lastDate,
         context=None):
     rights = RightsPerShare(mdbpool.get_db())
     return list(int(i) for i in rights.rightsPerShare(nshares,
             isodate(firstDate),
             isodate(lastDate)
             ))
 def setup_rights_per_share(self, cursor, uid,
         nshares, firstDate, data,
         context=None):
     rightsPerShare = RightsPerShare(mdbpool.get_db())
     rightsPerShare.updateRightsPerShare(nshares, isodate(firstDate), data)
     remainders = RemainderProvider(self, cursor, uid, context)
     lastDate = isodate(firstDate) + datetime.timedelta(days=(len(data)+24)%25)
     remainders.updateRemainders([
         (nshares, isodate(firstDate), 0),
         (nshares, lastDate, 0),
         ])
    def trace_rigths_compilation(self, cursor, uid,
            member, start, stop, fare, period,
            context=None):
        """
            Helper function to show data related to computation of available
            rights.
        """
        print "Dropping results for", member, start, stop, fare, period

        investment = InvestmentProvider(self, cursor, uid, context)
        memberActiveShares = MemberSharesCurve(investment)
        rightsPerShare = RightsPerShare(mdbpool.get_db())
        remainders = RemainderProvider(self, cursor, uid, context)

        generatedRights = MemberRightsCurve(
            activeShares=memberActiveShares,
            rightsPerShare=rightsPerShare,
            remainders=remainders,
            eager=True,
            )
        rightsUsage = MemberRightsUsage(mdbpool.get_db())
        holidays = HolidaysProvider(self, cursor, uid, context)
        farePeriod = FarePeriodCurve(holidays)

        print 'remainders', remainders.lastRemainders()
        print 'investment', investment.effectiveInvestments(
            start=isodate(start),
            end=isodate(stop),
            member=member)
        print 'active', memberActiveShares.hourly(
            isodate(start),
            isodate(stop),
            member)
        for nshares in set(memberActiveShares.hourly(
            isodate(start),
            isodate(stop),
            member)):
            print 'rightsPerShare', nshares, rightsPerShare.rightsPerShare(nshares,
                isodate(start),
                isodate(stop),
                )
        print 'rights', generatedRights.rights_kwh(member,
            isodate(start),
            isodate(stop),
            )

        print 'periodmask', farePeriod.periodMask(
            fare, period,
            isodate(start),
            isodate(stop),
            )