Openbravo Issue Tracking System - Retail Modules
View Issue Details
0032252Retail ModulesWeb POSpublic2016-02-16 23:272016-11-02 09:56
mtaal 
AugustoMauch 
normalminorhave not tried
closedfixed 
5
 
RR16Q4 
mtaal
No
0032252: Store Server Data Segmentation and Sync for BP
See:
http://wiki.openbravo.com/wiki/Projects:Store_Server_BP_Data_Segmentation [^]
See description
No tags attached.
related to feature request 0033634 closed mtaal Functional flow of BP not covered in StoreServer. 
related to design defect 0033535RR16Q4 closed mtaal Creating BP from webpos should make the BP non-standard 
has duplicate defect 0032648 closed mtaal [STORESERVER] Segmentation in "Business Partner" window is not correct. 
has duplicate design defect 0033657RR16Q4 closed AugustoMauch BP Segmentation: only use the BP by server table in case a BP is used by multiple servers/stores 
related to defect 0033727 new AugustoMauch Improve the initialization of the tables related with business partner segmentation 
related to defect 0034188 closed StoreServer More tables should be taken into account in the business partner segmentation logic 
causes design defect 0033674 closed AugustoMauch Store Server BP Data Segmentation - Table obstsyn_server_bpartner must sync from Store Server to Central Server 
Issue History
2016-02-16 23:27mtaalNew Issue
2016-02-16 23:27mtaalAssigned To => mtaal
2016-02-16 23:27mtaalTriggers an Emergency Pack => No
2016-04-11 13:46mtaalRelationship addedhas duplicate 0032648
2016-05-22 20:51AugustoMauchStatusnew => scheduled
2016-05-22 20:52AugustoMauchAssigned Tomtaal => AugustoMauch
2016-05-22 20:52AugustoMauchStatusscheduled => resolved
2016-05-22 20:52AugustoMauchResolutionopen => fixed
2016-05-22 20:52AugustoMauchNote Added: 0086635
2016-05-22 20:52AugustoMauchNote Edited: 0086635bug_revision_view_page.php?bugnote_id=0086635#r12197
2016-05-22 20:53AugustoMauchNote Edited: 0086635bug_revision_view_page.php?bugnote_id=0086635#r12198
2016-05-22 20:55AugustoMauchNote Added: 0086636
2016-06-06 10:23mtaalNote Added: 0087018
2016-06-06 10:23mtaalStatusresolved => new
2016-06-06 10:23mtaalResolutionfixed => open
2016-06-06 10:24mtaalNote Edited: 0087018bug_revision_view_page.php?bugnote_id=0087018#r12322
2016-06-08 11:14hgbotCheckin
2016-06-08 11:14hgbotNote Added: 0087087
2016-06-08 11:14hgbotCheckin
2016-06-08 11:14hgbotNote Added: 0087088
2016-06-08 13:12hgbotCheckin
2016-06-08 13:12hgbotNote Added: 0087092
2016-06-08 18:06hgbotCheckin
2016-06-08 18:06hgbotNote Added: 0087101
2016-06-08 18:06hgbotStatusnew => resolved
2016-06-08 18:06hgbotResolutionopen => fixed
2016-06-08 18:06hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/c24bbe2a056e68cd75d409d25b7228337691d79f [^]
2016-06-09 09:12AugustoMauchNote Added: 0087109
2016-06-09 09:12AugustoMauchStatusresolved => new
2016-06-09 09:12AugustoMauchResolutionfixed => open
2016-06-09 17:21hgbotCheckin
2016-06-09 17:21hgbotNote Added: 0087140
2016-06-09 17:21hgbotCheckin
2016-06-09 17:21hgbotNote Added: 0087141
2016-06-09 17:21hgbotCheckin
2016-06-09 17:21hgbotNote Added: 0087142
2016-06-09 17:22AugustoMauchStatusnew => scheduled
2016-06-09 17:22AugustoMauchStatusscheduled => resolved
2016-06-09 17:22AugustoMauchResolutionopen => fixed
2016-06-13 16:53mtaalReview Assigned To => mtaal
2016-06-20 15:35mtaalNote Added: 0087678
2016-06-20 15:45mtaalNote Added: 0087680
2016-06-20 15:46mtaalStatusresolved => new
2016-06-20 15:46mtaalResolutionfixed => open
2016-06-22 11:06hgbotCheckin
2016-06-22 11:06hgbotNote Added: 0087784
2016-06-22 11:07hgbotCheckin
2016-06-22 11:07hgbotNote Added: 0087785
2016-06-22 11:09AugustoMauchNote Added: 0087786
2016-06-30 11:57mtaalTarget VersionRR16Q3 => RR16Q4
2016-08-10 12:21mtaalRelationship addedcauses 0033674
2016-08-10 12:21mtaalRelationship addedrelated to 0033634
2016-08-10 12:25mtaalRelationship addedrelated to 0033535
2016-08-15 12:16mtaalNote Added: 0089097
2016-08-17 09:19hgbotCheckin
2016-08-17 09:19hgbotNote Added: 0089167
2016-08-17 10:55hgbotCheckin
2016-08-17 10:55hgbotNote Added: 0089173
2016-08-17 10:56AugustoMauchNote Edited: 0089173bug_revision_view_page.php?bugnote_id=0089173#r12840
2016-08-17 11:03AugustoMauchRelationship addedrelated to 0033727
2016-08-22 15:32AugustoMauchRelationship addedhas duplicate 0033657
2016-09-05 11:47AugustoMauchStatusnew => scheduled
2016-09-05 11:47AugustoMauchStatusscheduled => resolved
2016-09-05 11:47AugustoMauchResolutionopen => fixed
2016-10-11 10:52mtaalNote Added: 0090524
2016-10-11 10:52mtaalStatusresolved => new
2016-10-11 10:52mtaalResolutionfixed => open
2016-10-11 15:16AugustoMauchRelationship addedrelated to 0034188
2016-10-11 15:16AugustoMauchStatusnew => scheduled
2016-10-11 15:16AugustoMauchStatusscheduled => resolved
2016-10-11 15:16AugustoMauchResolutionopen => fixed
2016-10-11 15:17AugustoMauchNote Added: 0090535
2016-11-01 23:37hgbotCheckin
2016-11-01 23:37hgbotNote Added: 0091043
2016-11-01 23:38mtaalNote Added: 0091044
2016-11-02 09:56AugustoMauchNote Added: 0091052
2016-11-02 09:56AugustoMauchStatusresolved => closed

