=head3 ModReceiveOrder
- &ModReceiveOrder({
- biblionumber => $biblionumber,
- ordernumber => $ordernumber,
- quantityreceived => $quantityreceived,
- user => $user,
- cost => $cost,
- ecost => $ecost,
- invoiceid => $invoiceid,
- rrp => $rrp,
- budget_id => $budget_id,
- datereceived => $datereceived,
- received_itemnumbers => \@received_itemnumbers,
- order_internalnote => $order_internalnote,
- order_vendornote => $order_vendornote,
- });
+ my ( $date_received, $new_ordernumber ) = ModReceiveOrder(
+ {
+ biblionumber => $biblionumber,
+ order => $order,
+ quantityreceived => $quantityreceived,
+ user => $user,
+ invoice => $invoice,
+ budget_id => $budget_id,
+ received_itemnumbers => \@received_itemnumbers,
+ order_internalnote => $order_internalnote,
+ }
+ );
Updates an order, to reflect the fact that it was received, at least
-in part. All arguments not mentioned below update the fields with the
-same name in the aqorders table of the Koha database.
+in part.
If a partial order is received, splits the order into two.
-Updates the order with bibilionumber C<$biblionumber> and ordernumber
-C<$ordernumber>.
+Updates the order with biblionumber C<$biblionumber> and ordernumber
+C<$order->{ordernumber}>.
=cut
sub ModReceiveOrder {
- my ( $params ) = @_;
- my $biblionumber = $params->{biblionumber};
- my $ordernumber = $params->{ordernumber};
- my $quantrec = $params->{quantityreceived};
- my $user = $params->{user};
- my $cost = $params->{cost};
- my $ecost = $params->{ecost};
- my $invoiceid = $params->{invoiceid};
- my $rrp = $params->{rrp};
- my $budget_id = $params->{budget_id};
- my $datereceived = $params->{datereceived};
+ my ($params) = @_;
+ my $biblionumber = $params->{biblionumber};
+ my $order = { %{ $params->{order} } }; # Copy the order, we don't want to modify it
+ my $invoice = $params->{invoice};
+ my $quantrec = $params->{quantityreceived};
+ my $user = $params->{user};
+ my $budget_id = $params->{budget_id};
my $received_items = $params->{received_items};
- my $order_internalnote = $params->{order_internalnote};
- my $order_vendornote = $params->{order_vendornote};
my $dbh = C4::Context->dbh;
- $datereceived = output_pref(
- {
- dt => ( $datereceived ? dt_from_string( $datereceived ) : dt_from_string ),
- dateformat => 'iso',
- dateonly => 1,
- }
- );
+ my $datereceived = ( $invoice and $invoice->{datereceived} ) ? $invoice->{datereceived} : dt_from_string;
my $suggestionid = GetSuggestionFromBiblionumber( $biblionumber );
if ($suggestionid) {
ModSuggestion( {suggestionid=>$suggestionid,
);
}
- my $result_set = $dbh->selectall_arrayref(
-q{SELECT *, aqbasket.is_standing FROM aqorders LEFT JOIN aqbasket USING (basketno) WHERE biblionumber=? AND aqorders.ordernumber=?},
- { Slice => {} }, $biblionumber, $ordernumber
- );
-
- # we assume we have a unique order
- my $order = $result_set->[0];
-
- my $new_ordernumber = $ordernumber;
- if ( $order->{is_standing} || $order->{quantity} > $quantrec ) {
+ my $new_ordernumber = $order->{ordernumber};
+ if ( $order->{quantity} > $quantrec ) {
# Split order line in two parts: the first is the original order line
# without received items (the quantity is decreased),
# the second part is a new order line with quantity=quantityrec
UPDATE aqorders
SET quantity = ?,
orderstatus = 'partial'|;
- $query .= q|, order_internalnote = ?| if defined $order_internalnote;
- $query .= q|, order_vendornote = ?| if defined $order_vendornote;
+ $query .= q|, order_internalnote = ?| if defined $order->{order_internalnote};
$query .= q| WHERE ordernumber = ?|;
my $sth = $dbh->prepare($query);
$sth->execute(
- ( $order->{is_standing} ? 1 : ( $order->{quantity} - $quantrec ) ),
- ( defined $order_internalnote ? $order_internalnote : () ),
- ( defined $order_vendornote ? $order_vendornote : () ),
- $ordernumber
+ $order->{quantity} - $quantrec,
+ ( defined $order->{order_internalnote} ? $order->{order_internalnote} : () ),
+ $order->{ordernumber}
);
- delete $order->{'ordernumber'};
- $order->{'budget_id'} = ( $budget_id || $order->{'budget_id'} );
- $order->{'quantity'} = $quantrec;
- $order->{'quantityreceived'} = $quantrec;
- $order->{'datereceived'} = $datereceived;
- $order->{'invoiceid'} = $invoiceid;
- $order->{'unitprice'} = $cost;
- $order->{'rrp'} = $rrp;
- $order->{ecost} = $ecost;
- $order->{'orderstatus'} = 'complete';
+ delete $order->{ordernumber};
+ $order->{budget_id} = ( $budget_id || $order->{budget_id} );
+ $order->{quantity} = $quantrec;
+ $order->{quantityreceived} = $quantrec;
+ $order->{datereceived} = $datereceived;
+ $order->{invoiceid} = $invoice->{invoiceid};
+ $order->{orderstatus} = 'complete';
$new_ordernumber = Koha::Acquisition::Order->new($order)->insert->{ordernumber};
if ($received_items) {
}
} else {
my $query = q|
- update aqorders
- set quantityreceived=?,datereceived=?,invoiceid=?,
- unitprice=?,rrp=?,ecost=?,budget_id=?,orderstatus='complete'|;
- $query .= q|, order_internalnote = ?| if defined $order_internalnote;
- $query .= q|, order_vendornote = ?| if defined $order_vendornote;
+ UPDATE aqorders
+ SET quantityreceived = ?,
+ datereceived = ?,
+ invoiceid = ?,
+ budget_id = ?,
+ orderstatus = 'complete'
+ |;
+
+ $query .= q|
+ , unitprice = ?, unitprice_tax_included = ?, unitprice_tax_excluded = ?
+ | if defined $order->{unitprice};
+
+ $query .= q|
+ , rrp = ?, rrp_tax_included = ?, rrp_tax_excluded = ?
+ | if defined $order->{rrp};
+
+ $query .= q|
+ , ecost = ?, ecost_tax_included = ?, ecost_tax_excluded = ?
+ | if defined $order->{ecost};
+
+ $query .= q|
+ , order_internalnote = ?
+ | if defined $order->{order_internalnote};
+
$query .= q| where biblionumber=? and ordernumber=?|;
+
my $sth = $dbh->prepare( $query );
- $sth->execute(
- $quantrec,
- $datereceived,
- $invoiceid,
- $cost,
- $rrp,
- $ecost,
- ( $budget_id ? $budget_id : $order->{budget_id} ),
- ( defined $order_internalnote ? $order_internalnote : () ),
- ( defined $order_vendornote ? $order_vendornote : () ),
- $biblionumber,
- $ordernumber
- );
+ my @params = ( $quantrec, $datereceived, $invoice->{invoiceid}, $budget_id );
+
+ if ( defined $order->{unitprice} ) {
+ push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded};
+ }
+ if ( defined $order->{rrp} ) {
+ push @params, $order->{rrp}, $order->{rrp_tax_included}, $order->{rrp_tax_excluded};
+ }
+ if ( defined $order->{ecost} ) {
+ push @params, $order->{ecost}, $order->{ecost_tax_included}, $order->{ecost_tax_excluded};
+ }
+ if ( defined $order->{order_internalnote} ) {
+ push @params, $order->{order_internalnote};
+ }
+
+ push @params, ( $biblionumber, $order->{ordernumber} );
+
+ $sth->execute( @params );
# All items have been received, sent a notification to users
- NotifyOrderUsers( $ordernumber );
+ NotifyOrderUsers( $order->{ordernumber} );
}
return ($datereceived, $new_ordernumber);
$order->{ecost} = Koha::Number::Price->new( $order->{ecost} )->round;
if ($ordering) {
if ( $bookseller->{listincgst} ) {
- $order->{rrpgsti} = $order->{rrp};
- $order->{rrpgste} = Koha::Number::Price->new(
- $order->{rrpgsti} / ( 1 + $order->{gstrate} ) )->round;
- $order->{ecostgsti} = $order->{ecost};
- $order->{ecostgste} = Koha::Number::Price->new(
- $order->{ecost} / ( 1 + $order->{gstrate} ) )->round;
- $order->{gstvalue} = Koha::Number::Price->new(
- ( $order->{ecostgsti} - $order->{ecostgste} ) *
+ $order->{rrp_tax_included} = $order->{rrp};
+ $order->{rrp_tax_excluded} = Koha::Number::Price->new(
+ $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
+ $order->{ecost_tax_included} = $order->{ecost};
+ $order->{ecost_tax_excluded} = Koha::Number::Price->new(
+ $order->{ecost} / ( 1 + $order->{tax_rate} ) )->round;
+ $order->{tax_value} = Koha::Number::Price->new(
+ ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
$order->{quantity} )->round;
- $order->{totalgste} = $order->{ecostgste} * $order->{quantity};
- $order->{totalgsti} = $order->{ecostgsti} * $order->{quantity};
}
else {
- $order->{rrpgste} = $order->{rrp};
- $order->{rrpgsti} = Koha::Number::Price->new(
- $order->{rrp} * ( 1 + $order->{gstrate} ) )->round;
- $order->{ecostgste} = $order->{ecost};
- $order->{ecostgsti} = Koha::Number::Price->new(
- $order->{ecost} * ( 1 + $order->{gstrate} ) )->round;
- $order->{gstvalue} = Koha::Number::Price->new(
- ( $order->{ecostgsti} - $order->{ecostgste} ) *
+ $order->{rrp_tax_excluded} = $order->{rrp};
+ $order->{rrp_tax_included} = Koha::Number::Price->new(
+ $order->{rrp} * ( 1 + $order->{tax_rate} ) )->round;
+ $order->{ecost_tax_excluded} = $order->{ecost};
+ $order->{ecost_tax_included} = Koha::Number::Price->new(
+ $order->{ecost} * ( 1 + $order->{tax_rate} ) )->round;
+ $order->{tax_value} = Koha::Number::Price->new(
+ ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
$order->{quantity} )->round;
- $order->{totalgste} = $order->{ecostgste} * $order->{quantity};
- $order->{totalgsti} = $order->{ecostgsti} * $order->{quantity};
}
}
if ($receiving) {
if ( $bookseller->{listincgst} ) {
- $order->{unitpricegsti} = Koha::Number::Price->new( $order->{unitprice} )->round;
- $order->{unitpricegste} = Koha::Number::Price->new(
- $order->{unitpricegsti} / ( 1 + $order->{gstrate} ) )->round;
+ $order->{unitprice_tax_included} = Koha::Number::Price->new( $order->{unitprice} )->round;
+ $order->{unitprice_tax_excluded} = Koha::Number::Price->new(
+ $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
}
else {
- $order->{unitpricegste} = Koha::Number::Price->new( $order->{unitprice} )->round;
- $order->{unitpricegsti} = Koha::Number::Price->new(
- $order->{unitpricegste} * ( 1 + $order->{gstrate} ) )->round;
+ $order->{unitprice_tax_excluded} = Koha::Number::Price->new( $order->{unitprice} )->round;
+ $order->{unitprice_tax_included} = Koha::Number::Price->new(
+ $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ) )->round;
}
- $order->{gstvalue} = Koha::Number::Price->new(
- ( $order->{unitpricegsti} - $order->{unitpricegste} )
+ $order->{tax_value} = Koha::Number::Price->new(
+ ( $order->{unitprice_tax_included} - $order->{unitprice_tax_excluded} )
* $order->{quantityreceived} )->round;
- $order->{totalgste} = $order->{unitpricegste} * $order->{quantity};
- $order->{totalgsti} = $order->{unitpricegsti} * $order->{quantity};
}
return $order;
name, address1, address2, address3, address4,
postal, phone, accountnumber,fax, url,
active, listprice, invoiceprice, gstreg,
- listincgst,invoiceincgst, gstrate, discount, notes,
+ listincgst,invoiceincgst, tax_rate, discount, notes,
deliverytime
)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
$data->{'active'}, $data->{'listprice'},
$data->{'invoiceprice'}, $data->{'gstreg'},
$data->{'listincgst'}, $data->{'invoiceincgst'},
- $data->{'gstrate'}, $data->{'discount'},
+ $data->{'tax_rate'}, $data->{'discount'},
$data->{notes}, $data->{deliverytime},
);
postal=?,phone=?,accountnumber=?,fax=?,url=?,
active=?,listprice=?, invoiceprice=?,
gstreg=?,listincgst=?,invoiceincgst=?,
- discount=?,notes=?,gstrate=?,deliverytime=?
+ discount=?,notes=?,tax_rate=?,deliverytime=?
WHERE id=?';
my $sth = $dbh->prepare($query);
my $cnt = $sth->execute(
$data->{'invoiceprice'}, $data->{'gstreg'},
$data->{'listincgst'}, $data->{'invoiceincgst'},
$data->{'discount'}, $data->{'notes'},
- $data->{'gstrate'}, $data->{deliverytime},
+ $data->{'tax_rate'}, $data->{deliverytime},
$data->{'id'}
);
$contacts ||= $data->{'contacts'};
# in this case, the price will be x100 when unformatted ! Replace the . by a , to get a proper price calculation
$price =~ s/\./,/ if C4::Context->preference("CurrencyFormat") eq "FR";
$price = Koha::Number::Price->new($price)->unformat;
- $orderinfo{gstrate} = $bookseller->{gstrate};
+ $orderinfo{tax_rate} = $bookseller->{tax_rate};
my $c = $c_discount ? $c_discount : $bookseller->{discount} / 100;
if ( $bookseller->{listincgst} ) {
if ( $c_discount ) {
}
} else {
if ( $c_discount ) {
- $orderinfo{ecost} = $price / ( 1 + $orderinfo{gstrate} );
+ $orderinfo{ecost} = $price / ( 1 + $orderinfo{tax_rate} );
$orderinfo{rrp} = $orderinfo{ecost} / ( 1 - $c );
} else {
- $orderinfo{rrp} = $price / ( 1 + $orderinfo{gstrate} );
+ $orderinfo{rrp} = $price / ( 1 + $orderinfo{tax_rate} );
$orderinfo{ecost} = $orderinfo{rrp} * ( 1 - $c );
}
}
my @book_foot_loop;
my %foot;
my $total_quantity = 0;
- my $total_gste = 0;
- my $total_gsti = 0;
- my $total_gstvalue = 0;
+ my $total_tax_excluded = 0;
+ my $total_tax_included = 0;
+ my $total_tax_value = 0;
for my $order (@orders) {
- $order = C4::Acquisition::populate_order_with_prices({ order => $order, booksellerid => $booksellerid, ordering => 1 });
my $line = get_order_infos( $order, $bookseller);
if ( $line->{uncertainprice} ) {
$template->param( uncertainprices => 1 );
}
+ $line->{total_tax_excluded} = Koha::Number::Price->new( $line->{ecost_tax_excluded} * $line->{quantity} )->format;
+ $line->{total_tax_included} = Koha::Number::Price->new( $line->{ecost_tax_included} * $line->{quantity} )->format;
+
push @books_loop, $line;
- $foot{$$line{gstrate}}{gstrate} = $$line{gstrate};
- $foot{$$line{gstrate}}{gstvalue} += $$line{gstvalue};
- $total_gstvalue += $$line{gstvalue};
- $foot{$$line{gstrate}}{quantity} += $$line{quantity};
+ $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
+ $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value};
+ $total_tax_value += $$line{tax_value};
+ $foot{$$line{tax_rate}}{quantity} += $$line{quantity};
$total_quantity += $$line{quantity};
- $foot{$$line{gstrate}}{totalgste} += $$line{totalgste};
- $total_gste += $$line{totalgste};
- $foot{$$line{gstrate}}{totalgsti} += $$line{totalgsti};
- $total_gsti += $$line{totalgsti};
+ $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
+ $total_tax_excluded += $$line{total_tax_excluded};
+ $foot{$$line{tax_rate}}{total_tax_included} += $$line{total_tax_included};
+ $total_tax_included += $$line{total_tax_included};
}
push @book_foot_loop, map {$_} values %foot;
my @cancelledorders = GetOrders($basketno, { cancelled => 1 });
my @cancelledorders_loop;
for my $order (@cancelledorders) {
- $order = C4::Acquisition::populate_order_with_prices({ order => $order, booksellerid => $booksellerid, ordering => 1 });
my $line = get_order_infos( $order, $bookseller);
push @cancelledorders_loop, $line;
}
book_foot_loop => \@book_foot_loop,
cancelledorders_loop => \@cancelledorders_loop,
total_quantity => $total_quantity,
- total_gste => sprintf( "%.2f", $total_gste ),
- total_gsti => sprintf( "%.2f", $total_gsti ),
- total_gstvalue => sprintf( "%.2f", $total_gstvalue ),
+ total_tax_excluded => $total_tax_excluded,
+ total_tax_included => $total_tax_included,
+ total_tax_value => $total_tax_value,
currency => $active_currency->currency,
listincgst => $bookseller->{listincgst},
basketgroups => $basketgroups,
$line{budget_name} = $budget->{budget_name};
if ( $line{uncertainprice} ) {
- $line{rrpgste} .= ' (Uncertain)';
+ $line{rrp_tax_excluded} .= ' (Uncertain)';
}
if ( $line{'title'} ) {
my $volume = $order->{'volume'};
my $total = 0;
my @orders = GetOrders($basketno);
for my $order (@orders){
- $total = $total + ( $order->{ecost} * $order->{quantity} );
- if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{gstrate} // C4::Context->preference("gist") )) {
- my $gst = $bookseller->{gstrate} // C4::Context->preference("gist");
+ # FIXME The following is wrong
+ if ( $bookseller->{listincgst} ) {
+ $total = $total + ( $order->{ecost_tax_included} * $order->{quantity} );
+ } else {
+ $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
+ }
+ if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{tax_rate} // C4::Context->preference("gist") )) {
+ my $gst = $bookseller->{tax_rate} // C4::Context->preference("gist");
$total = $total * ( $gst / 100 +1);
}
}
croak $@;
}
- $ord = C4::Acquisition::populate_order_with_prices({ order => $ord, booksellerid => $bookseller->{id}, ordering => 1 });
+ $ord->{total_tax_included} = $ord->{ecost_tax_included} * $ord->{quantity};
+ $ord->{total_tax_excluded} = $ord->{ecost_tax_excluded} * $ord->{quantity};
+
my $bib = GetBiblioData($ord->{biblionumber});
my $itemtypes = GetItemTypes();
#FIXME DELETE ME
# 0 1 2 3 4 5 6 7 8 9
- #isbn, itemtype, author, title, publishercode, quantity, listprice ecost discount gstrate
+ #isbn, itemtype, author, title, publishercode, quantity, listprice ecost discount tax_rate
# Editor Number
my $en;
-type => 'application/pdf',
-attachment => ( $basketgroup->{name} || $basketgroupid ) . '.pdf'
);
- my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{gstrate} // C4::Context->preference("gist")) || die "pdf generation failed";
+ my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{tax_rate} // C4::Context->preference("gist")) || die "pdf generation failed";
print $pdf;
}
my $cnt = 0;
my $ecost = $input->param('ecost');
my $rrp = $input->param('rrp');
-my $order_internalnote = $input->param("order_internalnote");
my $bookfund = $input->param("bookfund");
my $order = GetOrder($ordernumber);
my $new_ordernumber = $ordernumber;
}
}
+ $order->{order_internalnote} = $input->param("order_internalnote");
$order->{rrp} = $rrp;
$order->{ecost} = $ecost;
$order->{unitprice} = $unitprice;
+
+ # FIXME is it still useful?
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
if ( $bookseller->{listincgst} ) {
if ( not $bookseller->{invoiceincgst} ) {
- $order->{rrp} = $order->{rrp} * ( 1 + $order->{gstrate} );
- $order->{ecost} = $order->{ecost} * ( 1 + $order->{gstrate} );
- $order->{unitprice} = $order->{unitprice} * ( 1 + $order->{gstrate} );
+ $order->{rrp} = $order->{rrp} * ( 1 + $order->{tax_rate} );
+ $order->{ecost} = $order->{ecost} * ( 1 + $order->{tax_rate} );
+ $order->{unitprice} = $order->{unitprice} * ( 1 + $order->{tax_rate} );
}
} else {
if ( $bookseller->{invoiceincgst} ) {
- $order->{rrp} = $order->{rrp} / ( 1 + $order->{gstrate} );
- $order->{ecost} = $order->{ecost} / ( 1 + $order->{gstrate} );
- $order->{unitprice} = $order->{unitprice} / ( 1 + $order->{gstrate} );
+ $order->{rrp} = $order->{rrp} / ( 1 + $order->{tax_rate} );
+ $order->{ecost} = $order->{ecost} / ( 1 + $order->{tax_rate} );
+ $order->{unitprice} = $order->{unitprice} / ( 1 + $order->{tax_rate} );
}
}
# save the quantity received.
if ( $quantityrec > 0 ) {
- ($datereceived, $new_ordernumber) = ModReceiveOrder({
- biblionumber => $biblionumber,
- ordernumber => $ordernumber,
- quantityreceived => $quantityrec,
- user => $user,
- cost => $order->{unitprice},
- ecost => $order->{ecost},
- invoiceid => $invoiceid,
- rrp => $order->{rrp},
- budget_id => $bookfund,
- datereceived => $datereceived,
- received_items => \@received_items,
- order_internalnote => $order_internalnote,
- } );
+ ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
+ {
+ biblionumber => $biblionumber,
+ order => $order,
+ quantityreceived => $quantityrec,
+ user => $user,
+ invoice => $invoice,
+ budget_id => $bookfund,
+ received_items => \@received_items,
+ }
+ );
}
# now, add items if applicable
my @foot_loop;
my %foot;
my $total_quantity = 0;
-my $total_gste = 0;
-my $total_gsti = 0;
-my $total_gstvalue = 0;
+my $total_tax_excluded = 0;
+my $total_tax_included = 0;
+my $total_tax_value = 0;
foreach my $order (@$orders) {
- $order = C4::Acquisition::populate_order_with_prices(
- {
- order => $order,
- booksellerid => $bookseller->{id},
- receiving => 1,
- }
- );
my $line = get_infos( $order, $bookseller);
- $foot{$$line{gstrate}}{gstrate} = $$line{gstrate};
- $foot{$$line{gstrate}}{gstvalue} += $$line{gstvalue};
- $total_gstvalue += $$line{gstvalue};
- $foot{$$line{gstrate}}{quantity} += $$line{quantity};
+ $line->{total_tax_excluded} = Koha::Number::Price->new( $line->{unitprice_tax_excluded} * $line->{quantity} )->format;
+ $line->{total_tax_included} = Koha::Number::Price->new( $line->{unitprice_tax_included} * $line->{quantity} )->format;
+
+ $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
+ $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value};
+ $total_tax_value += $$line{tax_value};
+ $foot{$$line{tax_rate}}{quantity} += $$line{quantity};
$total_quantity += $$line{quantity};
- $foot{$$line{gstrate}}{totalgste} += $$line{totalgste};
- $total_gste += $$line{totalgste};
- $foot{$$line{gstrate}}{totalgsti} += $$line{totalgsti};
- $total_gsti += $$line{totalgsti};
+ $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded};
+ $total_tax_excluded += $$line{total_tax_excluded};
+ $foot{$$line{tax_rate}}{total_tax_included} += $$line{total_tax_included};
+ $total_tax_included += $$line{total_tax_included};
$line->{orderline} = $line->{parent_ordernumber};
push @orders_loop, $line;
orders_loop => \@orders_loop,
foot_loop => \@foot_loop,
total_quantity => $total_quantity,
- total_gste => sprintf( $format, $total_gste ),
- total_gsti => sprintf( $format, $total_gsti ),
- total_gstvalue => sprintf( $format, $total_gstvalue ),
- total_gste_shipment => sprintf( $format, $total_gste + $details->{shipmentcost}),
- total_gsti_shipment => sprintf( $format, $total_gsti + $details->{shipmentcost}),
+ total_tax_excluded => sprintf( $format, $total_tax_excluded ),
+ total_tax_included => sprintf( $format, $total_tax_included ),
+ total_tax_value => sprintf( $format, $total_tax_value ),
+ total_tax_excluded_shipment => sprintf( $format, $total_tax_excluded + $details->{shipmentcost}),
+ total_tax_included_shipment => sprintf( $format, $total_tax_included + $details->{shipmentcost}),
invoiceincgst => $bookseller->{invoiceincgst},
currency => Koha::Acquisition::Currencies->get_active,
budgets_loop => \@budgets_loop,
$budget_id = $lastOrderReceived->{budgetid};
$data->{listprice} = $lastOrderReceived->{listprice};
$data->{uncertainprice} = $lastOrderReceived->{uncertainprice};
- $data->{gstrate} = $lastOrderReceived->{gstrate};
+ $data->{tax_rate} = $lastOrderReceived->{tax_rate};
$data->{discount} = $lastOrderReceived->{discount};
$data->{rrp} = $lastOrderReceived->{rrp};
$data->{ecost} = $lastOrderReceived->{ecost};
quantityrec => $quantity,
rrp => $data->{'rrp'},
gst_values => \@gst_values,
- gstrate => $data->{gstrate} ? $data->{gstrate}+0.0 : $bookseller->{gstrate} ? $bookseller->{gstrate}+0.0 : 0,
+ tax_rate => $data->{tax_rate} ? $data->{tax_rate}+0.0 : $bookseller->{tax_rate} ? $bookseller->{tax_rate}+0.0 : 0,
listprice => sprintf( "%.2f", $data->{listprice} || $data->{price} || $listprice),
total => sprintf( "%.2f", ($data->{ecost} || 0) * ($data->{'quantity'} || 0) ),
ecost => sprintf( "%.2f", $data->{ecost} || 0),
$ecost = $order->{ecost};
$unitprice = $order->{unitprice};
} else {
- $rrp = $order->{rrp} / ( 1 + $order->{gstrate} );
- $ecost = $order->{ecost} / ( 1 + $order->{gstrate} );
- $unitprice = $order->{unitprice} / ( 1 + $order->{gstrate} );
+ $rrp = $order->{rrp} / ( 1 + $order->{tax_rate} );
+ $ecost = $order->{ecost} / ( 1 + $order->{tax_rate} );
+ $unitprice = $order->{unitprice} / ( 1 + $order->{tax_rate} );
}
} else {
if ( $bookseller->{invoiceincgst} ) {
- $rrp = $order->{rrp} * ( 1 + $order->{gstrate} );
- $ecost = $order->{ecost} * ( 1 + $order->{gstrate} );
- $unitprice = $order->{unitprice} * ( 1 + $order->{gstrate} );
+ $rrp = $order->{rrp} * ( 1 + $order->{tax_rate} );
+ $ecost = $order->{ecost} * ( 1 + $order->{tax_rate} );
+ $unitprice = $order->{unitprice} * ( 1 + $order->{tax_rate} );
} else {
$rrp = $order->{rrp};
$ecost = $order->{ecost};
my $booksellerid = $invoice->{booksellerid};
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
-my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
+my $gst = $bookseller->{tax_rate} // C4::Context->preference("gist") // 0;
my @orders = @{ $invoice->{orders} };
my $countlines = scalar @orders;
my @loop_received = ();
my @book_foot_loop;
my %foot;
-my $total_gste = 0;
-my $total_gsti = 0;
+my $total_tax_excluded = 0;
+my $total_tax_included = 0;
my $subtotal_for_funds;
for my $order ( @orders ) {
- $order = C4::Acquisition::populate_order_with_prices({ order => $order, booksellerid => $bookseller->{id}, receiving => 1, ordering => 1 });
$order->{'unitprice'} += 0;
if ( $bookseller->{listincgst} and not $bookseller->{invoiceincgst} ) {
- $order->{ecost} = $order->{ecostgste};
- $order->{unitprice} = $order->{unitpricegste};
+ $order->{ecost} = $order->{ecost_tax_excluded};
+ $order->{unitprice} = $order->{unitprice_tax_excluded};
}
elsif ( not $bookseller->{listinct} and $bookseller->{invoiceincgst} ) {
- $order->{ecost} = $order->{ecostgsti};
- $order->{unitprice} = $order->{unitpricegsti};
+ $order->{ecost} = $order->{ecost_tax_included};
+ $order->{unitprice} = $order->{unitprice_tax_included};
+ } else {
+ $order->{ecost} = $order->{ecost_tax_excluded};
+ $order->{unitprice} = $order->{unitprice_tax_excluded};
}
$order->{total} = $order->{unitprice} * $order->{quantity};
$line{holds} += scalar( @$holds );
}
$line{budget} = GetBudgetByOrderNumber( $line{ordernumber} );
- $foot{$line{gstrate}}{gstrate} = $line{gstrate};
- $foot{$line{gstrate}}{gstvalue} += $line{gstvalue};
- $total_gste += $line{totalgste};
- $total_gsti += $line{totalgsti};
+ $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
+ $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
+ $total_tax_excluded += Koha::Number::Price->new( $line{ecost_tax_excluded} * $line{quantity} )->format;
+ $total_tax_included += Koha::Number::Price->new( $line{ecost_tax_included} * $line{quantity} )->format;
my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber});
$line{suggestionid} = $suggestion->{suggestionid};
for (my $i = 0 ; $i < $countpendings ; $i++) {
my $order = $pendingorders->[$i];
- $order = C4::Acquisition::populate_order_with_prices({ order => $order, booksellerid => $bookseller->{id}, receiving => 1, ordering => 1 });
if ( $bookseller->{listincgst} and not $bookseller->{invoiceincgst} ) {
- $order->{ecost} = $order->{ecostgste};
+ $order->{ecost} = $order->{ecost_tax_excluded};
} elsif ( not $bookseller->{listinct} and $bookseller->{invoiceincgst} ) {
- $order->{ecost} = $order->{ecostgsti};
+ $order->{ecost} = $order->{ecost_tax_included};
+ } else {
+ $order->{ecost} = $order->{ecost_tax_excluded};
}
$order->{total} = $order->{ecost} * $order->{quantity};
loop_orders => \@loop_orders,
book_foot_loop => \@book_foot_loop,
(uc(C4::Context->preference("marcflavour"))) => 1,
- total_gste => $total_gste,
- total_gsti => $total_gsti,
+ total_tax_excluded => $total_tax_excluded,
+ total_tax_included => $total_tax_included,
subtotal_for_funds => $subtotal_for_funds,
sticky_filters => $sticky_filters,
);
$basket->{basketno},
$titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote for vendor : " . $line->{order_vendornote} : '' ),
$line->{quantity},
- Koha::Number::Price->new( $line->{rrpgsti} )->format,
+ Koha::Number::Price->new( $line->{rrp_tax_included} )->format,
Koha::Number::Price->new( $line->{discount} )->format . '%',
- Koha::Number::Price->new( $line->{gstrate} * 100 )->format . '%',
- Koha::Number::Price->new( $line->{totalgste} )->format,
- Koha::Number::Price->new( $line->{totalgsti} )->format,
+ Koha::Number::Price->new( $line->{tax_rate} * 100 )->format . '%',
+ Koha::Number::Price->new( $line->{total_tax_excluded} )->format,
+ Koha::Number::Price->new( $line->{total_tax_included} )->format,
);
push(@$abaskets, $arrbasket);
}
$basket->{basketno},
$titleinfo. ($line->{order_vendornote} ? "\n----------------\nLieferantennotiz : ". $line->{order_vendornote} : '' ), $line->{quantity},
$line->{quantity},
- Koha::Number::Price->new( $line->{rrpgsti} )->format,
+ Koha::Number::Price->new( $line->{rrp_tax_included} )->format,
Koha::Number::Price->new( $line->{discount} )->format . '%',
- Koha::Number::Price->new( $line->{gstrate} * 100 )->format . '%',
- Koha::Number::Price->new( $line->{totalgste} )->format,
- Koha::Number::Price->new( $line->{totalgsti} )->format,
+ Koha::Number::Price->new( $line->{tax_rate} * 100 )->format . '%',
+ Koha::Number::Price->new( $line->{total_tax_excluded} )->format,
+ Koha::Number::Price->new( $line->{total_tax_included} )->format,
);
push(@$abaskets, $arrbasket);
}
push( @$arrbasket,
$titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote for vendor : " . $line->{order_vendornote} : '' ),
$line->{quantity},
- Koha::Number::Price->new( $line->{rrpgste} )->format,
- Koha::Number::Price->new( $line->{rrpgsti} )->format,
+ Koha::Number::Price->new( $line->{rrp_tax_excluded} )->format,
+ Koha::Number::Price->new( $line->{rrp_tax_included} )->format,
Koha::Number::Price->new( $line->{discount} )->format . '%',
- Koha::Number::Price->new( $line->{rrpgste} - $line->{ecostgste})->format,
- Koha::Number::Price->new( $line->{gstrate} * 100 )->format . '%',
- Koha::Number::Price->new( $line->{totalgste} )->format,
- Koha::Number::Price->new( $line->{totalgsti} )->format,
+ Koha::Number::Price->new( $line->{rrp_tax_excluded} - $line->{ecost_tax_excluded})->format,
+ Koha::Number::Price->new( $line->{tax_rate} * 100 )->format . '%',
+ Koha::Number::Price->new( $line->{total_tax_excluded} )->format,
+ Koha::Number::Price->new( $line->{total_tax_included} )->format,
);
push(@$abaskets, $arrbasket);
}
for my $bkey (@keys) {
push(@$arrbasket, $bkey);
}
- my ($grandtotalrrpgsti, $grandtotalrrpgste, $grandtotalgsti, $grandtotalgste, $grandtotalgstvalue, $grandtotaldiscount);
+ my ($grandtotal_rrp_tax_included, $grandtotal_rrp_tax_excluded, $grandtotal_tax_included, $grandtotal_tax_excluded, $grandtotaltax_value, $grandtotaldiscount);
# calculate each basket total
push(@$abaskets, $arrbasket);
for my $basket (@$hbaskets) {
my @gst;
$arrbasket = undef;
- my ($totalrrpgste, $totalrrpgsti, $totalgste, $totalgsti, $totalgstvalue, $totaldiscount);
+ my ($total_rrp_tax_excluded, $total_rrp_tax_included, $total_tax_excluded, $total_tax_included, $totaltax_value, $totaldiscount);
my $ords = $orders->{$basket->{basketno}};
my $ordlength = @$ords;
foreach my $ord (@$ords) {
- $totalgste += $ord->{totalgste};
- $totalgsti += $ord->{totalgsti};
- $totalgstvalue += $ord->{gstvalue};
- $totaldiscount += ($ord->{rrpgste} - $ord->{ecostgste} ) * $ord->{quantity};
- $totalrrpgste += $ord->{rrpgste} * $ord->{quantity};
- $totalrrpgsti += $ord->{rrpgsti} * $ord->{quantity};
- push @gst, $ord->{gstrate};
+ $total_tax_excluded += $ord->{total_tax_excluded};
+ $total_tax_included += $ord->{total_tax_included};
+ $totaltax_value += $ord->{tax_value};
+ $totaldiscount += ($ord->{rrp_tax_excluded} - $ord->{ecost_tax_excluded} ) * $ord->{quantity};
+ $total_rrp_tax_excluded += $ord->{rrp_tax_excluded} * $ord->{quantity};
+ $total_rrp_tax_included += $ord->{rrp_tax_included} * $ord->{quantity};
+ push @gst, $ord->{tax_rate};
}
@gst = uniq map { $_ * 100 } @gst;
- $grandtotalrrpgste += $totalrrpgste;
- $grandtotalrrpgsti += $totalrrpgsti;
- $grandtotalgsti += $totalgsti;
- $grandtotalgste += $totalgste;
- $grandtotalgstvalue += $totalgstvalue;
+ $grandtotal_rrp_tax_excluded += $total_rrp_tax_excluded;
+ $grandtotal_rrp_tax_included += $total_rrp_tax_included;
+ $grandtotal_tax_included += $total_tax_included;
+ $grandtotal_tax_excluded += $total_tax_excluded;
+ $grandtotaltax_value += $totaltax_value;
$grandtotaldiscount += $totaldiscount;
my @gst_string =
map { Koha::Number::Price->new($_)->format . '%' } @gst;
push(@$arrbasket,
$basket->{contractname},
$basket->{basketname} . ' (No. ' . $basket->{basketno} . ')',
- Koha::Number::Price->new( $totalrrpgste )->format,
- Koha::Number::Price->new( $totalrrpgsti )->format,
+ Koha::Number::Price->new( $total_rrp_tax_excluded )->format,
+ Koha::Number::Price->new( $total_rrp_tax_included )->format,
"@gst_string",
- Koha::Number::Price->new( $totalgstvalue )->format,
+ Koha::Number::Price->new( $totaltax_value )->format,
Koha::Number::Price->new( $totaldiscount )->format,
- Koha::Number::Price->new( $totalgste )->format,
- Koha::Number::Price->new( $totalgsti )->format,
+ Koha::Number::Price->new( $total_tax_excluded )->format,
+ Koha::Number::Price->new( $total_tax_included )->format,
);
push(@$abaskets, $arrbasket);
}
push @$arrbasket,
'',
'Total',
- Koha::Number::Price->new( $grandtotalrrpgste )->format,
- Koha::Number::Price->new( $grandtotalrrpgsti )->format,
+ Koha::Number::Price->new( $grandtotal_rrp_tax_excluded )->format,
+ Koha::Number::Price->new( $grandtotal_rrp_tax_included )->format,
'',
- Koha::Number::Price->new( $grandtotalgstvalue )->format,
+ Koha::Number::Price->new( $grandtotaltax_value )->format,
Koha::Number::Price->new( $grandtotaldiscount )->format,
- Koha::Number::Price->new( $grandtotalgste )->format,
- Koha::Number::Price->new( $grandtotalgsti )->format;
+ Koha::Number::Price->new( $grandtotal_tax_excluded )->format,
+ Koha::Number::Price->new( $grandtotal_tax_included )->format;
push @$abaskets,$arrbasket;
# height is width and width is height in this function, as the pdf is in landscape mode for the Tables.
push( @$arrbasket,
$titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote pour le fournisseur : ". $line->{order_vendornote} : '' ),
$line->{quantity},
- Koha::Number::Price->new( $line->{rrpgste})->format,
- Koha::Number::Price->new( $line->{rrpgsti})->format,
+ Koha::Number::Price->new( $line->{rrp_tax_excluded})->format,
+ Koha::Number::Price->new( $line->{rrp_tax_included})->format,
Koha::Number::Price->new( $line->{discount})->format.'%',
- Koha::Number::Price->new( $line->{rrpgste} - $line->{ecostgste})->format,
- Koha::Number::Price->new( $line->{gstrate} * 100)->format.'%',
- Koha::Number::Price->new( $line->{totalgste})->format,
- Koha::Number::Price->new( $line->{totalgsti})->format,
+ Koha::Number::Price->new( $line->{rrp_tax_excluded} - $line->{ecost_tax_excluded})->format,
+ Koha::Number::Price->new( $line->{tax_rate} * 100)->format.'%',
+ Koha::Number::Price->new( $line->{total_tax_excluded})->format,
+ Koha::Number::Price->new( $line->{total_tax_included})->format,
);
push(@$abaskets, $arrbasket);
}
for my $bkey (@keys) {
push(@$arrbasket, $bkey);
}
- my ($grandtotalrrpgsti, $grandtotalrrpgste, $grandtotalgsti, $grandtotalgste, $grandtotalgstvalue, $grandtotaldiscount);
+ my ($grandtotal_rrp_tax_included, $grandtotal_rrp_tax_excluded, $grandtotal_tax_included, $grandtotal_tax_excluded, $grandtotaltax_value, $grandtotaldiscount);
# calculate each basket total
push(@$abaskets, $arrbasket);
for my $basket (@$hbaskets) {
my @gst;
$arrbasket = undef;
- my ($totalrrpgste, $totalrrpgsti, $totalgste, $totalgsti, $totalgstvalue, $totaldiscount);
+ my ($total_rrp_tax_excluded, $total_rrp_tax_included, $total_tax_excluded, $total_tax_included, $totaltax_value, $totaldiscount);
my $ords = $orders->{$basket->{basketno}};
my $ordlength = @$ords;
foreach my $ord (@$ords) {
- $totalgste += $ord->{totalgste};
- $totalgsti += $ord->{totalgsti};
- $totalgstvalue += $ord->{gstvalue};
- $totaldiscount += ($ord->{rrpgste} - $ord->{ecostgste} ) * $ord->{quantity};
- $totalrrpgste += $ord->{rrpgste} * $ord->{quantity};
- $totalrrpgsti += $ord->{rrpgsti} * $ord->{quantity};
- push @gst, $ord->{gstrate};
+ $total_tax_excluded += $ord->{total_tax_excluded};
+ $total_tax_included += $ord->{total_tax_included};
+ $totaltax_value += $ord->{tax_value};
+ $totaldiscount += ($ord->{rrp_tax_excluded} - $ord->{ecost_tax_excluded} ) * $ord->{quantity};
+ $total_rrp_tax_excluded += $ord->{rrp_tax_excluded} * $ord->{quantity};
+ $total_rrp_tax_included += $ord->{rrp_tax_included} * $ord->{quantity};
+ push @gst, $ord->{tax_rate};
}
@gst = uniq map { $_ * 100 } @gst;
- $grandtotalrrpgste += $totalrrpgste;
- $grandtotalrrpgsti += $totalrrpgsti;
- $grandtotalgsti += $totalgsti;
- $grandtotalgste += $totalgste;
- $grandtotalgstvalue += $totalgstvalue;
+ $grandtotal_rrp_tax_excluded += $total_rrp_tax_excluded;
+ $grandtotal_rrp_tax_included += $total_rrp_tax_included;
+ $grandtotal_tax_included += $total_tax_included;
+ $grandtotal_tax_excluded += $total_tax_excluded;
+ $grandtotaltax_value += $totaltax_value;
$grandtotaldiscount += $totaldiscount;
my @gst_string =
map { Koha::Number::Price->new($_)->format . '%' } @gst;
push(@$arrbasket,
$basket->{contractname},
$basket->{basketname} . ' (No. ' . $basket->{basketno} . ')',
- Koha::Number::Price->new( $totalrrpgste )->format,
- Koha::Number::Price->new( $totalrrpgsti )->format,
+ Koha::Number::Price->new( $total_rrp_tax_excluded )->format,
+ Koha::Number::Price->new( $total_rrp_tax_included )->format,
"@gst_string",
- Koha::Number::Price->new( $totalgstvalue )->format,
+ Koha::Number::Price->new( $totaltax_value )->format,
Koha::Number::Price->new( $totaldiscount )->format,
- Koha::Number::Price->new( $totalgste )->format,
- Koha::Number::Price->new( $totalgsti )->format,
+ Koha::Number::Price->new( $total_tax_excluded )->format,
+ Koha::Number::Price->new( $total_tax_included )->format,
);
push(@$abaskets, $arrbasket);
}
push @$arrbasket,
'',
'Total',
- Koha::Number::Price->new( $grandtotalrrpgste )->format,
- Koha::Number::Price->new( $grandtotalrrpgsti )->format,
+ Koha::Number::Price->new( $grandtotal_rrp_tax_excluded )->format,
+ Koha::Number::Price->new( $grandtotal_rrp_tax_included )->format,
'',
- Koha::Number::Price->new( $grandtotalgstvalue )->format,
+ Koha::Number::Price->new( $grandtotaltax_value )->format,
Koha::Number::Price->new( $grandtotaldiscount )->format,
- Koha::Number::Price->new( $grandtotalgste )->format,
- Koha::Number::Price->new( $grandtotalgsti )->format;
+ Koha::Number::Price->new( $grandtotal_tax_excluded )->format,
+ Koha::Number::Price->new( $grandtotal_tax_included )->format;
push @$abaskets,$arrbasket;
# height is width and width is height in this function, as the pdf is in landscape mode for the Tables.
$template->param(
active => $supplier->{'active'},
- gstrate => $supplier->{'gstrate'} + 0.0,
+ tax_rate => $supplier->{'tax_rate'} + 0.0,
invoiceprice => $supplier->{'invoiceprice'},
listprice => $supplier->{'listprice'},
basketcount => $supplier->{'basketcount'},
$template->param(
# set active ON by default for supplier add (id empty for add)
active => $booksellerid ? $supplier->{'active'} : 1,
- gstrate => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
+ tax_rate => $supplier->{tax_rate} ? $supplier->{'tax_rate'}+0.0 : 0,
gst_values => \@gst_values,
currencies => \@currencies,
enter => 1,
supplier, id, company, company_postal, physical, company_phone,
physical, company_phone, company_fax, website, company_email, notes,
status, publishers_imprints, list_currency, gst, list_gst, invoice_gst,
-discount, gstrate, contact_name, contact_position, contact_phone,
+discount, tax_rate, contact_name, contact_position, contact_phone,
contact_altphone, contact_fax, contact_email, contact_notes,
contact_claimacquisition, contact_claimissues, contact_acqprimary,
contact_serialsprimary.
$data{'listincgst'}=$input->param('list_gst');
$data{'invoiceincgst'}=$input->param('invoice_gst');
#have to transform this into fraction so it's easier to use
-$data{'gstrate'} = $input->param('gstrate');
+$data{'tax_rate'} = $input->param('tax_rate');
$data{'discount'} = $input->param('discount');
$data{deliverytime} = $input->param('deliverytime');
$data{'active'}=$input->param('status');
//<![CDATA[
function updateColumnsVisibility(visible) {
if ( visible ) {
- $("table .gste, .gsti").show();
+ $("table .tax_excluded, .tax_included").show();
} else {
[% IF ( listincgst ) %]
- $("table .gste").hide();
+ $("table .tax_excluded").hide();
[% ELSE %]
- $("table .gsti").hide();
+ $("table .tax_included").hide();
[% END %]
}
}
<tr>
<th>No.</th>
<th class="anti-the">Order</th>
- <th class="gste">RRP tax exc.</th>
- <th class="gste">Ecost tax exc.</th>
- <th class="gsti">RRP tax inc.</th>
- <th class="gsti">ecost tax inc.</th>
+ <th class="tax_excluded">RRP tax exc.</th>
+ <th class="tax_excluded">ecost tax exc.</th>
+ <th class="tax_included">RRP tax inc.</th>
+ <th class="tax_included">ecost tax inc.</th>
<th>Qty.</th>
- <th class="gste">Total tax exc. ([% currency %])</th>
- <th class="gsti">Total tax inc. ([% currency %])</th>
+ <th class="tax_excluded">Total tax exc. ([% currency %])</th>
+ <th class="tax_included">Total tax inc. ([% currency %])</th>
<th>GST %</th>
<th>GST</th>
<th>Fund</th>
[% FOREACH foot_loo IN book_foot_loop %]
<tr>
<th></th>
- <th>Total (GST [% foot_loo.gstrate * 100 | $Price %])</th>
- <th class="gste"> </th>
- <th class="gste"> </th>
- <th class="gsti"> </th>
- <th class="gsti"> </th>
+ <th>Total (GST [% foot_loo.tax_rate * 100 | $Price %])</th>
+ <th class="tax_excluded"> </th>
+ <th class="tax_excluded"> </th>
+ <th class="tax_included"> </th>
+ <th class="tax_included"> </th>
<th>[% foot_loo.quantity %]</th>
- <th class="gste">[% foot_loo.totalgste | $Price%]</th>
- <th class="gsti">[% foot_loo.totalgsti | $Price %]</th>
+ <th class="tax_excluded">[% foot_loo.total_tax_excluded | $Price%]</th>
+ <th class="tax_included">[% foot_loo.total_tax_included | $Price %]</th>
<th> </th>
- <th>[% foot_loo.gstvalue | $Price %]</th>
+ <th>[% foot_loo.tax_value | $Price %]</th>
<th> </th>
<th> </th>
[% IF ( active ) %]
<tr>
<th></th>
<th>Total ([% currency %])</th>
- <th class="gste"> </th>
- <th class="gste"> </th>
- <th class="gsti"> </th>
- <th class="gsti"> </th>
+ <th class="tax_excluded"> </th>
+ <th class="tax_excluded"> </th>
+ <th class="tax_included"> </th>
+ <th class="tax_included"> </th>
<th>[% total_quantity %]</th>
- <th class="gste">[% total_gste | $Price %]</th>
- <th class="gsti">[% total_gsti | $Price %]</th>
+ <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
+ <th class="tax_included">[% total_tax_included | $Price %]</th>
<th> </th>
- <th>[% total_gstvalue | $Price %]</th>
+ <th>[% total_tax_value | $Price %]</th>
<th> </th>
<th> </th>
[% IF ( active ) %]
</td>
[% SET zero_regex = "^0{1,}\.?0{1,}[^1-9]" %] [%# 0 or 0.0 or 0.00 or 00 or 00.0 or 00.00 or 0.000 ... %]
[%# FIXME: use of a regexp is not ideal; bugs 9410 and 10929 suggest better way of handling this %]
- <td class="number gste [% IF books_loo.rrpgste.search(zero_regex) %]error[% END %]">[% books_loo.rrpgste | $Price %]</td>
- <td class="number gste [% IF books_loo.ecostgste.search(zero_regex) %]error[% END %]">[% books_loo.ecostgste | $Price%]</td>
- <td class="number gsti [% IF books_loo.rrpgsti.search(zero_regex) %]error[% END %]">[% books_loo.rrpgsti | $Price %]</td>
- <td class="number gsti [% IF books_loo.ecostgsti.search(zero_regex) %]error[% END %]">[% books_loo.ecostgsti | $Price %]</td>
+ <td class="number tax_excluded [% IF books_loo.rrp_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.rrp_tax_excluded | $Price %]</td>
+ <td class="number tax_excluded [% IF books_loo.ecost_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.ecost_tax_excluded | $Price%]</td>
+ <td class="number tax_included [% IF books_loo.rrp_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.rrp_tax_included | $Price %]</td>
+ <td class="number tax_included [% IF books_loo.ecost_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.ecost_tax_included | $Price %]</td>
<td class="number [% IF books_loo.quantity.search(zero_regex) %]error[% END %]">[% books_loo.quantity %]</td>
- <td class="number gste [% IF books_loo.totalgste.search(zero_regex) %]error[% END %]">[% books_loo.totalgste | $Price %]</td>
- <td class="number gsti [% IF books_loo.totalgsti.search(zero_regex) %]error[% END %]">[% books_loo.totalgsti | $Price %]</td>
- <td class="number">[% books_loo.gstrate * 100 | $Price %]</td>
- <td class="number [% IF books_loo.gstvalue.search(zero_regex) %]error[% END %]">[% books_loo.gstvalue | $Price %]</td>
+ <td class="number tax_excluded [% IF books_loo.total_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.total_tax_excluded | $Price %]</td>
+ <td class="number tax_included [% IF books_loo.total_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.total_tax_included | $Price %]</td>
+ <td class="number">[% books_loo.tax_rate * 100 | $Price %]</td>
+ <td class="number [% IF books_loo.tax_value.search(zero_regex) %]error[% END %]">[% books_loo.tax_value | $Price %]</td>
<td>[% books_loo.budget_name %]</td>
<td>[% books_loo.suppliers_report %]</td>
[% IF ( active ) %]
<tr>
<th>No.</th>
<th>Order</th>
- <th class="gste">RRP tax exc.</th>
- <th class="gste">ecost tax exc.</th>
- <th class="gsti">RRP tax inc.</th>
- <th class="gsti">ecost tax inc.</th>
+ <th class="tax_excluded">RRP tax exc.</th>
+ <th class="tax_excluded">ecost tax exc.</th>
+ <th class="tax_included">RRP tax inc.</th>
+ <th class="tax_included">ecost tax inc.</th>
<th>Qty.</th>
- <th class="gste">Total tax exc. ([% currency %])</th>
- <th class="gsti">Total tax inc. ([% currency %])</th>
+ <th class="tax_excluded">Total tax exc. ([% currency %])</th>
+ <th class="tax_included">Total tax inc. ([% currency %])</th>
<th>GST %</th>
<th>GST</th>
<th>Fund</th>
</p>
[% END %]
</td>
- <td class="number gste">[% order.rrpgste | $Price %]</td>
- <td class="number gste">[% order.ecostgste | $Price %]</td>
- <td class="number gsti">[% order.rrpgsti | $Price %]</td>
- <td class="number gsti">[% order.ecostgsti | $Price %]</td>
+ <td class="number tax_excluded">[% order.rrp_tax_excluded | $Price %]</td>
+ <td class="number tax_excluded">[% order.ecost_tax_excluded | $Price %]</td>
+ <td class="number tax_included">[% order.rrp_tax_included | $Price %]</td>
+ <td class="number tax_included">[% order.ecost_tax_included | $Price %]</td>
<td class="number">[% order.quantity %]</td>
- <td class="number gste">[% order.totalgste | $Price %]</td>
- <td class="number gsti">[% order.totalgsti | $Price %]</td>
- <td class="number">[% order.gstrate * 100 | $Price %]</td>
- <td class="number">[% order.gstvalue | $Price %]</td>
+ <td class="number tax_excluded">[% order.total_tax_excluded | $Price %]</td>
+ <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
+ <td class="number">[% order.tax_rate * 100 | $Price %]</td>
+ <td class="number">[% order.tax_value | $Price %]</td>
<td>[% order.budget_name %]
</tr>
[% END %]
//<![CDATA[
function updateColumnsVisibility(visible) {
if ( visible ) {
- $("table .gste, .gsti").show();
+ $("table .tax_excluded, .tax_included").show();
} else {
[% IF ( invoiceincgst ) %]
- $("table .gste").hide();
+ $("table .tax_excluded").hide();
[% ELSE %]
- $("table .gsti").hide();
+ $("table .tax_included").hide();
[% END %]
}
}
<tr>
<th class="anti-the">Summary</th>
<th>Library</th>
- <th class="gste">Actual cost tax exc.</th>
- <th class="gsti">Actual cost tax inc.</th>
+ <th class="tax_excluded">Actual cost tax exc.</th>
+ <th class="tax_included">Actual cost tax inc.</th>
<th>Qty.</th>
- <th class="gste">Total tax exc. ([% currency.symbol %])</th>
- <th class="gsti">Total tax inc. ([% currency.symbol %])</th>
+ <th class="tax_excluded">Total tax exc. ([% currency.symbol %])</th>
+ <th class="tax_included">Total tax inc. ([% currency.symbol %])</th>
<th>GST %</th>
<th>GST</th>
<th>Fund</th>
[% END %]
</td>
<td><p>[% order.branchcode %]</p></td>
- <td class="number gste">[% order.unitpricegste | $Price %]</td>
- <td class="number gsti">[% order.unitpricegsti | $Price %]</td>
+ <td class="number tax_excluded">[% order.unitprice_tax_excluded | $Price %]</td>
+ <td class="number tax_included">[% order.unitprice_tax_included | $Price %]</td>
<td class="number">[% order.quantity %]</td>
- <td class="number gste">[% order.totalgste | $Price %]</td>
- <td class="number gsti">[% order.totalgsti | $Price %]</td>
- <td class="number">[% order.gstrate * 100 | $Price %]</td>
- <td class="number">[% order.gstvalue | $Price %]</td>
+ <td class="number tax_excluded">[% order.total_tax_excluded | $Price %]</td>
+ <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
+ <td class="number">[% order.tax_rate * 100 | $Price %]</td>
+ <td class="number">[% order.tax_value | $Price %]</td>
<td>[% order.budget_name %]</td>
</tr>
[% END %]
<tfoot>
[% FOR tf IN foot_loop %]
<tr>
- <th colspan='2'>Total (GST [% tf.gstrate * 100 | $Price %] %)</th>
- <th class="gste"/><th class="gsti"/>
+ <th colspan='3'>Total (GST [% tf.tax_rate * 100 | $Price %] %)</th>
+ <th class="tax_excluded"/><th class="tax_included"/>
<th>[% tf.quantity %]</th>
- <th class="gste">[% tf.totalgste | $Price %]</th>
- <th class="gsti">[% tf.totalgsti | $Price %]</th>
+ <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
+ <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
<th> </th>
- <th>[% tf.gstvalue | $Price %]</th>
+ <th>[% tf.tax_value | $Price %]</th>
<th> </th>
</tr>
[% END %]
<tr>
<th colspan='2'>Total ([% currency.symbol %])</th>
- <th class="gste"/><th class="gsti"/>
+ <th class="tax_excluded"/><th class="tax_included"/>
<th>[% total_quantity %]</th>
- <th class="gste">[% total_gste | $Price %]</th>
- <th class="gsti">[% total_gsti | $Price %]</th>
+ <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
+ <th class="tax_included">[% total_tax_included | $Price %]</th>
<th> </th>
- <th>[% total_gstvalue | $Price %]</th>
+ <th>[% total_tax_value | $Price %]</th>
<th> </th>
</tr>
<tr>
<th colspan="2">Total + Shipment cost ([% currency.symbol %])</th>
- <th class="gste"></th>
- <th class="gsti"></th>
+ <th class="tax_excluded"></th>
+ <th class="tax_included"></th>
<th>[% total_quantity %]</th>
- <th class="gste">[% total_gste_shipment | $Price %]</th>
- <th class="gsti">[% total_gsti_shipment | $Price %]</th>
+ <th class="tax_excluded">[% total_tax_excluded_shipment | $Price %]</th>
+ <th class="tax_included">[% total_tax_included_shipment | $Price %]</th>
<th> </th>
- <th>[% total_gstvalue | $Price %]</th>
+ <th>[% total_tax_value | $Price %]</th>
<th> </th>
</tr>
</tfoot>
<li>
[% IF ( close ) %]
<span class="label">Tax rate: </span>
- <input type="hidden" name="gstrate" id="gstrate" value="[% gstrate %]" />[% gstrate %]%
+ <input type="hidden" name="tax_rate" id="tax_rate" value="[% tax_rate %]" />[% tax_rate %]%
[% ELSE %]
- <label for="gstrate">Tax rate: </label>
- <select name="gstrate" id="gstrate" onchange="updateCosts();">
+ <label for="tax_rate">Tax rate: </label>
+ <select name="tax_rate" id="tax_rate" onchange="updateCosts();">
[% FOREACH gst IN gst_values %]
- [% IF ( gst.option == gstrate ) %]
+ [% IF ( gst.option == tax_rate ) %]
<option value="[% gst.option %]" selected="selected">[% gst.option * 100 | format("%.1f") %]%</option>
[% ELSE %]
<option value="[% gst.option %]">[% gst.option * 100 | format("%.1f") %]%</option>
</select>
[% END %]
[% ELSE %]
- <input type="hidden" name="gstrate" value="0" />
+ <input type="hidden" name="tax_rate" value="0" />
</li>
[% END %]
<li>
<input type="hidden" name="invoiceid" value="[% invoiceid %]" />
<input type="hidden" name="ordernumber" value="[% ordernumber %]" />
<input type="hidden" name="booksellerid" value="[% booksellerid %]" />
- <input type="hidden" name="gstrate" value="[% gstrate %]" />
+ <input type="hidden" name="tax_rate" value="[% tax_rate %]" />
</div>
<div class="yui-u">
<fieldset class="rows">
[% END %]
<tr>
<th colspan="10" class="total">Total tax exc.</th>
- <th>[% total_gste | $Price %]</th>
+ <th>[% total_tax_excluded | $Price %]</th>
<th></th>
</tr>
[% FOREACH book_foot IN book_foot_loop %]
<tr>
- <th colspan="10">Total (GST [% book_foot.gstrate * 100 | $Price %]%)</th>
- <th>[% book_foot.gstvalue | $Price %]</th>
+ <th colspan="10">Total (GST [% book_foot.tax_rate * 100 | $Price %]%)</th>
+ <th>[% book_foot.tax_value | $Price %]</th>
<th></th>
</tr>
[% END %]
<tr>
<th colspan="10" class="total">Total tax inc.</th>
- <th>[% total_gsti | $Price %]</th>
+ <th>[% total_tax_included | $Price %]</th>
<th></th>
</tr>
</tfoot>
[% IF gst_values %]
<ol>
<li>
- <label for="gstrate">Tax rate: </label>
- <select name="gstrate" id="gstrate">
+ <label for="tax_rate">Tax rate: </label>
+ <select name="tax_rate" id="tax_rate">
[% FOREACH gst IN gst_values %]
- [% IF ( gstrate == gst.option ) %]
+ [% IF ( tax_rate == gst.option ) %]
<option value="[% gst.option %]" selected="selected">[% gst.option * 100 | format ("%.1f") %] %</option>
[% ELSE %]
<option value="[% gst.option %]">[% gst.option * 100 | format ("%.1f") %] %</option>
</li>
</ol>
[% ELSE %]
- <input type="hidden" name="gstrate" value="0" />
+ <input type="hidden" name="tax_rate" value="0" />
[% END %]
<ol>
<li><label for="discount">Discount: </label>
[% END %]</p>
<p><strong>List prices are: </strong>[% listprice %]</p>
<p><strong>Invoice prices are: </strong>[% invoiceprice %]</p>
- [% IF ( gstrate ) %]<p><strong>Tax number registered: </strong>
+ [% IF ( tax_rate ) %]<p><strong>Tax number registered: </strong>
[% IF ( gstreg ) %]Yes[% ELSE %]No[% END %]</p>
<p><strong>List item price includes tax: </strong>
[% IF ( listincgst ) %]Yes[% ELSE %]No[% END %]</p>
<p><strong>Discount: </strong>
[% discount | format("%.1f") %] %</p>
<p><strong>Tax rate: </strong>
- [% 0 + gstrate * 100 | format("%.1f") %] %</p>
+ [% 0 + tax_rate * 100 | format("%.1f") %] %</p>
[% IF deliverytime.defined %]
<p><strong>Delivery time: </strong>
[% deliverytime %] days</p>
<li>A basket with at least one uncertain price can't be closed.</li>
</ul>
</li>
- <li>If you are charged sales tax, choose that from the gstrate field</li>
+ <li>If you are charged sales tax, choose that from the tax_rate field</li>
<li>Enter the percentage discount you're receiving on this order, once you enter this, hit tab and Koha will populate the rest of the cost fields below.</li>
<li>If you added Planning Values when creating the Fund, those values will appear in the two Planning Value fields.</li>
</ul>
<tbody>
<tr>
<td>Ordered amount</td>
- <td>[% valuegste_ordered %]</td>
- <td>[% valuegsti_ordered %]</td>
+ <td>[% value_tax_excluded_ordered %]</td>
+ <td>[% value_tax_included_ordered %]</td>
<td>[% budget_name_ordered %]</td>
<td>
[% IF ( ordered_exists ) %]
</tr>
<tr>
<td>Spent amount</td>
- <td>[% valuegste_spent %]</td>
- <td>[% valuegsti_spent %]</td>
+ <td>[% value_tax_excluded_spent %]</td>
+ <td>[% value_tax_included_spent %]</td>
<td>[% budget_name_spent %]</td>
<td>
[% IF ( spent_exists ) %]
if ( defined $lastOrderNotReceived ) {
my $basket = GetBasket $lastOrderNotReceived->{basketno};
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
- ( $tmpl_infos->{valuegsti_ordered}, $tmpl_infos->{valuegste_ordered} ) = get_value_with_gst_params ( $lastOrderNotReceived->{ecost}, $lastOrderNotReceived->{gstrate}, $bookseller );
- $tmpl_infos->{valuegsti_ordered} = sprintf( "%.2f", $tmpl_infos->{valuegsti_ordered} );
- $tmpl_infos->{valuegste_ordered} = sprintf( "%.2f", $tmpl_infos->{valuegste_ordered} );
+ ( $tmpl_infos->{value_tax_included_ordered}, $tmpl_infos->{value_tax_excluded_ordered} ) = get_value_with_gst_params ( $lastOrderNotReceived->{ecost}, $lastOrderNotReceived->{tax_rate}, $bookseller );
+ $tmpl_infos->{value_tax_included_ordered} = sprintf( "%.2f", $tmpl_infos->{value_tax_included_ordered} );
+ $tmpl_infos->{value_tax_excluded_ordered} = sprintf( "%.2f", $tmpl_infos->{value_tax_excluded_ordered} );
$tmpl_infos->{budget_name_ordered} = GetBudgetName $lastOrderNotReceived->{budget_id};
$tmpl_infos->{basketno} = $lastOrderNotReceived->{basketno};
$tmpl_infos->{ordered_exists} = 1;
if ( defined $lastOrderReceived ) {
my $basket = GetBasket $lastOrderReceived->{basketno};
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
- ( $tmpl_infos->{valuegsti_spent}, $tmpl_infos->{valuegste_spent} ) = get_value_with_gst_params ( $lastOrderReceived->{unitprice}, $lastOrderReceived->{gstrate}, $bookseller );
- $tmpl_infos->{valuegsti_spent} = sprintf( "%.2f", $tmpl_infos->{valuegsti_spent} );
- $tmpl_infos->{valuegste_spent} = sprintf( "%.2f", $tmpl_infos->{valuegste_spent} );
+ ( $tmpl_infos->{value_tax_included_spent}, $tmpl_infos->{value_tax_excluded_spent} ) = get_value_with_gst_params ( $lastOrderReceived->{unitprice}, $lastOrderReceived->{tax_rate}, $bookseller );
+ $tmpl_infos->{value_tax_included_spent} = sprintf( "%.2f", $tmpl_infos->{value_tax_included_spent} );
+ $tmpl_infos->{value_tax_excluded_spent} = sprintf( "%.2f", $tmpl_infos->{value_tax_excluded_spent} );
$tmpl_infos->{budget_name_spent} = GetBudgetName $lastOrderReceived->{budget_id};
$tmpl_infos->{invoiceid} = $lastOrderReceived->{invoiceid};
$tmpl_infos->{spent_exists} = 1;
sub get_value_with_gst_params {
my $value = shift;
- my $gstrate = shift;
+ my $tax_rate = shift;
my $bookseller = shift;
if ( $bookseller->{listincgst} ) {
- return ( $value, $value / ( 1 + $gstrate ) );
+ return ( $value, $value / ( 1 + $tax_rate ) );
} else {
- return ( $value * ( 1 + $gstrate ), $value );
+ return ( $value * ( 1 + $tax_rate ), $value );
}
}
-sub get_gste {
+sub get_tax_excluded {
my $value = shift;
- my $gstrate = shift;
+ my $tax_rate = shift;
my $bookseller = shift;
if ( $bookseller->{invoiceincgst} ) {
- return $value / ( 1 + $gstrate );
+ return $value / ( 1 + $tax_rate );
} else {
return $value;
}
sub get_gst {
my $value = shift;
- my $gstrate = shift;
+ my $tax_rate = shift;
my $bookseller = shift;
if ( $bookseller->{invoiceincgst} ) {
- return $value / ( 1 + $gstrate ) * $gstrate;
+ return $value / ( 1 + $tax_rate ) * $tax_rate;
} else {
- return $value * ( 1 + $gstrate ) - $value;
+ return $value * ( 1 + $tax_rate ) - $value;
}
}
invoiceid => $invoiceid_0_0,
rrp => 82.00,
ecost => 73.80,
- gstrate => 0.0500,
+ tax_rate => 0.0500,
discount => 10.0000,
datereceived => $today
};
# Note that this configuration is correct \o/
compare(
{
- got => $order_0_0->{rrpgsti},
+ got => $order_0_0->{rrp_tax_included},
expected => 86.10,
conf => '0 0',
- field => 'rrpgsti'
+ field => 'rrp_tax_included'
}
);
compare(
{
- got => $order_0_0->{rrpgste},
+ got => $order_0_0->{rrp_tax_excluded},
expected => 82.00,
conf => '0 0',
- field => 'rrpgste'
+ field => 'rrp_tax_excluded'
}
);
compare(
{
- got => $order_0_0->{ecostgsti},
+ got => $order_0_0->{ecost_tax_included},
expected => 77.49,
conf => '0 0',
- field => 'ecostgsti'
+ field => 'ecost_tax_included'
}
);
compare(
{
- got => $order_0_0->{ecostgste},
+ got => $order_0_0->{ecost_tax_excluded},
expected => 73.80,
conf => '0 0',
- field => 'ecostgste'
+ field => 'ecost_tax_excluded'
}
);
compare(
{
- got => $order_0_0->{gstvalue},
+ got => $order_0_0->{tax_value},
expected => 7.38,
conf => '0 0',
- field => 'gstvalue'
+ field => 'tax_value'
}
);
compare(
{
- got => $order_0_0->{totalgsti},
+ got => $order_0_0->{total_tax_included},
expected => 154.98,
conf => '0 0',
- field => 'totalgsti'
+ field => 'total_tax_included'
}
);
compare(
{
- got => $order_0_0->{totalgste},
+ got => $order_0_0->{total_tax_excluded},
expected => 147.60,
conf => '0 0',
- field => 'totalgste'
+ field => 'total_tax_excluded'
}
);
# Note that this configuration is correct \o/
compare(
{
- got => $order_0_0->{unitpricegsti},
+ got => $order_0_0->{unitprice_tax_included},
expected => 77.49,
conf => '0 0',
- field => 'unitpricegsti'
+ field => 'unitprice_tax_included'
}
);
compare(
{
- got => $order_0_0->{unitpricegste},
+ got => $order_0_0->{unitprice_tax_excluded},
expected => 73.80,
conf => '0 0',
- field => 'unitpricegste'
+ field => 'unitprice_tax_excluded'
}
);
compare(
{
- got => $order_0_0->{gstvalue},
+ got => $order_0_0->{tax_value},
expected => 7.38,
conf => '0 0',
- field => 'gstvalue'
+ field => 'tax_value'
}
);
compare(
{
- got => $order_0_0->{totalgsti},
+ got => $order_0_0->{total_tax_included},
expected => 154.98,
conf => '0 0',
- field => 'totalgsti'
+ field => 'total_tax_included'
}
);
compare(
{
- got => $order_0_0->{totalgste},
+ got => $order_0_0->{total_tax_excluded},
expected => 147.60,
conf => '0 0',
- field => 'totalgste'
+ field => 'total_tax_excluded'
}
);
};
invoiceid => $invoiceid_1_1,
rrp => 82.00,
ecost => 73.80,
- gstrate => 0.0500,
+ tax_rate => 0.0500,
discount => 10.0000,
datereceived => $today
};
);
# Note that this configuration is *not* correct
- # gstvalue should be 7.03 instead of 7.02
+ # tax_value should be 7.03 instead of 7.02
compare(
{
- got => $order_1_1->{rrpgsti},
+ got => $order_1_1->{rrp_tax_included},
expected => 82.00,
conf => '1 1',
- field => 'rrpgsti'
+ field => 'rrp_tax_included'
}
);
compare(
{
- got => $order_1_1->{rrpgste},
+ got => $order_1_1->{rrp_tax_excluded},
expected => 78.10,
conf => '1 1',
- field => 'rrpgste'
+ field => 'rrp_tax_excluded'
}
);
compare(
{
- got => $order_1_1->{ecostgsti},
+ got => $order_1_1->{ecost_tax_included},
expected => 73.80,
conf => '1 1',
- field => 'ecostgsti'
+ field => 'ecost_tax_included'
}
);
compare(
{
- got => $order_1_1->{ecostgste},
+ got => $order_1_1->{ecost_tax_excluded},
expected => 70.29,
conf => '1 1',
- field => 'ecostgste'
+ field => 'ecost_tax_excluded'
}
);
compare(
{
- got => $order_1_1->{gstvalue},
+ got => $order_1_1->{tax_value},
expected => 7.02,
conf => '1 1',
- field => 'gstvalue'
+ field => 'tax_value'
}
);
compare(
{
- got => $order_1_1->{totalgsti},
+ got => $order_1_1->{total_tax_included},
expected => 147.60,
conf => '1 1',
- field => 'totalgsti'
+ field => 'total_tax_included'
}
);
compare(
{
- got => $order_1_1->{totalgste},
+ got => $order_1_1->{total_tax_excluded},
expected => 140.58,
conf => '1 1',
- field => 'totalgste'
+ field => 'total_tax_excluded'
}
);
}
);
# Note that this configuration is *not* correct!
- # gstvalue should be 7.03
+ # tax_value should be 7.03
compare(
{
- got => $order_1_1->{unitpricegsti},
+ got => $order_1_1->{unitprice_tax_included},
expected => 73.80,
conf => '1 1',
- field => 'unitpricegsti'
+ field => 'unitprice_tax_included'
}
);
compare(
{
- got => $order_1_1->{unitpricegste},
+ got => $order_1_1->{unitprice_tax_excluded},
expected => 70.29,
conf => '1 1',
- field => 'unitpricegste'
+ field => 'unitprice_tax_excluded'
}
);
compare(
{
- got => $order_1_1->{gstvalue},
+ got => $order_1_1->{tax_value},
expected => 7.02,
conf => '1 1',
- field => 'gstvalue'
+ field => 'tax_value'
}
);
compare(
{
- got => $order_1_1->{totalgsti},
+ got => $order_1_1->{total_tax_included},
expected => 147.60,
conf => '1 1',
- field => 'totalgsti'
+ field => 'total_tax_included'
}
);
compare(
{
- got => $order_1_1->{totalgste},
+ got => $order_1_1->{total_tax_excluded},
expected => 140.58,
conf => '1 1',
- field => 'totalgste'
+ field => 'total_tax_excluded'
}
);
};
invoiceid => $invoiceid_1_1,
rrp => 82.01,
ecost => 73.80,
- gstrate => 0.0500,
+ tax_rate => 0.0500,
discount => 10.0000,
datereceived => $today
};
);
# Note that this configuration is *not* correct!
- # rrp gsti should be 82 (what we inserted!)
- # => Actually we need to fix the inserted value (here we have 82.01 in DB)
- # gstvalue should be 7.03 instead of 7.02
+ # rrp_tax_included should be 82 (what we inserted!)
+ # tax_value should be 7.03 instead of 7.02
compare(
{
- got => $order_1_0->{rrpgsti},
+ got => $order_1_0->{rrp_tax_included},
expected => 82.01,
conf => '1 0',
- field => 'rrpgsti'
+ field => 'rrp_tax_included'
}
);
compare(
{
- got => $order_1_0->{rrpgste},
+ got => $order_1_0->{rrp_tax_excluded},
expected => 78.10,
conf => '1 0',
- field => 'rrpgste'
+ field => 'rrp_tax_excluded'
}
);
compare(
{
- got => $order_1_0->{ecostgsti},
+ got => $order_1_0->{ecost_tax_included},
expected => 73.80,
conf => '1 0',
- field => 'ecostgsti'
+ field => 'ecost_tax_included'
}
);
compare(
{
- got => $order_1_0->{ecostgste},
+ got => $order_1_0->{ecost_tax_excluded},
expected => 70.29,
conf => '1 0',
- field => 'ecostgste'
+ field => 'ecost_tax_excluded'
}
);
compare(
{
- got => $order_1_0->{gstvalue},
+ got => $order_1_0->{tax_value},
expected => 7.02,
conf => '1 0',
- field => 'gstvalue'
+ field => 'tax_value'
}
);
compare(
{
- got => $order_1_0->{totalgsti},
+ got => $order_1_0->{total_tax_included},
expected => 147.60,
conf => '1 0',
- field => 'totalgsti'
+ field => 'total_tax_included'
}
);
compare(
{
- got => $order_1_0->{totalgste},
+ got => $order_1_0->{total_tax_excluded},
expected => 140.58,
conf => '1 0',
- field => 'totalgste'
+ field => 'total_tax_excluded'
}
);
# gstvalue should be 7.03
compare(
{
- got => $order_1_0->{unitpricegsti},
+ got => $order_1_0->{unitprice_tax_included},
expected => 73.80,
conf => '1 0',
- field => 'unitpricegsti'
+ field => 'unitprice_tax_included'
}
);
compare(
{
- got => $order_1_0->{unitpricegste},
+ got => $order_1_0->{unitprice_tax_excluded},
expected => 70.29,
conf => '1 0',
- field => 'unitpricegste'
+ field => 'unitprice_tax_excluded'
}
);
compare(
{
- got => $order_1_0->{gstvalue},
+ got => $order_1_0->{tax_value},
expected => 7.02,
conf => '1 0',
- field => 'gstvalue'
+ field => 'tax_value'
}
);
compare(
{
- got => $order_1_0->{totalgsti},
+ got => $order_1_0->{total_tax_included},
expected => 147.60,
conf => '1 0',
- field => 'totalgsti'
+ field => 'total_tax_included'
}
);
compare(
{
- got => $order_1_0->{totalgste},
+ got => $order_1_0->{total_tax_excluded},
expected => 140.58,
conf => '1 0',
- field => 'totalgste'
+ field => 'total_tax_excluded'
}
);
};
invoiceid => $invoiceid_1_1,
rrp => 82.00,
ecost => 73.80,
- gstrate => 0.0500,
+ tax_rate => 0.0500,
discount => 10.0000,
datereceived => $today
};
# Note that this configuration is correct \o/
compare(
{
- got => $order_0_1->{rrpgsti},
+ got => $order_0_1->{rrp_tax_included},
expected => 86.10,
conf => '1 0',
- field => 'rrpgsti'
+ field => 'rrp_tax_included'
}
);
compare(
{
- got => $order_0_1->{rrpgste},
+ got => $order_0_1->{rrp_tax_excluded},
expected => 82.00,
conf => '1 0',
- field => 'rrpgste'
+ field => 'rrp_tax_excluded'
}
);
compare(
{
- got => $order_0_1->{ecostgsti},
+ got => $order_0_1->{ecost_tax_included},
expected => 77.49,
conf => '1 0',
- field => 'ecostgsti'
+ field => 'ecost_tax_included'
}
);
compare(
{
- got => $order_0_1->{ecostgste},
+ got => $order_0_1->{ecost_tax_excluded},
expected => 73.80,
conf => '1 0',
- field => 'ecostgste'
+ field => 'ecost_tax_excluded'
}
);
compare(
{
- got => $order_0_1->{gstvalue},
+ got => $order_0_1->{tax_value},
expected => 7.38,
conf => '1 0',
- field => 'gstvalue'
+ field => 'tax_value'
}
);
compare(
{
- got => $order_0_1->{totalgsti},
+ got => $order_0_1->{total_tax_included},
expected => 154.98,
conf => '1 0',
- field => 'totalgsti'
+ field => 'total_tax_included'
}
);
compare(
{
- got => $order_0_1->{totalgste},
+ got => $order_0_1->{total_tax_excluded},
expected => 147.60,
conf => '1 0',
- field => 'totalgste'
+ field => 'total_tax_excluded'
}
);
# Note that this configuration is correct
compare(
{
- got => $order_0_1->{unitpricegsti},
+ got => $order_0_1->{unitprice_tax_included},
expected => 77.49,
conf => '0 1',
- field => 'unitpricegsti'
+ field => 'unitprice_tax_included'
}
);
compare(
{
- got => $order_0_1->{unitpricegste},
+ got => $order_0_1->{unitprice_tax_excluded},
expected => 73.80,
conf => '0 1',
- field => 'unitpricegste'
+ field => 'unitprice_tax_excluded'
}
);
compare(
{
- got => $order_0_1->{gstvalue},
+ got => $order_0_1->{tax_value},
expected => 7.38,
conf => '0 1',
- field => 'gstvalue'
+ field => 'tax_value'
}
);
compare(
{
- got => $order_0_1->{totalgsti},
+ got => $order_0_1->{total_tax_included},
expected => 154.98,
conf => '0 1',
- field => 'totalgsti'
+ field => 'total_tax_included'
}
);
compare(
{
- got => $order_0_1->{totalgste},
+ got => $order_0_1->{total_tax_excluded},
expected => 147.60,
conf => '0 1',
- field => 'totalgste'
+ field => 'total_tax_excluded'
}
);
};
ecost => 38.15,
rrp => 40.15,
discount => 5.1111,
- gstrate => 0.0515
+ tax_rate => 0.0515
}
},
{
ecost => 38.1,
rrp => 11.0,
discount => 5.1,
- gstrate => 0.1
+ tax_rate => 0.1
}
},
{
rrp => 11.00,
discount => 0,
uncertainprice => 0,
- gstrate => 0
+ tax_rate => 0
}
},
{
rrp => 10,
discount => 0,
uncertainprice => 0,
- gstrate => 0
+ tax_rate => 0
}
}
);
invoiceid
freight
unitprice
+ unitprice_tax_included
+ unitprice_tax_excluded
quantityreceived
datecancellationprinted
purchaseordernumber
basketno
timestamp
rrp
+ rrp_tax_included
+ rrp_tax_excluded
ecost
+ ecost_tax_included
+ ecost_tax_excluded
unitpricesupplier
unitpricelib
- gstrate
+ tax_rate
+ tax_value
discount
budget_id
budgetdate
notes
ordernumber
ecost
+ ecost_tax_included
+ ecost_tax_excluded
uncertainprice
url
isbn
budget_parent_id
publishercode
unitprice
+ unitprice_tax_included
+ unitprice_tax_excluded
collectionvolume
budget_amount
budget_owner_id
suppliers_report
agerestriction
budget_branchcode
- gstrate
+ tax_rate
+ tax_value
listprice
budget_code
budgetdate
sort2_authcat
budget_expend
rrp
+ rrp_tax_included
+ rrp_tax_excluded
cn_sort
lccn
sort1
firstname
biblioitemnumber
ecost
+ ecost_tax_included
+ ecost_tax_excluded
uncertainprice
creationdate
datereceived
suppliers_report
isbn
copyrightdate
- gstrate
+ tax_rate
+ tax_value
serial
listprice
budgetdate
unititle
sort2_authcat
rrp
+ rrp_tax_included
+ rrp_tax_excluded
unitprice
+ unitprice_tax_included
+ unitprice_tax_excluded
sort1
ordernumber
datecreated
unknown => "unknown"
);
+my $invoice = GetInvoice( $invoiceid );
+
my ($datereceived, $new_ordernumber) = ModReceiveOrder(
{
biblionumber => $biblionumber4,
- ordernumber => $ordernumbers[4],
+ order => GetOrder( $ordernumbers[4] ),
quantityreceived => 1,
- cost => 10,
- ecost => 10,
- invoiceid => $invoiceid,
- rrp => 10,
+ invoice => $invoice,
budget_id => $order_content[4]->{str}->{budget_id},
}
);
"AddClaim : Check claimed_date"
);
+my $order2 = GetOrder( $ordernumbers[1] );
+$order2->{order_internalnote} = "my notes";
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber2,
- ordernumber => $ordernumbers[1],
+ order => $order2,
quantityreceived => 2,
- cost => 12,
- ecost => 12,
- invoiceid => $invoiceid,
- rrp => 42,
- order_internalnote => "my notes",
- order_vendornote => "my vendor notes",
+ invoice => $invoice,
}
-);
-my $order2 = GetOrder( $ordernumbers[1] );
+)
+;
+$order2 = GetOrder( $ordernumbers[1] );
is( $order2->{'quantityreceived'},
0, 'Splitting up order did not receive any on original order' );
is( $order2->{'quantity'}, 40, '40 items on original order' );
'Budget on original order is unchanged' );
is( $order2->{order_internalnote}, "my notes",
'ModReceiveOrder and GetOrder deal with internal notes' );
-is( $order2->{order_vendornote}, "my vendor notes",
- 'ModReceiveOrder and GetOrder deal with vendor notes' );
$neworder = GetOrder($new_ordernumber);
is( $neworder->{'quantity'}, 2, '2 items on new order' );
}
);
+my $order3 = GetOrder( $ordernumbers[2] );
+$order3->{order_internalnote} = "my other notes";
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber2,
- ordernumber => $ordernumbers[2],
+ order => $order3,
quantityreceived => 2,
- cost => 12,
- ecost => 12,
- invoiceid => $invoiceid,
- rrp => 42,
+ invoice => $invoice,
budget_id => $budgetid2,
- order_internalnote => "my other notes",
}
);
-my $order3 = GetOrder( $ordernumbers[2] );
+$order3 = GetOrder( $ordernumbers[2] );
is( $order3->{'quantityreceived'},
0, 'Splitting up order did not receive any on original order' );
is( $order3->{'quantity'}, 2, '2 items on original order' );
2, 'Splitting up order received items on new order' );
is( $neworder->{'budget_id'}, $budgetid2, 'Budget on new order is changed' );
+$order3 = GetOrder( $ordernumbers[2] );
+$order3->{order_internalnote} = "my third notes";
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber2,
- ordernumber => $ordernumbers[2],
+ order => $order3,
quantityreceived => 2,
- cost => 12,
- ecost => 12,
- invoiceid => $invoiceid,
- rrp => 42,
+ invoice => $invoice,
budget_id => $budgetid2,
- order_internalnote => "my third notes",
}
);
ModReceiveOrder(
{
biblionumber => $biblionumber,
- ordernumber => $ordernumber,
+ order => $order,
quantityreceived => 2,
- datereceived => dt_from_string
}
);
CancelReceipt($ordernumber);
-$order = GetOrder( $ordernumber );
-is(scalar GetItemnumbersFromOrder($order->{ordernumber}), 0, "Create items on receiving: 0 item exist after cancelling a receipt");
+is(scalar GetItemnumbersFromOrder($ordernumber), 0, "Create items on receiving: 0 item exist after cancelling a receipt");
my $itemnumber1 = AddItem({}, $biblionumber);
my $itemnumber2 = AddItem({}, $biblionumber);
my ( undef, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber,
- ordernumber => $ordernumber,
+ order => $order,
quantityreceived => 1,
- datereceived => dt_from_string,
received_items => [ $itemnumber1 ],
}
);
shipmentdate => '2012-12-24',
);
+my $invoice1 = GetInvoice( $invoiceid1 );
+my $invoice2 = GetInvoice( $invoiceid2 );
+
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber1,
- ordernumber => $ordernumber1,
+ order => $order1,
quantityreceived => 2,
- cost => 12,
- ecost => 12,
- invoiceid => $invoiceid1,
- rrp => 42
+ invoice => $invoice1,
}
);
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber2,
- ordernumber => $ordernumber2,
+ order => $order2,
quantityreceived => 1,
- cost => 5,
- ecost => 5,
- invoiceid => $invoiceid2,
+ invoice => $invoice2,
rrp => 42
}
);
( $datereceived, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber3,
- ordernumber => $ordernumber3,
+ order => $order3,
quantityreceived => 1,
- cost => 12,
- ecost => 12,
- invoiceid => $invoiceid2,
- rrp => 42
+ invoice => $invoice2,
}
);
-my $invoice1 = GetInvoiceDetails($invoiceid1);
-my $invoice2 = GetInvoiceDetails($invoiceid2);
+$invoice1 = GetInvoiceDetails($invoiceid1);
+$invoice2 = GetInvoiceDetails($invoiceid2);
is(scalar @{$invoice1->{'orders'}}, 1, 'Invoice1 has only one order');
is(scalar @{$invoice2->{'orders'}}, 2, 'Invoice2 has only two orders');
basketno => $basketno,
rrp => $cost,
ecost => $cost,
- gstrate => 0.0500,
+ tax_rate => 0.0500,
orderstatus => 'new',
subscriptionid => $subscription->{subscriptionid},
budget_id => $budget_id,
$dbh->do(q{DELETE FROM aqinvoices});
my $invoiceid = AddInvoice(invoicenumber => 'invoice1', booksellerid => $booksellerid, unknown => "unknown");
+my $invoice = GetInvoice( $invoiceid );
+$invoice->{datereceived} = '02-01-2013';
+
my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
{
biblionumber => $biblionumber,
- ordernumber => $ordernumber,
+ order => $order,
quantityreceived => 1,
- cost => $cost,
- ecost => $cost,
- rrp => $cost,
budget_id => $budget_id,
- invoiceid => $invoiceid,
+ invoice => $invoice,
}
);
is ( scalar( @$orders ), 1, 'SearchOrders returns 1 order with [old]ordernumber' );
is ( $orders->[0]->{ordernumber}, $newordernumber, 'SearchOrders returns newordernumber if [old]ordernumber is given' );
+my $neworder = GetOrder( $newordernumber );
+
ModReceiveOrder({
biblionumber => $biblionumber,
- ordernumber => $newordernumber,
+ order => $neworder,
quantityreceived => 2,
- datereceived => dt_from_string(),
});
CancelReceipt( $newordernumber );
$order = GetOrder( $newordernumber );
gstreg => 1,
listincgst => 1,
invoiceincgst => 1,
- gstrate => '1.0000',
+ tax_rate => '1.0000',
discount => '1.0000',
notes => 'notes1',
deliverytime => undef
gstreg => 1,
listincgst => 1,
invoiceincgst => 1,
- gstrate => '2.0000',
+ tax_rate => '2.0000',
discount => '2.0000',
notes => 'notes2',
deliverytime => 2
gstreg => 1,
listincgst => 1,
invoiceincgst => 1,
- gstrate => '2.0000 ',
+ tax_rate => '2.0000 ',
discount => '2.0000',
notes => 'notes2 modified',
deliverytime => 2,
gstreg => 1,
listincgst => 1,
invoiceincgst => 1,
- gstrate => '3.0000',
+ tax_rate => '3.0000',
discount => '3.0000',
notes => 'notes3',
deliverytime => 3
gstreg => 1,
listincgst => 1,
invoiceincgst => 1,
- gstrate => '3.0000',
+ tax_rate => '3.0000',
discount => '3.0000',
notes => 'notes3',
};
entrydate => '01-01-2013',
currency => 'EUR',
notes => "This is a note1",
- gstrate => 0.0500,
+ tax_rate => 0.0500,
orderstatus => 1,
subscriptionid => $id_subscription1,
quantityreceived => 2,
entrydate => '01-01-2013',
currency => 'EUR',
notes => "This is a note2",
- gstrate => 0.0500,
+ tax_rate => 0.0500,
orderstatus => 1,
subscriptionid => $id_subscription2,
rrp => 10,
entrydate => '02-02-2013',
currency => 'EUR',
notes => "This is a note3",
- gstrate => 0.0500,
+ tax_rate => 0.0500,
orderstatus => 2,
subscriptionid => $id_subscription3,
rrp => 11,
entrydate => '02-02-2013',
currency => 'EUR',
notes => "This is a note3",
- gstrate => 0.0500,
+ tax_rate => 0.0500,
orderstatus => 2,
subscriptionid => $id_subscription3,
rrp => 11,
my %budgets;
my $invoiceid = AddInvoice(invoicenumber => 'invoice_test_clone', booksellerid => $booksellerid, unknown => "unknown");
+my $invoice = GetInvoice( $invoiceid );
my $item_price = 10;
my $item_quantity = 2;
my $number_of_orders_to_move = 0;
rrp => $item_price,
discount => 0,
uncertainprice => 0,
- gstrate => 0,
+ tax_rate => 0,
}
)->insert;
my $ordernumber = $order->{ordernumber};
rrp => $item_price,
discount => 0,
uncertainprice => 0,
- gstrate => 0,
+ tax_rate => 0,
}
)->insert;
my $ordernumber = $order->{ordernumber};
ModReceiveOrder({
biblionumber => $biblionumber,
- ordernumber => $ordernumber,
+ order => $order,
budget_id => $infos->{budget_id},
quantityreceived => $item_quantity,
- cost => $item_price,
- ecost => $item_price,
- invoiceid => $invoiceid,
- rrp => $item_price,
+ invoice => $invoice,
received_items => [],
} );
}
gstreg => 1,
listincgst => 1,
invoiceincgst => 1,
- gstrate => '1.0000',
+ tax_rate => '1.0000',
discount => '1.0000',
notes => 'notes1',
deliverytime => undef
gstreg => 1,
listincgst => 1,
invoiceincgst => 1,
- gstrate => '2.0000',
+ tax_rate => '2.0000',
discount => '2.0000',
notes => 'notes2',
deliverytime => 2