Bug 38010: Prevent vendor contacts from duplicating
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
027582efef
commit
29ca78bb48
|
|
@ -60,9 +60,27 @@ Returns the list of contacts for the vendor
|
|||
=cut
|
||||
|
||||
sub contacts {
|
||||
my ($self) = @_;
|
||||
my $contacts_rs = $self->_result->aqcontacts;
|
||||
return Koha::Acquisition::Bookseller::Contacts->_new_from_dbic($contacts_rs);
|
||||
my ( $self, $contacts ) = @_;
|
||||
|
||||
if ($contacts) {
|
||||
my $schema = $self->_result->result_source->schema;
|
||||
$schema->txn_do(
|
||||
sub {
|
||||
$self->contacts->delete;
|
||||
for my $contact (@$contacts) {
|
||||
Koha::Acquisition::Bookseller::Contact->new(
|
||||
{
|
||||
%$contact,
|
||||
booksellerid => $self->id,
|
||||
}
|
||||
)->store;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
my $rs = $self->_result->aqcontacts;
|
||||
return Koha::Acquisition::Bookseller::Contacts->_new_from_dbic($rs);
|
||||
}
|
||||
|
||||
=head3 contracts
|
||||
|
|
|
|||
|
|
@ -98,10 +98,7 @@ sub add {
|
|||
return try {
|
||||
$vendor_to_store->store;
|
||||
|
||||
foreach my $contact (@$contacts) {
|
||||
$contact->{booksellerid} = $vendor_to_store->id;
|
||||
Koha::Acquisition::Bookseller::Contact->new($contact)->store;
|
||||
}
|
||||
$vendor_to_store->contacts($contacts) if scalar($contacts) > 0;
|
||||
$vendor_to_store->aliases($aliases) if scalar($aliases) > 0;
|
||||
$vendor_to_store->interfaces($interfaces) if scalar($interfaces) > 0;
|
||||
|
||||
|
|
@ -142,10 +139,7 @@ sub update {
|
|||
$vendor->set_from_api($vendor_update);
|
||||
$vendor->store();
|
||||
|
||||
foreach my $contact (@$contacts) {
|
||||
$contact->{booksellerid} = $vendor_id;
|
||||
Koha::Acquisition::Bookseller::Contact->new($contact)->store;
|
||||
}
|
||||
$vendor->contacts($contacts) if scalar($contacts) > 0;
|
||||
$vendor->aliases($aliases) if scalar($aliases) > 0;
|
||||
$vendor->interfaces($interfaces) if scalar($interfaces) > 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@
|
|||
<div style="display: flex">
|
||||
<div>
|
||||
<fieldset class="rows">
|
||||
<legend>Acquisitions options</legend>
|
||||
<legend>{{ $__("Acquisitions options") }}</legend>
|
||||
<ol class="radio">
|
||||
<li>
|
||||
<label>
|
||||
|
|
@ -216,7 +216,7 @@
|
|||
</div>
|
||||
<div>
|
||||
<fieldset class="rows">
|
||||
<legend>Serials options</legend>
|
||||
<legend>{{ $__("Serials options") }}</legend>
|
||||
<ol class="radio">
|
||||
<li>
|
||||
<label>
|
||||
|
|
|
|||
Loading…
Reference in New Issue