Skip to content

Commit

Permalink
Auto Increase of Document References (company setup)
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-hunt committed Apr 16, 2018
1 parent 67b2242 commit 469ef80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 8 additions & 1 deletion admin/company_preferences.php
Expand Up @@ -113,7 +113,7 @@
'postal_address','phone', 'fax', 'email', 'coy_logo', 'domicile',
'use_dimension', 'curr_default', 'f_year', 'shortname_name_in_list',
'no_item_list' => 0, 'no_customer_list' => 0,
'no_supplier_list' =>0, 'base_sales',
'no_supplier_list' =>0, 'base_sales', 'ref_no_auto_increase' => 0,
'time_zone' => 0, 'company_logo_report' => 0, 'barcodes_on_stock' => 0, 'add_pct', 'round_to', 'login_tout',
'auto_curr_reval', 'bcc_email', 'alternative_tax_include_on_docs', 'suppress_tax_rates',
'use_manufacturing', 'use_fixed_assets'))
Expand Down Expand Up @@ -161,6 +161,12 @@
$myrow["company_logo_report"] = get_company_pref("company_logo_report");
}
$_POST['company_logo_report'] = $myrow["company_logo_report"];
if (!isset($myrow["ref_no_auto_increase"]))
{
set_company_pref("ref_no_auto_increase", "setup.company", "tinyint", 1, '0');
$myrow["ref_no_auto_increase"] = get_company_pref("ref_no_auto_increase");
}
$_POST['ref_no_auto_increase'] = $myrow["ref_no_auto_increase"];
if (!isset($myrow["barcodes_on_stock"]))
{
set_company_pref("barcodes_on_stock", "setup.company", "tinyint", 1, '0');
Expand Down Expand Up @@ -208,6 +214,7 @@
check_row(_("Time Zone on Reports"), 'time_zone', $_POST['time_zone']);
check_row(_("Company Logo on Reports"), 'company_logo_report', $_POST['company_logo_report']);
check_row(_("Use Barcodes on Stocks"), 'barcodes_on_stock', $_POST['barcodes_on_stock']);
check_row(_("Auto Increase of Document References"), 'ref_no_auto_increase', $_POST['ref_no_auto_increase']);
label_row(_("Database Scheme Version"), $_POST['version_id']);

table_section(2);
Expand Down
13 changes: 10 additions & 3 deletions sales/includes/cart_class.inc
Expand Up @@ -285,12 +285,19 @@ class Cart
// Makes parent documents for direct delivery/invoice by recurent call.
// $policy - 0 or 1: writeoff/return for IV, back order/cancel for DN
function write($policy=0) {


global $SysPrefs, $Refs;

begin_transaction(); // prevents partial database changes in case of direct delivery/invoice
if ($this->reference != 'auto' && $this->trans_no == 0 && !is_new_reference($this->reference, $this->trans_type))
{
commit_transaction();
return -1;
if (!empty($SysPrefs->prefs['ref_no_auto_increase']))
$this->reference = $Refs->get_next($this->trans_type, null, array('date' => Today()));
if (!is_new_reference($this->reference, $this->trans_type))
{
commit_transaction();
return -1;
}
}
if (count($this->src_docs) == 0 && ($this->trans_type == ST_SALESINVOICE || $this->trans_type == ST_CUSTDELIVERY) && !$this->is_prepaid()) {
// this is direct document - first add parent
Expand Down

2 comments on commit 469ef80

@apmuthu
Copy link
Contributor

@apmuthu apmuthu commented on 469ef80 Apr 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the standard Charts (and upgrade script) to reflect default value for the new flag.

@apmuthu
Copy link
Contributor

@apmuthu apmuthu commented on 469ef80 Apr 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

companysetup_newflag

Please sign in to comment.