Skip to content

Commit

Permalink
NEW Revenue stamp can be a percent
Browse files Browse the repository at this point in the history
FIX Revenue stamp not visible on the transfer payment page
  • Loading branch information
eldy committed Dec 18, 2017
1 parent 8e12551 commit 98b82d7
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 25 deletions.
17 changes: 10 additions & 7 deletions htdocs/admin/dict.php
Expand Up @@ -197,7 +197,7 @@
$tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
$tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
$tabsql[23]= "SELECT t.rowid as rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[23]= "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")";
$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
Expand Down Expand Up @@ -275,7 +275,7 @@
$tabfield[20]= "code,libelle";
$tabfield[21]= "code,label";
$tabfield[22]= "code,label";
$tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[23]= "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[24]= "code,label";
//$tabfield[25]= "label,type_template,private,position,topic,content_lines,content";
$tabfield[26]= "code,label,short_label";
Expand Down Expand Up @@ -314,7 +314,7 @@
$tabfieldvalue[20]= "code,libelle";
$tabfieldvalue[21]= "code,label";
$tabfieldvalue[22]= "code,label";
$tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[23]= "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[24]= "code,label";
//$tabfieldvalue[25]= "label,type_template,private,position,topic,content_lines,content";
$tabfieldvalue[26]= "code,label,short_label";
Expand Down Expand Up @@ -353,7 +353,7 @@
$tabfieldinsert[20]= "code,libelle";
$tabfieldinsert[21]= "code,label";
$tabfieldinsert[22]= "code,label";
$tabfieldinsert[23]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[23]= "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[24]= "code,label";
//$tabfieldinsert[25]= "label,type_template,private,position,topic,content_lines,content,entity";
$tabfieldinsert[26]= "code,label,short_label";
Expand Down Expand Up @@ -472,7 +472,7 @@
$tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[23] = array();
$tabhelp[23] = array('revenuestamp_type'=>'FixedOfPercent');
$tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
//$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'content_lines'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
Expand Down Expand Up @@ -651,6 +651,7 @@
if ($fieldnamekey == 'deductible') $fieldnamekey = 'Deductible';
if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated';
if ($fieldnamekey == 'revenuestamp_type') $fieldnamekey = 'TypeOfRevenueStamp';

setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
}
Expand Down Expand Up @@ -1117,7 +1118,8 @@
if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); }
if ($fieldlist[$field]=='fk_tva') { $valuetoshow=$langs->trans("VAT"); }
if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat'){ $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); }

if ($id == 2) // Special cas for state page
{
Expand Down Expand Up @@ -1343,7 +1345,8 @@
if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); }
if ($fieldlist[$field]=='fk_tva') { $valuetoshow=$langs->trans("VAT"); }
if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat'){ $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); }

// Affiche nom du champ
if ($showfield)
Expand Down
31 changes: 29 additions & 2 deletions htdocs/compta/facture/card.php
Expand Up @@ -3707,10 +3707,37 @@
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setrevenuestamp">';
print $formother->select_revenue_stamp(GETPOST('revenuestamp'), 'revenuestamp', $mysoc->country_code);
// print '<input type="text" class="flat" size="4" name="revenuestamp" value="'.price2num($object->revenuestamp).'">';
print '<input type="hidden" name="revenuestamp" id="revenuestamp_val" value="'.price2num($object->revenuestamp).'">';
print $formother->select_revenue_stamp('', 'revenuestamp_type', $mysoc->country_code);
print ' &rarr; <span id="revenuestamp_span"></span>';
print ' <input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
print " <script>
$(document).ready(function(){
js_recalculate_revenuestamp();
$('select[name=revenuestamp_type]').on('change',function(){
js_recalculate_revenuestamp();
});
});
function js_recalculate_revenuestamp(){
var valselected = $('select[name=revenuestamp_type]').val();
console.log('Calculate revenue stamp from '+valselected);
var revenue = 0;
if (valselected.indexOf('%') == -1)
{
revenue = valselected;
}
else
{
var revenue_type = parseFloat(valselected);
var amount_net = ".round($object->total_ht , 2).";
revenue = revenue_type * amount_net / 100;
revenue = revenue.toFixed(2);
}
$('#revenuestamp_val').val(revenue);
$('#revenuestamp_span').html(revenue);
}
</script>";
} else {
print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency);
}
Expand Down
14 changes: 3 additions & 11 deletions htdocs/compta/facture/prelevement.php
Expand Up @@ -120,6 +120,8 @@

