Business Rules for Address Handling

From OpenPetra Wiki
Jump to navigation Jump to search

This page lists the Business Rules that exist for the handling of Addresses in OpenPetra.

Address Got Added / Got Changed

  • If a Location got added: make sure that Location 0 is no longer mapped to the Partner
    • Solution:
      • This is done silently in Method TPPartnerAddressAggregate.MakeSureLocation0IsNotPresent.
  • For FAMILY Partners: if a Location got added give option to apply to all family members
    • Solution:
      • Ask question when saving, showing address data of the affected address
      • If user wants to add it to all family members, set field 'UserAnswer' to 'YES' in the corresponding record in Typed DataTable AddressAddedOrChangedPromotion
      • Adding of addresses to Family Members is done in TPPartnerAddressAggregate.PerformLocationFamilyMemberPropagationChecks
  • If a Location got added or changed: check if similar Location exists and give user the option to use the existing Location
    • Solution :
      • Ask question when saving
      • If user wants to use existing Location, change the LocationKey of the Location to the LocationKey of the existing Location
      • Functionality found in TPPartnerAddressAggregate.PerformLocationReUseChecks
  • If a Location is changed: if this Location is used by other Partners let the user select those Partners whose Location should be changed as well
    • Details: In case the user selects all Partners, the shared Location is simply updated. In case the user selects no Partners, a new Location is created and applied to the current partner only. In case the user selects some Partners, a new Location is created and applied to the current partner and all selected Partners.
      • Solution:
        • Bring up a selection dialog that shows all Partners with the same LocationKey when saving (data for that comes in the Typed DataTable ChangePromotionParameters, which is generated in function TPPartnerAddressAggregate.CheckLocationChange)
          • The records that got selected by the user will be put into the in Typed DataTable AddressAddedOrChangedPromotion (PartnerKeys of the selected partner get concatenated and are put in the field 'UserAnswer').
        • The changing of PartnerLocations / creation of new PartnerLocation for the Partner(s) is done in TPPartnerAddressAggregate.PerformLocationChangeChecks
  • For FAMILY Partners: if certain PartnerLocation details are changed give option to apply this change to some Persons
    • Details: Changed fields of the PartnerLocation record of the Family should get copied over to the PartnerLocation records of the selected Persons. The changes that were done should be displayed to the user (Field's Label [Name on Screen], old value, new value).
      • Solution:
        • Bring up a selection dialog that shows all Family members when saving (data for that comes in the Typed DataTable ChangePromotionParameters, which is generated in function TPPartnerAddressAggregate.CheckPartnerLocationChange)
          • The records that got selected by the user will be put into the AddressAddedOrChangedPromotion table, one for each selected person (specified in p_partner_key_n).
        • The changing of PartnerLocations for family members is done in TPPartnerAddressAggregate.PerformPartnerLocationChangeChecks
  • For FAMILY Partners: if DateGoodUntil in PartnerLocation has changed silently apply this to all family members
    • Solution:
      • This is done in TPPartnerAddressAggregate.PromoteToFamilyMembersDateGoodUntilChange


Address Got Deleted

  • Find all extract records using this p_partner_location and set to p_location_key_i 0
    • Solution:
      • This is done in TPPartnerAddressAggregate.RemoveLocationFromExtracts
  • If the address is not in use by other Partners delete it from p_location
    • Solution:
      • This is done in TPPartnerAddressAggregate.SubmitChanges (look for comment 'Handle deletion of Location row: delete it only if no other PartnerLocation is referencing it')
  • Assign location 0 to the p_partner_location record if the last p_partner_location record is about to being deleted
    • Solution:
      • This is done in TPPartnerAddressAggregate.SubmitChanges (look for comment Undelete' DataRow and make it point to Location 0')