From 9fc6691b16513979dbda6d1fc92fc9ae3695c095 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 5 Dec 2024 14:37:35 +0000 Subject: [PATCH] Bug 38010: Check for invoices before allowing vendor deletion Signed-off-by: Michaela Sieber Signed-off-by: Jonathan Druart --- Koha/Acquisition/Bookseller.pm | 15 +++++++++++++++ api/v1/swagger/definitions/vendor.yaml | 3 +++ api/v1/swagger/paths/acquisitions_vendors.yaml | 1 + .../prog/js/vue/components/Vendors/VendorList.vue | 8 ++++++-- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Koha/Acquisition/Bookseller.pm b/Koha/Acquisition/Bookseller.pm index 5f96b8c7a32..b845aba7370 100644 --- a/Koha/Acquisition/Bookseller.pm +++ b/Koha/Acquisition/Bookseller.pm @@ -187,6 +187,21 @@ sub issues { return Koha::Acquisition::Bookseller::Issues->_new_from_dbic($rs); } +=head3 invoices + + my $vendor = Koha::Acquisition::Booksellers->find( $id ); + my @invoices = $vendor->invoices(); + +Returns the list of invoices for the vendor + +=cut + +sub invoices { + my ($self) = @_; + my $invoices_rs = $self->_result->aqinvoices; + return Koha::Acquisition::Invoices->_new_from_dbic($invoices_rs); +} + =head3 to_api_mapping This method returns the mapping for representing a Koha::Acquisition::Bookseller object diff --git a/api/v1/swagger/definitions/vendor.yaml b/api/v1/swagger/definitions/vendor.yaml index e7f1f0d847f..163276fdbbf 100644 --- a/api/v1/swagger/definitions/vendor.yaml +++ b/api/v1/swagger/definitions/vendor.yaml @@ -136,6 +136,9 @@ properties: contracts: type: array description: List of contracts + invoices: + type: array + description: List of invoices additionalProperties: false required: - name \ No newline at end of file diff --git a/api/v1/swagger/paths/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml index 52463cd1493..1cefcf82dee 100644 --- a/api/v1/swagger/paths/acquisitions_vendors.yaml +++ b/api/v1/swagger/paths/acquisitions_vendors.yaml @@ -37,6 +37,7 @@ - aliases - baskets - subscriptions+count + - invoices collectionFormat: csv responses: "200": diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue index 36adb8c43b4..79e96d0d1cf 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue @@ -67,7 +67,9 @@ export default { searchTerm: null, tableOptions: { columns: this.getTableColumns(), - options: { embed: "aliases,baskets,subscriptions+count" }, + options: { + embed: "aliases,baskets,subscriptions+count,invoices", + }, url: () => this.tableURL(), add_filters: true, filters_options: { @@ -91,7 +93,9 @@ export default { (!row.baskets || row.baskets.length === 0) && (!row.subscriptions_count || - row.subscriptions_count === 0), + row.subscriptions_count === 0) && + (!row.invoices || + row.invoices.length === 0), }, }, { -- 2.34.1