From e3b22df781799c308f937774cb4a4d03e0ad44e0 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Mon, 20 Jan 2020 11:08:23 -0300
Subject: [PATCH] Bug 24461: Add to_api_mapping to
 Koha::Acquisition::BasketGroup

This patch adds to_api_mapping to the Koha::Acquistion::BasketGroup
class.

To test:
1. Compare the mapping with the one on the RFC
=> SUCCESS: They match
2. Sigh off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
 Koha/Acquisition/BasketGroup.pm     | 18 +++++++++++++++++-
 Koha/Schema/Result/Aqbasketgroup.pm |  4 ++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/Koha/Acquisition/BasketGroup.pm b/Koha/Acquisition/BasketGroup.pm
index 69a8738a67..74af77720d 100644
--- a/Koha/Acquisition/BasketGroup.pm
+++ b/Koha/Acquisition/BasketGroup.pm
@@ -27,10 +27,26 @@ Koha::Acquisition::BasketGroup - Koha Basket group Object class
 
 =head1 API
 
-=head2 Class Methods
+=head2 Class methods
+
+=head3 to_api_mapping
+
+This method returns the mapping for representing a Koha::Acquisition::BasketGroup object
+on the API.
 
 =cut
 
+sub to_api_mapping {
+    return {
+        id                => 'basket_group_id',
+        booksellerid      => 'vendor_id',
+        deliveryplace     => 'delivery_library_id',
+        freedeliveryplace => 'delivery_place',
+        deliverycomment   => 'delivery_note',
+        billingplace      => 'invoice_library_id',
+    };
+}
+
 =head2 Internal methods
 
 =head3 _type
diff --git a/Koha/Schema/Result/Aqbasketgroup.pm b/Koha/Schema/Result/Aqbasketgroup.pm
index da3a3997c2..2f5c112b32 100644
--- a/Koha/Schema/Result/Aqbasketgroup.pm
+++ b/Koha/Schema/Result/Aqbasketgroup.pm
@@ -138,10 +138,14 @@ __PACKAGE__->belongs_to(
 # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9cEWAMwcFKPYPEG1CaaD3w
 
+__PACKAGE__->add_columns(
+    '+closed' => { is_boolean => 1 }
+);
 
 sub koha_object_class {
     'Koha::Acquisition::BasketGroup';
 }
+
 sub koha_objects_class {
     'Koha::Acquisition::BasketGroups';
 }
-- 
2.20.1