feat: Inter warehouse stock transfer on valuation rate with taxation (#20083)

* fix: Validation for target warehouse

* feat: Get items on valuation rate in delivery note on Internal transfers

* fix: Create Inter company purchase receipt from delivery note

* feat: Inter company stock transfer on valuation rate with taxation

* fix: Add from warehouse in purchase invoice

* fix: Use get_value instead of get_cached_value

* fix: Get incoming rate instead of valuation rate

* fix: GL entry for from warehouse in purchase receipt

* fix: GL Entries fixes in purchase invoice

* fix: Address and tax fetching fixes

* fix: Add test case for stock transfer via purchase receipt

* fix: Code cleanup, added validations and test cases

* fix: Validation for supplier warehouse

* fix: Test Cases

* fix: Change validation condition

* fix: Address fixes while creating Purchase Receipt from delivery note

* fix: Set taxes while creating Purchase Receipt from Delivery Note

* fix: Update set_missing_value function

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
Deepesh Garg
2020-02-18 12:28:41 +05:30
committed by GitHub
parent db00270895
commit 15ff6a594b
29 changed files with 887 additions and 1676 deletions

View File

@@ -141,18 +141,24 @@ def get_place_of_supply(party_details, doctype):
address_name = party_details.shipping_address or party_details.supplier_address
if address_name:
address = frappe.db.get_value("Address", address_name, ["gst_state", "gst_state_number"], as_dict=1)
address = frappe.db.get_value("Address", address_name, ["gst_state", "gst_state_number", "gstin"], as_dict=1)
if address and address.gst_state and address.gst_state_number:
party_details.gstin = address.gstin
return cstr(address.gst_state_number) + "-" + cstr(address.gst_state)
@frappe.whitelist()
def get_regional_address_details(party_details, doctype, company, return_taxes=None):
if isinstance(party_details, string_types):
party_details = json.loads(party_details)
party_details = frappe._dict(party_details)
party_details.place_of_supply = get_place_of_supply(party_details, doctype)
if is_internal_transfer(party_details, doctype):
party_details.taxes_and_charges = ''
party_details.taxes = ''
return
if doctype in ("Sales Invoice", "Delivery Note", "Sales Order"):
master_doctype = "Sales Taxes and Charges Template"
@@ -167,7 +173,6 @@ def get_regional_address_details(party_details, doctype, company, return_taxes=N
elif doctype in ("Purchase Invoice", "Purchase Order", "Purchase Receipt"):
master_doctype = "Purchase Taxes and Charges Template"
get_tax_template_for_sez(party_details, master_doctype, company, 'Supplier')
get_tax_template_based_on_category(master_doctype, company, party_details)
@@ -196,6 +201,17 @@ def get_regional_address_details(party_details, doctype, company, return_taxes=N
if return_taxes:
return party_details
def is_internal_transfer(party_details, doctype):
if doctype in ("Sales Invoice", "Delivery Note", "Sales Order"):
destination_gstin = party_details.company_gstin
elif doctype in ("Purchase Invoice", "Purchase Order", "Purchase Receipt"):
destination_gstin = party_details.supplier_gstin
if party_details.gstin == destination_gstin:
return True
else:
False
def get_tax_template_based_on_category(master_doctype, company, party_details):
if not party_details.get('tax_category'):
return
@@ -218,7 +234,6 @@ def get_tax_template(master_doctype, company, is_inter_state, state_code):
(not default_tax and not tax_category.gst_state):
default_tax = frappe.db.get_value(master_doctype,
{'disabled': 0, 'tax_category': tax_category.name}, 'name')
return default_tax
def get_tax_template_for_sez(party_details, master_doctype, company, party_type):
@@ -357,16 +372,13 @@ def calculate_hra_exemption_for_period(doc):
return exemptions
def get_ewb_data(dt, dn):
if dt != 'Sales Invoice':
frappe.throw(_('E-Way Bill JSON can only be generated from Sales Invoice'))
dn = dn.split(',')
ewaybills = []
for doc_name in dn:
doc = frappe.get_doc(dt, doc_name)
validate_sales_invoice(doc)
validate_doc(doc)
data = frappe._dict({
"transporterId": "",
@@ -376,7 +388,9 @@ def get_ewb_data(dt, dn):
data.userGstin = data.fromGstin = doc.company_gstin
data.supplyType = 'O'
if doc.gst_category in ['Registered Regular', 'SEZ']:
if dt == 'Delivery Note':
data.subSupplyType = 1
elif doc.gst_category in ['Registered Regular', 'SEZ']:
data.subSupplyType = 1
elif doc.gst_category in ['Overseas', 'Deemed Export']:
data.subSupplyType = 3
@@ -535,7 +549,7 @@ def get_item_list(data, doc):
return data
def validate_sales_invoice(doc):
def validate_doc(doc):
if doc.docstatus != 1:
frappe.throw(_('E-Way Bill JSON can only be generated from submitted document'))