|
Lines 38-44
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 38 |
my $logger = t::lib::Mocks::Logger->new(); |
38 |
my $logger = t::lib::Mocks::Logger->new(); |
| 39 |
|
39 |
|
| 40 |
subtest 'process_quote' => sub { |
40 |
subtest 'process_quote' => sub { |
| 41 |
plan tests => 6; |
41 |
plan tests => 7; |
| 42 |
|
42 |
|
| 43 |
$schema->storage->txn_begin; |
43 |
$schema->storage->txn_begin; |
| 44 |
|
44 |
|
|
Lines 742-747
subtest 'process_quote' => sub {
Link Here
|
| 742 |
$schema->storage->txn_rollback; |
742 |
$schema->storage->txn_rollback; |
| 743 |
}; |
743 |
}; |
| 744 |
|
744 |
|
|
|
745 |
# Test 7: Duplicate purchase order number validation |
| 746 |
subtest 'duplicate_purchase_order_validation' => sub { |
| 747 |
plan tests => 5; |
| 748 |
|
| 749 |
$schema->storage->txn_begin; |
| 750 |
|
| 751 |
# Create vendor EDI account with po_is_basketname set to true |
| 752 |
my $account = $builder->build( |
| 753 |
{ |
| 754 |
source => 'VendorEdiAccount', |
| 755 |
value => { |
| 756 |
description => 'test vendor duplicate po', |
| 757 |
transport => 'FILE', |
| 758 |
po_is_basketname => 1, |
| 759 |
}, |
| 760 |
} |
| 761 |
); |
| 762 |
|
| 763 |
# Create first basket with purchase order number "orders 23/1" (same as in QUOTES_SMALL.CEQ) |
| 764 |
my $first_basket = $builder->build( |
| 765 |
{ |
| 766 |
source => 'Aqbasket', |
| 767 |
value => { |
| 768 |
basketname => 'orders 23/1', |
| 769 |
booksellerid => $account->{vendor_id}, |
| 770 |
closedate => undef, # Open basket |
| 771 |
}, |
| 772 |
} |
| 773 |
); |
| 774 |
|
| 775 |
# Use existing test file that contains RFF+ON:orders 23/1 |
| 776 |
my $filename = 'QUOTES_SMALL.CEQ'; |
| 777 |
my $trans = Koha::Edifact::Transport->new( $account->{id} ); |
| 778 |
$trans->working_directory($dirname); |
| 779 |
|
| 780 |
my $mhash = $trans->message_hash(); |
| 781 |
$mhash->{message_type} = 'QUOTE'; |
| 782 |
$trans->ingest( $mhash, $filename ); |
| 783 |
|
| 784 |
my $quote = $schema->resultset('EdifactMessage')->find( { filename => $filename } ); |
| 785 |
ok( $quote, 'Quote message created successfully' ); |
| 786 |
|
| 787 |
# Process the quote (this should trigger duplicate detection) |
| 788 |
process_quote($quote); |
| 789 |
|
| 790 |
# Check that duplicate purchase order error was logged |
| 791 |
my $errors = $quote->edifact_errors; |
| 792 |
ok( $errors->count >= 1, 'At least one error logged during quote processing' ); |
| 793 |
|
| 794 |
# Find the specific duplicate purchase order error |
| 795 |
my $duplicate_error = $errors->search( { section => 'RFF+ON:orders 23/1' } )->first; |
| 796 |
ok( $duplicate_error, 'Duplicate purchase order error found' ); |
| 797 |
is( $duplicate_error->section, 'RFF+ON:orders 23/1', 'Error section contains the RFF+ON segment' ); |
| 798 |
like( |
| 799 |
$duplicate_error->details, qr/Duplicate purchase order number 'orders 23\/1' found for vendor/, |
| 800 |
'Error details describe the duplicate issue' |
| 801 |
); |
| 802 |
|
| 803 |
$schema->storage->txn_rollback; |
| 804 |
}; |
| 805 |
|
| 745 |
# Clean up |
806 |
# Clean up |
| 746 |
$logger->clear(); |
807 |
$logger->clear(); |
| 747 |
$schema->storage->txn_rollback; |
808 |
$schema->storage->txn_rollback; |
| 748 |
- |
|
|