NEW Manage VAT on all lines on purchases cycle

This commit is contained in:
Alexandre SPANGARO 2022-09-02 16:22:54 +02:00
parent e0b1ad308b
commit 38352d0c28
5 changed files with 31 additions and 3 deletions

View File

@ -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)) {

View File

@ -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');

View File

@ -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();

View File

@ -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;

View File

@ -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