diff --git a/api/v1/swagger/definitions/vendor.yaml b/api/v1/swagger/definitions/vendor.yaml index a35fbb57a6..ddad6ca9ab 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 569f53647d..f97bf16c9d 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 @@ -458,7 +458,7 @@ export default { { value: true, description: $__("Active") }, { value: false, description: $__("Inactive") }, ], - value: true, + defaultValue: true, }, { name: "list_currency", @@ -490,7 +490,7 @@ export default { { value: true, description: $__("Yes") }, { value: false, description: $__("No") }, ], - value: true, + defaultValue: true, hideIn: ["List"], }, { @@ -502,7 +502,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"], }, { @@ -514,7 +523,7 @@ export default { { value: true, description: $__("Include tax") }, { value: false, description: $__("Don't include tax") }, ], - value: true, + defaultValue: true, hideIn: ["List"], }, { @@ -731,6 +740,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) { return baseResource.apiClient.update(vendor, vendorId).then( vendor => { @@ -769,6 +784,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 = ""; @@ -778,6 +796,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 9a67ec1cc4..3a17bf986f 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, });