From 0bf35c99a2b06809633dbf38fd5bc5621cba30cd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 17 Mar 2020 10:46:14 +0100 Subject: [PATCH] Bug 15272: Merge aqbooksellers addressX columns The physical address of a vendor is stored in 4 different DB columns: address1, address2, address3 and address4 The are concatenated and split for storage/display purpose. If you enter an address on more than 4 lines, the other lines are truncated: data loss To avoid such weird behavior, we could simplify the code and get more flexibility (like address as long as you wish) merging those 4 columns into 1, address Test plan: 0. Do not apply the patches 1. Create a vendor and enter more than 4 lines in the physical address, save => Notice that the lines has been stored in the 4 columns, and that you lost the end of the address 2. Apply the patches and execute the updatedatabase script 3. Edit the vendor's address => Notice that the address is displayed correctly 4. Add more lines, save => Notice that the extra lines are kept 5. Generate a ACQCLAIM or ACQORDER notice for this vendor => Confirm that the address is displayed correctly in the generated notice --- C4/Acquisition.pm | 2 +- acqui/uncertainprice.pl | 5 +--- acqui/updatesupplier.pl | 7 +----- api/v1/swagger/definitions/vendor.json | 25 ++----------------- .../prog/en/modules/acqui/supplier.tt | 6 ++--- .../prog/en/modules/acqui/uncertainprice.tt | 5 +--- t/db_dependent/Bookseller.t | 25 ++++--------------- t/db_dependent/Serials/Claims.t | 10 ++------ 8 files changed, 16 insertions(+), 69 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index e7f489fb29..54ac421898 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -410,7 +410,7 @@ sub GetBasketGroupAsCSV { notes => $order->{order_vendornote}, entrydate => $order->{entrydate}, booksellername => $bookseller->name, - bookselleraddress => $bookseller->address1, + bookselleraddress => $bookseller->address, booksellerpostal => $bookseller->postal, contractnumber => $contract->{contractnumber}, contractname => $contract->{contractname}, diff --git a/acqui/uncertainprice.pl b/acqui/uncertainprice.pl index bd98a71001..908b7f8412 100755 --- a/acqui/uncertainprice.pl +++ b/acqui/uncertainprice.pl @@ -103,10 +103,7 @@ $template->param( uncertainpriceorders => \@orders, booksellername => "".$bookseller->name, booksellerid => $bookseller->id, booksellerpostal =>$bookseller->postal, - bookselleraddress1 => $bookseller->address1, - bookselleraddress2 => $bookseller->address2, - bookselleraddress3 => $bookseller->address3, - bookselleraddress4 => $bookseller->address4, + bookselleraddress => $bookseller->address, booksellerphone =>$bookseller->phone, booksellernotes => $bookseller->notes, basketcount => $bookseller->baskets->count, diff --git a/acqui/updatesupplier.pl b/acqui/updatesupplier.pl index 5b077f171e..f222d32319 100755 --- a/acqui/updatesupplier.pl +++ b/acqui/updatesupplier.pl @@ -70,12 +70,7 @@ $data{'id'}=$booksellerid; $data{'name'}=$input->param('company'); $data{'postal'}=$input->param('company_postal'); -my $address=$input->param('physical'); -my @addresses=split('\n',$address); -$data{'address1'}=$addresses[0]; -$data{'address2'}=$addresses[1]; -$data{'address3'}=$addresses[2]; -$data{'address4'}=$addresses[3]; +$data{'address'}=$input->param('address'); $data{'phone'}=$input->param('company_phone'); $data{'accountnumber'}=$input->param('accountnumber'); $data{'fax'}=$input->param('company_fax'); diff --git a/api/v1/swagger/definitions/vendor.json b/api/v1/swagger/definitions/vendor.json index 71259b0924..ab74458d52 100644 --- a/api/v1/swagger/definitions/vendor.json +++ b/api/v1/swagger/definitions/vendor.json @@ -10,33 +10,12 @@ ], "description": "Vendor name" }, - "address1": { + "address": { "type": [ "string", "null" ], - "description": "Vendor physical address (line 1)" - }, - "address2": { - "type": [ - "string", - "null" - ], - "description": "Vendor physical address (line 2)" - }, - "address3": { - "type": [ - "string", - "null" - ], - "description": "Vendor physical address (line 3)" - }, - "address4": { - "type": [ - "string", - "null" - ], - "description": "Vendor physical address (line 4)" + "description": "Vendor physical address" }, "phone": { "type": [ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt index 88dede5a0c..94488b5b8b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt @@ -130,8 +130,8 @@ Required
  • -
  • -
  • +
  • +
  • @@ -285,7 +285,7 @@

    Vendor details

    Company name: [% name | html %]

    Postal address: [% postal | html %]

    -

    Physical address: [% address1 | html %][% address2 | html %][% address3 | html %][% address4 | html %]

    +

    Physical address: [% address | html %]

    Phone: [% phone | html %]

    Fax: [% fax | html %]

    [% IF ( url ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt index 940127c0ca..ed85dad3ad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/uncertainprice.tt @@ -29,10 +29,7 @@

    Contact information

    Address: [% booksellerpostal | html %] - [% bookselleraddress1 | html %] - [% bookselleraddress2 | html %] - [% bookselleraddress3 | html %] - [% bookselleraddress4 | html %] + [% bookselleraddress | html %]

    Phone: [% booksellerphone | html %] / Fax: diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t index c5d52841f2..39edfb9d34 100644 --- a/t/db_dependent/Bookseller.t +++ b/t/db_dependent/Bookseller.t @@ -54,10 +54,7 @@ my $curcode = $builder->build({ source => 'Currency' })->{currencycode}; my $count = Koha::Acquisition::Booksellers->search()->count(); my $sample_supplier1 = { name => 'Name1', - address1 => 'address1_1', - address2 => 'address1-2', - address3 => 'address1_2', - address4 => 'address1_2', + address => 'address', postal => 'postal1', phone => 'phone1', accountnumber => 'accountnumber1', @@ -74,10 +71,7 @@ my $sample_supplier1 = { }; my $sample_supplier2 = { name => 'Name2', - address1 => 'address1_2', - address2 => 'address2-2', - address3 => 'address3_2', - address4 => 'address4_2', + address => 'address2', postal => 'postal2', phone => 'phone2', accountnumber => 'accountnumber2', @@ -217,10 +211,7 @@ is( $bookseller1fromid->subscriptions->count, $sample_supplier2 = { id => $id_supplier2, name => 'Name2 modified', - address1 => 'address1_2 modified', - address2 => 'address2-2 modified', - address3 => 'address3_2 modified', - address4 => 'address4_2 modified', + address => 'address2 modified', postal => 'postal2 modified', phone => 'phone2 modified', accountnumber => 'accountnumber2 modified', @@ -247,10 +238,7 @@ is( $supplier2->name, 'Name2 modified', "supplier's name should have been modifi #Add 2 suppliers my $sample_supplier3 = { name => 'Name3', - address1 => 'address1_3', - address2 => 'address1-3', - address3 => 'address1_3', - address4 => 'address1_3', + address => 'address_3', postal => 'postal3', phone => 'phone3', accountnumber => 'accountnumber3', @@ -267,10 +255,7 @@ my $sample_supplier3 = { }; my $sample_supplier4 = { name => 'Name4', - address1 => 'address1_4', - address2 => 'address1-4', - address3 => 'address1_4', - address4 => 'address1_4', + address => 'address_4', postal => 'postal4', phone => 'phone4', accountnumber => 'accountnumber4', diff --git a/t/db_dependent/Serials/Claims.t b/t/db_dependent/Serials/Claims.t index 6458497219..82c3f56dc1 100644 --- a/t/db_dependent/Serials/Claims.t +++ b/t/db_dependent/Serials/Claims.t @@ -36,10 +36,7 @@ my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, ''); my $sample_supplier1 = { name => 'Name1', - address1 => 'address1_1', - address2 => 'address1-2', - address3 => 'address1_2', - address4 => 'address1_2', + address => 'address1', postal => 'postal1', phone => 'phone1', accountnumber => 'accountnumber1', @@ -56,10 +53,7 @@ my $sample_supplier1 = { }; my $sample_supplier2 = { name => 'Name2', - address1 => 'address1_2', - address2 => 'address2-2', - address3 => 'address3_2', - address4 => 'address4_2', + address => 'address2', postal => 'postal2', phone => 'phone2', accountnumber => 'accountnumber2', -- 2.20.1