本文整理汇总了Python中stoqlib.domain.payment.payment.Payment类的典型用法代码示例。如果您正苦于以下问题:Python Payment类的具体用法?Python Payment怎么用?Python Payment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Payment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: on_confirm
def on_confirm(self):
self.model.base_value = self.model.value
facet = self.person.read()
if facet and facet is not ValueUnset:
setattr(self.model.group,
self.person_attribute,
facet.person)
self.model.attachment = self.fields['attachment'].attachment
# We can only change the identifier if the object is branch new (not edit_mode). If the
# object is being edited and the identifier is not temporary, it has already being synced
# with the destination branch and the identifier should no longer change.
# XXX: We can probably remove the temporary identifiers now that we have the station_id as
# part of the key in the identifiable domain.
other_branch = self._is_for_another_branch()
if other_branch and not self.edit_mode:
self.model.identifier = Payment.get_temporary_identifier(self.store)
self.store.add(self.model.group)
self.store.add(self.model)
if self.repeat.get_selected() != _ONCE:
Payment.create_repeated(self.store, self.model,
self.repeat.get_selected(),
self.model.due_date.date(),
self.end_date.get_date(),
temporary_identifiers=other_branch)
开发者ID:hackedbellini,项目名称:stoq,代码行数:28,代码来源:paymenteditor.py
示例2: _create_payment
def _create_payment(self):
group = PaymentGroup()
group.payer = self.client.person
method = PaymentMethod.get_by_name(self.store, u'credit')
branch = api.get_current_branch(self.store)
if self.model.value < 0:
payment_type = Payment.TYPE_IN
else:
payment_type = Payment.TYPE_OUT
# Set status to PENDING now, to avoid calling set_pending on
# on_confirm for payments that shoud not have its status changed.
payment = Payment(open_date=localtoday(),
branch=branch,
status=Payment.STATUS_PENDING,
description=self.model.description,
value=abs(self.model.value),
base_value=abs(self.model.value),
due_date=localtoday(),
method=method,
group=group,
till=None,
category=None,
payment_type=payment_type,
bill_received=False)
payment.pay()
return payment
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:30,代码来源:crediteditor.py
示例3: testGetOpenDateString
def testGetOpenDateString(self):
method = PaymentMethod.get_by_name(self.store, u'check')
payment = Payment(value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
method=method,
group=None,
till=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
self.assertNotEqual(payment.get_open_date_string(), u"")
开发者ID:leandrorchaves,项目名称:stoq,代码行数:12,代码来源:test_payment.py
示例4: test_get_penalty
def test_get_penalty(self):
method = PaymentMethod.get_by_name(self.store, u"check")
payment = Payment(
value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
method=method,
group=None,
till=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store,
)
for day, expected_value in [(0, 0), (-1, 0), (-30, 0), (30, 0)]:
payment.due_date = self._get_relative_day(day)
self.assertEqual(payment.get_penalty(), currency(expected_value))
method.penalty = Decimal(20)
for day, expected_value in [(0, 0), (-1, 20), (-30, 20), (30, 0)]:
payment.due_date = self._get_relative_day(day)
self.assertEqual(payment.get_penalty(), currency(expected_value))
due_date = self._get_relative_day(-15)
paid_date = self._get_relative_day(-5)
payment.due_date = payment.open_date = due_date
self.assertEqual(payment.get_penalty(paid_date.date()), currency(20))
self.assertEqual(payment.get_penalty(due_date.date()), currency(0))
for day in (18, -18):
paid_date = self._get_relative_day(day)
self.assertRaises(ValueError, payment.get_penalty, paid_date.date())
开发者ID:,项目名称:,代码行数:33,代码来源:
示例5: test_create_repeated_with_temporary_identifier
def test_create_repeated_with_temporary_identifier(self):
payment = self.create_payment()
payment.description = u'temporary'
payments = Payment.create_repeated(self.store, payment,
INTERVALTYPE_MONTH,
localdate(2012, 1, 1).date(),
localdate(2012, 3, 1).date(),
temporary_identifiers=True)
(self.assertTrue(p.identifier < 0) for p in payments)
开发者ID:hackedbellini,项目名称:stoq,代码行数:9,代码来源:test_payment.py
示例6: on_confirm
def on_confirm(self):
self.model.base_value = self.model.value
facet = self.person.read()
if facet and facet is not ValueUnset:
setattr(self.model.group,
self.person_attribute,
facet.person)
self.model.attachment = self.fields['attachment'].attachment
self.store.add(self.model.group)
self.store.add(self.model)
if self.repeat.get_selected() != _ONCE:
Payment.create_repeated(self.store, self.model,
self.repeat.get_selected(),
self.model.due_date.date(),
self.end_date.get_date())
开发者ID:Guillon88,项目名称:stoq,代码行数:18,代码来源:paymenteditor.py
示例7: _dialog_payment_details
def _dialog_payment_details(self, id):
from stoqlib.domain.payment.payment import Payment
store = api.new_store()
payment = Payment.get(int(id), store)
dialog_class = get_dialog_for_payment(payment)
retval = run_dialog(dialog_class, self.app, store, payment)
if store.confirm(retval):
self.refresh()
store.close()
开发者ID:leandrorchaves,项目名称:stoq,代码行数:9,代码来源:webview.py
示例8: _create_return_payment
def _create_return_payment(self):
money = PaymentMethod.get_by_name(self.store, u'money')
description = _(u'Money returned for order %s') % (
self.purchase.identifier, )
value = currency(self.model.paid_value - self.model.received_value)
today = localtoday().date()
payment = Payment(open_date=today,
branch=self.purchase.branch,
description=description,
value=value,
base_value=value,
due_date=today,
method=money,
group=self.purchase.group,
category=None,
store=self.store,
payment_type=Payment.TYPE_IN)
payment.set_pending()
return payment
开发者ID:amaurihamasu,项目名称:stoq,代码行数:20,代码来源:purchasefinishwizard.py
示例9: on_confirm
def on_confirm(self):
self.model.base_value = self.model.value
person = self.person.get_selected_data()
if (person is not None and person is not ValueUnset and
# FIXME: PersonField should never let get_selected_data()
# return anything different from None and the model.
person != ""):
setattr(self.model.group,
self.person_attribute,
self.store.fetch(person.person))
self.model.attachment = self.fields['attachment'].attachment
self.store.add(self.model.group)
self.store.add(self.model)
if self.repeat.get_selected() != _ONCE:
Payment.create_repeated(self.store, self.model,
self.repeat.get_selected(),
self.model.due_date.date(),
self.end_date.get_date())
开发者ID:LeonamSilva,项目名称:stoq,代码行数:21,代码来源:paymenteditor.py
示例10: test_create_repeated_month
def test_create_repeated_month(self):
p = self.create_payment()
p.description = u"Rent"
p.category = self.create_payment_category()
with self.assertRaises(AssertionError):
Payment.create_repeated(
self.store, p, INTERVALTYPE_MONTH, localdate(2012, 1, 1).date(), localdate(2012, 1, 1).date()
)
payments = Payment.create_repeated(
self.store, p, INTERVALTYPE_MONTH, localdate(2012, 1, 1).date(), localdate(2012, 12, 31).date()
)
self.assertEquals(len(payments), 11)
self.assertEquals(p.due_date, localdatetime(2012, 1, 1))
self.assertEquals(p.description, u"1/12 Rent")
self.assertEquals(payments[0].due_date, localdatetime(2012, 2, 1))
self.assertEquals(payments[1].due_date, localdatetime(2012, 3, 1))
self.assertEquals(payments[10].due_date, localdatetime(2012, 12, 1))
self.assertEquals(payments[0].description, u"2/12 Rent")
self.assertEquals(payments[10].description, u"12/12 Rent")
开发者ID:,项目名称:,代码行数:21,代码来源:
示例11: test_get_days_late
def test_get_days_late(self):
method = PaymentMethod.get_by_name(self.store, u'check')
open_date = due_date = self._get_relative_day(-4)
payment = Payment(value=currency(100),
branch=self.create_branch(),
due_date=due_date,
open_date=open_date,
method=method,
group=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
payment.set_pending()
self.assertEqual(payment.get_days_late(), 4)
payment.due_date = self._get_relative_day(+4)
self.assertFalse(payment.get_days_late())
payment.pay()
self.assertEqual(payment.get_days_late(), 0)
开发者ID:Guillon88,项目名称:stoq,代码行数:18,代码来源:test_payment.py
示例12: test_is_paid
def test_is_paid(self):
method = PaymentMethod.get_by_name(self.store, u'check')
payment = Payment(value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
method=method,
group=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
self.failIf(payment.is_paid())
payment.set_pending()
self.failIf(payment.is_paid())
payment.pay()
self.failUnless(payment.is_paid())
开发者ID:Guillon88,项目名称:stoq,代码行数:15,代码来源:test_payment.py
示例13: test_cancel
def test_cancel(self):
method = PaymentMethod.get_by_name(self.store, u'check')
payment = Payment(value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
method=method,
group=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
payment.set_pending()
payment.pay()
payment.cancel(change_entry=payment)
self.assertEqual(payment.status, Payment.STATUS_CANCELLED)
开发者ID:Guillon88,项目名称:stoq,代码行数:14,代码来源:test_payment.py
示例14: testCreateRepeatedMonth
def testCreateRepeatedMonth(self):
p = self.create_payment()
p.description = u"Rent"
p.category = self.create_payment_category()
payments = Payment.create_repeated(
self.store, p, INTERVALTYPE_MONTH, datetime.date(2012, 1, 1), datetime.date(2012, 12, 31)
)
self.assertEquals(len(payments), 11)
self.assertEquals(p.due_date, datetime.datetime(2012, 1, 1))
self.assertEquals(p.description, u"1/12 Rent")
self.assertEquals(payments[0].due_date, datetime.datetime(2012, 2, 1))
self.assertEquals(payments[1].due_date, datetime.datetime(2012, 3, 1))
self.assertEquals(payments[10].due_date, datetime.datetime(2012, 12, 1))
self.assertEquals(payments[0].description, u"2/12 Rent")
self.assertEquals(payments[10].description, u"12/12 Rent")
开发者ID:romaia,项目名称:stoq,代码行数:17,代码来源:test_payment.py
示例15: test_get_paid_date_string
def test_get_paid_date_string(self):
method = PaymentMethod.get_by_name(self.store, u'check')
payment = Payment(value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
method=method,
group=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
today = localnow().strftime(u'%x')
self.assertFalse(payment.get_paid_date_string() == today)
payment.set_pending()
payment.pay()
self.assertTrue(payment.get_paid_date_string() == today)
开发者ID:hackedbellini,项目名称:stoq,代码行数:15,代码来源:test_payment.py
示例16: test_create_repeated_month
def test_create_repeated_month(self):
p = self.create_payment()
p.description = u'Rent'
p.category = self.create_payment_category()
payments = Payment.create_repeated(self.store, p,
INTERVALTYPE_MONTH,
localdate(2012, 1, 1).date(),
localdate(2012, 12, 31).date())
self.assertEquals(len(payments), 11)
self.assertEquals(p.due_date, localdatetime(2012, 1, 1))
self.assertEquals(p.description, u'1/12 Rent')
self.assertEquals(payments[0].due_date, localdatetime(2012, 2, 1))
self.assertEquals(payments[1].due_date, localdatetime(2012, 3, 1))
self.assertEquals(payments[10].due_date, localdatetime(2012, 12, 1))
self.assertEquals(payments[0].description, u'2/12 Rent')
self.assertEquals(payments[10].description, u'12/12 Rent')
开发者ID:rosalin,项目名称:stoq,代码行数:18,代码来源:test_payment.py
示例17: testCancel
def testCancel(self):
method = PaymentMethod.get_by_name(self.store, u"check")
payment = Payment(
value=currency(100),
branch=self.create_branch(),
due_date=datetime.datetime.now(),
method=method,
group=None,
till=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store,
)
payment.set_pending()
payment.pay()
payment.cancel()
self.assertEqual(payment.status, Payment.STATUS_CANCELLED)
开发者ID:romaia,项目名称:stoq,代码行数:17,代码来源:test_payment.py
示例18: test_get_paid_date_string
def test_get_paid_date_string(self):
method = PaymentMethod.get_by_name(self.store, u"check")
payment = Payment(
value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
method=method,
group=None,
till=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store,
)
today = localnow().strftime(u"%x")
self.failIf(payment.get_paid_date_string() == today)
payment.set_pending()
payment.pay()
self.failUnless(payment.get_paid_date_string() == today)
开发者ID:,项目名称:,代码行数:18,代码来源:
示例19: testGetInterest
def testGetInterest(self):
method = PaymentMethod.get_by_name(self.store, u'check')
payment = Payment(value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
open_date=localnow(),
method=method,
group=None,
till=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
for day, expected_value in [(0, 0),
(-1, 0),
(-30, 0),
(30, 0)]:
payment.due_date = self._get_relative_day(day)
self.assertEqual(payment.get_interest(), currency(expected_value))
method.daily_interest = Decimal(1)
for day, expected_value in [(0, 0),
(-1, 1),
(-30, 30),
(30, 0)]:
payment.due_date = self._get_relative_day(day)
self.assertEqual(payment.get_interest(), currency(expected_value))
due_date = self._get_relative_day(-15)
paid_date = self._get_relative_day(-5)
payment.due_date = payment.open_date = due_date
method.daily_interest = Decimal(2)
self.assertEqual(payment.get_interest(paid_date.date()), currency(20))
self.assertEqual(payment.get_interest(due_date.date()), currency(0))
for day in (18, -18):
paid_date = self._get_relative_day(day)
self.assertRaises(ValueError, payment.get_interest, paid_date.date())
开发者ID:leandrorchaves,项目名称:stoq,代码行数:39,代码来源:test_payment.py
示例20: test_is_cancelled
def test_is_cancelled(self):
method = PaymentMethod.get_by_name(self.store, u'check')
payment = Payment(value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
method=method,
group=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
self.failIf(payment.is_cancelled())
payment.set_pending()
self.failIf(payment.is_cancelled())
payment.pay()
self.failIf(payment.is_cancelled())
payment.cancel()
self.failUnless(payment.is_cancelled())
with self.assertRaises(StoqlibError):
payment.status = Payment.STATUS_CANCELLED
payment.cancel()
开发者ID:Guillon88,项目名称:stoq,代码行数:20,代码来源:test_payment.py
注:本文中的stoqlib.domain.payment.payment.Payment类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论