Commit 772d8fed authored by Jérome Perrin's avatar Jérome Perrin

configurator_standard: use specific sale and purchase business processes

Using different business process is more flexible, it allows to configure
different to build at different time, to generate different accounting etc.

This introduce two different business processes and also modernize the configuration to:
 - generate accounting only for the supplier in sales
 - generate accounting only for the client in purchases
 - generate accounting using income/expense accounts defined on supplies
 - generate accounting without analytics (project, function) only for
   income/expense accounts

and to fix an "infinite loop" with tax business link, it had the same
predecessor and successor
parent a5581cd5
configuration_save = context.restrictedTraverse(configuration_save_url) configuration_save = context.restrictedTraverse(configuration_save_url)
# business processes
configuration_save.addConfigurationItem("Business Process Configurator Item", configuration_save.addConfigurationItem("Business Process Configurator Item",
title="Default Trade Business Process" , title="Default Trade Business Process" ,
configuration_spreadsheet_data = getattr(context, "standard_business_process.ods").data, configuration_spreadsheet_data = getattr(context, "standard_business_process.ods").data,
reference="default_erp5_business_process") reference="default_erp5_business_process")
configuration_save.addConfigurationItem("Business Process Configurator Item",
title="Default Sales Business Process" ,
configuration_spreadsheet_data = getattr(context, "standard_sale_business_process.ods").data,
reference="default_erp5_sale_business_process")
configuration_save.addConfigurationItem("Business Process Configurator Item",
title="Default Purchase Business Process" ,
configuration_spreadsheet_data = getattr(context, "standard_purchase_business_process.ods").data,
reference="default_erp5_purchase_business_process")
# setup Sale Trade Condition # setup Sale Trade Condition
configuration_save.addConfigurationItem("Sale Trade Condition Configurator Item", configuration_save.addConfigurationItem("Sale Trade Condition Configurator Item",
title="General Sale Trade Condition", title="General Sale Trade Condition",
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>standard_purchase_business_process.ods</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/vnd.oasis.opendocument.spreadsheet</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>standard_sale_business_process.ods</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/vnd.oasis.opendocument.spreadsheet</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -618,11 +618,18 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin): ...@@ -618,11 +618,18 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin):
business_process_list = \ business_process_list = \
self.getBusinessConfigurationObjectList(business_configuration, self.getBusinessConfigurationObjectList(business_configuration,
'Business Process') 'Business Process')
self.assertEqual(len(business_process_list), 1) self.assertEqual(len(business_process_list), 3)
self.assertEqual(
["default_erp5_business_process",
"default_erp5_purchase_business_process",
"default_erp5_sale_business_process", ],
sorted([bp.getReference() for bp in business_process_list])
)
business_process = business_process_list[0] # Check in detail default_erp5_business_process, other business processes we'll only
self.assertEqual("default_erp5_business_process", # test they work in high level simulation scenario tests.
business_process.getReference()) business_process, = [bp for bp in business_process_list if bp.getReference() == 'default_erp5_business_process']
self.assertEqual("Default Trade Business Process", self.assertEqual("Default Trade Business Process",
business_process.getTitle()) business_process.getTitle())
...@@ -792,14 +799,12 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin): ...@@ -792,14 +799,12 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin):
self.assertEqual(None, sale_trade_condition.getExpirationDate()) self.assertEqual(None, sale_trade_condition.getExpirationDate())
# Check relation with Business Process # Check relation with Business Process
business_process_list = \ self.assertIn(
self.getBusinessConfigurationObjectList(business_configuration, sale_trade_condition.getSpecialiseValue(),
'Business Process') self.getBusinessConfigurationObjectList(business_configuration, 'Business Process'))
self.assertEqual(len(business_process_list), 1) self.assertEqual(
sale_trade_condition.getSpecialiseReference(),
business_process = business_process_list[0] 'default_erp5_sale_business_process')
self.assertEqual(business_process,
sale_trade_condition.getSpecialiseValue())
# Check relation with Organisation # Check relation with Organisation
organisation_list = \ organisation_list = \
...@@ -841,14 +846,12 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin): ...@@ -841,14 +846,12 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin):
self.assertEqual(None, purchase_trade_condition.getExpirationDate()) self.assertEqual(None, purchase_trade_condition.getExpirationDate())
# Check relation with Business Process # Check relation with Business Process
business_process_list = \ self.assertIn(
self.getBusinessConfigurationObjectList(business_configuration, purchase_trade_condition.getSpecialiseValue(),
'Business Process') self.getBusinessConfigurationObjectList(business_configuration, 'Business Process'))
self.assertEqual(len(business_process_list), 1) self.assertEqual(
purchase_trade_condition.getSpecialiseReference(),
business_process = business_process_list[0] 'default_erp5_purchase_business_process')
self.assertEqual(business_process,
purchase_trade_condition.getSpecialiseValue())
# Check relation with Organisation # Check relation with Organisation
organisation_list = \ organisation_list = \
......
  • @jerome when @Daetalus do osoe tutorial in a instance configurated by this configurator

    he found that after add a invoice line in purchase invoice transaction:

    Screenshot_2021-02-16_at_17.59.41

    only one payable accounting transaction line is generated.

    according to @Yanni , it should have one payable and one receivable accounting transaction line

    The problem seems because account_module/receivable is not set to Accounting Debit at standard_purchase_business_process.ods

    Screenshot_2021-02-16_at_17.00.54

    can you pls check it ?

  • Oh thanks, it really looks like this case is missing. I'll check this during this week and let you know.

    The expense account for purchase invoices is supposed to be taken from the supply lines first (for example, on product or service "A", we choose the account from the "Purchase" tab), but if it's not defined on supply lines, there's supposed to have a default account configured on the trade model path, but as we can see on this spreadsheet it's not.

    Sales seems to have the same problem.

  • according to @Yanni , it should have one payable and one receivable accounting transaction line

    You should double check this, that's not correct. I saw this new published screenshot, that should not be like this: https://www.erp5.com/image_module/13249

    I don't know a good introduction in english, maybe https://www.double-entry-bookkeeping.com/accounts-payable/what-is-accounts-payable/ is not bad, but it's a bit simplified because there is no tax.

    This OSOE tutorial was correct, the accounts from this screenshot are correct and they include tax. The accounts are correct, but the amounts are strange, I this 750 should be the price before tax, so with a 20% tax, it should be:

    Account Debit Credit
    Purchase 750
    Refundable VAT 150
    Supplier 900

    That tutorial also does not explain how to configure trade model lines for tax.

    Also, this new feature is interesting, if you want to document it in OSOE it would be good. The idea is that instead of generating on the default Purchase account, we can configure on the product or service which account should be used, by selecting the account on the "Purchase" tab of the product or service. This is useful, because it can generate different accounting depending on the product. For example if we are a company which purchases books and computers, we can create two purchase accounts, one for Books Purchase one for Computer Purchase and on each books product set the account to be books purchase and on computer products set the account to be computer purchase, then accounting is automatically generated on the corresponding accounts.

    I'll keep looking at this to fix the issue so that it works even when no account is set on "Purchase" tab, but I wanted to point out that "one payable and one receivable" is not really correct and that this is now a more powerful feature.

  • this test is a full scenario with accounts configured on the products

  • @jerome @xiaowu.zhang I think xiaowu misunderstood me. If it is a sales, then the accounting lines should generate at least two lines: "Account receivable" and "Sales". If it is a purchase, then the accounting lines should generate at least two lines: "Account payable" and "Purchase". (This is the case without considering tax, if there's tax applicated, then there should be three lines generated for each case.)

    @jerome

    This OSOE tutorial was correct, the accounts from this screenshot are correct and they include tax.

    Yes, the original OSOE is correct. But I don't understand why the "General purchase condition" generated by default from the configurator does not define tax in the trade model lines, so I guess if the purchase that applicated this trade condition generates only two lines is understandable, but surely should not be one line. so my original questions were:

    1. why it generates only one accounting line?
    2. why the "general purchase trade condition" generated by default from the erp5 standard configurator does not define tax in the trade model line as it is supposed to be?
  • Thanks @Yanni , here's my answers:

    1. It generates only one line because of a bug. The "recommended" way would be when creating the product to choose on the purchase tab of the product the account to use as "Purchase" (this works, but OSOE tutorial does not do this). If we don't define the account on purchase tab of the product, then default "Purchase" account should be selected - but this is broken. I'm fixing right now, I think it will be OK at the end of this week.
    2. As far as I know configurator never generated configuration for tax, because the tax ratio and the taxes are different in every country and this does not really target a specific country. So configuring the tax is "user configuration" that can be done by adding trade model line in trade condition.

    If you are updating OSOE tutorial and want to include more, we can discuss, but first I'm repairing this bug.

  • Thanks Jerome. The reason we are discovering this is that we are updating the OSOE tutorial to the new interface, JP would like we keep minimum change on the steps of the OSOE tutorial, so we try to keep everything same.

    1.It generates only one line because of a bug. The "recommended" way would be when creating the product to choose on the purchase tab of the product the account to use as "Purchase" (this works, but OSOE tutorial does not do this). If we don't define the account on purchase tab of the product, then default "Purchase" account should be selected - but this is broken. I'm fixing right now, I think it will be OK at the end of this week.

    So yes, we would like this to be fixed, so we don't have to add extra steps to the tutorial.

    2.As far as I know configurator never generated configuration for tax, because the tax ratio and the taxes are different in every country and this does not really target a specific country. So configuring the tax is "user configuration" that can be done by adding trade model line in trade condition.

    In original OSOE, there are no steps telling the reader to edit trade model lines in trade condition to add tax calculation, but the screenshot gives a tax line, I guess maybe this step has to be added to the tutorial, otherwise, we only show a screenshot with two accounting lines.

  • My theory is that the accounting lines might have been created by hand, the amount are 603 and 147, this does not seem an actual VAT rate.

  • it's very possible, when jingling made this, probably she made it by hand just to make a screenshot.

  • mentioned in commit bb30a9f1

    Toggle commit list
  • mentioned in merge request !1364 (merged)

    Toggle commit list
  • I'm suggesting a fix in !1364 (merged)

  • mentioned in commit 42c2a915

    Toggle commit list
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