mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix for deleting vendor contacts
This commit is contained in:
parent
6c02ee2c60
commit
9fe183f125
@ -85,12 +85,22 @@ class VendorRepository extends BaseRepository
|
||||
|
||||
$first = true;
|
||||
$vendorcontacts = isset($data['vendor_contact']) ? [$data['vendor_contact']] : $data['vendor_contacts'];
|
||||
$vendorcontactIds = [];
|
||||
|
||||
foreach ($vendorcontacts as $vendorcontact) {
|
||||
$vendorcontact = $vendor->addVendorContact($vendorcontact, $first);
|
||||
$vendorcontactIds[] = $vendorcontact->public_id;
|
||||
$first = false;
|
||||
}
|
||||
|
||||
if ( ! $vendor->wasRecentlyCreated) {
|
||||
foreach ($vendor->vendor_contacts as $contact) {
|
||||
if (!in_array($contact->public_id, $vendorcontactIds)) {
|
||||
$contact->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $vendor;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user