Skip to content

Commit 55b7358

Browse files
committed
Merge branch 'master' into drs/plm
2 parents 46175f2 + 0281595 commit 55b7358

9 files changed

Lines changed: 65 additions & 1757 deletions

File tree

PDFAck.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565
ON salesorders.fromstkloc=locations.loccode
6666
INNER JOIN currencies
6767
ON debtorsmaster.currcode=currencies.currabrev
68-
AND salesorders.orderno='" . $_GET['AcknowledgementNo'] . "'";
69-
68+
WHERE salesorders.orderno='" . $_GET['AcknowledgementNo'] . "'";
7069
$Result = DB_query($SQL, $ErrMsg);
7170

7271
if (DB_num_rows($Result) == 0) {
@@ -137,21 +136,18 @@
137136
ON taxgrouptaxes.taxgroupid=custbranch.taxgroupid
138137
WHERE custbranch.branchcode='" . $Branch . "'";
139138
$Result3 = DB_query($SQL3, $ErrMsg);
140-
$TaxAuth = '';
139+
$TaxClass = 0;
141140
while ($MyRow3 = DB_fetch_array($Result3)) {
142141
$TaxAuth = $MyRow3['taxauthid'];
143-
}
144-
145-
// Get Tax Rate
146-
$SQL4 = "SELECT taxrate
147-
FROM taxauthrates
148-
WHERE dispatchtaxprovince='" . $TaxProv . "'
142+
$SQL4 = "SELECT taxrate
143+
FROM taxauthrates
144+
WHERE dispatchtaxprovince='" . $TaxProv . "'
149145
AND taxcatid='" . $TaxCat . "'
150146
AND taxauthority='" . $TaxAuth . "'";
151-
$Result4 = DB_query($SQL4, $ErrMsg);
152-
$TaxClass = 0;
153-
while ($MyRow4 = DB_fetch_array($Result4)) {
154-
$TaxClass = 100 * $MyRow4['taxrate'];
147+
$Result4 = DB_query($SQL4, $ErrMsg);
148+
if ($MyRow4 = DB_fetch_array($Result4)) {
149+
$TaxClass += 100 * $MyRow4['taxrate'];
150+
}
155151
}
156152

157153
$TaxAmount = (($SubTot / 100) * (100 + $TaxClass)) - $SubTot;

PDFQuotation.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
salesorders.deladd5,
5353
salesorders.deladd6,
5454
debtorsmaster.name,
55+
debtorsmaster.debtorno,
5556
debtorsmaster.currcode,
5657
debtorsmaster.address1,
5758
debtorsmaster.address2,
@@ -174,26 +175,27 @@
174175
$SubTot = $MyRow2['unitprice']*$MyRow2['quantity']*(1-$MyRow2['discountpercent']);
175176
$TaxProv = $MyRow['taxprovinceid'];
176177
$TaxCat = $MyRow2['taxcatid'];
178+
$DebtorNo = $MyRow['debtorno'];
177179
$Branch = $MyRow['branchcode'];
178180
$SQL3 = "SELECT taxgrouptaxes.taxauthid
179181
FROM taxgrouptaxes INNER JOIN custbranch
180182
ON taxgrouptaxes.taxgroupid=custbranch.taxgroupid
181-
WHERE custbranch.branchcode='" .$Branch ."'";
183+
WHERE custbranch.debtorno='" . $DebtorNo . "'
184+
AND custbranch.branchcode='" . $Branch . "'";
182185
$Result3=DB_query($SQL3, $ErrMsg);
183-
$TaxAuth = 0;
186+
$TaxClass = 0;
184187
while ($MyRow3=DB_fetch_array($Result3)){
185188
$TaxAuth = $MyRow3['taxauthid'];
189+
$SQL4 = "SELECT taxrate FROM taxauthrates
190+
WHERE dispatchtaxprovince='" .$TaxProv ."'
191+
AND taxcatid='" .$TaxCat ."'
192+
AND taxauthority='" .$TaxAuth ."'";
193+
$Result4=DB_query($SQL4, $ErrMsg);
194+
if ($MyRow4=DB_fetch_array($Result4)){
195+
$TaxClass += 100 * $MyRow4['taxrate'];
196+
}
186197
}
187-
$SQL4 = "SELECT * FROM taxauthrates
188-
WHERE dispatchtaxprovince='" .$TaxProv ."'
189-
AND taxcatid='" .$TaxCat ."'
190-
AND taxauthority='" .$TaxAuth ."'";
191-
$Result4=DB_query($SQL4, $ErrMsg);
192-
$TaxClass = 0;
193-
while ($MyRow4=DB_fetch_array($Result4)){
194-
$TaxClass = 100 * $MyRow4['taxrate'];
195-
}
196-
$DisplayTaxClass = $TaxClass . '%';
198+
$DisplayTaxClass = number_format($TaxClass, 2) . '%';
197199
$TaxAmount = (($SubTot/100)*(100+$TaxClass))-$SubTot;
198200
$DisplayTaxAmount = locale_number_format($TaxAmount,$MyRow['currdecimalplaces']);
199201
$LineTotal = $SubTot + $TaxAmount;
@@ -267,4 +269,4 @@
267269
$DomPDF->render();
268270

269271
// Output the generated PDF to Browser
270-
$DomPDF->stream($PdfFileName, array("Attachment" => false));
272+
$DomPDF->stream($PdfFileName, array("Attachment" => false));

SupplierCredit.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,13 +939,16 @@
939939
$CostIncrement = ($PurchPriceVar - $WriteOffToVariances) / $TotalQuantityOnHand;
940940

941941
$SQL = "UPDATE stockmaster SET lastcost=materialcost+overheadcost+labourcost,
942-
materialcost=materialcost-" . $CostIncrement . "
942+
materialcost=materialcost-" . $CostIncrement . ",
943+
lastcostupdate=CURRENT_DATE
943944
WHERE stockid='" . $EnteredGRN->ItemCode . "'";
944945

945946
$Result = DB_query($SQL, $ErrMsg, '', true);
946947
} else {
947948
$SQL = "UPDATE stockmaster SET lastcost=materialcost+overheadcost+labourcost,
948-
materialcost=" . ($EnteredGRN->ChgPrice / $_SESSION['SuppTrans']->ExRate) . " WHERE stockid='" . $EnteredGRN->ItemCode . "'";
949+
materialcost=" . ($EnteredGRN->ChgPrice / $_SESSION['SuppTrans']->ExRate) . ",
950+
lastcostupdate=CURRENT_DATE
951+
WHERE stockid='" . $EnteredGRN->ItemCode . "'";
949952
$Result = DB_query($SQL, $ErrMsg, '', true);
950953
}
951954
/* End of Weighted Average Costing Code */

