Fix tax inclusive pricing for non taxable customer

Show receiving quantity in receiving receipt
Allow to use invoice number as zero (a bug prevented 0 to be saved to
db, causing it to stop incrementing next time)
This commit is contained in:
jekkos-t520
2014-12-18 19:55:20 +01:00
parent 0132c9092c
commit c00c604c21
4 changed files with 27 additions and 35 deletions

View File

@@ -501,7 +501,7 @@ class Sale_lib
{
return array();
}
$taxes = array();
foreach($this->get_cart() as $line=>$item)
{
@@ -572,21 +572,14 @@ class Sale_lib
$subtotal = 0;
foreach($this->get_cart() as $item)
{
if ($this->is_customer_taxable())
if ($this->CI->config->config['tax_included'])
{
$subtotal += $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount']);
}
else
{
$subtotal += $this->get_item_total($item['quantity'], $item['price'], $item['discount']);
}
else
{
if ($this->CI->config->config['tax_included'])
{
$subtotal += $this->get_item_total($item['quantity'], $item['price'], $item['discount']);
}
else
{
$subtotal += $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount']);
}
}
}
return $subtotal;
}
@@ -595,12 +588,9 @@ class Sale_lib
{
$total = $this->calculate_subtotal();
if (!$this->CI->config->config['tax_included'])
foreach($this->get_taxes() as $tax)
{
foreach($this->get_taxes() as $tax)
{
$total = bcadd($total, $tax, 4);
}
$total = bcadd($total, $tax, 4);
}
return to_currency_no_money($total);

View File

@@ -50,7 +50,7 @@ class Receiving extends CI_Model
'employee_id'=>$employee_id,
'payment_type'=>$payment_type,
'comment'=>$comment,
'invoice_number'=>empty($invoice_number) ? NULL : $invoice_number
'invoice_number'=>$invoice_number
);
//Run these queries as a transaction, we want to make sure we do all or nothing
@@ -81,13 +81,13 @@ class Receiving extends CI_Model
$this->db->insert('receivings_items',$receivings_items_data);
//Update stock quantity
$item_quantity = $this->Item_quantities->get_item_quantity($item['item_id'], $item['item_location']);
$this->Item_quantities->save(array('quantity'=>$item_quantity->quantity + $item['quantity'],
$item_quantity = $this->Item_quantities->get_item_quantity($item['item_id'], $item['item_location']);
$items_received = $item['quantity'] * $item['receiving_quantity'];
$this->Item_quantities->save(array('quantity'=>$item_quantity->quantity + $items_received,
'item_id'=>$item['item_id'],
'location_id'=>$item['item_location']), $item['item_id'], $item['item_location']);
$qty_recv = $item['quantity'];
$recv_remarks ='RECV '.$receiving_id;
$inv_data = array
(
@@ -96,7 +96,7 @@ class Receiving extends CI_Model
'trans_user'=>$employee_id,
'trans_location'=>$item['item_location'],
'trans_comment'=>$recv_remarks,
'trans_inventory'=>$qty_recv
'trans_inventory'=>$items_received
);
$this->Inventory->insert($inv_data);

View File

@@ -59,7 +59,7 @@ class Sale extends CI_Model
'employee_id'=>$employee_id,
'payment_type'=>$payment_types,
'comment'=>$comment,
'invoice_number'=>empty($invoice_number) ? NULL : $invoice_number
'invoice_number'=>$invoice_number
);
//Run these queries as a transaction, we want to make sure we do all or nothing

View File

@@ -37,7 +37,8 @@ if (isset($error_message))
<tr>
<th style="width:50%;"><?php echo $this->lang->line('items_item'); ?></th>
<th style="width:17%;"><?php echo $this->lang->line('common_price'); ?></th>
<th style="width:16%;text-align:center;"><?php echo $this->lang->line('sales_quantity'); ?></th>
<th style="width:10%;text-align:center;"><?php echo $this->lang->line('sales_quantity'); ?></th>
<th style="width:6%;"></th>
<th style="width:16%;text-align:center;"><?php echo $this->lang->line('sales_discount'); ?></th>
<th style="width:17%;text-align:right;"><?php echo $this->lang->line('sales_total'); ?></th>
</tr>
@@ -51,29 +52,30 @@ if (isset($error_message))
<td style='text-align:center;'><?php
echo $item['quantity'] . " " . ($show_stock_locations ? " [" . $item['stock_name'] . "]" : "");
?></td>
<td>x <?php echo $item['receiving_quantity']; ?></td>
<td style='text-align:center;'><?php echo $item['discount']; ?></td>
<td style='text-align:right;'><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td>
</tr>
<tr>
<td colspan="2" align="center"><?php echo $item['description']; ?></td>
<td colspan="2" ><?php echo $item['serialnumber']; ?></td>
<td colspan="1"><?php echo '---'; ?></td>
<td colspan="3 " ><?php echo $item['serialnumber']; ?></td>
<td colspan="1"><?php echo '---------'; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="3" style='text-align:right;'><?php echo $this->lang->line('sales_total'); ?></td>
<td colspan="2" style='text-align:right'><?php echo to_currency($total); ?></td>
<td colspan="4" style='text-align:right;'><?php echo $this->lang->line('sales_total'); ?></td>
<td colspan="3" style='text-align:right'><?php echo to_currency($total); ?></td>
</tr>
<?php
if($mode!='requisition')
{
?>
<tr>
<td colspan="3" style='text-align:right;'><?php echo $this->lang->line('sales_payment'); ?></td>
<td colspan="2" style='text-align:right'><?php echo $payment_type; ?></td>
<td colspan="4" style='text-align:right;'><?php echo $this->lang->line('sales_payment'); ?></td>
<td colspan="3" style='text-align:right'><?php echo $payment_type; ?></td>
</tr>
@@ -81,13 +83,13 @@ if (isset($error_message))
{
?>
<tr>
<td colspan="3" style='text-align:right;'><?php echo $this->lang->line('sales_amount_tendered'); ?></td>
<td colspan="2" style='text-align:right'><?php echo to_currency($amount_tendered); ?></td>
<td colspan="4" style='text-align:right;'><?php echo $this->lang->line('sales_amount_tendered'); ?></td>
<td colspan="3" style='text-align:right'><?php echo to_currency($amount_tendered); ?></td>
</tr>
<tr>
<td colspan="3" style='text-align:right;'><?php echo $this->lang->line('sales_change_due'); ?></td>
<td colspan="2" style='text-align:right'><?php echo $amount_change; ?></td>
<td colspan="4" style='text-align:right;'><?php echo $this->lang->line('sales_change_due'); ?></td>
<td colspan="3" style='text-align:right'><?php echo $amount_change; ?></td>
</tr>
<?php
}