LP#1145213: improvements to record merge
authorRogan Hamby <rogan.hamby@gmail.com>
Wed, 9 Aug 2017 12:50:41 +0000 (08:50 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 7 Nov 2017 20:51:40 +0000 (15:51 -0500)
This patch checks for suffix and prefix of call number before merging
assets and ensures that unused call number records are marked
deleted.

To test:

[0] Apply the patch.
[1] Attempt a record merge where each record has a volumes with the
    same call number label and owning library but different
    affixes. Verify that the volumes and their associated copies
    are not merged onto the same volume..
[2] Attempt a merge with records having matching volumes. Verify
    that the copies are moved to one volume and that the other is
    marked deleted.

Signed-off-by: Rogan Hamby <rhamby@equinoxinitiative.org>
Signed-off-by: Cesar Velez <cesar.velez@equinoxinitiative.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/src/sql/Pg/999.functions.global.sql

index a42bf69..dc72926 100644 (file)
@@ -1061,6 +1061,8 @@ BEGIN
                SELECT  INTO target_cn *
                  FROM  asset.call_number
                  WHERE label = source_cn.label
+            AND prefix = source_cn.prefix
+            AND suffix = source_cn.suffix
                        AND owning_lib = source_cn.owning_lib
                        AND record = target_record
                        AND NOT deleted;
@@ -1082,6 +1084,8 @@ BEGIN
                
                                moved_objects := moved_objects + 1;
                        END LOOP;
+        
+            UPDATE asset.call_number SET deleted = TRUE WHERE id = source_cn.id;
 
                -- ... if not ...
                ELSE