Esempio n. 1
0
	def purchaseCoupon(self, worker):
		# get a list of available coupons
		assignedcoupon = False
		coupons = Coupon.objects.filter(reward = self, status = 'AV')
		if coupons.count()>0 and worker.profile.personalAccount.balance >= self.cost_for_worker:
			#TODO - clear out who pays to whom and which amount
			transaction = FundTransfer(to_account = self.vendor.account, from_account = worker.profile.personalAccount, amount = self.cost_for_worker, description = 'reward '+self.title)
			transaction.save()

			assignedcoupon = coupons.all()[0]
			assignedcoupon.status = 'AC'
			assignedcoupon.account = worker.profile.personalAccount
			assignedcoupon.save()
		return assignedcoupon
Esempio n. 2
0
    def purchaseCoupon(self, worker):
        # get a list of available coupons
        assignedcoupon = False
        coupons = Coupon.objects.filter(reward=self, status='AV')
        if coupons.count(
        ) > 0 and worker.profile.personalAccount.balance >= self.cost_for_worker:
            #TODO - clear out who pays to whom and which amount
            transaction = FundTransfer(
                to_account=self.vendor.account,
                from_account=worker.profile.personalAccount,
                amount=self.cost_for_worker,
                description='reward ' + self.title)
            transaction.save()

            assignedcoupon = coupons.all()[0]
            assignedcoupon.status = 'AC'
            assignedcoupon.account = worker.profile.personalAccount
            assignedcoupon.save()
        return assignedcoupon
Esempio n. 3
0
    def save(self, *args, **kwargs):
        #if answer is new, task reward is greater than 0 and the worker and the requestor are different people
        if self.pk is None and self.unit.job.price>0 and self.score >= 0:

            # Worker gets money from Requestor
            fundtransfer = FundTransfer(to_account = self.worker.profile.personalAccount, from_account = self.unit.job.app.account, amount = self.unit.job.price, description = 'judgement for unit ['+str(self.unit.id)+']')
            fundtransfer.save()
            
            # Platform gets comission from Requestor
            platform_owner_account = Account.objects.get(pk = settings.BUSINESS['platform_owner_account_id'])
            commission = FundTransfer(to_account = platform_owner_account, from_account = self.unit.job.app.account, amount = Decimal(settings.BUSINESS['platform_commission'])*fundtransfer.amount, description = 'commission for judgement for unit ['+str(self.unit.id)+']')
            commission.save()
        super(Judgement, self).save(*args, **kwargs)
Esempio n. 4
0
    def save(self, *args, **kwargs):
        #if answer is new, task reward is greater than 0 and the worker and the requestor are different people
        if self.pk is None and self.unit.job.price > 0 and self.score >= 0:

            # Worker gets money from Requestor
            fundtransfer = FundTransfer(
                to_account=self.worker.profile.personalAccount,
                from_account=self.unit.job.app.account,
                amount=self.unit.job.price,
                description='judgement for unit [' + str(self.unit.id) + ']')
            fundtransfer.save()

            # Platform gets comission from Requestor
            platform_owner_account = Account.objects.get(
                pk=settings.BUSINESS['platform_owner_account_id'])
            commission = FundTransfer(
                to_account=platform_owner_account,
                from_account=self.unit.job.app.account,
                amount=Decimal(settings.BUSINESS['platform_commission']) *
                fundtransfer.amount,
                description='commission for judgement for unit [' +
                str(self.unit.id) + ']')
            commission.save()
        super(Judgement, self).save(*args, **kwargs)
Esempio n. 5
0
 def chargeOwner(self, amount, description):
     admin_account = Account.objects.get(pk = settings.BUSINESS['admin_account_id'])
     if self.user:
         log.debug('create a payment')
         payment = FundTransfer(from_account = self.user.profile.personalAccount, to_account = admin_account, amount = float(amount), description = description)
         payment.save()