Sponsored Development: Libero Global Tax Management
From AdempiereWiki
Contents |
[edit]
Proposal
Current the tax functionality is very limited. The goal is to create new functionality that let configure any tax in any country. This is an effort under the Libero project of ADempiere spearheaded by e-Evolution and supported by the ADempiere Bazaar.
[edit]
Project Team
[edit]
Coordinator
[edit]
Functional Specs
- New Tax Group Window, this window let define a group tax to business partner as same way that a tax category is defined in a product , so we have a best definition to tax.
- New Tax Type Window, this window let define the tax type and can be to use to tax definition, a example is VAT tax.
- New Tax Base, this window let define the base to tax, so you can define the base to tax is based in price or cost and percentage the price or cost used to calculate the tax
- New Rate Parent,this window defined the hierarchical of the taxes
- New Definition Tax, this window let you defining the tax combination necessary to any country, so you can create a new callout to determinate what is the hierarchical tax you can use to calculate the tax.
[edit]
Developers
[edit]
Testers
- everybody is invited to participate
[edit]
Sponsors
[edit]
Requirements
[edit]
Screenshot
[edit]
Tax Group
[edit]
Tax Type
[edit]
Tax Base
[edit]
Tax Rate Parent
[edit]
Tax Definition
[edit]
Tax Rate
- You can see now a new field called Rule, this let you can define a rule to calculate a dynamic rate.
[edit]
Business Partner
- You can see now a new field called Tax Group , this let you can grouping the business partner with referent to tax
[edit]
How create a new Logic Tax Calculation ?
- Create Tax with the right rate that you want use
- Create a new record in Tax Definition with you Tax definition
- Entry as System and Table and Column Window
- Create new Table Script Validator with Event Model Validator (Table After Change)
- Create new Rule (groovy:TaxDefinition):
Example the Logic:
import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.Level;
import org.compiere.util.*;
import org.compiere.model.*;
//
Integer reg = (Integer)A_Value;
String IsSOTrx = Env.getContext(A_Ctx, "IsSOTrx");
//
if (reg == null || reg.intValue() == 0 || IsSOTrx.compareTo("Y") > 0 ) // No documento de venta
return "";
//
int AD_Org_ID,C_BPartner_ID,M_Product_ID,C_Charge_ID,AD_OrgType_ID,C_BP_Group_ID,GL_TaxGroup_ID,tax;
AD_Org_ID = Env.getContextAsInt(A_Ctx, "AD_Org_ID");
C_BPartner_ID = Env.getContextAsInt(A_Ctx, "C_BPartner_ID");
C_Charge_ID = Env.getContextAsInt(A_Ctx,"C_Charge_ID");
//
AD_OrgType_ID = DB.getSQLValue("OrgType", "SELECT AD_OrgType_ID FROM AD_OrgInfo WHERE AD_Org_ID="+AD_Org_ID);
MBPartner bp = new MBPartner(A_Ctx,C_BPartner_ID,null);
M_Product_ID = Env.getContextAsInt(A_Ctx, "M_Product_ID");
MCharge charge = new MCharge(A_Ctx,C_Charge_ID,null);
//
C_BP_Group_ID = bp.getC_BP_Group_ID();
GL_TaxGroup_ID = bp.getGT_TaxGroup_ID();
//
String sql = "SELECT C_Tax_ID FROM GT_TaxDefinition WHERE AD_OrgType_ID =" +AD_OrgType_ID
+ " AND (C_BPartner_ID =" +C_BPartner_ID+ " OR C_BPartner_ID IS NULL)" // optional
+ " AND (C_BP_Group_ID =" +C_BP_Group_ID+ " OR C_BP_Group_ID IS NULL)" // optional
+ " AND GT_TaxGroup_ID =" +GL_TaxGroup_ID; // necess
//
if(M_Product_ID > 0) // productos
{
MProduct product = new MProduct(ctx,M_Product_ID,null);
sql = sql + " AND (M_Product_ID =" + M_Product_ID + " OR M_Product_ID IS NULL)" // optional
+ " AND (M_Product_Category_ID =" + product.getM_Product_Category_ID()
+ " OR M_Product_Category_ID IS NULL)" // optional
+ " AND C_TaxCategory_ID = " + product.getC_TaxCategory_ID(); // necess
}
else // cargos
{
sql = sql + " AND (C_Charge_ID = " + C_Charge_ID + " OR C_Charge_ID IS NULL) AND C_TaxCategory_ID = " + charge.getC_TaxCategory_ID();
}
tax = DB.getSQLValue("Tax", sq + " ORDER BY SeqNo");
if ( tax < 1 )
result "No Existe Combinacion Valida";
A_Tab.setValue("C_Tax_ID", tax);
return "";
[edit]







