From eefbd8b5aeb5ecd5678c4811245869c879929258 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Fri, 18 Oct 2024 14:49:51 +0000 Subject: [PATCH] Bug 38207: Update UI to use new field Signed-off-by: David Nind --- api/v1/swagger/definitions/vendor.yaml | 6 +++ .../vue/components/Vendors/VendorResource.vue | 43 +++++++++++++++++-- .../prog/js/vue/stores/vendors.js | 1 + 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/api/v1/swagger/definitions/vendor.yaml b/api/v1/swagger/definitions/vendor.yaml index 1a759b2ff9e..f0942c67027 100644 --- a/api/v1/swagger/definitions/vendor.yaml +++ b/api/v1/swagger/definitions/vendor.yaml @@ -121,6 +121,12 @@ properties: - "null" description: External id maxLength: 255 + payment_method: + type: + - string + - "null" + description: Payment method + maxLength: 255 aliases: type: array description: List of aliases diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorResource.vue index a87ce3a1b7d..d58900ee45f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorResource.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorResource.vue @@ -523,7 +523,7 @@ export default { { value: true, description: $__("Active") }, { value: false, description: $__("Inactive") }, ], - value: true, + defaultValue: true, }, { name: "list_currency", @@ -555,7 +555,7 @@ export default { { value: true, description: $__("Yes") }, { value: false, description: $__("No") }, ], - value: true, + defaultValue: true, hideIn: ["List"], }, { @@ -567,7 +567,7 @@ export default { { value: true, description: $__("Include tax") }, { value: false, description: $__("Don't include tax") }, ], - value: true, + defaultValue: true, hideIn: ["List"], }, { @@ -579,7 +579,16 @@ export default { { value: true, description: $__("Include tax") }, { value: false, description: $__("Don't include tax") }, ], - value: true, + defaultValue: true, + hideIn: ["List"], + }, + { + name: "payment_method", + group: $__("Ordering information"), + type: "select", + label: $__("Payment method"), + avCat: "av_vendor_payment_methods", + allowMultipleChoices: true, hideIn: ["List"], }, { @@ -794,6 +803,12 @@ export default { baseResource.setWarning(errors.join("
")); if (errors.length) return false; + if (vendor.payment_method && vendor.payment_method.length) { + vendor.payment_method = vendor.payment_method.join("|"); + } else { + vendor.payment_method = null; + } + if (vendorId) { baseResource.apiClient.update(vendor, vendorId).then( success => { @@ -832,6 +847,9 @@ export default { componentData.resource.value.discount = componentData.resource.value.discount.toFixed(1); } + componentData.resource.payment_method = resource.payment_method + ? resource.payment_method.split("|") + : []; } if (caller === "show") { let physicalAddress = ""; @@ -841,6 +859,23 @@ export default { } }); resource.physical = physicalAddress; + + if (resource.payment_method) { + const avs = + componentData.instancedResource.authorisedValues + .av_vendor_payment_methods; + const paymentMethods = resource.payment_method.split("|"); + let displayString = ""; + paymentMethods.forEach((method, i) => { + const isLastMethod = i + 1 === paymentMethods.length; + const avMatch = avs.find(av => av.value === method); + if (avMatch) { + displayString += avMatch.description; + if (!isLastMethod) displayString += ", "; + } + }); + resource.payment_method = displayString; + } } }; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/vendors.js b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/vendors.js index 9a67ec1cc47..3a17bf986fc 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/vendors.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/vendors.js @@ -17,6 +17,7 @@ export const useVendorStore = defineStore("vendors", () => { authorisedValues: { av_vendor_types: "VENDOR_TYPE", av_vendor_interface_types: "VENDOR_INTERFACE_TYPE", + av_vendor_payment_methods: "VENDOR_PAYMENT_METHOD", }, userPermissions: null, }); -- 2.50.1