예제 #1
0
파일: views.py 프로젝트: loudubewe/syndic
 def fillresponse(self, owner, begin_date, end_date):
     currentowner = Owner.objects.get(id=owner)
     currentowner.set_dates(begin_date, end_date)
     if self.getparam('SAVE') is None:
         dlg = self.create_custom(model=Payoff)
         dlg.item.supporting = self.RefundSupporting(currentowner)
         dlg.item.date = currentowner.default_date()
         dlg.params['supportings'] = ''
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 6)
         dlg.add_component(img)
         dlg.fill_from_model(1, 0, False)
         dlg.add_action(self.return_action(TITLE_OK, 'images/ok.png'),
                        params={"SAVE": "YES"})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         Payoff.multi_save([currentowner.id],
                           -1 * self.getparam('amount', 0.0),
                           self.getparam('mode', Payoff.MODE_CASH), '',
                           self.getparam('reference', ''),
                           self.getparam('bank_account', None),
                           self.getparam('date',
                                         currentowner.default_date()),
                           self.getparam('fee_bank',
                                         0.0), Payoff.REPARTITION_BYDATE)
예제 #2
0
def add_test_callfunds(simple=True, with_payoff=False):
    call1 = CallFunds.objects.create(date='2015-06-10', comment='uvw 987')
    CallDetail.objects.create(callfunds=call1,
                              type_call=0,
                              set_id=1,
                              price='250.00',
                              designation='set 1')
    CallDetail.objects.create(callfunds=call1,
                              type_call=0,
                              set_id=2,
                              price='25.00',
                              designation='set 2')
    call1.valid()  # => 5 6 7
    if not simple:
        call2 = CallFunds.objects.create(date='2015-07-14',
                                         comment='working...')
        CallDetail.objects.create(callfunds=call2,
                                  type_call=1,
                                  set_id=3,
                                  price='100.00',
                                  designation='set 3')
        call2.valid()  # => 9 10 11
    if with_payoff:
        pay1 = Payoff(supporting_id=4, date='2015-06-15', mode=0, amount=100.0)
        pay1.editor.before_save(None)
        pay1.save()
        pay2 = Payoff(supporting_id=7, date='2015-07-21', mode=0, amount=30.0)
        pay2.editor.before_save(None)
        pay2.save()
예제 #3
0
 def fill_confirm(self, transition, trans):
     withpayoff = self.getparam('withpayoff', True)
     if (transition != 'valid') or (self.item.bill_type == 0):
         XferTransition.fill_confirm(self, transition, trans)
         if transition == 'cancel':
             if self.trans_result is not None:
                 self.redirect_action(ActionsManage.get_action_url('invoice.Bill', 'Show', self), params={self.field_id: self.trans_result})
     elif self.getparam("CONFIRME") is None:
         self.fill_dlg_payoff(withpayoff)
     else:
         XferTransition.fill_confirm(self, transition, trans)
         if (self.item.bill_type != 0) and withpayoff:
             Payoff.multi_save((self.item.id,), self.getparam('amount', 0.0), self.getparam('mode', 0), self.getparam('payer'),
                               self.getparam('reference'), self.getparam('bank_account', 0), self.getparam('date_payoff'))
예제 #4
0
def _add_test_expenses(expense_account1, expense_account2, simple,
                       with_payoff):
    expense1 = Expense(date=convert_date('2015-05-07'),
                       comment='opq 666',
                       expensetype=0,
                       third_id=2)
    expense1.editor.before_save(None)
    expense1.save()
    ExpenseDetail.objects.create(expense=expense1,
                                 set_id=2,
                                 designation='set 2',
                                 expense_account=expense_account1,
                                 price='100')
    expense1.valid()
    if not simple:
        expense2 = Expense(date=convert_date('2015-08-28'),
                           comment='creation',
                           expensetype=0,
                           third_id=2)
        expense2.editor.before_save(None)
        expense2.save()
        ExpenseDetail.objects.create(expense=expense2,
                                     set_id=3,
                                     designation='set 1',
                                     expense_account=expense_account2,
                                     price='75')
        expense2.valid()
    if with_payoff:
        pay = Payoff(supporting_id=expense1.id,
                     date='2015-05-11',
                     mode=0,
                     amount=35.0)
        pay.editor.before_save(None)
        pay.save()
        pay = Payoff(supporting_id=expense2.id,
                     date='2015-08-30',
                     mode=0,
                     amount=75.0)
        pay.editor.before_save(None)
        pay.save()
