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