@@ -, +, @@ --- Koha/EDI.pm | 3 +++ Koha/Edifact/Line.pm | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) --- a/Koha/EDI.pm +++ a/Koha/EDI.pm @@ -288,6 +288,7 @@ sub process_invoice { } my $price = _get_invoiced_price($line); + my $tax_rate = $line->tax_rate; if ( $order->quantity > $line->quantity ) { my $ordered = $order->quantity; @@ -305,6 +306,7 @@ sub process_invoice { unitprice => $price, invoiceid => $invoiceid, datereceived => $msg_date, + tax_rate_on_receiving => $tax_rate->{rate}, } ); my $p_updates = @@ -324,6 +326,7 @@ sub process_invoice { $order->datereceived($msg_date); $order->invoiceid($invoiceid); $order->unitprice($price); + $order->tax_rate_on_receiving($tax_rate->{rate}); $order->orderstatus('complete'); my $p_updates = update_price_from_invoice( $order, $invoice_message->vendor_id ); --- a/Koha/Edifact/Line.pm +++ a/Koha/Edifact/Line.pm @@ -804,6 +804,30 @@ sub tax { return $self->moa_amt('124'); } +sub tax_rate { + my $self = shift; + my $tr = {}; + foreach my $s ( @{ $self->{segs} } ) { + if ( $s->tag eq 'TAX' && $s->elem( 0, 0 ) == 7 ) { + $tr->{type} = $s->elem( 1, 0 ); # VAT, GST or IMP + $tr->{rate} = $s->elem( 4, 3 ); # percentage + # category values may be: + # E = exempt from tax + # G = export item, tax not charged + # H = higher rate + # L = lower rate + # S = standard rate + # Z = zero-rated + $tr->{category} = $s->elem( 5, 0 ); + if (!defined $tr->{rate} && $tr->{category} eq 'Z') { + $tr->{rate} = 0; + } + return $tr; + } + } + return; +} + sub availability_date { my $self = shift; if ( exists $self->{availability_date} ) { --