From ed732a1d8d300acf5cb2e15d235558bb203e0e4f 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 --- Koha/Acquisition/Bookseller.pm | 16 ++++++++++++++++ api/v1/swagger/definitions/vendor.yaml | 3 +++ api/v1/swagger/paths/acquisitions_vendors.yaml | 1 + .../js/vue/components/Vendors/VendorList.vue | 9 ++++++--- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Koha/Acquisition/Bookseller.pm b/Koha/Acquisition/Bookseller.pm index f10c0ea4f52..da9c98c86b5 100644 --- a/Koha/Acquisition/Bookseller.pm +++ b/Koha/Acquisition/Bookseller.pm @@ -189,6 +189,22 @@ 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 0724ea69214..007b24c8ba7 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 diff --git a/api/v1/swagger/paths/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml index 4577db62dc7..9f9380fdcb3 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 3c69a618e96..7d3c30ba3ef 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 @@ -14,7 +14,6 @@ v-bind="tableOptions" @edit="goToResourceEdit" @delete="doResourceDelete" - @select="doSelect" @receive="doReceive" > @@ -69,7 +68,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: { @@ -93,7 +94,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.39.3 (Apple Git-146)