mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW Manage VAT on all lines on purchases cycle
This commit is contained in:
parent
e0b1ad308b
commit
38352d0c28
|
|
@ -68,7 +68,7 @@ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FA
|
|||
print $langs->trans('VAT');
|
||||
}
|
||||
|
||||
if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) {
|
||||
if (in_array($object->element, array('propal', 'commande', 'facture', 'supplier_proposal', 'order_supplier', 'invoice_supplier')) && $object->status == $object::STATUS_DRAFT) {
|
||||
global $mysoc;
|
||||
|
||||
if (empty($disableedit)) {
|
||||
|
|
|
|||
|
|
@ -405,7 +405,16 @@ if (empty($reshook)) {
|
|||
}
|
||||
|
||||
// Add a product line
|
||||
if ($action == 'addline' && $usercancreate) {
|
||||
if ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
|
||||
// Define vat_rate
|
||||
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
|
||||
foreach($object->lines as $line) {
|
||||
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, 0, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
|
||||
}
|
||||
} elseif ($action == 'addline' && $usercancreate) {
|
||||
$db->begin();
|
||||
|
||||
$langs->load('errors');
|
||||
|
|
|
|||
|
|
@ -1383,6 +1383,15 @@ if (empty($reshook)) {
|
|||
$db->rollback();
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
|
||||
// Define vat_rate
|
||||
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
|
||||
foreach($object->lines as $line) {
|
||||
$result = $object->updateline($line->id, $line->desc, $line->subprice, $vat_rate, $localtax1_rate, $localtax2_rate, $line->qty, $line->fk_product, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, 0, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice, $line->ref_supplier, $line->rang);
|
||||
}
|
||||
} elseif ($action == 'addline' && $usercancreate) {
|
||||
// Add a product line
|
||||
$db->begin();
|
||||
|
|
|
|||
|
|
@ -546,7 +546,16 @@ if (empty($reshook)) {
|
|||
}
|
||||
|
||||
// Add a product line
|
||||
if ($action == 'addline' && $usercancreate) {
|
||||
if ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
|
||||
// Define vat_rate
|
||||
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
|
||||
$vat_rate = str_replace('*', '', $vat_rate);
|
||||
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
|
||||
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
|
||||
foreach($object->lines as $line) {
|
||||
$result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
|
||||
}
|
||||
} elseif ($action == 'addline' && $usercancreate) {
|
||||
$langs->load('errors');
|
||||
$error = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1257,6 +1257,7 @@ class SupplierProposal extends CommonObject
|
|||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->statut = (int) $obj->fk_statut;
|
||||
$this->status = (int) $obj->fk_statut;
|
||||
$this->statut_libelle = $obj->statut_label;
|
||||
$this->datec = $this->db->jdate($obj->datec); // TODO deprecated
|
||||
$this->datev = $this->db->jdate($obj->datev); // TODO deprecated
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user