Notes
(0086635)
AugustoMauch   
2016-05-22 20:52   
(edited on: 2016-05-22 20:53)
Changes done to a business partner will be synchronized to a store if any of these conditions are met:
- The business partner has been explicitely included in a store. The Business Partner by Server window stores the relation between business partners and stores.
- The business partner is NOT flagged as Standard Store Customer. The sales representatives and the business partners that are the default business partners of the organizations should not have that flag checked

(0086636)
AugustoMauch   
2016-05-22 20:55   
When a business partner is added to a store, the c_bpartner table, along with other tables related to it (these tables are defined in the Table Related with Business Partner window) are "touched" so that its relevant rows are synchronized to the store.

This event handler is the class responsible to touch the tables related with business partner: https://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/file/tip/src/org/openbravo/retail/storeserver/synchronization/eventhandler/TableRelatedWithBusinessPartnerEventHandler.java [^]
(0087018)
mtaal   
2016-06-06 10:23   
(edited on: 2016-06-06 10:24)
Comments:
- check the connection usage/closing in the new routers as the new routers seem to use DAL and DAL connection which are not closed
- the simple_customer column is not updated when new user/bp is created, additional event handlers are needed
- two warnings in the code related to not-used log-member

(0087087)
hgbot   
2016-06-08 11:14   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: 94848d2cd44f100a8d89ef50b133050e3bd6e72c
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Tue Jun 07 17:21:45 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/94848d2cd44f100a8d89ef50b133050e3bd6e72c [^]

