Ignore:
Timestamp:
Sep 21, 2015, 12:12:26 AM (9 years ago)
Author:
chronos
Message:

This solves problem with inconsistency between invoice and invoice items values and inconsistency between selected document line and incorrect positive or negative values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Setup/Updates.php

    r743 r747  
    14891489}
    14901490
     1491function UpdateTo748($Manager)
     1492{
     1493  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `ValueUser` FLOAT NOT NULL AFTER `Value`;');
     1494  $Manager->Execute('UPDATE `FinanceOperation` SET `ValueUser`=`Value`');
     1495  $Manager->Execute('UPDATE `FinanceOperation` SET `Value`=`ValueUser`*`ValueSign`');
     1496  $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=1 WHERE (`ValueSign`=1) AND (`Cash`=1)');
     1497  $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=2 WHERE (`ValueSign`=-1) AND (`Cash`=1)');
     1498  $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=3 WHERE (`ValueSign`=1) AND (`Cash`=0)');
     1499  $Manager->Execute('UPDATE `FinanceOperation` SET `Group`=4 WHERE (`ValueSign`=-1) AND (`Cash`=0)');
     1500  $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `Direction`, DROP `ValueSign`;');
     1501
     1502  // SELECT FinanceInvoice.* FROM `FinanceInvoice` LEFT JOIN FinanceInvoiceGroup ON FinanceInvoiceGroup.Id=FinanceInvoice.Group WHERE FinanceInvoice.ValueSign != FinanceInvoiceGroup.ValueSign
     1503  $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=1 WHERE (`ValueSign`=-1)');
     1504  $Manager->Execute('UPDATE `FinanceInvoice` SET `Group`=2 WHERE (`ValueSign`=1)');
     1505  $Manager->Execute('UPDATE `FinanceInvoice` SET `Value`=`Value`*`ValueSign`');
     1506  $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `Direction`, DROP `ValueSign`;');
     1507  // Check manual vs. calculated value from items
     1508  // SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(`Price` * `Quantity`) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value`
     1509}
    14911510
    14921511class Updates
     
    15571576      735 => array('Revision' => 736, 'Function' => 'UpdateTo736'),
    15581577      736 => array('Revision' => 739, 'Function' => 'UpdateTo739'),
    1559           739 => array('Revision' => 740, 'Function' => 'UpdateTo740'),
     1578      739 => array('Revision' => 740, 'Function' => 'UpdateTo740'),
    15601579      740 => array('Revision' => 741, 'Function' => 'UpdateTo741'),
    15611580      741 => array('Revision' => 742, 'Function' => 'UpdateTo742'),
     1581      742 => array('Revision' => 748, 'Function' => 'UpdateTo748'),
    15621582    ));
    15631583  }
Note: See TracChangeset for help on using the changeset viewer.