From 4c7907b773b321ce5f589014641dce2a6b5ddd98 Mon Sep 17 00:00:00 2001 From: simnandez Date: Sun, 15 Sep 2013 11:47:31 +0200 Subject: [PATCH] [ task #1060 ] Register fields localtax(1|2)_type into details tables --- ChangeLog | 1 + .../commande/doc/pdf_einstein.modules.php | 17 ++++++++++------- .../commande/doc/pdf_proforma.modules.php | 15 +++++++++------ .../modules/facture/doc/pdf_crabe.modules.php | 19 +++++++++++-------- .../modules/propale/doc/pdf_azur.modules.php | 17 ++++++++++------- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 58aaf22595e..b9762661f07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,7 @@ For users: - New: User permissions on margin module - New: Add ref supplier into muscadet model - New: Can use tag {mm} before {yy} even when there is a reset into numbering masks. +- New: [ task #1060 ] Register fields localtax(1|2)_type into details tables For translators: - Qual: Normalized sort order of all languages files with english reference files. diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index b7866212b79..a954c68c906 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -377,11 +377,14 @@ class pdf_einstein extends ModelePDFCommandes $vatrate=(string) $object->lines[$i]->tva_tx; - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index f90871b2471..35d7dd3f9fc 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2013 Juanjo Menent @@ -377,11 +377,14 @@ class pdf_proforma extends ModelePDFCommandes $vatrate=(string) $object->lines[$i]->tva_tx; - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 7c8f7307255..0f2ac346e69 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -378,12 +378,15 @@ class pdf_crabe extends ModelePDFFactures if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; $vatrate=(string) $object->lines[$i]->tva_tx; - - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 6a3d0709963..a8b8a8dfdb6 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -432,11 +432,14 @@ class pdf_azur extends ModelePDFPropales $vatrate=(string) $object->lines[$i]->tva_tx; - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0)