Add company_name field to customers for invoicing purposes

Total discount is now shown as one amount in receipt

Conflicts:

	application/controllers/sales.php

Conflicts:

	database/migrate_phppos.sql
This commit is contained in:
jekkos
2015-04-06 15:15:34 +02:00
parent ebd473ea11
commit b85b9d37a1
17 changed files with 64 additions and 22 deletions

View File

@@ -72,6 +72,7 @@ class Customers extends Person_controller
);
$customer_data=array(
'account_number'=>$this->input->post('account_number')=='' ? null:$this->input->post('account_number'),
'company_name'=>$this->input->post('company_name')=='' ? null:$this->input->post('company_name'),
'taxable'=>$this->input->post('taxable')=='' ? 0:1,
);
if($this->Customer->save($person_data,$customer_data,$customer_id))

View File

@@ -723,7 +723,7 @@ class Items extends Secure_area implements iData_controller
*/
function get_form_width()
{
return 400;
return 450;
}
}

View File

@@ -286,7 +286,7 @@ class Sales extends Secure_area
$data['tax_exclusive_subtotal']=$this->sale_lib->get_subtotal(TRUE, TRUE);
$data['taxes']=$this->sale_lib->get_taxes();
$data['total']=$this->sale_lib->get_total();
$data['discounts']=$this->sale_lib->get_discounts();
$data['discount']=$this->sale_lib->get_discount();
$data['receipt_title']=$this->lang->line('sales_receipt');
$data['transaction_time']= date('m/d/Y h:i:s a');
$data['transaction_date']= date('d/m/Y', strtotime($data['transaction_time']));
@@ -309,7 +309,14 @@ class Sales extends Secure_area
if($customer_id!=-1)
{
$cust_info=$this->Customer->get_info($customer_id);
$data['customer']=$cust_info->first_name.' '.$cust_info->last_name;
if (isset($cust_info->company_name))
{
$data['customer']=$cust_info->company_name;
}
else
{
$data['customer']=$cust_info->first_name.' '.$cust_info->last_name;
}
$data['customer_address'] = $cust_info->address_1;
$data['customer_location'] = $cust_info->zip . ' ' . $cust_info->city;
$data['account_number'] = $cust_info->account_number;
@@ -492,7 +499,7 @@ class Sales extends Secure_area
$data['tax_exclusive_subtotal']=$this->sale_lib->get_subtotal(TRUE, TRUE);
$data['taxes']=$this->sale_lib->get_taxes();
$data['total']=$this->sale_lib->get_total();
$data['discounts']=$this->sale_lib->get_discounts();
$data['discount']=$this->sale_lib->get_discount();
$data['receipt_title']=$this->lang->line('sales_receipt');
$data['transaction_time']= date('d/m/Y H:i:s', strtotime($sale_info['sale_time']));
$stock_locations=$this->Stock_locations->get_undeleted_all('sales')->result_array();
@@ -508,7 +515,14 @@ class Sales extends Secure_area
if($customer_id!=-1)
{
$cust_info=$this->Customer->get_info($customer_id);
$data['customer']=$cust_info->first_name.' '.$cust_info->last_name;
if (isset($cust_info->company_name))
{
$data['customer']=$cust_info->company_name;
}
else
{
$data['customer']=$cust_info->first_name.' '.$cust_info->last_name;
}
$data['first_name']=$cust_info->first_name;
$data['last_name']=$cust_info->last_name;
$data['customer_address'] = $cust_info->address_1;
@@ -647,7 +661,7 @@ class Sales extends Secure_area
$data['subtotal']=$this->sale_lib->get_subtotal(TRUE);
$data['taxes']=$this->sale_lib->get_taxes();
$data['discounts']=$this->sale_lib->get_discounts();
$data['discount']=$this->sale_lib->get_discount();
$data['total']=$this->sale_lib->get_total();
$data['items_module_allowed']=$this->Employee->has_grant('items', $person_info->person_id);
$data['comment']=$this->sale_lib->get_comment();
@@ -715,7 +729,14 @@ class Sales extends Secure_area
if($customer_id!=-1)
{
$cust_info=$this->Customer->get_info($customer_id);
$data['customer']=$cust_info->first_name.' '.$cust_info->last_name;
if (isset($cust_info->company_name))
{
$data['customer']=$cust_info->company_name;
}
else
{
$data['customer']=$cust_info->first_name.' '.$cust_info->last_name;
}
}
$total_payments = 0;

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "Account #";
$lang["customers_account_number_duplicate"] = "This account number is already present in the database";
$lang["customers_basic_information"] = "Customer Information";
$lang["customers_cannot_be_deleted"] = "Could not deleted selected customers, one or more of the selected customers has sales.";
$lang["customers_company_name"] = "Company Name";
$lang["customers_confirm_delete"] = "Are you sure you want to delete the selected customers?";
$lang["customers_customer"] = "Customer";
$lang["customers_error_adding_updating"] = "Error adding/updating customer";

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "Cuenta #";
$lang["customers_account_number_duplicate"] = "This account number is already present in the database";
$lang["customers_basic_information"] = "Información de Clientes";
$lang["customers_cannot_be_deleted"] = "No se pudo borrar los clientes seleccionados. Uno o más de éstos tiene ventas.";
$lang["customers_company_name"] = "Company Name";
$lang["customers_confirm_delete"] = "¿Estás seguro(a) de que quieres borrar a los clientes seleccionados?";
$lang["customers_customer"] = "Cliente";
$lang["customers_error_adding_updating"] = "Error agregando/actualizando cliente";

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "# Compte";
$lang["customers_account_number_duplicate"] = "This account number is already present in the database";
$lang["customers_basic_information"] = "Informations Client";
$lang["customers_cannot_be_deleted"] = "Impossible de supprimer. Un ou plusiers client(s) sélectionné(s) ont des ventes.";
$lang["customers_company_name"] = "Company Name";
$lang["customers_confirm_delete"] = "Etes vous sûr(e) de vouloir supprimer ces clients?";
$lang["customers_customer"] = "Client";
$lang["customers_error_adding_updating"] = "Érreur lors de l\'ajout/suppression de client";

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "No.Pelanggan";
$lang["customers_account_number_duplicate"] = "This account number is already present in the database";
$lang["customers_basic_information"] = "Informasi Pelanggan";
$lang["customers_cannot_be_deleted"] = "pelanggan terpilih tidak bisa dihapus; satu atau lebih dari pelanggan yang dipilih memiliki penjualan.";
$lang["customers_company_name"] = "Company Name";
$lang["customers_confirm_delete"] = "Apakah Anda yakin ingin menghapus pelanggan yang dipilih?";
$lang["customers_customer"] = "Pelanggan";
$lang["customers_error_adding_updating"] = "Menambah / Memperbarui Pelanggan Salah";

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "Btwnummer";
$lang["customers_account_number_duplicate"] = "Deze VAT nummer is reeds aanwezig in de database";
$lang["customers_basic_information"] = "Klantgegevens";
$lang["customers_cannot_be_deleted"] = "De geselecteerde klanten konden niet worden verwijderd. Eén of meerdere klanten hebben verkoopsgegevens in de database zitten.";
$lang["customers_company_name"] = "Bedrijfsnaam";
$lang["customers_confirm_delete"] = "Bent u zeker dat u de geselecteerde klanten wil verwijderen?";
$lang["customers_customer"] = "Klant";
$lang["customers_error_adding_updating"] = "Fout bij het toevoegen/bewerken van een klant";

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "Номер счота";
$lang["customers_account_number_duplicate"] = "This account number is already present in the database";
$lang["customers_basic_information"] = "Информация о клиенте";
$lang["customers_cannot_be_deleted"] = "Невозможно удалить выбранных клиентов, один или более из них имеет продаж.";
$lang["customers_company_name"] = "Company Name";
$lang["customers_confirm_delete"] = "Вы уверены, что хотите удалить выбранных клиентов?";
$lang["customers_customer"] = "Клиент";
$lang["customers_error_adding_updating"] = "Ошибка при добавлении/обновлении клиента";

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "บัญชี #";
$lang["customers_account_number_duplicate"] = "This account number is already present in the database";
$lang["customers_basic_information"] = "ข้อมูลลูกค้า";
$lang["customers_cannot_be_deleted"] = "ไม่สามารลบลูกค้าที่ถูกเลือก, ลูกค้าที่ถูกเลือกถูขายไปแล้ว.";
$lang["customers_company_name"] = "Company Name";
$lang["customers_confirm_delete"] = "ยืนยันลบข้อมูลลูกค้า?";
$lang["customers_customer"] = "ลูกค้า";
$lang["customers_error_adding_updating"] = "แก้ไขข้อมูลลูกค้าผิดพลาด";

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "Hesap No";
$lang["customers_account_number_duplicate"] = "This account number is already present in the database";
$lang["customers_basic_information"] = "Müşteri bilgisi";
$lang["customers_cannot_be_deleted"] = "Seçili müşteriler silinemedi, müşterilerin satışları var.";
$lang["customers_company_name"] = "Company Name";
$lang["customers_confirm_delete"] = "Seçili müşteriyi silmek istediğinize emin misiniz?";
$lang["customers_customer"] = "Müşteri";
$lang["customers_error_adding_updating"] = "Müşteri ekleme/güncelleme hatası";

View File

@@ -4,6 +4,7 @@ $lang["customers_account_number"] = "帳號 #";
$lang["customers_account_number_duplicate"] = "This account number is already present in the database";
$lang["customers_basic_information"] = "客戶資訊";
$lang["customers_cannot_be_deleted"] = "無法刪除選定的客戶,選定的客戶存有銷售紀錄。";
$lang["customers_company_name"] = "Company Name";
$lang["customers_confirm_delete"] = "你確定要刪除選定的客戶?";
$lang["customers_customer"] = "客戶";
$lang["customers_error_adding_updating"] = "添加/更新客戶錯誤";

View File

@@ -558,17 +558,18 @@ class Sale_lib
return $taxes;
}
function get_discounts()
function get_discount()
{
$discounts = array();
$discount = 0;
foreach($this->get_cart() as $line=>$item)
{
if ($item['discount'] > 0)
{
$discounts[] = $this->get_item_discount($item['quantity'], $item['price'], $item['discount']);
$item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount']);
$discount = bcadd($discount, $item_discount, PRECISION);
}
}
return $discounts;
return $discount;
}
function get_subtotal($include_discount=FALSE, $exclude_tax=FALSE)

View File

@@ -6,6 +6,17 @@ echo form_open('customers/save/'.$person_info->person_id,array('id'=>'customer_f
<fieldset id="customer_basic_info">
<legend><?php echo $this->lang->line("customers_basic_information"); ?></legend>
<?php $this->load->view("people/form_basic_info"); ?>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('customers_company_name').':', 'company_name'); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'company_name',
'value'=>$person_info->company_name)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('customers_account_number').':', 'account_number'); ?>
<div class='form_field'>

