mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW: Accountancy - Manage intra-community VAT on supplier invoices - FPC22
This commit is contained in:
parent
5252b6804c
commit
b29eba6e00
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
|
|
@ -81,6 +81,10 @@ $list_account[] = '---Others---';
|
|||
$list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT';
|
||||
$list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT';
|
||||
$list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT';
|
||||
if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
$list_account[] = 'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT';
|
||||
$list_account[] = 'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT';
|
||||
}
|
||||
if (isModEnabled('banque')) {
|
||||
$list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
|
|
@ -275,6 +275,19 @@ if ($action == 'setenableautolettering') {
|
|||
}
|
||||
}
|
||||
|
||||
if ($action == 'setenablevatreversecharge') {
|
||||
$setenablevatreversecharge = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE", $setenablevatreversecharge, 'yesno', 0, '', $conf->entity);
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
|
|
@ -531,6 +544,32 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
|
|||
|
||||
print '</table>';
|
||||
|
||||
// Show specific accountancy FR option
|
||||
if ($mysoc->country_code == 'FR') {
|
||||
print '<br>';
|
||||
|
||||
// Advanced params
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">' . $langs->trans('OptionsAdvanced') . '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>' . $langs->trans("ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE") . '</td>';
|
||||
if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenablevatreversecharge&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?token=' . newToken() . '&action=setenablevatreversecharge&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
|
||||
|
||||
print '</form>';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
|
|
@ -32,6 +32,7 @@ require '../../main.inc.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
|
|
@ -103,9 +104,11 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
|
|||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
}
|
||||
|
||||
$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlr, f.close_code,";
|
||||
$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlr, f.close_code, f.vat_reverse_charge,";
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code, fd.info_bits,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur,";
|
||||
$sql .= " p.default_vat_code AS product_buy_default_vat_code, p.tva_tx as product_buy_vat, p.localtax1_tx as product_buy_localvat1, p.localtax2_tx as product_buy_localvat2,";
|
||||
$sql .= " co.code as country_code, co.label as country_label,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta,";
|
||||
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
|
||||
|
|
@ -127,6 +130,7 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
|||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
|
|
@ -166,12 +170,18 @@ if ($result) {
|
|||
$tablocaltax2 = array();
|
||||
$tabcompany = array();
|
||||
$tabother = array();
|
||||
$tabrctva = array();
|
||||
$tabrclocaltax1 = array();
|
||||
$tabrclocaltax2 = array();
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
// Variables
|
||||
$cptfour = ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined';
|
||||
$cpttva = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
|
||||
$rcctva = (!empty($conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT)) ? $conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT : 'NotDefined';
|
||||
$rcdtva = (!empty($conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT)) ? $conf->global->ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT : 'NotDefined';
|
||||
$country_code_in_EEC = getCountriesInEEC(); // This make a database call but there is a cache done into $conf->cache['country_code_in_EEC']
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
|
|
@ -230,6 +240,53 @@ if ($result) {
|
|||
$tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
|
||||
}
|
||||
|
||||
// VAT Reverse charge
|
||||
if (($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) && $obj->vat_reverse_charge == 1 && in_array($obj->country_code, $country_code_in_EEC)) {
|
||||
$rcvatdata = getTaxesFromId($obj->product_buy_vat . ($obj->product_buy_default_vat_code ? ' (' . $obj->product_buy_default_vat_code . ')' : ''), $mysoc, $mysoc, 0);
|
||||
$rcc_compta_tva = (!empty($vatdata['accountancy_code_vat_reverse_charge_credit']) ? $vatdata['accountancy_code_vat_reverse_charge_credit'] : $rcctva);
|
||||
$rcd_compta_tva = (!empty($vatdata['accountancy_code_vat_reverse_charge_debit']) ? $vatdata['accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
|
||||
$rcc_compta_localtax1 = (!empty($vatdata['accountancy_code_vat_reverse_charge_credit']) ? $vatdata['accountancy_code_vat_reverse_charge_credit'] : $rcctva);
|
||||
$rcd_compta_localtax1 = (!empty($vatdata['accountancy_code_vat_reverse_charge_debit']) ? $vatdata['accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
|
||||
$rcc_compta_localtax2 = (!empty($vatdata['accountancy_code_vat_reverse_charge_credit']) ? $vatdata['accountancy_code_vat_reverse_charge_credit'] : $rcctva);
|
||||
$rcd_compta_localtax2 = (!empty($vatdata['accountancy_code_vat_reverse_charge_debit']) ? $vatdata['accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
|
||||
if (price2num($obj->product_buy_vat) || !empty($obj->product_buy_default_vat_code)) {
|
||||
$vat_key = vatrate($obj->product_buy_vat) . ($obj->product_buy_default_vat_code ? ' (' . $obj->product_buy_default_vat_code . ')' : '');
|
||||
$val_value = $vat_key;
|
||||
$def_tva[$obj->rowid][$rcc_compta_tva][$vat_key] = $val_value;
|
||||
$def_tva[$obj->rowid][$rcd_compta_tva][$vat_key] = $val_value;
|
||||
}
|
||||
|
||||
if (!isset($tabrctva[$obj->rowid][$rcc_compta_tva])) {
|
||||
$tabrctva[$obj->rowid][$rcc_compta_tva] = 0;
|
||||
}
|
||||
if (!isset($tabrctva[$obj->rowid][$rcd_compta_tva])) {
|
||||
$tabrctva[$obj->rowid][$rcd_compta_tva] = 0;
|
||||
}
|
||||
if (!isset($tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1])) {
|
||||
$tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] = 0;
|
||||
}
|
||||
if (!isset($tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1])) {
|
||||
$tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] = 0;
|
||||
}
|
||||
if (!isset($tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2])) {
|
||||
$tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] = 0;
|
||||
}
|
||||
if (!isset($tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2])) {
|
||||
$tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] = 0;
|
||||
}
|
||||
|
||||
$rcvat = (double) price2num($obj->total_ttc * $obj->product_buy_vat / 100, 'MT');
|
||||
$rclocalvat1 = (double) price2num($obj->total_ttc * $obj->product_buy_localvat1 / 100, 'MT');
|
||||
$rclocalvat2 = (double) price2num($obj->total_ttc * $obj->product_buy_localvat2 / 100, 'MT');
|
||||
|
||||
$tabrctva[$obj->rowid][$rcd_compta_tva] += $rcvat;
|
||||
$tabrctva[$obj->rowid][$rcc_compta_tva] -= $rcvat;
|
||||
$tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] += $rclocalvat1;
|
||||
$tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] -= $rclocalvat1;
|
||||
$tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] += $rclocalvat2;
|
||||
$tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] -= $rclocalvat2;
|
||||
}
|
||||
|
||||
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
|
||||
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
|
||||
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
|
||||
|
|
@ -470,6 +527,29 @@ if ($action == 'writebookkeeping') {
|
|||
$arrayofvat = $tablocaltax2;
|
||||
}
|
||||
|
||||
// VAT Reverse charge
|
||||
if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
$has_vat = false;
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
$has_vat = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$has_vat) {
|
||||
$arrayofvat = $tabrctva;
|
||||
if ($numtax == 1) {
|
||||
$arrayofvat = $tabrclocaltax1;
|
||||
}
|
||||
if ($numtax == 2) {
|
||||
$arrayofvat = $tabrclocaltax2;
|
||||
}
|
||||
if (!is_array($arrayofvat[$key])) {
|
||||
$arrayofvat[$key] = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
$accountingaccount->fetch(null, $k, true); // TODO Use a cache for label
|
||||
|
|
@ -720,6 +800,29 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
|||
$arrayofvat = $tablocaltax2;
|
||||
}
|
||||
|
||||
// VAT Reverse charge
|
||||
if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
$has_vat = false;
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
$has_vat = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$has_vat) {
|
||||
$arrayofvat = $tabrctva;
|
||||
if ($numtax == 1) {
|
||||
$arrayofvat = $tabrclocaltax1;
|
||||
}
|
||||
if ($numtax == 2) {
|
||||
$arrayofvat = $tabrclocaltax2;
|
||||
}
|
||||
if (!is_array($arrayofvat[$key])) {
|
||||
$arrayofvat[$key] = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
print '"'.$key.'"'.$sep;
|
||||
|
|
@ -998,6 +1101,29 @@ if (empty($action) || $action == 'view') {
|
|||
$arrayofvat = $tablocaltax2;
|
||||
}
|
||||
|
||||
// VAT Reverse charge
|
||||
if ($mysoc->country_code == 'FR' || !empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
$has_vat = false;
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
$has_vat = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$has_vat) {
|
||||
$arrayofvat = $tabrctva;
|
||||
if ($numtax == 1) {
|
||||
$arrayofvat = $tabrclocaltax1;
|
||||
}
|
||||
if ($numtax == 2) {
|
||||
$arrayofvat = $tabrclocaltax2;
|
||||
}
|
||||
if (!is_array($arrayofvat[$key])) {
|
||||
$arrayofvat[$key] = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
print '<tr class="oddeven">';
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ if (isModEnabled('adherent')) {
|
|||
if (isModEnabled('categorie')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
}
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
}
|
||||
|
||||
// Load translation files required by page
|
||||
$langs->loadLangs(array(
|
||||
|
|
@ -270,6 +273,15 @@ if ($object->id > 0) {
|
|||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// VAT reverse-charge by default on supplier invoice or not
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">';
|
||||
print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc'));
|
||||
print '</td><td>';
|
||||
print '<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge == '1' ? ' checked' : '').' disabled>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// TVA Intra
|
||||
print '<tr><td class="nowrap">';
|
||||
//print $langs->trans('VATIntra').'</td><td>';
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
|
||||
* Copyright (C) 2015-2022 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2016-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
|
||||
|
|
@ -552,6 +552,7 @@ class FactureFournisseur extends CommonInvoice
|
|||
$sql .= ", fk_soc";
|
||||
$sql .= ", datec";
|
||||
$sql .= ", datef";
|
||||
$sql .= ", vat_reverse_charge";
|
||||
$sql .= ", fk_projet";
|
||||
$sql .= ", fk_cond_reglement";
|
||||
$sql .= ", fk_mode_reglement";
|
||||
|
|
@ -577,6 +578,7 @@ class FactureFournisseur extends CommonInvoice
|
|||
$sql .= ", ".((int) $this->socid);
|
||||
$sql .= ", '".$this->db->idate($now)."'";
|
||||
$sql .= ", '".$this->db->idate($this->date)."'";
|
||||
$sql .= ", ".($this->vat_reverse_charge != '' ? ((int) $this->db->escape($this->vat_reverse_charge)) : 0);
|
||||
$sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : "null");
|
||||
$sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : "null");
|
||||
$sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : "null");
|
||||
|
|
@ -890,6 +892,7 @@ class FactureFournisseur extends CommonInvoice
|
|||
$sql .= " t.fk_user_author,";
|
||||
$sql .= " t.fk_user_valid,";
|
||||
$sql .= " t.fk_facture_source,";
|
||||
$sql .= " t.vat_reverse_charge,";
|
||||
$sql .= " t.fk_fac_rec_source,";
|
||||
$sql .= " t.fk_projet as fk_project,";
|
||||
$sql .= " t.fk_cond_reglement,";
|
||||
|
|
@ -961,6 +964,7 @@ class FactureFournisseur extends CommonInvoice
|
|||
$this->author = $obj->fk_user_author;
|
||||
$this->fk_user_valid = $obj->fk_user_valid;
|
||||
$this->fk_facture_source = $obj->fk_facture_source;
|
||||
$this->vat_reverse_charge = empty($obj->vat_reverse_charge) ? '0' : '1';
|
||||
$this->fk_fac_rec_source = $obj->fk_fac_rec_source;
|
||||
$this->fk_project = $obj->fk_project;
|
||||
$this->cond_reglement_id = $obj->fk_cond_reglement;
|
||||
|
|
@ -1261,6 +1265,7 @@ class FactureFournisseur extends CommonInvoice
|
|||
$sql .= " fk_user_author=".(isset($this->author) ? ((int) $this->author) : "null").",";
|
||||
$sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? ((int) $this->fk_user_valid) : "null").",";
|
||||
$sql .= " fk_facture_source=".($this->fk_facture_source ? ((int) $this->fk_facture_source) : "null").",";
|
||||
$sql .= " vat_reverse_charge = ".($this->vat_reverse_charge != '' ? ((int) $this->db->escape($this->vat_reverse_charge)) : 0).",";
|
||||
$sql .= " fk_projet=".(isset($this->fk_project) ? ((int) $this->fk_project) : "null").",";
|
||||
$sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? ((int) $this->cond_reglement_id) : "null").",";
|
||||
$sql .= " date_lim_reglement=".(dol_strlen($this->date_echeance) != 0 ? "'".$this->db->idate($this->date_echeance)."'" : 'null').",";
|
||||
|
|
@ -3315,6 +3320,36 @@ class FactureFournisseur extends CommonInvoice
|
|||
$return .= '</div>';
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the option VAT reverse charge
|
||||
*
|
||||
* @param int $vatreversecharge 0 = Off, 1 = On
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
public function setVATReverseCharge($vatreversecharge)
|
||||
{
|
||||
if (!$this->table_element) {
|
||||
dol_syslog(get_class($this)."::setVATReverseCharge was called on objet with property table_element not defined", LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this).'::setVATReverseCharge('.$vatreversecharge.')');
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= " SET vat_reverse_charge = ".((int) $vatreversecharge);
|
||||
$sql .= " WHERE rowid=".((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
$this->vat_reverse_charge = ($vatreversecharge == 0) ? 0 : 1;
|
||||
return 1;
|
||||
} else {
|
||||
dol_syslog(get_class($this).'::setVATReverseCharge Error ', LOG_DEBUG);
|
||||
$this->error = $this->db->error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018-2022 Charlene Benke <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2019 Nicolas Zabouri <info@inovea-conseil.com>
|
||||
* Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2021-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -385,6 +385,12 @@ if (empty($reshook)) {
|
|||
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
|
||||
$objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
||||
} else {
|
||||
// Search if the VAT reverse-charge is activated by default in supplier card to resume the information
|
||||
if (!empty($cmd->socid) > 0) {
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($cmd->socid);
|
||||
$objecttmp->vat_reverse_charge = $societe->vat_reverse_charge;
|
||||
}
|
||||
$objecttmp->socid = $cmd->socid;
|
||||
$objecttmp->type = $objecttmp::TYPE_STANDARD;
|
||||
$objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* Copyright (C) 2013-2022 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2016-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
|
||||
|
|
@ -416,9 +416,12 @@ if (empty($reshook)) {
|
|||
} elseif ($action == 'setbankaccount' && $usercancreate) {
|
||||
// bank account
|
||||
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
} elseif ($action == 'setvatreversecharge' && $usercancreate) {
|
||||
// vat reverse charge
|
||||
$vatreversecharge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
|
||||
$result = $object->setVATReverseCharge($vatreversecharge);
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'settransportmode' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
|
||||
// transport mode
|
||||
$result = $object->setTransportMode(GETPOST('transport_mode_id', 'int'));
|
||||
|
|
@ -761,6 +764,7 @@ if (empty($reshook)) {
|
|||
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
|
||||
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
|
|
@ -827,6 +831,7 @@ if (empty($reshook)) {
|
|||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
|
||||
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
|
|
@ -982,6 +987,7 @@ if (empty($reshook)) {
|
|||
$object->cond_reglement_id = GETPOST('cond_reglement_id');
|
||||
$object->mode_reglement_id = GETPOST('mode_reglement_id');
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
|
||||
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
|
|
@ -1629,6 +1635,16 @@ if (empty($reshook)) {
|
|||
}
|
||||
}
|
||||
|
||||
$ref_supplier = $productsupplier->ref_supplier;
|
||||
|
||||
$tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha'));
|
||||
$tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha'));
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}
|
||||
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
|
||||
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
|
||||
|
||||
if (empty($pu)) {
|
||||
$pu = 0; // If pu is '' or null, we force to have a numeric value
|
||||
}
|
||||
|
|
@ -2122,6 +2138,7 @@ if ($action == 'create') {
|
|||
} else {
|
||||
$cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
|
||||
$mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
|
||||
$vat_reverse_charge = $societe->vat_reverse_charge;
|
||||
$transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
|
||||
$fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
|
||||
$datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
|
|
@ -2574,6 +2591,20 @@ if ($action == 'create') {
|
|||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Vat reverse-charge by default
|
||||
if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
print '<tr><td>' . $langs->trans('VATReverseCharge') . '</td><td>';
|
||||
// Try to propose to use VAT reverse charge even if the VAT reverse charge is not activated in the supplier card, if this corresponds to the context of use, the activation is proposed
|
||||
if ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code != 'FR' && isInEEC($societe) && !empty($societe->tva_intra))) {
|
||||
$vat_reverse_charge = 1;
|
||||
} else {
|
||||
$vat_reverse_charge = 0;
|
||||
}
|
||||
|
||||
print '<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ? ' checked ' : '') . '>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Multicurrency
|
||||
if (isModEnabled("multicurrency")) {
|
||||
print '<tr>';
|
||||
|
|
@ -3258,6 +3289,32 @@ if ($action == 'create') {
|
|||
print '</tr>';
|
||||
}
|
||||
|
||||
// Vat reverse-charge by default
|
||||
if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('VATReverseCharge');
|
||||
print '<td>';
|
||||
if ($action != 'editvatreversecharge' && $usercancreate) {
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editvatreversecharge&id='.$object->id.'">'.img_edit($langs->trans('SetVATReverseCharge'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editvatreversecharge') {
|
||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
print '<input type="hidden" name="action" value="setvatreversecharge">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
print '<input type="checkbox" name="vat_reverse_charge"' . ($object->vat_reverse_charge == '1' ? ' checked ' : '') . '>';
|
||||
|
||||
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
print '</form>';
|
||||
} else {
|
||||
print '<input type="checkbox" name="vat_reverse_charge"'. ($object->vat_reverse_charge == '1' ? ' checked ' : '') . ' disabled>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Incoterms
|
||||
if (isModEnabled('incoterm')) {
|
||||
print '<tr><td>';
|
||||
|
|
|
|||
|
|
@ -386,3 +386,5 @@ ALTER TABLE llx_product_fournisseur_price_log ADD INDEX idx_product_fournisseur_
|
|||
|
||||
ALTER TABLE llx_bordereau_cheque ADD COLUMN label varchar(255) AFTER ref;
|
||||
|
||||
ALTER TABLE llx_societe ADD COLUMN vat_reverse_charge tinyint DEFAULT 0 AFTER tva_assuj;
|
||||
ALTER TABLE llx_facture_fourn ADD COLUMN vat_reverse_charge tinyint DEFAULT 0 AFTER close_note;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-- Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2007-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
-- Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
-- Copyright (C) 2021-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -47,6 +47,8 @@ create table llx_facture_fourn
|
|||
close_missing_amount double(24,8), -- Amount missing when closing with a not complete payment
|
||||
close_note varchar(128), -- Commentaire cloture sans paiement complet
|
||||
|
||||
vat_reverse_charge tinyint DEFAULT 0, -- By default, supplier invoice not concerned by vat reverse charge
|
||||
|
||||
tva double(24,8) DEFAULT 0,
|
||||
localtax1 double(24,8) DEFAULT 0,
|
||||
localtax2 double(24,8) DEFAULT 0,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
-- Copyright (C) 2010 Juanjo Menent <dolibarr@2byte.es>
|
||||
-- Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
|
||||
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
-- Copyright (C) 2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -89,7 +90,8 @@ create table llx_societe
|
|||
cond_reglement_supplier tinyint, -- payment term supplier
|
||||
transport_mode_supplier tinyint, -- transport mode supplier (Intracomm report)
|
||||
fk_shipping_method integer, -- preferred shipping method id
|
||||
tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA
|
||||
tva_assuj tinyint DEFAULT 1, -- assujetti ou non a la TVA
|
||||
vat_reverse_charge tinyint DEFAULT 0, -- By default, company not concerned by vat reverse charge
|
||||
localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1
|
||||
localtax1_value double(7,4),
|
||||
localtax2_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 2
|
||||
|
|
|
|||
|
|
@ -346,6 +346,8 @@ ACCOUNTING_DISABLE_BINDING_ON_PURCHASES=Disable binding & transfer in accountanc
|
|||
ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS=Disable binding & transfer in accountancy on expense reports (expense reports will not be taken into account in accounting)
|
||||
ACCOUNTING_ENABLE_LETTERING=Enable the lettering function in the accounting
|
||||
ACCOUNTING_ENABLE_AUTOLETTERING=Enable the automatic lettering when transferring to accounting
|
||||
OptionsAdvanced=Advanced options
|
||||
ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE=Activate the management of VAT reverse charge on supplier purchases
|
||||
|
||||
## Export
|
||||
NotExportLettering=Do not export the lettering when generating the file
|
||||
|
|
|
|||
|
|
@ -86,6 +86,9 @@ DefaultLang=Default language
|
|||
VATIsUsed=Sales tax used
|
||||
VATIsUsedWhenSelling=This defines if this third party includes a sales tax or not when it makes an invoice to its own customers
|
||||
VATIsNotUsed=Sales tax is not used
|
||||
VATReverseCharge=VAT reverse-charge
|
||||
VATReverseChargeByDefault=VAT reverse-charge by default
|
||||
VATReverseChargeByDefaultDesc=On supplier invoice, VAT reverse-charge is used by default
|
||||
CopyAddressFromSoc=Copy address from third-party details
|
||||
ThirdpartyNotCustomerNotSupplierSoNoRef=Third party neither customer nor vendor, no available referring objects
|
||||
ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts=Third party neither customer nor vendor, discounts are not available
|
||||
|
|
|
|||
|
|
@ -253,6 +253,8 @@ AccountancyJournal=Accounting code journal
|
|||
ACCOUNTING_VAT_SOLD_ACCOUNT=Account (from the Chart Of Account) to be used as the default account for VAT on sales (used if not defined on VAT dictionary setup)
|
||||
ACCOUNTING_VAT_BUY_ACCOUNT=Account (from the Chart Of Account) to be used as the default account for VAT on purchases (used if not defined on VAT dictionary setup)
|
||||
ACCOUNTING_VAT_PAY_ACCOUNT=Account (from the Chart Of Account) to be used as the default account for paying VAT
|
||||
ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT=Account (from the Chart Of Account) to be used as the default account for VAT on purchases for reverse charges (Credit)
|
||||
ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT=Account (from the Chart Of Account) to be used as the default account for VAT on purchases for reverse charges (Debit)
|
||||
ACCOUNTING_ACCOUNT_CUSTOMER=Account (from the Chart Of Account) used for "customer" third parties
|
||||
ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated customer accounting account on third party is not defined.
|
||||
ACCOUNTING_ACCOUNT_SUPPLIER=Account (from the Chart of Account) used for the "vendor" third parties
|
||||
|
|
@ -306,4 +308,4 @@ InvoiceToPay15Days=To pay (15 to 30 days)
|
|||
InvoiceToPay30Days=To pay (> 30 days)
|
||||
ConfirmPreselectAccount=Preselect accountancy code
|
||||
ConfirmPreselectAccountQuestion=Are you sure you want to preselect the %s selected lines with this accountancy code ?
|
||||
AmountPaidMustMatchAmountOfDownPayment=Amount paid must match amount of down payment
|
||||
AmountPaidMustMatchAmountOfDownPayment=Amount paid must match amount of down payment
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2011-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
|
|
@ -497,6 +497,7 @@ if (empty($reshook)) {
|
|||
|
||||
$object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
|
||||
$object->tva_assuj = GETPOST('assujtva_value', 'alpha');
|
||||
$object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
|
||||
$object->status = GETPOST('status', 'alpha');
|
||||
|
||||
// Local Taxes
|
||||
|
|
@ -1140,6 +1141,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||
$object->civility_id = GETPOST('civility_id', 'alpha');
|
||||
|
||||
$object->tva_assuj = GETPOST('assujtva_value', 'int');
|
||||
$object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
|
||||
$object->status = GETPOST('status', 'int');
|
||||
|
||||
//Local Taxes
|
||||
|
|
@ -1731,6 +1733,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// VAT reverse charge by default
|
||||
if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
print '<tr><td>' . $form->editfieldkey('VATReverseChargeByDefault', 'vat_reverse_charge', '', $object, 0) . '</td><td colspan="3">';
|
||||
print '<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge == '1' ? ' checked' : '').'>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Local Taxes
|
||||
//TODO: Place into a function to control showing by country or study better option
|
||||
if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
|
||||
|
|
@ -2006,8 +2015,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||
$object->default_lang = GETPOST('default_lang', 'alpha');
|
||||
|
||||
$object->tva_assuj = GETPOST('assujtva_value', 'int');
|
||||
$object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
|
||||
$object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
|
||||
$object->status = GETPOST('status', 'int');
|
||||
$object->status = GETPOST('status', 'int');
|
||||
|
||||
// Webservices url/key
|
||||
$object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
|
||||
|
|
@ -2457,6 +2467,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// VAT reverse charge by default
|
||||
if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
print '<tr><td>' . $form->editfieldkey('VATReverseChargeByDefault', 'vat_reverse_charge', '', $object, 0) . '</td><td colspan="3">';
|
||||
print '<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge == '1' ? ' checked' : '').'>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// VAT Code
|
||||
print '<tr><td>'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).'</td>';
|
||||
print '<td colspan="3">';
|
||||
|
|
@ -2834,6 +2851,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
|||
print yn($object->tva_assuj);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
|
||||
// VAT reverse charge by default
|
||||
print '<tr><td>';
|
||||
print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc'));
|
||||
print '</td><td>';
|
||||
print '<input type="checkbox" name="vat_reverse_charge" ' . ($object->vat_reverse_charge == '1' ? ' checked' : '') . ' disabled>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// Local Taxes
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
||||
* Copyright (C) 2010-2018 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
|
|
@ -245,6 +245,7 @@ class Societe extends CommonObject
|
|||
'localtax1_value' =>array('type'=>'double(6,3)', 'label'=>'Localtax1 value', 'enabled'=>1, 'visible'=>-1, 'position'=>345),
|
||||
'localtax2_assuj' =>array('type'=>'tinyint(4)', 'label'=>'Localtax2 assuj', 'enabled'=>1, 'visible'=>-1, 'position'=>350),
|
||||
'localtax2_value' =>array('type'=>'double(6,3)', 'label'=>'Localtax2 value', 'enabled'=>1, 'visible'=>-1, 'position'=>355),
|
||||
'vat_reverse_charge' =>array('type'=>'tinyint(4)', 'label'=>'Vat reverse charge', 'enabled'=>1, 'visible'=>-1, 'position'=>335),
|
||||
'barcode' =>array('type'=>'varchar(255)', 'label'=>'Barcode', 'enabled'=>1, 'visible'=>-1, 'position'=>360),
|
||||
'price_level' =>array('type'=>'integer', 'label'=>'Price level', 'enabled'=>'$conf->global->PRODUIT_MULTIPRICES || $conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES', 'visible'=>-1, 'position'=>365),
|
||||
'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>-1, 'position'=>370),
|
||||
|
|
@ -509,6 +510,11 @@ class Societe extends CommonObject
|
|||
*/
|
||||
public $tva_intra;
|
||||
|
||||
/**
|
||||
* @var int Vat reverse-charge concerned
|
||||
*/
|
||||
public $vat_reverse_charge = 0;
|
||||
|
||||
// Local taxes
|
||||
public $localtax1_assuj;
|
||||
public $localtax1_value;
|
||||
|
|
@ -877,6 +883,7 @@ class Societe extends CommonObject
|
|||
$this->effectif_id = 0;
|
||||
$this->forme_juridique_code = 0;
|
||||
$this->tva_assuj = 1;
|
||||
$this->vat_reverse_charge = 0;
|
||||
$this->status = 1;
|
||||
|
||||
if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
|
||||
|
|
@ -967,6 +974,7 @@ class Societe extends CommonObject
|
|||
$sql .= ", fk_multicurrency";
|
||||
$sql .= ", multicurrency_code";
|
||||
if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", vat_reverse_charge";
|
||||
$sql .= ", accountancy_code_buy";
|
||||
$sql .= ", accountancy_code_sell";
|
||||
}
|
||||
|
|
@ -983,8 +991,9 @@ class Societe extends CommonObject
|
|||
$sql .= ", ".(int) $this->fk_multicurrency;
|
||||
$sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
|
||||
if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'";
|
||||
$sql .= ", ".(empty($this->vat_reverse_charge) ? '0' : '1');
|
||||
$sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'";
|
||||
$sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'";
|
||||
}
|
||||
$sql .= ")";
|
||||
|
||||
|
|
@ -1002,6 +1011,7 @@ class Societe extends CommonObject
|
|||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_perentity (";
|
||||
$sql .= " fk_soc";
|
||||
$sql .= ", entity";
|
||||
$sql .= ", vat_reverse_charge";
|
||||
$sql .= ", accountancy_code_customer";
|
||||
$sql .= ", accountancy_code_supplier";
|
||||
$sql .= ", accountancy_code_buy";
|
||||
|
|
@ -1009,6 +1019,7 @@ class Societe extends CommonObject
|
|||
$sql .= ") VALUES (";
|
||||
$sql .= $this->id;
|
||||
$sql .= ", ".((int) $conf->entity);
|
||||
$sql .= ", ".(empty($this->vat_reverse_charge) ? '0' : '1');
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_customer)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_supplier)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'";
|
||||
|
|
@ -1329,8 +1340,9 @@ class Societe extends CommonObject
|
|||
$this->order_min_amount = price2num($this->order_min_amount);
|
||||
$this->supplier_order_min_amount = price2num($this->supplier_order_min_amount);
|
||||
|
||||
$this->tva_assuj = trim($this->tva_assuj);
|
||||
$this->tva_intra = dol_sanitizeFileName($this->tva_intra, '');
|
||||
$this->tva_assuj = trim($this->tva_assuj);
|
||||
$this->tva_intra = dol_sanitizeFileName($this->tva_intra, '');
|
||||
$this->vat_reverse_charge = empty($this->vat_reverse_charge) ? '0' : '1';
|
||||
if (empty($this->status)) {
|
||||
$this->status = 0;
|
||||
}
|
||||
|
|
@ -1484,6 +1496,9 @@ class Societe extends CommonObject
|
|||
|
||||
$sql .= ",tva_assuj = ".($this->tva_assuj != '' ? "'".$this->db->escape($this->tva_assuj)."'" : "null");
|
||||
$sql .= ",tva_intra = '".$this->db->escape($this->tva_intra)."'";
|
||||
if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ",vat_reverse_charge = " . ($this->vat_reverse_charge != '' ? "'" . $this->db->escape($this->vat_reverse_charge) . "'" : 0);
|
||||
}
|
||||
$sql .= ",status = ".((int) $this->status);
|
||||
|
||||
// Local taxes
|
||||
|
|
@ -1543,9 +1558,8 @@ class Societe extends CommonObject
|
|||
$sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount != '' ? $this->supplier_order_min_amount : 'null');
|
||||
$sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'";
|
||||
if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'";
|
||||
$sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'";
|
||||
|
||||
$sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'";
|
||||
$sql .= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell) . "'";
|
||||
if ($customer) {
|
||||
$sql .= ", code_compta = ".(!empty($this->code_compta_client) ? "'".$this->db->escape($this->code_compta_client)."'" : "null");
|
||||
}
|
||||
|
|
@ -1641,6 +1655,7 @@ class Societe extends CommonObject
|
|||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_perentity (";
|
||||
$sql .= " fk_soc";
|
||||
$sql .= ", entity";
|
||||
$sql .= ", vat_reverse_charge";
|
||||
$sql .= ", accountancy_code_customer";
|
||||
$sql .= ", accountancy_code_supplier";
|
||||
$sql .= ", accountancy_code_buy";
|
||||
|
|
@ -1648,6 +1663,7 @@ class Societe extends CommonObject
|
|||
$sql .= ") VALUES (";
|
||||
$sql .= $this->id;
|
||||
$sql .= ", ".$conf->entity;
|
||||
$sql .= ", ".(empty($this->vat_reverse_charge) ? '0' : '1');
|
||||
$sql .= ", '".$this->db->escape($this->code_compta_client)."'";
|
||||
$sql .= ", '".$this->db->escape($this->code_compta_fournisseur)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'";
|
||||
|
|
@ -1752,8 +1768,10 @@ class Societe extends CommonObject
|
|||
$sql .= ', s.webservices_url, s.webservices_key, s.model_pdf, s.last_main_doc';
|
||||
if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ', s.code_compta, s.code_compta_fournisseur, s.accountancy_code_buy, s.accountancy_code_sell';
|
||||
$sql .= ', s.vat_reverse_charge as soc_vat_reverse_charge';
|
||||
} else {
|
||||
$sql .= ', spe.accountancy_code_customer as code_compta, spe.accountancy_code_supplier as code_compta_fournisseur, spe.accountancy_code_buy, spe.accountancy_code_sell';
|
||||
$sql .= ', spe.vat_reverse_charge as spe_vat_reverse_charge';
|
||||
}
|
||||
$sql .= ', s.code_client, s.code_fournisseur, s.parent, s.barcode';
|
||||
$sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.mode_reglement, s.cond_reglement, s.deposit_percent, s.transport_mode';
|
||||
|
|
@ -1905,9 +1923,18 @@ class Societe extends CommonObject
|
|||
|
||||
$this->barcode = $obj->barcode;
|
||||
|
||||
$this->tva_assuj = $obj->tva_assuj;
|
||||
$this->tva_intra = $obj->tva_intra;
|
||||
$this->status = $obj->status;
|
||||
$this->tva_assuj = $obj->tva_assuj;
|
||||
$this->tva_intra = $obj->tva_intra;
|
||||
|
||||
if (!empty($obj->spe_vat_reverse_charge)) {
|
||||
$this->vat_reverse_charge = $obj->spe_vat_reverse_charge;
|
||||
} elseif (!empty($obj->soc_vat_reverse_charge)) {
|
||||
$this->vat_reverse_charge = $obj->soc_vat_reverse_charge;
|
||||
} else {
|
||||
$this->vat_reverse_charge = 0;
|
||||
}
|
||||
|
||||
$this->status = $obj->status;
|
||||
|
||||
// Local Taxes
|
||||
$this->localtax1_assuj = $obj->localtax1_assuj;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user