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( ...@@ -31,11 +31,15 @@ current_payment = portal.accounting_module.newContent(
portal_type="Payment Transaction", portal_type="Payment Transaction",
causality=current_invoice.getRelativeUrl(), causality=current_invoice.getRelativeUrl(),
source_section=current_invoice.getSourceSection(), source_section=current_invoice.getSourceSection(),
source_project=current_invoice.getSourceProject(),
destination_section=current_invoice.getDestinationSection(),
destination_project=current_invoice.getDestinationProject(),
resource=current_invoice.getResource(), resource=current_invoice.getResource(),
price_currency=current_invoice.getResource(), price_currency=current_invoice.getResource(),
specialise=current_invoice.getSpecialise(), specialise=current_invoice.getSpecialise(),
destination_section=current_invoice.getDestinationSection(), destination_section=current_invoice.getDestinationSection(),
payment_mode=current_invoice.getPaymentMode(), payment_mode=current_invoice.getPaymentMode(),
ledger=current_invoice.getLedger(),
start_date=current_invoice.getStartDate(), start_date=current_invoice.getStartDate(),
stop_date=current_invoice.getStopDate(), stop_date=current_invoice.getStopDate(),
source_payment='%s/bank_account' % current_invoice.getSourceSection(), # the other place defnied: business process source_payment='%s/bank_account' % current_invoice.getSourceSection(), # the other place defnied: business process
......
...@@ -22,7 +22,20 @@ ...@@ -22,7 +22,20 @@
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSEntityCreatePaymentMixin(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): def sumReceivable(self, payment_transaction):
quantity = .0 quantity = .0
default_source_uid = self.portal.restrictedTraverse( default_source_uid = self.portal.restrictedTraverse(
...@@ -44,11 +57,14 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin): ...@@ -44,11 +57,14 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
expected_set = [ expected_set = [
'causality/%s' % invoice.getRelativeUrl(), 'causality/%s' % invoice.getRelativeUrl(),
'destination_section/%s' % invoice.getDestinationSection(), 'destination_section/%s' % invoice.getDestinationSection(),
'destination_project/%s' % invoice.getDestinationProject(),
'price_currency/%s' % invoice.getPriceCurrency(), 'price_currency/%s' % invoice.getPriceCurrency(),
'resource/%s' % invoice.getResource(), 'resource/%s' % invoice.getResource(),
'source_payment/organisation_module/slapos/bank_account', 'source_payment/organisation_module/slapos/bank_account',
'payment_mode/%s' % self.payment_mode, 'payment_mode/%s' % self.payment_mode,
'source_section/%s' % invoice.getSourceSection(), 'source_section/%s' % invoice.getSourceSection(),
#'source_project/%s' % invoice.getSourceProject(),
'ledger/%s' % invoice.getLedger(),
] ]
self.assertSameSet(expected_set, payment.getCategoryList()) self.assertSameSet(expected_set, payment.getCategoryList())
self.assertEqual(invoice.getStartDate(), payment.getStartDate()) self.assertEqual(invoice.getStartDate(), payment.getStartDate())
...@@ -87,12 +103,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin): ...@@ -87,12 +103,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
invoice.REQUEST.set(payment_tag, None) invoice.REQUEST.set(payment_tag, None)
def _test(self): def _test(self):
person = self.portal.person_module.template_member\ person, invoice = self.makeSaleInvoiceTransaction()
.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)
invoice.confirm() invoice.confirm()
invoice.stop() invoice.stop()
self.tic() self.tic()
...@@ -101,12 +112,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin): ...@@ -101,12 +112,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment, invoice) self.assertPayment(payment, invoice)
def _test_twice(self): def _test_twice(self):
person = self.portal.person_module.template_member\ person, invoice = self.makeSaleInvoiceTransaction()
.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)
invoice.confirm() invoice.confirm()
invoice.stop() invoice.stop()
self.tic() self.tic()
...@@ -120,12 +126,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin): ...@@ -120,12 +126,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment, invoice) self.assertPayment(payment, invoice)
def _test_twice_transaction(self): def _test_twice_transaction(self):
person = self.portal.person_module.template_member\ person, invoice = self.makeSaleInvoiceTransaction()
.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)
invoice.confirm() invoice.confirm()
invoice.stop() invoice.stop()
self.tic() self.tic()
...@@ -135,12 +136,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin): ...@@ -135,12 +136,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment, invoice) self.assertPayment(payment, invoice)
def _test_twice_indexation(self): def _test_twice_indexation(self):
person = self.portal.person_module.template_member\ person, invoice = self.makeSaleInvoiceTransaction()
.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)
invoice.confirm() invoice.confirm()
invoice.stop() invoice.stop()
self.tic() self.tic()
...@@ -155,15 +151,9 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin): ...@@ -155,15 +151,9 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.tic() self.tic()
self.assertPayment(payment, invoice) self.assertPayment(payment, invoice)
self.assertPayment(payment2, invoice) self.assertPayment(payment2, invoice)
def _test_cancelled_payment(self): def _test_cancelled_payment(self):
person = self.portal.person_module.template_member\ person, invoice = self.makeSaleInvoiceTransaction()
.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)
invoice.confirm() invoice.confirm()
invoice.stop() invoice.stop()
self.tic() self.tic()
...@@ -177,18 +167,10 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin): ...@@ -177,18 +167,10 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment, invoice) self.assertPayment(payment, invoice)
def _test_two_invoices(self): def _test_two_invoices(self):
person = self.portal.person_module.template_member\ person, invoice_1 = self.makeSaleInvoiceTransaction()
.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)
invoice_1.confirm() invoice_1.confirm()
invoice_1.stop() invoice_1.stop()
invoice_2 = self.portal.accounting_module.template_sale_invoice_transaction\ _, invoice_2 = self.makeSaleInvoiceTransaction(person=person)
.Base_createCloneDocument(batch_mode=1)
invoice_2.edit(destination_section=person.getRelativeUrl(),
payment_mode=self.payment_mode)
invoice_2.confirm() invoice_2.confirm()
invoice_2.stop() invoice_2.stop()
self.tic() self.tic()
...@@ -210,12 +192,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin): ...@@ -210,12 +192,7 @@ class TestSlapOSEntityCreatePaymentMixin(SlapOSTestCaseMixin):
self.assertPayment(payment_2, invoice_2) self.assertPayment(payment_2, invoice_2)
def _test_two_lines(self): def _test_two_lines(self):
person = self.portal.person_module.template_member\ person, invoice = self.makeSaleInvoiceTransaction()
.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)
self.tic() self.tic()
default_source_uid = self.portal.restrictedTraverse( default_source_uid = self.portal.restrictedTraverse(
'account_module/receivable').getUid() '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