Related with issue 32252: Improves logging, removes warning from routers

---
M src/org/openbravo/retail/storeserver/synchronization/router/BusinessPartnerLocationRouter.java
M src/org/openbravo/retail/storeserver/synchronization/router/LocationRouter.java
---
(0087088)
hgbot   
2016-06-08 11:14   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: 2713ab5f69993948044d4b0e952530430d031fd5
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Tue Jun 07 18:35:25 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/2713ab5f69993948044d4b0e952530430d031fd5 [^]

Related with issue 32252: Routers take into account Standard Customer flag

The Is Standard Store Customer flag will be checked for those business partners that are not standard customers (i.e. they are also sales representatives or the default business
partner of a store). When one of these business partners change, all the store servers should receive these changes. This was already taken into account in the dataset table wher
e clause, but not in the routers.

---
M src/org/openbravo/retail/storeserver/synchronization/router/BusinessPartnerLocationRouter.java
M src/org/openbravo/retail/storeserver/synchronization/router/BusinessPartnerRouter.java
M src/org/openbravo/retail/storeserver/synchronization/router/LocationRouter.java
---
(0087092)
hgbot   
2016-06-08 13:12   
Repository: erp/pmods/org.openbravo.replication.symmetricds
Changeset: c0b9b39f8e9c88d61501206b1a346dd1a8dc7f5c
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed Jun 08 13:09:57 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.replication.symmetricds/rev/c0b9b39f8e9c88d61501206b1a346dd1a8dc7f5c [^]

Related with issue 32252: Prevents leaving the DAL connection open

There was a risk of leaving DAL connections open if routers implementations used DAL but forgot to close the connection. This has now been prevented by committing and closing the connection in AbstractClientFilteredRouter (a superclass of all routers defined in OB) after invoking doRouteToNodes (which is implemented by router implementations).

---
M src/org/openbravo/replication/symmetricds/extensions/AbstractClientFilteredRouter.java
---
(0087101)
hgbot   
2016-06-08 18:06   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: c24bbe2a056e68cd75d409d25b7228337691d79f
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed Jun 08 18:04:13 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/c24bbe2a056e68cd75d409d25b7228337691d79f [^]

Fixes issue 32252: Adds event handler to keep Is Standard Customer flag updated

The value of the BusinessPartner.IsStandardCustomer flag will be false if one of these conditions are met:
- The business partner is a sales representative
- The business partner is used as the default business partner of a store (organization)
- The business partner is related to an OrganizationInfo

An event handler has been added to each one of these tables to update this flag automatically. The event handlers only set the flag to false and never back to true, because if a business partner has not been a standard customer at one point, it will remain like that from then on.

---
A src/org/openbravo/retail/storeserver/synchronization/eventhandler/BusinessPartnerEventHandlerForStandardCustomerFlag.java
A src/org/openbravo/retail/storeserver/synchronization/eventhandler/OrganizationEventHandlerForStandardCustomerFlag.java
A src/org/openbravo/retail/storeserver/synchronization/eventhandler/OrganizationInfoEventHandlerForStandardCustomerFlag.java
---
(0087109)
AugustoMauch   
2016-06-09 09:12   
When a 'Is Standard Customer' flag of a business partner is set to false, that business partner, along with its related tables, need to be synchronized to all servers.
(0087140)
hgbot   
2016-06-09 17:21   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: 4f0612e986ca7f8f52e02d87af9a855967c1d738
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Thu Jun 09 17:04:55 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/4f0612e986ca7f8f52e02d87af9a855967c1d738 [^]

Related with bug 32252: Change how the business partner router gets flag value

The Is Standard Customer flag of c_bpartner is used to route business partners: if its value is false the business partner will be sent to all store servers, otherwise it will only be sent to the stores the business partner belongs to.

The router used to take the flag value from the metadata, that is the value it had in the database when the trigger captured the change. This was a problem in an event handler that "touched" the c_bpartner tables and the related ones when the flag was updated from true to false. The tables were touched inside the eventhandler, which is executed before actually commiting the change to the database, and the wrong value (true) was being used in the router. This resulted in referencial integrity errors.

