Commit 7199efe4 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: set source/destination_project and ledger on created payment

parent 1bd7a349
......@@ -31,11 +31,15 @@ current_payment = portal.accounting_module.newContent(
portal_type="Payment Transaction",
causality=current_invoice.getRelativeUrl(),
source_section=current_invoice.getSourceSection(),
source_project=current_invoice.getSourceProject(),
destination_section=current_invoice.getDestinationSection(),
destination_project=current_invoice.getDestinationProject(),
resource=current_invoice.getResource(),
price_currency=current_invoice.getResource(),
specialise=current_invoice.getSpecialise(),
destination_section=current_invoice.getDestinationSection(),
payment_mode=current_invoice.getPaymentMode(),
ledger=current_invoice.getLedger(),
start_date=current_invoice.getStartDate(),
stop_date=current_invoice.getStopDate(),
source_payment='%s/bank_account' % current_invoice.getSourceSection(), # the other place defnied: business process
......
......@@ -22,7 +22,20 @@
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
def makeSaleInvoiceTransaction(self, person=None):
project = self.addProject()
if person is None:
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
invoice = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice.edit(destination_section_value=person,
destination_project_value=project,
ledger='automated',
payment_mode=self.payment_mode)
return person, invoice
def sumReceivable(self, payment_transaction):
quantity = .0
default_source_uid = self.portal.restrictedTraverse(
......@@ -44,11 +57,14 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
expected_set = [
'causality/%s' % invoice.getRelativeUrl(),
'destination_section/%s' % invoice.getDestinationSection(),
'destination_project/%s' % invoice.getDestinationProject(),
'price_currency/%s' % invoice.getPriceCurrency(),
'resource/%s' % invoice.getResource(),
'source_payment/organisation_module/slapos/bank_account',
'payment_mode/%s' % self.payment_mode,
'source_section/%s' % invoice.getSourceSection(),
#'source_project/%s' % invoice.getSourceProject(),
'ledger/%s' % invoice.getLedger(),
]
self.assertSameSet(expected_set, payment.getCategoryList())
self.assertEqual(invoice.getStartDate(), payment.getStartDate())
......@@ -87,12 +103,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
invoice.REQUEST.set(payment_tag, None)
def _test(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
invoice = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
person, invoice = self.makeSaleInvoiceTransaction()
invoice.confirm()
invoice.stop()
self.tic()
......@@ -101,12 +112,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment, invoice)
def _test_twice(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
invoice = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
person, invoice = self.makeSaleInvoiceTransaction()
invoice.confirm()
invoice.stop()
self.tic()
......@@ -120,12 +126,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment, invoice)
def _test_twice_transaction(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
invoice = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
person, invoice = self.makeSaleInvoiceTransaction()
invoice.confirm()
invoice.stop()
self.tic()
......@@ -135,12 +136,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment, invoice)
def _test_twice_indexation(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
invoice = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
person, invoice = self.makeSaleInvoiceTransaction()
invoice.confirm()
invoice.stop()
self.tic()
......@@ -155,15 +151,9 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.tic()
self.assertPayment(payment, invoice)
self.assertPayment(payment2, invoice)
def _test_cancelled_payment(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
invoice = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
person, invoice = self.makeSaleInvoiceTransaction()
invoice.confirm()
invoice.stop()
self.tic()
......@@ -177,18 +167,10 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment, invoice)
def _test_two_invoices(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
invoice_1 = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice_1.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
person, invoice_1 = self.makeSaleInvoiceTransaction()
invoice_1.confirm()
invoice_1.stop()
invoice_2 = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice_2.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
_, invoice_2 = self.makeSaleInvoiceTransaction(person=person)
invoice_2.confirm()
invoice_2.stop()
self.tic()
......@@ -210,12 +192,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment_2, invoice_2)
def _test_two_lines(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
invoice = self.portal.accounting_module.template_sale_invoice_transaction\
.Base_createCloneDocument(batch_mode=1)
invoice.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
person, invoice = self.makeSaleInvoiceTransaction()
self.tic()
default_source_uid = self.portal.restrictedTraverse(
'account_module/receivable').getUid()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment