View | Details | Raw Unified | Return to bug 5186
Collapse All | Expand All

(-)a/C4/Bookseller.pm (-2 / +3 lines)
Lines 173-182 sub AddBookseller { Link Here
173
                postal,    phone,         fax,        url,           contact,
173
                postal,    phone,         fax,        url,           contact,
174
                contpos,   contphone,     contfax,    contaltphone,  contemail,
174
                contpos,   contphone,     contfax,    contaltphone,  contemail,
175
                contnotes, active,        listprice,  invoiceprice,  gstreg,
175
                contnotes, active,        listprice,  invoiceprice,  gstreg,
176
                listincgst,invoiceincgst,   discount,
176
                listincgst,invoiceincgst, gstrate,    discount,
177
                notes
177
                notes
178
            )
178
            )
179
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
179
        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
180
    ";
180
    ";
181
    my $sth = $dbh->prepare($query);
181
    my $sth = $dbh->prepare($query);
182
    $sth->execute(
182
    $sth->execute(
Lines 191-196 sub AddBookseller { Link Here
191
        $data->{'active'},       $data->{'listprice'},
191
        $data->{'active'},       $data->{'listprice'},
192
        $data->{'invoiceprice'}, $data->{'gstreg'},
192
        $data->{'invoiceprice'}, $data->{'gstreg'},
193
        $data->{'listincgst'},   $data->{'invoiceincgst'},
193
        $data->{'listincgst'},   $data->{'invoiceincgst'},
194
        $data->{'gstrate'},
194
        $data->{'discount'},     $data->{'notes'}
195
        $data->{'discount'},     $data->{'notes'}
195
    );
196
    );
196
197
(-)a/acqui/addorderiso2709.pl (-2 / +3 lines)
Lines 149-155 if ($op eq ""){ Link Here
149
                  eval "use C4::Bookseller qw/GetBookSellerFromId/;";
149
                  eval "use C4::Bookseller qw/GetBookSellerFromId/;";
150
                  my $basket = GetBasket($orderinfo{basketno});
150
                  my $basket = GetBasket($orderinfo{basketno});
151
                  my $bookseller = GetBookSellerFromId($basket->{booksellerid});
151
                  my $bookseller = GetBookSellerFromId($basket->{booksellerid});
152
                  my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
152
                  # '//' is like '||' but tests for defined, rather than true
153
                  my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
153
                  $orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
154
                  $orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
154
                  $orderinfo{'ecost'} = $orderinfo{unitprice};
155
                  $orderinfo{'ecost'} = $orderinfo{unitprice};
155
              } else {
156
              } else {
Lines 166-172 if ($op eq ""){ Link Here
166
                  eval "use C4::Bookseller qw/GetBookSellerFromId/;";
167
                  eval "use C4::Bookseller qw/GetBookSellerFromId/;";
167
                  my $basket = GetBasket($orderinfo{basketno});
168
                  my $basket = GetBasket($orderinfo{basketno});
168
                  my $bookseller = GetBookSellerFromId($basket->{booksellerid});
169
                  my $bookseller = GetBookSellerFromId($basket->{booksellerid});
169
                  my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
170
                  my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
170
                  $orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
171
                  $orderinfo{'unitprice'} = $orderinfo{listprice} - ($orderinfo{listprice} * ($bookseller->{discount} / 100));
171
                  $orderinfo{'ecost'} = $orderinfo{unitprice};
172
                  $orderinfo{'ecost'} = $orderinfo{unitprice};
172
              } else {
173
              } else {
(-)a/acqui/basket.pl (-1 / +1 lines)
Lines 219-225 if ( $op eq 'delete_confirm' ) { Link Here
219
219
220
    my @results = GetOrders( $basketno );
220
    my @results = GetOrders( $basketno );
221
    
221
    
222
	my $gist = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
222
	my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
223
	my $discount = $bookseller->{'discount'} / 100;
223
	my $discount = $bookseller->{'discount'} / 100;
224
    my $total_rrp;      # RRP Total, its value will be assigned to $total_rrp_gsti or $total_rrp_gste depending of $bookseller->{'listincgst'}
224
    my $total_rrp;      # RRP Total, its value will be assigned to $total_rrp_gsti or $total_rrp_gste depending of $bookseller->{'listincgst'}
225
	my $total_rrp_gsti; # RRP Total, GST included
225
	my $total_rrp_gsti; # RRP Total, GST included
(-)a/acqui/basketgroup.pl (-4 / +4 lines)
Lines 137-144 sub BasketTotal { Link Here
137
    my @orders = GetOrders($basketno);
137
    my @orders = GetOrders($basketno);
138
    for my $order (@orders){
138
    for my $order (@orders){
139
        $total = $total + ( $order->{ecost} * $order->{quantity} );
139
        $total = $total + ( $order->{ecost} * $order->{quantity} );
140
        if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{gstrate} || C4::Context->preference("gist") )) {
140
        if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{gstrate} // C4::Context->preference("gist") )) {
141
            my $gst = $bookseller->{gstrate} || C4::Context->preference("gist");
141
            my $gst = $bookseller->{gstrate} // C4::Context->preference("gist");
142
            $total = $total * ( $gst / 100 +1);
142
            $total = $total * ( $gst / 100 +1);
143
        }
143
        }
144
    }
144
    }
Lines 220-226 sub printbasketgrouppdf{ Link Here
220
                    push(@ba_order, $ord->{$key});                                                  #Order lines
220
                    push(@ba_order, $ord->{$key});                                                  #Order lines
221
                }
221
                }
222
                push(@ba_order, $bookseller->{discount});
222
                push(@ba_order, $bookseller->{discount});
223
                push(@ba_order, $bookseller->{gstrate}*100 || C4::Context->preference("gist") || 0);
223
                push(@ba_order, $bookseller->{gstrate}*100 // C4::Context->preference("gist") // 0);
224
                push(@ba_orders, \@ba_order);
224
                push(@ba_orders, \@ba_order);
225
                # Editor Number
225
                # Editor Number
226
                my $en;
226
                my $en;
Lines 242-248 sub printbasketgrouppdf{ Link Here
242
        -type       => 'application/pdf',
242
        -type       => 'application/pdf',
243
        -attachment => ( $basketgroup->{name} || $basketgroupid ) . '.pdf'
243
        -attachment => ( $basketgroup->{name} || $basketgroupid ) . '.pdf'
244
    );
244
    );
245
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{gstrate} || C4::Context->preference("gist")) || die "pdf generation failed";
245
    my $pdf = printpdf($basketgroup, $bookseller, $baskets, \%orders, $bookseller->{gstrate} // C4::Context->preference("gist")) || die "pdf generation failed";
246
    print $pdf;
246
    print $pdf;
247
    exit;
247
    exit;
248
}
248
}
(-)a/acqui/neworderempty.pl (-1 / +1 lines)
Lines 356-362 $template->param( Link Here
356
    import_batch_id  => $import_batch_id,
356
    import_batch_id  => $import_batch_id,
357
357
358
# CHECKME: gst-stuff needs verifing, mason.
358
# CHECKME: gst-stuff needs verifing, mason.
359
    gstrate          => $bookseller->{'gstrate'} || C4::Context->preference("gist"),
359
    gstrate          => $bookseller->{'gstrate'} // C4::Context->preference("gist") // 0
360
    gstreg           => $bookseller->{'gstreg'},
360
    gstreg           => $bookseller->{'gstreg'},
361
);
361
);
362
362
(-)a/acqui/orderreceive.pl (-1 / +2 lines)
Lines 86-92 my $datereceived = $input->param('datereceived'); Link Here
86
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
86
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
87
87
88
my $bookseller = GetBookSellerFromId($supplierid);
88
my $bookseller = GetBookSellerFromId($supplierid);
89
my $gst= $input->param('gst') || $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
89
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
90
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
90
my $results = SearchOrder($ordernumber,$search);
91
my $results = SearchOrder($ordernumber,$search);
91
92
92
93
(-)a/acqui/parcel.pl (-1 / +2 lines)
Lines 71-77 my $bookseller=GetBookSellerFromId($supplierid); Link Here
71
71
72
my $invoice=$input->param('invoice') || '';
72
my $invoice=$input->param('invoice') || '';
73
my $freight=$input->param('freight');
73
my $freight=$input->param('freight');
74
my $gst= $input->param('gst') || $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
74
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
75
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
75
my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) 
76
my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) 
76
					:  C4::Dates->new($input->param('datereceived'), 'iso')   ;
