postal, phone, fax, url, contact,
contpos, contphone, contfax, contaltphone, contemail,
contnotes, active, listprice, invoiceprice, gstreg,
- listincgst,invoiceincgst, discount,
+ listincgst,invoiceincgst, gstrate, discount,
notes
)
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
";
my $sth = $dbh->prepare($query);
$sth->execute(
$data->{'active'}, $data->{'listprice'},
$data->{'invoiceprice'}, $data->{'gstreg'},
$data->{'listincgst'}, $data->{'invoiceincgst'},
+ $data->{'gstrate'},
$data->{'discount'}, $data->{'notes'}
);
eval "use C4::Bookseller qw/GetBookSellerFromId/;";
my $basket = GetBasket($orderinfo{basketno});
my $bookseller = GetBookSellerFromId($basket->{booksellerid});
- my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
+ # '//' is like '||' but tests for defined, rather than true
+ my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
$orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
$orderinfo{'ecost'} = $orderinfo{unitprice};
} else {
eval "use C4::Bookseller qw/GetBookSellerFromId/;";
my $basket = GetBasket($orderinfo{basketno});
my $bookseller = GetBookSellerFromId($basket->{booksellerid});
- my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
+ my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
$orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
$orderinfo{'ecost'} = $orderinfo{unitprice};
} else {
my @results = GetOrders( $basketno );
- my $gist = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
+ my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
my $discount = $bookseller->{'discount'} / 100;
my $total_rrp; # RRP Total, its value will be assigned to $total_rrp_gsti or $total_rrp_gste depending of $bookseller->{'listincgst'}
my $total_rrp_gsti; # RRP Total, GST included
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");
+ if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{gstrate} // C4::Context->preference("gist") )) {
+ my $gst = $bookseller->{gstrate} // C4::Context->preference("gist");
$total = $total * ( $gst / 100 +1);
}
}
push(@ba_order, $ord->{$key}); #Order lines
}
push(@ba_order, $bookseller->{discount});
- push(@ba_order, $bookseller->{gstrate}*100 || C4::Context->preference("gist") || 0);
+ push(@ba_order, $bookseller->{gstrate}*100 // C4::Context->preference("gist") // 0);
push(@ba_orders, \@ba_order);
# 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->{gstrate} // C4::Context->preference("gist")) || die "pdf generation failed";
print $pdf;
exit;
}
import_batch_id => $import_batch_id,
# CHECKME: gst-stuff needs verifing, mason.
- gstrate => $bookseller->{'gstrate'} || C4::Context->preference("gist"),
+ gstrate => $bookseller->{'gstrate'} // C4::Context->preference("gist") // 0,
gstreg => $bookseller->{'gstreg'},
);
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
my $bookseller = GetBookSellerFromId($supplierid);
-my $gst= $input->param('gst') || $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
+my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
+my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
my $results = SearchOrder($ordernumber,$search);
my $invoice=$input->param('invoice') || '';
my $freight=$input->param('freight');
-my $gst= $input->param('gst') || $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
+my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
+my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
my $datereceived = ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived'))
: C4::Dates->new($input->param('datereceived'), 'iso') ;
$datereceived = C4::Dates->new() unless $datereceived;
my $seller_gstrate = $supplier->{'gstrate'};
# ensure the scalar isn't flagged as a string
-$seller_gstrate = ( defined $seller_gstrate ) ? $seller_gstrate + 0 : 0;
-my $tax_rate = $seller_gstrate || C4::Context->preference('gist');
+$seller_gstrate = ( defined $seller_gstrate ) ? $seller_gstrate + 0 : undef;
+my $tax_rate = $seller_gstrate // C4::Context->preference('gist') // 0;
$tax_rate *= 100;
-
#build array for currencies
if ( $op eq 'display' ) {
$_->{contractenddate} = format_date( $_->{contractenddate} );
}
- my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : 0;
-
$template->param(
id => $id,
name => $supplier->{'name'},
gstreg => $supplier->{'gstreg'},
listincgst => $supplier->{'listincgst'},
invoiceincgst => $supplier->{'invoiceincgst'},
- gstrate => $gstrate,
discount => $supplier->{'discount'},
invoiceprice => $supplier->{'invoiceprice'},
listprice => $supplier->{'listprice'},
GST => $tax_rate,
+ default_tax => defined($seller_gstrate),
basketcount => $supplier->{'basketcount'},
- contracts => $contracts
+ contracts => $contracts,
);
} elsif ( $op eq 'delete' ) {
DelBookseller($id);
};
}
- my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : 0;
+ my $default_gst_rate = (C4::Context->preference('gist') * 100) || '0.0';
+
+ my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : '';
$template->param(
id => $id,
name => $supplier->{'name'},
loop_currency => $loop_currency,
GST => $tax_rate,
enter => 1,
+ default_gst_rate => $default_gst_rate,
);
}
$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')/100;
+my $gstrate = $input->param('gstrate');
+if ($gstrate eq '') {
+ $data{'gstrate'} = undef;
+} else {
+ $data{'gstrate'} = $input->param('gstrate')/100;
+}
$data{'discount'}=$input->param('discount');
$data{'active'}=$input->param('status');
if($data{'name'}) {
}
+$DBversion = "3.01.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("UPDATE aqbooksellers SET gstrate=NULL WHERE gstrate=0.0");
+ print "Upgrade to $DBversion done (Bug 5186: allow GST rate to be set to 0)\n";
+ SetVersion ($DBversion);
+}
=head1 FUNCTIONS
</li>
</ol>
<ol class="radio">
- <!-- TMPL_IF NAME="GST" --><li><label for="gstyes" class="radio">Tax Number Registered:</label>
+ <li><label for="gstyes" class="radio">Tax Number Registered:</label>
<!-- TMPL_IF name="gstreg" -->
<label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" checked="checked" />
<label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" />
<!-- TMPL_ELSE -->
<label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" />
<label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" checked="checked" />
- <!-- /TMPL_IF --></li><!-- /TMPL_IF -->
+ <!-- /TMPL_IF --></li>
- <!-- TMPL_IF NAME="GST" --><li><label for="list_gstyes" class="radio">List prices:</label>
+ <li><label for="list_gstyes" class="radio">List prices:</label>
<!-- TMPL_IF name="listincgst" -->
<label for="list_gstyes">Include tax</label> <input type="radio" id="list_gstyes" name="list_gst" value="1" checked="checked" />
<label for="list_gstno">Don't include tax</label> <input type="radio" id="list_gstno" name="list_gst" value="0" />
<!-- TMPL_ELSE -->
<label for="list_gstyes">Include tax</label> <input type="radio" id="list_gstyes" name="list_gst" value="1" />
<label for="list_gstno">Don't include tax</label> <input type="radio" id="list_gstno" name="list_gst" value="0" checked="checked" />
- <!-- /TMPL_IF --></li><!-- /TMPL_IF -->
+ <!-- /TMPL_IF --></li>
- <!-- TMPL_IF NAME="GST" --><li><label for="invoice_gstyes" class="radio">Invoice prices:</label>
+ <li><label for="invoice_gstyes" class="radio">Invoice prices:</label>
<!-- TMPL_IF name= "invoiceincgst" -->
<label for="invoice_gstyes">Include tax</label> <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" checked="checked" />
<label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" />
<!-- TMPL_ELSE -->
<label for="invoice_gstyes">Include tax</label> <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" />
<label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" checked="checked" />
- <!-- /TMPL_IF --></li><!-- /TMPL_IF -->
+ <!-- /TMPL_IF --></li>
</ol>
<ol>
<li><label for="discount">Discount</label>
- <input type="text" size="5" id="discount" name="discount" value="<!-- TMPL_VAR NAME="discount" -->" /> %</li>
- <!-- TMPL_IF NAME="GST" --><li><label for="gstrate">Tax rate</label><input type="text" name="gstrate" id="gstrate" size="5" value="<!-- TMPL_VAR name="gstrate" -->"/> %</li><!-- /TMPL_IF -->
+ <input type="text" size="6" id="discount" name="discount" value="<!-- TMPL_VAR NAME="discount" -->" />%</li>
+ <li><label for="gstrate">Tax rate</label><input type="text" name="gstrate" id="gstrate" size="6" value="<!-- TMPL_VAR name="gstrate" -->"/>% (leave blank for default tax of <!-- TMPL_VAR name="default_gst_rate" -->%)</li>
<li><label for="notes">Notes</label>
<textarea cols="40" rows="4" id="notes" name="notes" ><!-- TMPL_VAR NAME="notes" --></textarea></li></ol>
- <!-- TMPL_UNLESS NAME="GST" -->
- <input type="hidden" name="gst" value="0" />
- <input type="hidden" name="list_gst" value="0" />
- <input type="hidden" name="invoice_gst" value="0" />
- <!-- /TMPL_UNLESS -->
</fieldset>
<fieldset class="action"><input type="button" value="Save" onclick="check(this.form);" /> <!--TMPL_IF Name="id"-->
<a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!--TMPL_VAR Name="id"-->"><!--TMPL_ELSE--><a class="cancel" href="/cgi-bin/koha/acqui/acqui-home.pl">
<!-- TMPL_IF name= "invoiceincgst" -->Yes<!--TMPL_ELSE-->No<!-- /TMPL_IF --></p><!-- /TMPL_IF -->
<p><strong>Discount: </strong>
<!-- TMPL_VAR NAME="discount" --> %</p>
- <!-- TMPL_IF NAME="GST" --><p><strong>Tax rate: </strong>
- <!-- TMPL_VAR name="GST" -->%</p><!-- /TMPL_IF -->
+ <p><strong>Tax rate: </strong>
+ <!-- TMPL_VAR name="GST" -->%<!-- TMPL_UNLESS name="default_tax" --> (default)<!-- /TMPL_UNLESS --></p>
<!-- TMPL_IF NAME="notes" --><p><strong>Notes: </strong>
<!-- TMPL_VAR NAME="notes" --></p><!-- /TMPL_IF -->
</div>