7 use Test::More tests => 2;
14 use Koha::Acquisition::Order;
16 my $schema = Koha::Database->new()->schema();
17 $schema->storage->txn_begin();
19 my $dbh = C4::Context->dbh;
20 $dbh->{RaiseError} = 1;
22 my $query = CGI->new();
24 my $vendor = Koha::Acquisition::Bookseller->new({
26 address1 => 'vendor address',
31 my $budget_id = C4::Budgets::AddBudget({
32 budget_code => 'my_budget_code',
33 budget_name => 'My budget name',
35 my $budget = C4::Budgets::GetBudget( $budget_id );
37 my $csv_profile = Koha::CsvProfile->new({
38 profile => 'my user profile',
39 type => 'export_basket',
41 content => 'autor=biblio.author|title=biblio.title|quantity=aqorders.quantity',
45 $basketno = NewBasket($vendor->id, 1);
47 my $biblio = MARC::Record->new();
48 $biblio->append_fields(
49 MARC::Field->new( '100', ' ', ' ', a => 'King, Stephen' ),
50 MARC::Field->new( '245', ' ', ' ', a => 'Test Record' ),
52 my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
54 my $order = Koha::Acquisition::Order->new({
55 basketno => $basketno,
57 biblionumber => $biblionumber,
58 budget_id => $budget_id,
59 entrydate => '2016-01-02',
62 # Use user CSV profile
63 my $basket_csv1 = C4::Acquisition::GetBasketAsCSV($basketno, $query, $csv_profile->export_format_id);
64 is($basket_csv1, 'autor,title,quantity
65 "King, Stephen","Test Record",3
66 ', 'CSV should be generated with user profile');
68 # Use defautl template
69 my $basket_csv2 = C4::Acquisition::GetBasketAsCSV($basketno, $query);
70 is($basket_csv2, 'Contract name,Order number,Entry date,ISBN,Author,Title,Publication year,Publisher,Collection title,Note for vendor,Quantity,RRP,Delivery place,Billing place
72 "",' . $order->{ordernumber} . ',2016-01-02,,"King, Stephen","Test Record",,"","","",3,,"",""
74 ', 'CSV should be generated with default template');
76 $schema->storage->txn_rollback();