To prevent this, the router will no longer take the value from the metada but from the database itself. It requires an extra query, but it is done using an indexed column so the performance is hardly affected.

---
M src/org/openbravo/retail/storeserver/synchronization/router/BusinessPartnerRouter.java
---
(0087141)
hgbot   
2016-06-09 17:21   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: 9c221c39d9bb08f53ed13219a8e795d78193086d
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Thu Jun 09 17:17:54 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/9c221c39d9bb08f53ed13219a8e795d78193086d [^]

Related with bug 32252: Refactors logic to touch c_bpartner and related tables

The logic, which used to be in the BusinessPartnerPerStoreEventHandler has been moved to its own class (BusinessPartnerAndRelatedTablesSynchronizer) because it is going to be needed in other classes.

---
M src/org/openbravo/retail/storeserver/synchronization/eventhandler/BusinessPartnerPerStoreEventHandler.java
A src/org/openbravo/retail/storeserver/synchronization/process/BusinessPartnerAndRelatedTablesSynchronizer.java
---
(0087142)
hgbot   
2016-06-09 17:21   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: 74c4bf8b6a2446621be179afa34e9ce139a72dd4
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Thu Jun 09 17:19:15 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/74c4bf8b6a2446621be179afa34e9ce139a72dd4 [^]

Related with issue 32252: Touch c_bpartner tables if flag is set to false

Adds an event handler that will use the BusinessPartnerAndRelatedTablesSynchronizer class to touch the c_bpartner table and its related tables when the Is Standard Customer flag of c_bpartner is changed from false to true.

---
M src/org/openbravo/retail/storeserver/synchronization/eventhandler/BusinessPartnerEventHandlerForStandardCustomerFlag.java
---
(0087678)
mtaal   
2016-06-20 15:35   
Review comments:

#1
- add more tables of the standard retail solution to the related table window
- let more tables control if a BP is a non-standard BP
- See this spreadsheet for an overview:
https://docs.google.com/spreadsheets/d/1gSSuOjaDpVjiFI4_arvQH92Z17vJhB7d1U_fc1dwn0M/edit#gid=0 [^]

#2
- the code here seems to be copied, the two subsequent lines need to get a different state I guess:
https://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/c24bbe2a056e68cd75d409d25b7228337691d79f#l2.93 [^]

#3
- generalize the event handlers that set a BP to be non-standard, in a superclass and subclasses for each entity to check
(0087680)
mtaal   
2016-06-20 15:45   
#4
- the active column in servers by BP tab should as a default be set to Y

#5
- when a BP is created from webpos then the 'is standard store customer' column should be set to Y. Possibly using a customer hook in retail

#6
- should the client/org be explicitly set here? using the order organization for example:
https://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/file/tip/src/org/openbravo/retail/storeserver/synchronization/eventhandler/OrderEventHandler.java#l118 [^]

#7
- the code in the OrderEventHandler does not need to run if: 1) the current server is a store server, or 2) the BP is a non-standard BP
(0087784)
hgbot   
2016-06-22 11:06   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: d68bbb706a4085494e5a658ef7d24c034021abd0
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed Jun 22 10:18:08 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/d68bbb706a4085494e5a658ef7d24c034021abd0 [^]

Related with issue 32252: Retrieves properly the previous state in event handler

---
M src/org/openbravo/retail/storeserver/synchronization/eventhandler/OrganizationEventHandlerForStandardCustomerFlag.java
---
(0087785)
hgbot   
2016-06-22 11:07   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: 60eb421ee7849caafc339ebc13e4878f8237cbc0
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed Jun 22 11:04:54 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/60eb421ee7849caafc339ebc13e4878f8237cbc0 [^]

Related with issue 32252: Fixes some of the problems found in the code review

The default values in the Business Partners by Store subtab are now calculated problem. There was a javascript error because the business partner (which acts as parent field) field was not defined in that tab. Also the tab level of that tab has been fixed.