View File

@@ -4,9 +4,9 @@
echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form', 'enctype'=>'multipart/form-data'));
?>
<fieldset id="item_basic_info">
<legend><?php echo $this->lang->line("items_basic_information"); ?></legend>
<legend><?php echo $this->lang->line("items_basic_information"); ?></legend>
<div class="field_row clearfix">
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_item_number').':', 'item_number',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
@@ -16,9 +16,9 @@ echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form', 'encty
'value'=>$item_info->item_number)
);?>
</div>
</div>
</div>
<div class="field_row clearfix">
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_name').':', 'name',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(

View File

@@ -84,17 +84,15 @@ if (isset($error_message))
}
?>
<?php if ($this->Appconfig->get('show_total_discount') && count($discounts) > 0): ?>
<?php if ($this->Appconfig->get('show_total_discount') && $discount > 0): ?>
<tr>
<td colspan="3" style='text-align:right;border-top:2px solid #000000;'><?php echo $this->lang->line('sales_sub_total'); ?></td>
<td style='text-align:right;border-top:2px solid #000000;'><?php echo to_currency($subtotal); ?></td>
</tr>
<?php foreach($discounts as $name=>$value) { ?>
<tr>
<td colspan="3" class="total-value"><?php echo $this->lang->line('sales_discount'); ?>:</td>
<td class="total-value"><?php echo to_currency($value*-1); ?></td>
</tr>
<?php }; ?>
<tr>
<td colspan="3" class="total-value"><?php echo $this->lang->line('sales_discount'); ?>:</td>
<td class="total-value"><?php echo to_currency($discount*-1); ?></td>
</tr>
<?php endif; ?>
<?php if ($this->Appconfig->get('receipt_show_taxes')): ?>
<tr>

View File

@@ -77,6 +77,7 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
CREATE TABLE `ospos_customers` (
`person_id` int(10) NOT NULL,
`company_name` varchar(255) NOT NULL,
`account_number` varchar(255) DEFAULT NULL,
`taxable` int(1) NOT NULL DEFAULT '1',
`deleted` int(1) NOT NULL DEFAULT '0',