77
					:  C4::Dates->new($input->param('datereceived'), 'iso')   ;
77
$datereceived = C4::Dates->new() unless $datereceived;
78
$datereceived = C4::Dates->new() unless $datereceived;
(-)a/acqui/supplier.pl (-7 / +4 lines)
Lines 69-78 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
69
my $seller_gstrate = $supplier->{'gstrate'};
69
my $seller_gstrate = $supplier->{'gstrate'};
70
70
71
# ensure the scalar isn't flagged as a string
71
# ensure the scalar isn't flagged as a string
72
$seller_gstrate = ( defined $seller_gstrate ) ? $seller_gstrate + 0 : 0;
72
$seller_gstrate = ( defined $seller_gstrate ) ? $seller_gstrate + 0 : undef;
73
my $tax_rate = $seller_gstrate || C4::Context->preference('gist');
73
my $tax_rate = $seller_gstrate // C4::Context->preference('gist') // 0;
74
$tax_rate *= 100;
74
$tax_rate *= 100;
75
76
#build array for currencies
75
#build array for currencies
77
if ( $op eq 'display' ) {
76
if ( $op eq 'display' ) {
78
77
Lines 83-90 if ( $op eq 'display' ) { Link Here
83
        $_->{contractenddate}   = format_date( $_->{contractenddate} );
82
        $_->{contractenddate}   = format_date( $_->{contractenddate} );
84
    }
83
    }
85
84
86
    my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : 0;
87
88
    $template->param(
85
    $template->param(
89
        id            => $id,
86
        id            => $id,
90
        name          => $supplier->{'name'},
87
        name          => $supplier->{'name'},
Lines 108-118 if ( $op eq 'display' ) { Link Here
108
        gstreg        => $supplier->{'gstreg'},
105
        gstreg        => $supplier->{'gstreg'},
109
        listincgst    => $supplier->{'listincgst'},
106
        listincgst    => $supplier->{'listincgst'},
110
        invoiceincgst => $supplier->{'invoiceincgst'},
107
        invoiceincgst => $supplier->{'invoiceincgst'},
111
        gstrate       => $gstrate,
112
        discount      => $supplier->{'discount'},
108
        discount      => $supplier->{'discount'},
113
        invoiceprice  => $supplier->{'invoiceprice'},
109
        invoiceprice  => $supplier->{'invoiceprice'},
114
        listprice     => $supplier->{'listprice'},
110
        listprice     => $supplier->{'listprice'},
115
        GST           => $tax_rate,
111
        GST           => $tax_rate,
112
        default_tax   => $seller_gstrate,
116
        basketcount   => $supplier->{'basketcount'},
113
        basketcount   => $supplier->{'basketcount'},
117
        contracts     => $contracts
114
        contracts     => $contracts
118
    );
115
    );
Lines 131-137 if ( $op eq 'display' ) { Link Here
131
          };
128
          };
132
    }
