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 914-919
subtest 'process_quote' => sub {
Link Here
|
914 |
$schema->storage->txn_rollback; |
914 |
$schema->storage->txn_rollback; |
915 |
}; |
915 |
}; |
916 |
|
916 |
|
|
|
917 |
# Test 7: Duplicate purchase order number validation |
918 |
subtest 'duplicate_purchase_order_validation' => sub { |
919 |
plan tests => 5; |
920 |
|
921 |
$schema->storage->txn_begin; |
922 |
|
923 |
# Create vendor EDI account with po_is_basketname set to true |
924 |
my $account = $builder->build( |
925 |
{ |
926 |
source => 'VendorEdiAccount', |
927 |
value => { |
928 |
description => 'test vendor duplicate po', |
929 |
transport => 'FILE', |
930 |
po_is_basketname => 1, |
931 |
}, |
932 |
} |
933 |
); |
934 |
|
935 |
# Create first basket with purchase order number "orders 23/1" (same as in QUOTES_SMALL.CEQ) |
936 |
my $first_basket = $builder->build( |
937 |
{ |
938 |
source => 'Aqbasket', |
939 |
value => { |
940 |
basketname => 'orders 23/1', |
941 |
booksellerid => $account->{vendor_id}, |
942 |
closedate => undef, # Open basket |
943 |
}, |
944 |
} |
945 |
); |
946 |
|
947 |
# Use existing test file that contains RFF+ON:orders 23/1 |
948 |
my $filename = 'QUOTES_SMALL.CEQ'; |
949 |
my $trans = Koha::Edifact::Transport->new( $account->{id} ); |
950 |
$trans->working_directory($dirname); |
951 |
|
952 |
my $mhash = $trans->message_hash(); |
953 |
$mhash->{message_type} = 'QUOTE'; |
954 |
$trans->ingest( $mhash, $filename ); |
955 |
|
956 |
my $quote = $schema->resultset('EdifactMessage')->find( { filename => $filename } ); |
957 |
ok( $quote, 'Quote message created successfully' ); |
958 |
|
959 |
# Process the quote (this should trigger duplicate detection) |
960 |
process_quote($quote); |
961 |
|
962 |
# Check that duplicate purchase order error was logged |
963 |
my $errors = $quote->edifact_errors; |
964 |
ok( $errors->count >= 1, 'At least one error logged during quote processing' ); |
965 |
|
966 |
# Find the specific duplicate purchase order error |
967 |
my $duplicate_error = $errors->search( { section => 'RFF+ON:orders 23/1' } )->first; |
968 |
ok( $duplicate_error, 'Duplicate purchase order error found' ); |
969 |
is( $duplicate_error->section, 'RFF+ON:orders 23/1', 'Error section contains the RFF+ON segment' ); |
970 |
like( |
971 |
$duplicate_error->details, qr/Duplicate purchase order number 'orders 23\/1' found for vendor/, |
972 |
'Error details describe the duplicate issue' |
973 |
); |
974 |
|
975 |
$schema->storage->txn_rollback; |
976 |
}; |
977 |
|
917 |
# Clean up |
978 |
# Clean up |
918 |
$logger->clear(); |
979 |
$logger->clear(); |
919 |
$schema->storage->txn_rollback; |
980 |
$schema->storage->txn_rollback; |
920 |
- |
|
|