[ADD]:Reverse charge mechanism in GST
This commit is contained in:
parent
d4382431bd
commit
e9980155cb
@ -17,6 +17,7 @@
|
|||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'data/product_uom_data.xml',
|
'data/product_uom_data.xml',
|
||||||
'data/note_issue_reason_data.xml',
|
'data/note_issue_reason_data.xml',
|
||||||
|
'data/res_company_data.xml',
|
||||||
'wizard/account_invoice_refund_view.xml',
|
'wizard/account_invoice_refund_view.xml',
|
||||||
'views/product_uom_view.xml',
|
'views/product_uom_view.xml',
|
||||||
'views/res_partner_view.xml',
|
'views/res_partner_view.xml',
|
||||||
|
14
addons/l10n_in_gst/data/res_company_data.xml
Normal file
14
addons/l10n_in_gst/data/res_company_data.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<flectra noupdate="1">
|
||||||
|
|
||||||
|
<record id="in_gst_rc_account" model="account.account">
|
||||||
|
<field name="code">205311</field>
|
||||||
|
<field name="name">Reverse Charge(GST)</field>
|
||||||
|
<field name="user_type_id" ref="account.data_account_type_current_liabilities"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="base.main_company" model="res.company">
|
||||||
|
<field name="rc_gst_account_id" ref="in_gst_rc_account"/>
|
||||||
|
</record>
|
||||||
|
</flectra>
|
@ -52,6 +52,88 @@ class AccountInvoice(models.Model):
|
|||||||
readonly=True,
|
readonly=True,
|
||||||
states={
|
states={
|
||||||
'draft': [('readonly', False)]})
|
'draft': [('readonly', False)]})
|
||||||
|
reverse_charge = fields.Boolean(
|
||||||
|
'Reverse Charge', readonly=True,
|
||||||
|
states={'draft': [('readonly', False)]})
|
||||||
|
reverse_tax_line_ids = fields.One2many(
|
||||||
|
'reverse.account.invoice.tax', 'invoice_id', string='Tax Lines',
|
||||||
|
readonly=True, states={'draft': [('readonly', False)]}, copy=False)
|
||||||
|
|
||||||
|
@api.one
|
||||||
|
@api.depends(
|
||||||
|
'state', 'currency_id', 'invoice_line_ids.price_subtotal',
|
||||||
|
'move_id.line_ids.amount_residual',
|
||||||
|
'move_id.line_ids.currency_id')
|
||||||
|
def _compute_residual(self):
|
||||||
|
super(AccountInvoice, self)._compute_residual()
|
||||||
|
sign = self.type in ['in_refund', 'out_refund'] and -1 or 1
|
||||||
|
if self.reverse_charge:
|
||||||
|
residual = self.residual - self.amount_tax
|
||||||
|
self.residual_signed = abs(residual) * sign
|
||||||
|
self.residual = abs(residual)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_invoice_open(self):
|
||||||
|
if not self.reverse_charge:
|
||||||
|
return super(AccountInvoice, self).action_invoice_open()
|
||||||
|
list_data = []
|
||||||
|
account_tax_obj = self.env['account.tax']
|
||||||
|
custom_amount = 0.0
|
||||||
|
self.reverse_tax_line_ids = [[6, 0, []]]
|
||||||
|
for tax_line in self.tax_line_ids:
|
||||||
|
tax_id = account_tax_obj.search([('name', '=', tax_line.name)])
|
||||||
|
account_id = tax_id.account_id.id
|
||||||
|
if self.partner_id.vat:
|
||||||
|
account_id = tax_line.account_id.id
|
||||||
|
if not account_id:
|
||||||
|
account_id = tax_line.account_id.id
|
||||||
|
list_data.append((0, 0, {
|
||||||
|
'name': tax_line.name,
|
||||||
|
'partner_id':
|
||||||
|
self.partner_id.parent_id.id or self.partner_id.id,
|
||||||
|
'account_id': account_id,
|
||||||
|
'debit': tax_line.amount_total,
|
||||||
|
'move_id': False,
|
||||||
|
'invoice_id': self.id,
|
||||||
|
'tax_line_id': tax_id,
|
||||||
|
'quantity': 1,
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
|
total_tax_amount = self.amount_tax
|
||||||
|
reverse_list_data = []
|
||||||
|
for tax_line_id in self.tax_line_ids:
|
||||||
|
reverse_list_data.append((0, 0, tax_line_id.read()[0]))
|
||||||
|
|
||||||
|
if reverse_list_data:
|
||||||
|
self.update({'reverse_tax_line_ids': reverse_list_data})
|
||||||
|
for line_id in self.invoice_line_ids:
|
||||||
|
line_id.reverse_invoice_line_tax_ids = \
|
||||||
|
[[6, 0, line_id.invoice_line_tax_ids.ids]]
|
||||||
|
|
||||||
|
self.invoice_line_ids.update({'invoice_line_tax_ids': [[6, 0, []]]})
|
||||||
|
self.update({'tax_line_ids': [[6, 0, []]], 'amount_tax': 0.0})
|
||||||
|
res = super(AccountInvoice, self).action_invoice_open()
|
||||||
|
for move_line_id in list_data:
|
||||||
|
move_line_id[2].update({'move_id': self.move_id.id})
|
||||||
|
list_data.append(
|
||||||
|
(0, 0, self.get_move_line_vals(total_tax_amount - custom_amount)))
|
||||||
|
self.move_id.state = 'draft'
|
||||||
|
self.move_id.line_ids = list_data
|
||||||
|
self.move_id.post()
|
||||||
|
return res
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def get_move_line_vals(self, credit):
|
||||||
|
return {
|
||||||
|
'name': '/',
|
||||||
|
'partner_id': self.partner_id.parent_id.id or self.partner_id.id,
|
||||||
|
'account_id': self.company_id.rc_gst_account_id.id,
|
||||||
|
'credit': credit,
|
||||||
|
'move_id': self.move_id.id,
|
||||||
|
'invoice_id': self.id,
|
||||||
|
'quantity': 1,
|
||||||
|
}
|
||||||
|
|
||||||
@api.onchange('partner_id', 'company_id')
|
@api.onchange('partner_id', 'company_id')
|
||||||
def _onchange_partner_id(self):
|
def _onchange_partner_id(self):
|
||||||
@ -60,12 +142,31 @@ class AccountInvoice(models.Model):
|
|||||||
self.partner_id.partner_location = \
|
self.partner_id.partner_location = \
|
||||||
self.partner_id._get_partner_location_details(self.company_id)
|
self.partner_id._get_partner_location_details(self.company_id)
|
||||||
|
|
||||||
|
|
||||||
@api.onchange('fiscal_position_id')
|
@api.onchange('fiscal_position_id')
|
||||||
def _onchange_fiscal_position_id(self):
|
def _onchange_fiscal_position_id(self):
|
||||||
""" Onchange of Fiscal Position update tax values in invoice lines. """
|
""" Onchange of Fiscal Position update tax values in invoice lines. """
|
||||||
for line in self.invoice_line_ids:
|
if self.fiscal_position_id:
|
||||||
line._set_taxes()
|
for line in self.invoice_line_ids:
|
||||||
|
line._set_taxes()
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.returns('self')
|
||||||
|
def refund(self, date_invoice=None,
|
||||||
|
date=None, description=None, journal_id=None):
|
||||||
|
result = super(AccountInvoice, self).refund(
|
||||||
|
date_invoice=date_invoice, date=date,
|
||||||
|
description=description, journal_id=journal_id)
|
||||||
|
if result.refund_invoice_id.type == 'in_invoice':
|
||||||
|
result.write(
|
||||||
|
{'reverse_charge': result.refund_invoice_id.reverse_charge})
|
||||||
|
if result.type == 'in_refund' \
|
||||||
|
and result.refund_invoice_id.reverse_charge:
|
||||||
|
for index, line_id in enumerate(result.invoice_line_ids):
|
||||||
|
line_id.invoice_line_tax_ids = [[
|
||||||
|
6, 0, result.refund_invoice_id.invoice_line_ids[
|
||||||
|
index].reverse_invoice_line_tax_ids.ids]]
|
||||||
|
result._onchange_invoice_line_ids()
|
||||||
|
return result
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_move_create(self):
|
def action_move_create(self):
|
||||||
@ -128,3 +229,14 @@ class AccountInvoice(models.Model):
|
|||||||
'gst_type': invoice.gst_type,
|
'gst_type': invoice.gst_type,
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
class ReverseAccountInvoiceTax(models.Model):
|
||||||
|
_inherit = 'account.invoice.tax'
|
||||||
|
_name = 'reverse.account.invoice.tax'
|
||||||
|
|
||||||
|
|
||||||
|
class AccountInvoiceLine(models.Model):
|
||||||
|
_inherit = "account.invoice.line"
|
||||||
|
|
||||||
|
reverse_invoice_line_tax_ids = fields.Many2many(
|
||||||
|
'account.tax', string='Taxes', copy=False)
|
@ -20,6 +20,7 @@ class Company(models.Model):
|
|||||||
default=time.strftime('2017-07-01'))
|
default=time.strftime('2017-07-01'))
|
||||||
company_b2c_limit_line = fields.One2many('res.company.b2c.limit',
|
company_b2c_limit_line = fields.One2many('res.company.b2c.limit',
|
||||||
'company_id', string='B2C Limit')
|
'company_id', string='B2C Limit')
|
||||||
|
rc_gst_account_id = fields.Many2one('account.account', 'Reverse Charge')
|
||||||
|
|
||||||
def onchange_state(self, gst_type, vat, state):
|
def onchange_state(self, gst_type, vat, state):
|
||||||
result = {'vat': '', 'country_id': False}
|
result = {'vat': '', 'country_id': False}
|
||||||
|
@ -135,7 +135,6 @@ class GSTR1Report(models.AbstractModel):
|
|||||||
('gst_invoice', '=', 'b2b'), ('vat', '!=', False)]
|
('gst_invoice', '=', 'b2b'), ('vat', '!=', False)]
|
||||||
if post.get('gst_invoice') == 'cdnur':
|
if post.get('gst_invoice') == 'cdnur':
|
||||||
final_inv_domain = common_domain + refund_domain + cdnur_domain
|
final_inv_domain = common_domain + refund_domain + cdnur_domain
|
||||||
|
|
||||||
final_invoice_ids = acc_invoice.search(final_inv_domain)
|
final_invoice_ids = acc_invoice.search(final_inv_domain)
|
||||||
for inv in final_invoice_ids:
|
for inv in final_invoice_ids:
|
||||||
inv_data_list = []
|
inv_data_list = []
|
||||||
@ -159,15 +158,17 @@ class GSTR1Report(models.AbstractModel):
|
|||||||
|
|
||||||
for line in inv.invoice_line_ids:
|
for line in inv.invoice_line_ids:
|
||||||
cess_amount = igst_amount = cgst_amount = sgst_amount = 0.0
|
cess_amount = igst_amount = cgst_amount = sgst_amount = 0.0
|
||||||
|
if inv.reverse_charge:
|
||||||
if line.invoice_line_tax_ids:
|
tax_lines = line.reverse_invoice_line_tax_ids
|
||||||
|
else:
|
||||||
|
tax_lines = line.invoice_line_tax_ids
|
||||||
|
if tax_lines:
|
||||||
price_unit = line.price_unit * (
|
price_unit = line.price_unit * (
|
||||||
1 - (line.discount or 0.0) / 100.0)
|
1 - (line.discount or 0.0) / 100.0)
|
||||||
taxes = line.invoice_line_tax_ids.compute_all(
|
taxes = tax_lines.compute_all(
|
||||||
price_unit, line.invoice_id.currency_id,
|
price_unit, line.invoice_id.currency_id,
|
||||||
line.quantity, line.product_id,
|
line.quantity, line.product_id,
|
||||||
line.invoice_id.partner_id)['taxes']
|
line.invoice_id.partner_id)['taxes']
|
||||||
|
|
||||||
for tax_data in taxes:
|
for tax_data in taxes:
|
||||||
tax = acc_tax.browse(tax_data['id'])
|
tax = acc_tax.browse(tax_data['id'])
|
||||||
if tax.tax_group_id.name == 'Cess':
|
if tax.tax_group_id.name == 'Cess':
|
||||||
@ -185,7 +186,7 @@ class GSTR1Report(models.AbstractModel):
|
|||||||
'amount'] > 0):
|
'amount'] > 0):
|
||||||
sgst_amount += tax_data['amount']
|
sgst_amount += tax_data['amount']
|
||||||
|
|
||||||
for tax in line.invoice_line_tax_ids:
|
for tax in tax_lines:
|
||||||
rate = 0
|
rate = 0
|
||||||
if tax.id not in tax_list:
|
if tax.id not in tax_list:
|
||||||
if tax.tax_group_id.name == 'IGST' \
|
if tax.tax_group_id.name == 'IGST' \
|
||||||
@ -213,7 +214,6 @@ class GSTR1Report(models.AbstractModel):
|
|||||||
line_data = self._prepare_taxable_line_data(
|
line_data = self._prepare_taxable_line_data(
|
||||||
line, inv, igst_amount, cgst_amount,
|
line, inv, igst_amount, cgst_amount,
|
||||||
sgst_amount, cess_amount, rate, tax)
|
sgst_amount, cess_amount, rate, tax)
|
||||||
|
|
||||||
if post.get('gst_invoice') in \
|
if post.get('gst_invoice') in \
|
||||||
['b2b', 'b2cl', 'b2cs', 'b2bur']:
|
['b2b', 'b2cl', 'b2cs', 'b2bur']:
|
||||||
line_data.update({
|
line_data.update({
|
||||||
@ -241,7 +241,7 @@ class GSTR1Report(models.AbstractModel):
|
|||||||
if post.get('gst_invoice') == 'b2b':
|
if post.get('gst_invoice') == 'b2b':
|
||||||
line_data.update({
|
line_data.update({
|
||||||
'inv_type': 'Regular',
|
'inv_type': 'Regular',
|
||||||
'reverse_charge': 'N',
|
'reverse_charge': 'Y' if inv.reverse_charge else 'N',
|
||||||
})
|
})
|
||||||
if post.get('gst_invoice') == 'b2bur':
|
if post.get('gst_invoice') == 'b2bur':
|
||||||
supply_type = dict(inv.fields_get(
|
supply_type = dict(inv.fields_get(
|
||||||
@ -376,10 +376,14 @@ class GSTR1Report(models.AbstractModel):
|
|||||||
invoice_domain)
|
invoice_domain)
|
||||||
for line in hsn_invoice_line_ids:
|
for line in hsn_invoice_line_ids:
|
||||||
igst_amount = cgst_amount = sgst_amount = cess_amount = 0.0
|
igst_amount = cgst_amount = sgst_amount = cess_amount = 0.0
|
||||||
if line.invoice_line_tax_ids:
|
if line.invoice_id.reverse_charge:
|
||||||
|
tax_lines = line.reverse_invoice_line_tax_ids
|
||||||
|
else:
|
||||||
|
tax_lines = line.invoice_line_tax_ids
|
||||||
|
if tax_lines:
|
||||||
price_unit = line.price_unit * (
|
price_unit = line.price_unit * (
|
||||||
1 - (line.discount or 0.0) / 100.0)
|
1 - (line.discount or 0.0) / 100.0)
|
||||||
taxes = line.invoice_line_tax_ids.compute_all(
|
taxes = tax_lines.compute_all(
|
||||||
price_unit, line.invoice_id.currency_id,
|
price_unit, line.invoice_id.currency_id,
|
||||||
line.quantity, line.product_id,
|
line.quantity, line.product_id,
|
||||||
line.invoice_id.partner_id)['taxes']
|
line.invoice_id.partner_id)['taxes']
|
||||||
@ -446,10 +450,11 @@ class GSTR1Report(models.AbstractModel):
|
|||||||
no_of_recepient = 0
|
no_of_recepient = 0
|
||||||
|
|
||||||
for inv in result:
|
for inv in result:
|
||||||
taxable_value_total += float(inv['taxable_value'])
|
if inv.get('reverse_charge') != 'Y':
|
||||||
igst_amount += float(inv['igst'])
|
taxable_value_total += float(inv['taxable_value'])
|
||||||
sgst_amount += float(inv['sgst'])
|
igst_amount += float(inv['igst'])
|
||||||
cgst_amount += float(inv['cgst'])
|
sgst_amount += float(inv['sgst'])
|
||||||
|
cgst_amount += float(inv['cgst'])
|
||||||
|
|
||||||
if post.get('gst_invoice') == 'b2b':
|
if post.get('gst_invoice') == 'b2b':
|
||||||
if inv['reverse_charge'] == 'N':
|
if inv['reverse_charge'] == 'N':
|
||||||
@ -473,7 +478,7 @@ class GSTR1Report(models.AbstractModel):
|
|||||||
invoice_value = 0.0
|
invoice_value = 0.0
|
||||||
for invoice_id in invoices_list:
|
for invoice_id in invoices_list:
|
||||||
ids = self.env['account.invoice'].search(
|
ids = self.env['account.invoice'].search(
|
||||||
[('number', '=', invoice_id)])
|
[('number', '=', invoice_id), ('reverse_charge', '=', False)])
|
||||||
invoice_value += ids.amount_total
|
invoice_value += ids.amount_total
|
||||||
summary.update({
|
summary.update({
|
||||||
"no_of_invoices": no_of_invoices,
|
"no_of_invoices": no_of_invoices,
|
||||||
|
@ -3,3 +3,4 @@ access_note_issue_reason_all,access_note_issue_reason_all,model_note_issue_reaso
|
|||||||
access_note_issue_reason,access_note_issue_reason,model_note_issue_reason,,1,0,0,0
|
access_note_issue_reason,access_note_issue_reason,model_note_issue_reason,,1,0,0,0
|
||||||
access_res_company_b2c_limit_all,access_res_company_b2c_limit_all,model_res_company_b2c_limit,base.group_system,1,1,1,1
|
access_res_company_b2c_limit_all,access_res_company_b2c_limit_all,model_res_company_b2c_limit,base.group_system,1,1,1,1
|
||||||
access_res_company_b2c_limit,access_res_company_b2c_limit,model_res_company_b2c_limit,,1,0,0,0
|
access_res_company_b2c_limit,access_res_company_b2c_limit,model_res_company_b2c_limit,,1,0,0,0
|
||||||
|
access_reverse_account_invoice_tax,access_reverse_account_invoice_tax,model_reverse_account_invoice_tax,,1,0,0,0
|
|
@ -77,6 +77,9 @@
|
|||||||
<field name="vat" readonly="1"
|
<field name="vat" readonly="1"
|
||||||
attrs="{'invisible': [('state', 'not in', ('open', 'paid'))]}"/>
|
attrs="{'invisible': [('state', 'not in', ('open', 'paid'))]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='date_due']" position="after">
|
||||||
|
<field name="reverse_charge" attrs="{'invisible': [('type', 'in', ['out_invoice', 'out_refund'])]}"/>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//field[@name='partner_id']" position="after">
|
<xpath expr="//field[@name='partner_id']" position="after">
|
||||||
<field name="e_commerce_partner_id"
|
<field name="e_commerce_partner_id"
|
||||||
attrs="{'readonly': [('state', '!=', 'draft')]}"
|
attrs="{'readonly': [('state', '!=', 'draft')]}"
|
||||||
@ -85,6 +88,14 @@
|
|||||||
<xpath expr="//field[@name='tax_line_ids']" position="attributes">
|
<xpath expr="//field[@name='tax_line_ids']" position="attributes">
|
||||||
<attribute name="attrs">{'invisible': [('tax_line_ids', '=', [])]}</attribute>
|
<attribute name="attrs">{'invisible': [('tax_line_ids', '=', [])]}</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//field/tree/field[@name='invoice_line_tax_ids']" position="after">
|
||||||
|
<field name="reverse_invoice_line_tax_ids" widget="many2many_tags" invisible="1"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//page[@name='other_info']" position="after">
|
||||||
|
<page string="Reverse Charge" name="reverse_charge_info" attrs="{'invisible': [('reverse_charge', '=', False)]}">
|
||||||
|
<field name="reverse_tax_line_ids" nolabel="1"/>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@ -112,5 +123,18 @@
|
|||||||
<field name="name">Nature of Transaction</field>
|
<field name="name">Nature of Transaction</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="view_in_reverse_invoice_tax_tree" model="ir.ui.view">
|
||||||
|
<field name="name">in_reverse.account.invoice.tax.tree</field>
|
||||||
|
<field name="model">reverse.account.invoice.tax</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="Reverse Invoice Taxes">
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="account_id" groups="account.group_account_user"/>
|
||||||
|
<field name="base"/>
|
||||||
|
<field name="amount_total"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
</flectra>
|
</flectra>
|
@ -18,6 +18,9 @@
|
|||||||
<separator string="B2C Limit"/>
|
<separator string="B2C Limit"/>
|
||||||
<field name="company_b2c_limit_line"/>
|
<field name="company_b2c_limit_line"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='report_header']" position="after">
|
||||||
|
<field name="rc_gst_account_id" required="1"/>
|
||||||
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user