SupplierInvoice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,15 +1694,16 @@
16941694

16951695
$SQL = "UPDATE stockmaster
16961696
SET lastcost=materialcost+overheadcost+labourcost,
1697-
materialcost=materialcost+" . $CostIncrement . "
1697+
materialcost=materialcost+" . $CostIncrement . ", lastcostupdate = CURRENT_DATE
16981698
WHERE stockid='" . $EnteredGRN->ItemCode . "'";
16991699
$Result = DB_query($SQL, $ErrMsg, '', true);
17001700
}
17011701
else {
17021702
/* if stock is negative then update the cost to this cost */
17031703
$SQL = "UPDATE stockmaster
17041704
SET lastcost=materialcost+overheadcost+labourcost,
1705-
materialcost='" . $ActualCost . "'
1705+
materialcost='" . $ActualCost . "',
1706+
lastcostupdate = CURRENT_DATE
17061707
WHERE stockid='" . $EnteredGRN->ItemCode . "'";
17071708
$Result = DB_query($SQL, $ErrMsg, '', true);
17081709
}

includes/UpgradeDB_mariadb.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,21 @@ function DeleteConfigValue($ConfName) {
515515
}
516516

517517
function CreateTable($Table, $SQL, $CharacterSet='utf8mb4') {
518+
519+
$CollationSQL = "SHOW VARIABLES LIKE 'collation_connection'";
520+
$Result = DB_query($CollationSQL);
521+
if (DB_num_rows($Result) == 0) {
522+
$Collation='utf8mb4_general_ci';
523+
} else {
524+
$MyRow = DB_fetch_row($Result);
525+
$Collation = $MyRow[1];
526+
}
518527
$ShowSQL = "SHOW TABLES WHERE Tables_in_" . $_SESSION['DatabaseName'] . "='" . $Table . "'";
519528
$Result = DB_query($ShowSQL);
520529

521530
if (DB_num_rows($Result) == 0) {
522531
DB_IgnoreForeignKeys();
523-
$Response = executeSQL($SQL . ' ENGINE=InnoDB DEFAULT CHARSET=' . $CharacterSet, false);
532+
$Response = executeSQL($SQL . ' ENGINE=InnoDB DEFAULT CHARSET=' . $CharacterSet . ' COLLATE=' . $Collation, false);
524533
DB_ReinstateForeignKeys();
525534
if ($Response == 0) {
526535
OutputResult(__('The table') . ' ' . $Table . ' ' . __('has been created'), 'success');
@@ -532,6 +541,7 @@ function CreateTable($Table, $SQL, $CharacterSet='utf8mb4') {
532541
}
533542
}
534543

544+
535545
function ConstraintExists($Table, $Constraint) {
536546
$SQL = "SELECT CONSTRAINT_NAME
537547
FROM information_schema.TABLE_CONSTRAINTS

includes/UpgradeDB_mysql.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,21 @@ function DeleteConfigValue($ConfName) {
496496
}
497497

498498
function CreateTable($Table, $SQL, $CharacterSet='utf8mb4') {
499+
500+
$CollationSQL = "SHOW VARIABLES LIKE 'collation_connection'";
501+
$Result = DB_query($CollationSQL);
502+
if (DB_num_rows($Result) == 0) {
503+
$Collation='utf8mb4_general_ci';
504+
} else {
505+
$MyRow = DB_fetch_row($Result);
506+
$Collation = $MyRow[1];
507+
}
499508
$ShowSQL = "SHOW TABLES WHERE Tables_in_" . $_SESSION['DatabaseName'] . "='" . $Table . "'";
500509
$Result = DB_query($ShowSQL);
501510

502511
if (DB_num_rows($Result) == 0) {
503512
DB_IgnoreForeignKeys();
504-
$Response = executeSQL($SQL . ' ENGINE=InnoDB DEFAULT CHARSET=' . $CharacterSet, false);
513+
$Response = executeSQL($SQL . ' ENGINE=InnoDB DEFAULT CHARSET=' . $CharacterSet . ' COLLATE=' . $Collation, false);
505514
DB_ReinstateForeignKeys();
506515
if ($Response == 0) {
507516
OutputResult(__('The table') . ' ' . $Table . ' ' . __('has been created'), 'success');
@@ -513,6 +522,7 @@ function CreateTable($Table, $SQL, $CharacterSet='utf8mb4') {
513522
}
514523
}
515524

525+
516526
function ConstraintExists($Table, $Constraint) {
517527
$SQL = "SELECT CONSTRAINT_NAME
518528
FROM information_schema.TABLE_CONSTRAINTS

includes/UpgradeDB_mysqli.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,21 @@ function DeleteConfigValue($ConfName) {
514514
}
515515

516516
function CreateTable($Table, $SQL, $CharacterSet='utf8mb4') {
517+
518+
$CollationSQL = "SHOW VARIABLES LIKE 'collation_connection'";
519+
$Result = DB_query($CollationSQL);
520+
if (DB_num_rows($Result) == 0) {
521+
$Collation='utf8mb4_general_ci';
522+
} else {
523+
$MyRow = DB_fetch_row($Result);
524+
$Collation = $MyRow[1];
525+
}
517526
$ShowSQL = "SHOW TABLES WHERE Tables_in_" . $_SESSION['DatabaseName'] . "='" . $Table . "'";
518527
$Result = DB_query($ShowSQL);
519528

520529
if (DB_num_rows($Result) == 0) {
521530
DB_IgnoreForeignKeys();
522-
$Response = executeSQL($SQL . ' ENGINE=InnoDB DEFAULT CHARSET=' . $CharacterSet, false);
531+
$Response = executeSQL($SQL . ' ENGINE=InnoDB DEFAULT CHARSET=' . $CharacterSet . ' COLLATE=' . $Collation, false);
523532
DB_ReinstateForeignKeys();
524533
if ($Response == 0) {
525534
OutputResult(__('The table') . ' ' . $Table . ' ' . __('has been created'), 'success');

install/sql/demo.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ INSERT INTO `securitygroups` VALUES (1,0),(1,1),(1,2),(1,5),(2,0),(2,1),(2,2),(2
1111

1212
INSERT INTO `favourites` VALUES ('admin','Search Customers','SelectCustomer.php'),('admin','Search Inventory Items','SelectProduct.php'),('admin','Search Suppliers','SelectSupplier.php');
1313
INSERT INTO `systypes` VALUES (0,'Journal - GL',0),(1,'Payment - GL',0),(2,'Receipt - GL',0),(3,'Standing Journal',0),(4,'Journal Template Number',0),(10,'Sales Invoice',0),(11,'Credit Note',0),(12,'Receipt',0),(15,'Journal - Debtors',0),(16,'Location Transfer',0),(17,'Stock Adjustment',0),(18,'Purchase Order',0),(19,'Picking List',0),(20,'Purchase Invoice',0),(21,'Debit Note',0),(22,'Creditors Payment',0),(23,'Creditors Journal',0),(25,'Purchase Order Delivery',0),(26,'Work Order Receipt',0),(28,'Work Order Issue',0),(29,'Work Order Variance',0),(30,'Sales Order',0),(31,'Shipment Close',0),(32,'Contract Close',0),(35,'Cost Update',0),(36,'Exchange Difference',0),(37,'Tenders',0),(38,'Stock Requests',0),(39,'Sales Commision Accruals',0),(40,'Work Order',0),(41,'Asset Addition',0),(42,'Asset Category Change',0),(43,'Delete w/down asset',0),(44,'Depreciation',0),(49,'Import Fixed Assets',0),(50,'Opening Balance',0),(500,'Auto Debtor Number',0),(600,'Auto Supplier Number',0);
14-
INSERT INTO `companies` VALUES (1,'webERP Demonstration Company Ltd','1234567890','','123 Web Way','PO Box 123','Queen Street','Melbourne','Victoria 3043','Australia','+61 3 4567 8901','+61 3 4567 8902','weberp@weberpdemo.com','USD','1100','4900','2100','2400','2150','2150','4200','5200','4200','3500',1,1,1,'5600');
14+
INSERT INTO `companies` (`coycode`, `coyname`, `gstno`, `companynumber`, `regoffice1`, `regoffice2`, `regoffice3`, `regoffice4`, `regoffice5`, `regoffice6`, `telephone`, `fax`, `email`, `currencydefault`, `debtorsact`, `pytdiscountact`, `creditorsact`, `payrollact`, `grnact`, `commissionsact`, `salesexchangediffact`, `purchasesexchangediffact`, `currencyexchangediffact`, `unrealizedcurrencydiffact`,`retainedearnings`, `gllink_debtors`, `gllink_creditors`, `gllink_stock`, `freightact`) VALUES (1,'Green Power Motor Company Ltd','not entered yet','','123 Web Way','PO Box 123','Queen Street','Melbourne','Victoria 3043','Australia','+61 3 4567 8901','+61 3 4567 8902','weberp@weberpdemo.com','USD','1100','4900','2100','2400','2150','2150','4200','5200','4200','3500','3500',1,1,1,'5600');
1515

1616
INSERT INTO `accountsection` (`sectionid`, `sectionname`) VALUES
1717
(1, 'Revenue'),

0 commit comments

Comments
 (0)