if ($object->id > 0)
{
$selleruserevenustamp = $mysoc->useRevenueStamp();

$totalpaye = $object->getSommePaiement();
$totalcreditnotes = $object->getSumCreditNotesUsed();
$totaldeposits = $object->getSumDepositsUsed();
Expand Down Expand Up @@ -486,17 +488,7 @@
}
print '</tr></table>';
print '</td><td>';
if ($action == 'editrevenuestamp') {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setrevenuestamp">';
print $formother->select_revenue_stamp(GETPOST('revenuestamp'), 'revenuestamp', $mysoc->country_code);
// print '<input type="text" class="flat" size="4" name="revenuestamp" value="'.price2num($object->revenuestamp).'">';
print ' <input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency);
}
print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency);
print '</td></tr>';
}

Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/class/html.formother.class.php
Expand Up @@ -222,7 +222,7 @@ function select_revenue_stamp($selected='',$htmlname='revenuestamp',$country_cod

$out='';

$sql = "SELECT r.taux";
$sql = "SELECT r.taux, r.revenuestamp_type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_revenuestamp as r,".MAIN_DB_PREFIX."c_country as c";
$sql.= " WHERE r.active = 1 AND r.fk_pays = c.rowid";
$sql.= " AND c.code = '".$country_code."'";
Expand All @@ -242,14 +242,14 @@ function select_revenue_stamp($selected='',$htmlname='revenuestamp',$country_cod
$obj = $this->db->fetch_object($resql);
if (($selected && $selected == $obj->taux) || $num == 1)
{
$out.='<option value="'.$obj->taux.'" selected>';
$out.='<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').' selected>';
}
else
{
$out.='<option value="'.$obj->taux.'">';
$out.='<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').'>';
//print '<option onmouseover="showtip(\''.$obj->libelle.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">';
}
$out.=$obj->taux;
$out.=$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '');
$out.='</option>';
$i++;
}
Expand Down
8 changes: 7 additions & 1 deletion htdocs/install/mysql/data/llx_c_revenuestamp.sql
Expand Up @@ -27,4 +27,10 @@
delete from llx_c_revenuestamp;

-- TUNISIA (id country=10) --
insert into llx_c_revenuestamp(rowid,fk_pays,taux,note,active) values (101, 10, 0.4, 'Revenue stamp tunisia', 1);
insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (101, 10, 0.4, 'fixed', 'Revenue stamp tunisia', 1);


-- MEXICO (id country=154) --
insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1541, 154, 1.5, 'percent', 'Revenue stamp mexico', 1);
insert into llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) values (1542, 154, 3, 'percent', 'Revenue stamp mexico', 1);

2 changes: 2 additions & 0 deletions htdocs/install/mysql/migration/6.0.0-7.0.0.sql
Expand Up @@ -71,6 +71,8 @@ ALTER TABLE llx_website_page ADD COLUMN type_container varchar(16) NOT NULL DEFA

-- For 7.0

ALTER TABLE llx_c_revenuestamp ADD COLUMN revenuestamp_type varchar(16) DEFAULT 'fixed' NOT NULL;

UPDATE llx_contrat SET ref = rowid WHERE ref IS NULL OR ref = '';
ALTER TABLE llx_contratdet ADD COLUMN vat_src_code varchar(10) DEFAULT '';

Expand Down
1 change: 1 addition & 0 deletions htdocs/install/mysql/tables/llx_c_revenuestamp.sql
Expand Up @@ -21,6 +21,7 @@ create table llx_c_revenuestamp
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
fk_pays integer NOT NULL,
taux double NOT NULL,
revenuestamp_type varchar(16) DEFAULT 'fixed' NOT NULL,
note varchar(128),
active tinyint DEFAULT 1 NOT NULL,
accountancy_code_sell varchar(32) DEFAULT NULL,
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/admin.lang
Expand Up @@ -904,6 +904,7 @@ SetupSaved=Setup saved
SetupNotSaved=Setup not saved
BackToModuleList=Back to modules list
BackToDictionaryList=Back to dictionaries list
TypeOfRevenueStamp=Type of revenue stamp
VATManagement=VAT Management
VATIsUsedDesc=By default when creating prospects, invoices, orders etc the VAT rate follows the active standard rule:<br>If the seller is not subjected to VAT, then VAT defaults to 0. End of rule.<br>If the (selling country= buying country), then the VAT by default equals the VAT of the product in the selling country. End of rule. <br>If seller and buyer are both in the European Community and goods are transport products (car, ship, plane), the default VAT is 0 ( The VAT should be paid by the buyer to the customoffice of his country and not to the seller). End of rule.<br>If seller and buyer are both in the European Community and the buyer is not a company, then the VAT by defaults to the VAT of the product sold. End of rule.<br>If seller and buyer are both in the European Community and the buyer is a company, then the VAT is 0 by default . End of rule.<br>In any othe case the proposed default is VAT=0. End of rule.
VATIsNotUsedDesc=By default the proposed VAT is 0 which can be used for cases like associations, individuals ou small companies.
Expand Down

0 comments on commit 98b82d7

Please sign in to comment.