The OrderEventHandler event handler is not executed if:
- The server is a store server
- The business partner is a non standard customer (those are synched to all store servers, no need to add them to the business partner by store table)

The client and organization of the new record are taken from the order.

---
M src-db/database/sourcedata/AD_FIELD.xml
M src-db/database/sourcedata/AD_TAB.xml
M src/org/openbravo/retail/storeserver/synchronization/eventhandler/OrderEventHandler.java
---
(0087786)
AugustoMauch   
2016-06-22 11:09   
Code review items #1, #3 and #5 are pending to be fixed
(0089097)
mtaal   
2016-08-15 12:16   
#5 has been done, see issue 33535
(0089167)
hgbot   
2016-08-17 09:19   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: c67137c57a5211d4080683fe5ed1fa400997a683
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Mon Aug 15 11:35:44 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/c67137c57a5211d4080683fe5ed1fa400997a683 [^]

Related with issue 32252: Adds Default Store field to Business Partner

This field will be used in addition to the obstsyn_server_bpartner table to specify the stores where a business partner is a customer. Before this changeset all this info was stored in the obstsyn_server_bpartner, but given that most of the business partner will buy from only one store, it makes sense to include that info in the c_bpartner table itself.

---
M src-db/database/model/modifiedTables/C_BPARTNER.xml
M src-db/database/sourcedata/AD_COLUMN.xml
M src-db/database/sourcedata/AD_ELEMENT.xml
M src-db/database/sourcedata/AD_FIELD.xml
---
(0089173)
hgbot   
2016-08-17 10:55   
(edited on: 2016-08-17 10:56)
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: edacffe523c3efd267703d17784dd0494e0d1cd4
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Wed Aug 17 10:48:13 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/edacffe523c3efd267703d17784dd0494e0d1cd4 [^]

Related with issue 32252: Adds default store column to c_bpartner

Most business partners will buy only from one store. It will have better performance to include the default store in the c_bpartner location than having to create a new record for that business partner and that store in the obstsyn_server_bpartner. This change results not only in a big reduction in the volume on obstsyn_server_bpartner, but also on a big performance improvement in the queries related to business partner segmentation.

---
M src-db/database/sourcedata/AD_DATASET_TABLE.xml
M src/org/openbravo/retail/storeserver/synchronization/StoreBusinessPartnerLoaderHook.java
M src/org/openbravo/retail/storeserver/synchronization/eventhandler/OrderEventHandler.java
M src/org/openbravo/retail/storeserver/synchronization/router/BusinessPartnerLocationRouter.java
M src/org/openbravo/retail/storeserver/synchronization/router/BusinessPartnerRouter.java
M src/org/openbravo/retail/storeserver/synchronization/router/LocationRouter.java
A src/org/openbravo/retail/storeserver/synchronization/utils/BusinessPartnerSegmentationUtils.java
---

(0090524)
mtaal   
2016-10-11 10:52   
Point #1 is open to be done
(0090535)
AugustoMauch   
2016-10-11 15:17   
Code review points #1 and #3 will be addressed in issue https://issues.openbravo.com/view.php?id=34188 [^]
(0091043)
hgbot   
2016-11-01 23:37   
Repository: erp/pmods/org.openbravo.retail.storeserver.synchronization
Changeset: 817e856e0a8fd9942bbbde50a8189982059375f2
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Tue Nov 01 23:37:07 2016 +0100
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.storeserver.synchronization/rev/817e856e0a8fd9942bbbde50a8189982059375f2 [^]

Related to issue 32252: Store Server Data Segmentation and Sync for BP
Linking the BPartner to the store needs a OrderLoaderHook as the event handler
is not executing because the triggers are not enabled.

---
M src/org/openbravo/retail/storeserver/synchronization/eventhandler/OrderEventHandler.java
---
(0091044)
mtaal   
2016-11-01 23:38   
Previous changesets have been reviewed, last commit should be reviewed by separate developer
(0091052)
AugustoMauch   
2016-11-02 09:56   
Code reviewed and verified