예제 #5
0
def add_test_callfunds(simple=True, with_payoff=False):
    call1 = CallFunds.objects.create(date='2015-06-10', comment='uvw 987', type_call=0)
    CallDetail.objects.create(callfunds=call1, set_id=1, price='250.00', designation='set 1')
    CallDetail.objects.create(callfunds=call1, set_id=2, price='25.00', designation='set 2')
    call1.valid()  # => 5 6 7
    if not simple:
        call2 = CallFunds.objects.create(date='2015-07-14', comment='working...', type_call=1)
        CallDetail.objects.create(callfunds=call2, set_id=3, price='100.00', designation='set 3')
        call2.valid()  # => 9 10 11
    if with_payoff:
        pay = Payoff(supporting_id=4, date='2015-06-15', mode=0, amount=100.0)
        pay.editor.before_save(None)
        pay.save()
        pay = Payoff(supporting_id=7, date='2015-07-21', mode=0, amount=30.0)
        pay.editor.before_save(None)
        pay.save()
예제 #6
0
def add_test_expenses(simple=True, with_payoff=False):
    expense1 = Expense(date=convert_date('2015-05-07'), comment='opq 666', expensetype=0, third_id=2)
    expense1.editor.before_save(None)
    expense1.save()
    ExpenseDetail.objects.create(expense=expense1, set_id=2, designation='set 2', expense_account='604', price='100')
    expense1.valid()
    if not simple:
        expense2 = Expense(date=convert_date('2015-08-28'), comment='creation', expensetype=0, third_id=2)
        expense2.editor.before_save(None)
        expense2.save()
        ExpenseDetail.objects.create(expense=expense2, set_id=3, designation='set 1', expense_account='602', price='75')
        expense2.valid()
    if with_payoff:
        pay = Payoff(supporting_id=expense1.id, date='2015-05-11', mode=0, amount=35.0)
        pay.editor.before_save(None)
        pay.save()
        pay = Payoff(supporting_id=expense2.id, date='2015-08-30', mode=0, amount=75.0)
        pay.editor.before_save(None)
        pay.save()
예제 #7
0
 def fillresponse_multisave(self, supportings=(), amount=0.0,
                            mode=0, payer='', reference='',
                            bank_account=0, date=None):
     Payoff.multi_save(
         supportings, amount, mode, payer, reference, bank_account, date)
예제 #8
0
 def fillresponse(self):
     try:
         self.item.contains = ""
         self.item.payer = self.getparam(
             'first_name', '') + " " + self.getparam('last_name', '')
         self.item.amount = self.getparam('mc_gross', 0.0)
         try:
             self.item.date = datetime.strptime(
                 self.getparam("payment_date", '').replace('PDT', 'GMT'), '%H:%M:%S %b %d, %Y %Z')
             self.item.date += timedelta(hours=7)
         except:
             self.item.date = timezone.now()
         self.item.contains += "{[newline]}".join(
             ["%s = %s" % item for item in self.request.POST.items()])
         conf_res = self.confirm_paypal()
         if conf_res == 'VERIFIED':
             bank_account = None
             for payment_meth in PaymentMethod.objects.filter(paytype=2):
                 if payment_meth.get_items()[0] == self.getparam('receiver_email', ''):
                     bank_account = payment_meth.bank_account
             if bank_account is None:
                 raise LucteriosException(IMPORTANT, "No paypal account!")
             support = Supporting.objects.get(id=self.getparam('custom', 0))
             new_payoff = Payoff()
             new_payoff.supporting = support.get_final_child().support_validated(self.item.date)
             new_payoff.date = self.item.date
             new_payoff.amount = self.item.amount
             new_payoff.payer = self.item.payer
             new_payoff.mode = 2
             new_payoff.bank_account = bank_account
             new_payoff.reference = "PayPal " + self.getparam('txn_id', '')
             new_payoff.bank_fee = self.getparam('mc_fee', 0.0)
             new_payoff.save()
             self.item.status = 1
             self.success = True
         if conf_res == 'INVALID':
             self.item.contains += "{[newline]}--- INVALID ---{[newline]}"
         else:
             self.item.contains += "{[newline]}"
             if conf_res != 'VERIFIED':
                 self.item.contains += "NO VALID:"
             self.item.contains += conf_res.replace('\n', '{[newline]}')
     except Exception as err:
         logging.getLogger('diacamma.payoff').exception("ValidationPaymentPaypal")
         self.item.contains += "{[newline]}"
         self.item.contains += six.text_type(err)
     self.item.save()