fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [8586] property: more on manual invoice


From: Sigurd Nes
Subject: [Fmsystem-commits] [8586] property: more on manual invoice
Date: Mon, 16 Jan 2012 12:16:22 +0000

Revision: 8586
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8586
Author:   sigurdne
Date:     2012-01-16 12:16:17 +0000 (Mon, 16 Jan 2012)
Log Message:
-----------
property: more on manual invoice

Modified Paths:
--------------
    trunk/property/inc/class.boinvoice.inc.php
    trunk/property/inc/class.soXport.inc.php

Modified: trunk/property/inc/class.boinvoice.inc.php
===================================================================
--- trunk/property/inc/class.boinvoice.inc.php  2012-01-16 10:16:29 UTC (rev 
8585)
+++ trunk/property/inc/class.boinvoice.inc.php  2012-01-16 12:16:17 UTC (rev 
8586)
@@ -386,13 +386,15 @@
                                {
                                        $receipt['error'][] = 
array('msg'=>lang('voucher id already taken'));
                                }
+                               $skip_update_voucher_id = true;
                                $values['bilagsnr']             = 
$values['voucher_out_id'];
                                $values['bilagsnr_ut']  = '';
                        }
                        else
                        {
-                               $values['bilagsnr']                     = 
execMethod('property.socommon.increment_id','Bilagsnummer');
-                               $values['bilagsnr_ut']          = 
$values['voucher_out_id'];                    
+                               $skip_update_voucher_id = false;
+                               $values['bilagsnr']             = 
execMethod('property.socommon.increment_id','Bilagsnummer');
+                               $values['bilagsnr_ut']  = 
$values['voucher_out_id'];                    
                        }
 
                        if( $soXport->check_invoice_id($values['vendor_id'], 
$values['invoice_id']))
@@ -423,27 +425,30 @@
                                if($order_type=='s_agreement')
                                {
                                        $sos_agreement = 
CreateObject('property.sos_agreement');
-                                       $s_agreement = 
$sos_agreement->read_single(array('s_agreement_id'=>$values['order_id']));
-                                       $values = 
$this->set_responsible($values,$s_agreement['user_id'],$s_agreement['b_account_id']);
+                                       $s_agreement = 
$sos_agreement->read_single($values['order_id']);
+                       //              $values = 
$this->set_responsible($values,$s_agreement['user_id'],$s_agreement['b_account_id']);
                                        $s_agreement_detail = 
$sos_agreement->read(array('allrows'=>true,'s_agreement_id'=>$values['order_id'],'detail'=>true));
 
                                        $sum_agreement=0;
                                        for 
($i=0;$i<count($s_agreement_detail);$i++)
                                        {
+                                               $s_agreement_detail[$i]['cost'] 
= abs($s_agreement_detail[$i]['cost']) > 0 ? $s_agreement_detail[$i]['cost'] : 
1;
                                                $sum_agreement = $sum_agreement 
+ $s_agreement_detail[$i]['cost'];
                                        }
 
                                        for 
($i=0;$i<count($s_agreement_detail);$i++)
                                        {
+                                               $_location = explode('-', 
$s_agreement_detail[$i]['location_code']);
                                                $buffer[$i]                     
                        = $values;
                                                $buffer[$i]['location_code']    
= $s_agreement_detail[$i]['location_code'];
+                                               $buffer[$i]['loc1']             
                = $_location[0];
                                                $buffer[$i]['dima']             
                = str_replace('-','',$s_agreement_detail[$i]['location_code']);
                                                $buffer[$i]['belop']            
        = round($values['belop'] / $sum_agreement * 
$s_agreement_detail[$i]['cost'],2);
                                                $buffer[$i]['godkjentbelop']    
= $buffer[$i]['belop'];
                                        }
                                }
 
-                               if($soXport->add_manual_invoice($buffer))
+                               
if($soXport->add_manual_invoice($buffer,$skip_update_voucher_id))
                                {
                                        $receipt['message'][] = 
array('msg'=>lang('Invoice %1 is added',$soXport->voucher_id));
                                        $receipt['voucher_id'] = 
$soXport->voucher_id;

Modified: trunk/property/inc/class.soXport.inc.php
===================================================================
--- trunk/property/inc/class.soXport.inc.php    2012-01-16 10:16:29 UTC (rev 
8585)
+++ trunk/property/inc/class.soXport.inc.php    2012-01-16 12:16:17 UTC (rev 
8586)
@@ -209,7 +209,7 @@
                        return $this->db->f('cnt');
                }
 
-               function add($buffer)
+               function add($buffer, $skip_update_voucher_id = false)
                {
                        if ( $this->db->get_transaction() )
                        {
@@ -282,15 +282,18 @@
                                        
$this->db->query($sql,__LINE__,__FILE__);
 
                                        $num++;
+
+                                       if(!$skip_update_voucher_id)
+                                       {
+                                               $now = time();
+                                               $this->db->query("SELECT 
start_date FROM fm_idgenerator WHERE name='Bilagsnummer' AND start_date < 
{$now} ORDER BY start_date DESC");
+                                               $this->db->next_record();
+                                               $start_date = 
(int)$this->db->f('start_date');
+                                               $this->db->query("UPDATE 
fm_idgenerator set value = {$bilagsnr} WHERE name = 'Bilagsnummer' AND 
start_date = {$start_date}");
+                                       }
                                }
                        }
 
-                       $now = time();
-                       $this->db->query("SELECT start_date FROM fm_idgenerator 
WHERE name='Bilagsnummer' AND start_date < {$now} ORDER BY start_date DESC");
-                       $this->db->next_record();
-                       $start_date = (int)$this->db->f('start_date');
-                       $this->db->query("UPDATE fm_idgenerator set value = 
{$bilagsnr} WHERE name = 'Bilagsnummer' AND start_date = {$start_date}");
-
                        if ( !$this->global_lock )
                        {
                                $this->db->transaction_commit();
@@ -666,11 +669,13 @@
                        return $responsible;
                }
 
-               function add_manual_invoice($values)
+               function add_manual_invoice($values, $skip_update_voucher_id = 
false)
                {
-                       $this->add($values);
                        $_dateformat = $this->db->date_format();
                        $this->db->transaction_begin();
+
+                       $this->add($values, $skip_update_voucher_id);
+
                        $voucher = $this->get_voucher($values[0]['bilagsnr']);
                        foreach ($voucher as &$line)
                        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]