129
    }
133
130
134
    my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : 0;
131
    my $gstrate = defined $supplier->{gstrate} ? $supplier->{gstrate} * 100 : '';
135
    $template->param(
132
    $template->param(
136
        id           => $id,
133
        id           => $id,
137
        name         => $supplier->{'name'},
134
        name         => $supplier->{'name'},
(-)a/acqui/updatesupplier.pl (-1 / +6 lines)
Lines 98-104 $data{'gstreg'}=$input->param('gst'); Link Here
98
$data{'listincgst'}=$input->param('list_gst');
98
$data{'listincgst'}=$input->param('list_gst');
99
$data{'invoiceincgst'}=$input->param('invoice_gst');
99
$data{'invoiceincgst'}=$input->param('invoice_gst');
100
#have to transform this into fraction so it's easier to use
100
#have to transform this into fraction so it's easier to use
101
$data{'gstrate'}=$input->param('gstrate')/100;
101
my $gstrate = $input->param('gstrate');
102
if ($gstrate eq '') {
103
    $data{'gstrate'} = undef;
104
} else {
105
    $data{'gstrate'} = $input->param('gstrate')/100;
106
}
102
$data{'discount'}=$input->param('discount');
107
$data{'discount'}=$input->param('discount');
103
$data{'active'}=$input->param('status');
108
$data{'active'}=$input->param('status');
104
if($data{'name'}) {
109
if($data{'name'}) {
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 3701-3706 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
3701
    SetVersion ($DBversion);
3701
    SetVersion ($DBversion);
3702
}
3702
}
3703
3703
3704
$DBversion = "3.01.00.146";
3705
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
3706
    $dbh->do("UPDATE aqbooksellers SET gstrate=NULL WHERE gstrate=0.0");
3707
    print "Upgrade to $DBversion done (Add index on guarantorid)\n";
3708
    SetVersion ($DBversion);
3709
}
3710
3704
=item DropAllForeignKeys($table)
3711
=item DropAllForeignKeys($table)
3705
3712
3706
  Drop all foreign keys of the table $table
3713
  Drop all foreign keys of the table $table
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tmpl (-14 / +8 lines)
Lines 106-149 if (f.company.value == "") { Link Here
106
            </li>
106
            </li>
107
            </ol>
107
            </ol>
108
            <ol class="radio">
108
            <ol class="radio">
109
            <!-- TMPL_IF NAME="GST" --><li><label for="gstyes" class="radio">Tax Number Registered:</label>
109
            <li><label for="gstyes" class="radio">Tax Number Registered:</label>
110
                <!-- TMPL_IF name="gstreg" -->
110
                <!-- TMPL_IF name="gstreg" -->
111
                    <label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" checked="checked" />
111
                    <label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" checked="checked" />
112
                    <label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" />
112
                    <label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" />
113
                <!-- TMPL_ELSE -->
113
                <!-- TMPL_ELSE -->
114
                    <label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" />
114
                    <label for="gstyes">Yes</label> <input type="radio" name="gst" id="gstyes" value="1" />
115
                    <label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" checked="checked" />
115
                    <label for="gstno">No</label> <input type="radio" name="gst" id="gstno" value="0" checked="checked" />
116
                <!-- /TMPL_IF --></li><!-- /TMPL_IF -->
116
                <!-- /TMPL_IF --></li>
117
            
117
            
118
            <!-- TMPL_IF NAME="GST" --><li><label for="list_gstyes" class="radio">Ordering prices:</label>
118
            <li><label for="list_gstyes" class="radio">Ordering prices:</label>
119
                <!-- TMPL_IF name="listincgst" -->
119
                <!-- TMPL_IF name="listincgst" -->
120
                    <label for="list_gstyes">Include tax</label> <input type="radio" id="list_gstyes" name="list_gst" value="1" checked="checked" />
120
                    <label for="list_gstyes">Include tax</label> <input type="radio" id="list_gstyes" name="list_gst" value="1" checked="checked" />
121
                    <label for="list_gstno">Don't include tax</label> <input type="radio" id="list_gstno" name="list_gst" value="0" />
121
                    <label for="list_gstno">Don't include tax</label> <input type="radio" id="list_gstno" name="list_gst" value="0" />
122
                <!-- TMPL_ELSE -->
122
                <!-- TMPL_ELSE -->
123
                    <label for="list_gstyes">Include tax</label> <input type="radio" id="list_gstyes" name="list_gst" value="1" />
123
                    <label for="list_gstyes">Include tax</label> <input type="radio" id="list_gstyes" name="list_gst" value="1" />
124
                    <label for="list_gstno">Don't include tax</label> <input type="radio" id="list_gstno" name="list_gst" value="0" checked="checked" />
124
                    <label for="list_gstno">Don't include tax</label> <input type="radio" id="list_gstno" name="list_gst" value="0" checked="checked" />
125
                <!-- /TMPL_IF --></li><!-- /TMPL_IF -->
125
                <!-- /TMPL_IF --></li>
126
            
126
            
127
            <!-- TMPL_IF NAME="GST" --><li><label for="invoice_gstyes" class="radio">Invoice prices:</label>
127
            <li><label for="invoice_gstyes" class="radio">Invoice prices:</label>
128
                <!-- TMPL_IF name= "invoiceincgst" -->
128
                <!-- TMPL_IF name= "invoiceincgst" -->
129
                    <label for="invoice_gstyes">Include tax</label> <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" checked="checked" />
129
                    <label for="invoice_gstyes">Include tax</label> <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" checked="checked" />
130
                    <label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" />
130
                    <label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" />
131
                    <!-- TMPL_ELSE -->
131
                    <!-- TMPL_ELSE -->
132
                    <label for="invoice_gstyes">Include tax</label> <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" />
132
                    <label for="invoice_gstyes">Include tax</label> <input type="radio" id="invoice_gstyes" name="invoice_gst" value="1" />
133
                    <label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" checked="checked" />
133
                    <label for="invoice_gstno">Don't include tax</label> <input type="radio" id="invoice_gstno" name="invoice_gst" value="0" checked="checked" />
134
                <!-- /TMPL_IF --></li><!-- /TMPL_IF -->
134
                <!-- /TMPL_IF --></li>
135
            </ol>
135
            </ol>
136
            <ol>
136
            <ol>
137
            <li><label for="discount">Discount</label>
137
            <li><label for="discount">Discount</label>
138
                <input type="text" size="6" id="discount" name="discount" value="<!-- TMPL_VAR NAME="discount" -->" /> %</li>
138
                <input type="text" size="6" id="discount" name="discount" value="<!-- TMPL_VAR NAME="discount" -->" /> %</li>
139
            <!-- 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 -->
139
            <li><label for="gstrate">Tax rate</label><input type="text" name="gstrate" id="gstrate" size="5" value="<!-- TMPL_VAR name="gstrate" -->"/>%</li>
140
            <li><label for="notes">Notes</label>
140
            <li><label for="notes">Notes</label>
141
                <textarea cols="40" rows="4" id="notes" name="notes" ><!-- TMPL_VAR NAME="notes" --></textarea></li></ol>			
141
                <textarea cols="40" rows="4" id="notes" name="notes" ><!-- TMPL_VAR NAME="notes" --></textarea></li></ol>			
142
            <!-- TMPL_UNLESS NAME="GST" -->
143
                <input type="hidden" name="gst" value="0" />
144
                <input type="hidden" name="list_gst" value="0" />
145
                <input type="hidden"  name="invoice_gst" value="0" />
146
            <!-- /TMPL_UNLESS -->
147
        </fieldset>
142
        </fieldset>
148
        <fieldset class="action"><input type="button" value="Save" onclick="check(this.form);" /> <!--TMPL_IF Name="id"-->
143
        <fieldset class="action"><input type="button" value="Save" onclick="check(this.form);" /> <!--TMPL_IF Name="id"-->
149
        <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">
144
        <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">
Lines 198-204 if (f.company.value == "") { Link Here
198
            <p><strong>Discount: </strong>
193
            <p><strong>Discount: </strong>
199
                <!-- TMPL_VAR NAME="discount" --> %</p>
194
                <!-- TMPL_VAR NAME="discount" --> %</p>
200
            <!-- TMPL_IF NAME="GST" --><p><strong>Tax rate: </strong>
195
            <!-- TMPL_IF NAME="GST" --><p><strong>Tax rate: </strong>
201
                <!-- TMPL_VAR name="GST" -->%</p><!-- /TMPL_IF -->
196
                <!-- TMPL_VAR name="GST" -->%<!-- TMPL_UNLESS name="default_tax" --> (default)<!-- /TMPL_UNLESS --></p><!-- /TMPL_IF -->
202
            <!-- TMPL_IF NAME="notes" --><p><strong>Notes: </strong>
197
            <!-- TMPL_IF NAME="notes" --><p><strong>Notes: </strong>
203
                <!-- TMPL_VAR NAME="notes" --></p><!-- /TMPL_IF -->
198
                <!-- TMPL_VAR NAME="notes" --></p><!-- /TMPL_IF -->
204
        </div>
199
        </div>
205
- 

Return to bug 5186