Changeset 747 for trunk/Common


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.

Location:
trunk/Common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Form/Form.php

    r738 r747  
    11<?php
    22
    3 include_once(dirname(__FILE__).'/../Database.php');
    43include_once(dirname(__FILE__).'/Types/Type.php');
    54
     
    232231    foreach($this->Definition['Items'] as $Index => $Item)
    233232    {
    234       if(!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;
    235       if($Item['ReadOnly'] == false)
     233      if(array_key_exists($Index, $this->Values))
    236234      if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    237235      (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
  • 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.