Exemple #1
0
 def fundsAreSufficientToCoverAssignment(self, subset):
     units_count = len(subset)
     # if account is admins or if the balance with some allowed debt (from BUSINESS in settings) is above potential expenses
     if self.app.account.id == settings.BUSINESS['platform_owner_account_id'] or (self.app.account.balance+Decimal(settings.BUSINESS['allow_debt']) >= Decimal(units_count*self.price) + Decimal(units_count*settings.BUSINESS['platform_commission'])):
         return True
     else:
         account = self.app.account
         notifyMoneyAdmin(account,2)
         return False
Exemple #2
0
 def fundsAreSufficientToCoverAssignment(self, subset):
     units_count = len(subset)
     # if account is admins or if the balance with some allowed debt (from BUSINESS in settings) is above potential expenses
     if self.app.account.id == settings.BUSINESS[
             'platform_owner_account_id'] or (
                 self.app.account.balance +
                 Decimal(settings.BUSINESS['allow_debt']) >=
                 Decimal(units_count * self.price) +
                 Decimal(units_count *
                         settings.BUSINESS['platform_commission'])):
         return True
     else:
         account = self.app.account
         notifyMoneyAdmin(account, 2)
         return False
Exemple #3
0
def receivePayment(sender, **kwargs):
    ipn_obj = sender
    if ipn_obj.payment_status == "Completed":
        if ipn_obj.mc_currency == "EUR":
            # Undertake some action depending upon `ipn_obj`.
            account = get_object_or_404(Account, pk = ipn_obj.custom)
            deposit = FundTransfer(to_account = account, amount = ipn_obj.mc_gross, description = "PayPal invoice: "+ipn_obj.invoice+' transaction: '+ipn_obj.txn_id)
            deposit.save()
            notifyMoneyAdmin(account,0)
            #TODO #ASK to whom? creator?
        else:
            #TODO #ASK ok to get this account?
            account = get_object_or_404(Account, pk = ipn_obj.custom)
            notifyMoneyAdmin(account,1)

            send_email = True
Exemple #4
0
    def save(self, *args, **kwargs):
        log.debug('unit '+str(self.pk)+' was saved, its status = '+str(self.status))
        # if the job is published, there are no 

        # if this unit is not new
        if self.pk is not None:
            orig = Unit.objects.get(pk=self.pk)
            # if the status of this unit is "Completed" and before it was different
            if orig.status != self.status and self.status == 'CD':
                published_units = Unit.objects.filter(job = self.job, published = True).exclude(pk = self.pk)
                # if all the published units completed notify admin of the account 
                #TODO - as we update status via API - admin might receive multiple emails even when not all judgements are fully completed.
                #TODO - make it computationally efficient
                if self.job.status == 'PB' and len([x for x in published_units.filter(status = 'NC') if not x.gold]) == 0 and published_units.filter(status = 'CD').count() > 0:
                    notifyMoneyAdmin(self.job.app.account,3)
        
        super(Unit, self).save(*args, **kwargs)
Exemple #5
0
def receivePayment(sender, **kwargs):
    ipn_obj = sender
    if ipn_obj.payment_status == "Completed":
        if ipn_obj.mc_currency == "EUR":
            # Undertake some action depending upon `ipn_obj`.
            account = get_object_or_404(Account, pk=ipn_obj.custom)
            deposit = FundTransfer(to_account=account,
                                   amount=ipn_obj.mc_gross,
                                   description="PayPal invoice: " +
                                   ipn_obj.invoice + ' transaction: ' +
                                   ipn_obj.txn_id)
            deposit.save()
            notifyMoneyAdmin(account, 0)
            #TODO #ASK to whom? creator?
        else:
            #TODO #ASK ok to get this account?
            account = get_object_or_404(Account, pk=ipn_obj.custom)
            notifyMoneyAdmin(account, 1)

            send_email = True
Exemple #6
0
    def save(self, *args, **kwargs):
        log.debug('unit ' + str(self.pk) + ' was saved, its status = ' +
                  str(self.status))
        # if the job is published, there are no

        # if this unit is not new
        if self.pk is not None:
            orig = Unit.objects.get(pk=self.pk)
            # if the status of this unit is "Completed" and before it was different
            if orig.status != self.status and self.status == 'CD':
                published_units = Unit.objects.filter(
                    job=self.job, published=True).exclude(pk=self.pk)
                # if all the published units completed notify admin of the account
                #TODO - as we update status via API - admin might receive multiple emails even when not all judgements are fully completed.
                #TODO - make it computationally efficient
                if self.job.status == 'PB' and len([
                        x for x in published_units.filter(status='NC')
                        if not x.gold
                ]) == 0 and published_units.filter(status='CD').count() > 0:
                    notifyMoneyAdmin(self.job.app.account, 3)

        super(Unit, self).save(*args, **kwargs)
Exemple #7
0
    def test_notifySU(self):
        self.user = User.objects.create(username='******', password='******', first_name="Stefano",
                                        email="*****@*****.**")
        self.account = Account.objects.create(title='test', creator=self.user, email='*****@*****.**')
        # self.user
        notifyMoneyAdmin(self.account, 2)
        notifyMoneyAdmin(self.account, 1)
        self.account = Account.objects.create(title='test', creator=self.user)

        notifyMoneyAdmin(self.account, 0, 1.0)
Exemple #8
0
    def test_notifySU(self):
        self.user = User.objects.create(username='******',
                                        password='******',
                                        first_name="Stefano",
                                        email="*****@*****.**")
        self.account = Account.objects.create(title='test',
                                              creator=self.user,
                                              email='*****@*****.**')
        # self.user
        notifyMoneyAdmin(self.account, 2)
        notifyMoneyAdmin(self.account, 1)
        self.account = Account.objects.create(title='test', creator=self.user)

        notifyMoneyAdmin(self.account, 0, 1.0)