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 808-813
subtest 'process_quote' => sub {
Link Here
|
808 |
$schema->storage->txn_rollback; |
808 |
$schema->storage->txn_rollback; |
809 |
}; |
809 |
}; |
810 |
|
810 |
|
|
|
811 |
# Test 7: Duplicate purchase order number validation |
812 |
subtest 'duplicate_purchase_order_validation' => sub { |
813 |
plan tests => 5; |
814 |
|
815 |
$schema->storage->txn_begin; |
816 |
|
817 |
# Create vendor EDI account with po_is_basketname set to true |
818 |
my $account = $builder->build( |
819 |
{ |
820 |
source => 'VendorEdiAccount', |
821 |
value => { |
822 |
description => 'test vendor duplicate po', |
823 |
transport => 'FILE', |
824 |
po_is_basketname => 1, |
825 |
}, |
826 |
} |
827 |
); |
828 |
|
829 |
# Create first basket with purchase order number "orders 23/1" (same as in QUOTES_SMALL.CEQ) |
830 |
my $first_basket = $builder->build( |
831 |
{ |
832 |
source => 'Aqbasket', |
833 |
value => { |
834 |
basketname => 'orders 23/1', |
835 |
booksellerid => $account->{vendor_id}, |
836 |
closedate => undef, # Open basket |
837 |
}, |
838 |
} |
839 |
); |
840 |
|
841 |
# Use existing test file that contains RFF+ON:orders 23/1 |
842 |
my $filename = 'QUOTES_SMALL.CEQ'; |
843 |
my $trans = Koha::Edifact::Transport->new( $account->{id} ); |
844 |
$trans->working_directory($dirname); |
845 |
|
846 |
my $mhash = $trans->message_hash(); |
847 |
$mhash->{message_type} = 'QUOTE'; |
848 |
$trans->ingest( $mhash, $filename ); |
849 |
|
850 |
my $quote = $schema->resultset('EdifactMessage')->find( { filename => $filename } ); |
851 |
ok( $quote, 'Quote message created successfully' ); |
852 |
|
853 |
# Process the quote (this should trigger duplicate detection) |
854 |
process_quote($quote); |
855 |
|
856 |
# Check that duplicate purchase order error was logged |
857 |
my $errors = $quote->edifact_errors; |
858 |
ok( $errors->count >= 1, 'At least one error logged during quote processing' ); |
859 |
|
860 |
# Find the specific duplicate purchase order error |
861 |
my $duplicate_error = $errors->search( { section => 'RFF+ON:orders 23/1' } )->first; |
862 |
ok( $duplicate_error, 'Duplicate purchase order error found' ); |
863 |
is( $duplicate_error->section, 'RFF+ON:orders 23/1', 'Error section contains the RFF+ON segment' ); |
864 |
like( |
865 |
$duplicate_error->details, qr/Duplicate purchase order number 'orders 23\/1' found for vendor/, |
866 |
'Error details describe the duplicate issue' |
867 |
); |
868 |
|
869 |
$schema->storage->txn_rollback; |
870 |
}; |
871 |
|
811 |
# Clean up |
872 |
# Clean up |
812 |
$logger->clear(); |
873 |
$logger->clear(); |
813 |
$schema->storage->txn_rollback; |
874 |
$schema->storage->txn_rollback; |
814 |
- |
|
|