[fixed]TableInvoices COM_VIRTUEMART_INVOICE_NUMBER in record is missing! Can't

Started by apri, March 31, 2015, 05:06:49 AM

Previous topic - Next topic

apri

virtuemart 3.0.6.2

I get that message when trying to delete oder. Everything works except renaming invoice, all database tables get things related to that order deleted.

My findings after some debugging:

invoice is generated like vminvoice_150330cc1011.pdf. It's in the direcory with the correct permissions and could be renamed if no bug.
I put a loggin statements in orders.php directory (\administrator\components\com_virtuemart\models\ )
Here is code fragment with logging statements which are error_log

      // rename invoice pdf file
      $invoice_prefix='vminvoice_'.VmConfig::$vmlang.'_';
      $path = shopFunctions::getInvoicePath(VmConfig::get('forSale_path',0));
      error_log("renaming invoice 0 " . $path);
      $invoice_name_src = $path.DS.$invoice_prefix.$data['invoice_number'].'.pdf';
      error_log("renaming invoice 1 " . $invoice_name_src);
      if(!file_exists($invoice_name_src)){
         // may be it was already deleted when changing order items
         $data['invoice_number'] = "";
      } else {
         error_log("renaming invoice 2");
         $date = date("Ymd");
         $data['invoice_number'] = $data['invoice_number'].'_'.$date;
         $invoice_name_dst = $path.DS.$data['invoice_number'].'.pdf';

         if(!class_exists('JFile')) require(VMPATH_LIBS.DS.'joomla'.DS.'filesystem'.DS.'file.php');
         if (!JFile::move($invoice_name_src, $invoice_name_dst)) {
            vmError ('Could not rename Invoice '.$invoice_name_src.'to '. $invoice_name_dst );
         }
      }

Here're the lines from php error log file:

[30-Mar-2015 22:17:21 America/New_York] renaming invoice 0 C:\xampp\htdocs\vmfiles\invoices

[30-Mar-2015 22:17:21 America/New_York] renaming invoice 1 C:\xampp\htdocs\vmfiles\invoices\vminvoice_en_gb_150330cc1011.pdf

So, this statement
$invoice_prefix='vminvoice_'.VmConfig::$vmlang.'_';
inserts en_gb into invoice name which was originally generated without VmConfig::$vmlang

Such file does not exist and we have this error message and un-renamed file
This fixes the problem:
$invoice_prefix='vminvoice_'; // .VmConfig::$vmlang.'_';



Milbo

Thank you, good work.

does this work for you?


// rename invoice pdf file
$path = shopFunctions::getInvoicePath(VmConfig::get('forSale_path',0));
$invoice_prefix='vminvoice_';
$invoice_name_src = $path.DS.$invoice_prefix.$data['invoice_number'].'.pdf';
if(!file_exists($invoice_name_src)){
$invoice_prefix='vminvoice_'.VmConfig::$vmlang.'_';
$invoice_name_src = $path.DS.$invoice_prefix.$data['invoice_number'].'.pdf';
}

if(!file_exists($invoice_name_src)){


??
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/


Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

apri

I've checked the code of other versions of VM I have, version 2.9.8.a does not have VmConfig::$vmlang.
Nothing personal, but did whoever added VmConfig::$vmlang  into code bother to test and delete invoice after the routine was modified? It should be fixed when invoice is created.

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Wapsel

Hi there,

I'm getting the same error when I try to edit a placed order and want to save it for the second time (first time is okay).
I noticed that the pdf invoice in the invoices folder gets the title "_deprecated" with the date behind it. Maybe this has someting to do with it?

Joomla: 3.4.1
VM: 3.0.9

Maybe someone can help me out?

Henrik Holm Nielsen

I see the same in my upgraded install with J3.4.1 & VM3.0.9 when deleting orders....
/Zorroson :)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Billigt og professionelt design af din hjemmeside | Brug for en billig, flot og professionel hjemmeside?

green-products.co.uk

Regards

David

rojones31

@Milbo  - I"m having the same issue however, I'm following the code listed above and I can't seem to follow where to input the updated script into the orders.php file. 

In the original orders.php the code is as follows:
// rename invoice pdf file
      $invoice_prefix='vminvoice_';
      $path = shopFunctions::getInvoicePath(VmConfig::get('forSale_path',0));
      $invoice_name_src = $path.DS.$invoice_prefix.$data['invoice_number'].'.pdf';

      if(!file_exists($invoice_name_src)){


In the edited code you posted it reads as follows:  (however it has another if statement at the bottom)
// rename invoice pdf file
      $path = shopFunctions::getInvoicePath(VmConfig::get('forSale_path',0));
      $invoice_prefix='vminvoice_';
      $invoice_name_src = $path.DS.$invoice_prefix.$data['invoice_number'].'.pdf';
      if(!file_exists($invoice_name_src)){
         $invoice_prefix='vminvoice_'.VmConfig::$vmlang.'_';
         $invoice_name_src = $path.DS.$invoice_prefix.$data['invoice_number'].'.pdf';
      }
      
      if(!file_exists($invoice_name_src)){  (Should this script be included? There are two if statements and in the original there is only one if statement.)

I have attached the orginial orders.php in a zip file, so you can edit where the updated script needs to be replaced.

I'm using J3.4 and VM 3.0.6.2

Please edit the file and resend with the correct code.

Thanks for all your help,
RJ




eclark461

Line 1997 VM 3.0.9 path /administrator/components/com_virtuemart/models/orders.php

Found it there or around there.

Still having same issue after applying script as stated above.
Joomla 3.4.3
Template Gantry 4
Virtuemart 3.0.9