Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Respect Company Filter in Purchase Reconciliation Tool (backport #2505) #2542

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@
"TEST_DIFFERENT_COMPANY_GSTIN_MISMATCH": [
{
"PURCHASE_INVOICE": {
"bill_no": "BILL-23-00021",
"bill_no": "BILLXYZ-23-00021",
"company_gstin": "24AAQCA8719H1ZC"
},
"INWARD_SUPPLY": {
"bill_no": "BILL-23-00021",
"bill_no": "BILLXYZ-23-00021",
"company_gstin": "29AABCR1718E1ZL"
},
"RECONCILED_DATA": {
"action": "No Action",
"bill_date": "2023-12-11",
"bill_no": "BILL-23-00021",
"bill_no": "BILLXYZ-23-00021",
"classification": "B2B",
"differences": "COMPANY_GSTIN",
"inward_supply_company_gstin": "29AABCR1718E1ZL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from frappe.utils import add_months, format_date, getdate, rounded

from india_compliance.gst_india.constants import GST_TAX_TYPES
from india_compliance.gst_india.utils import get_party_for_gstin
from india_compliance.gst_india.utils import get_gstin_list, get_party_for_gstin
from india_compliance.gst_india.utils.gstr_2 import IMPORT_CATEGORY, ReturnType


Expand Down Expand Up @@ -307,7 +307,12 @@ def get_query(self, additional_fields=None):
)

if self.company_gstin == "All":
query = query.where(self.GSTR2.company_gstin.notnull())
if self.company:
gstin_list = get_gstin_list(self.company)
query = query.where(self.GSTR2.company_gstin.isin(gstin_list))
else:
query = query.where(self.GSTR2.company_gstin.notnull())

else:
query = query.where(self.company_gstin == self.GSTR2.company_gstin)

Expand Down Expand Up @@ -427,6 +432,9 @@ def get_query(self, additional_fields=None, is_return=False):
)
)

if self.company:
query = query.where(self.company == self.PI.company)

if self.company_gstin == "All":
query = query.where(self.PI.company_gstin.notnull())
else:
Expand Down Expand Up @@ -569,6 +577,14 @@ def get_query(self, additional_fields=None):
.select(*fields, ConstantColumn("Bill of Entry").as_("doctype"))
)

if self.company:
query = query.where(self.company == self.BOE.company)

if self.company_gstin == "All":
query = query.where(self.BOE.company_gstin.notnull())
else:
query = query.where(self.company_gstin == self.BOE.company_gstin)

if self.include_ignored == 0:
query = query.where(IfNull(self.BOE.reconciliation_status, "") != "Ignored")

Expand Down Expand Up @@ -642,6 +658,7 @@ def get_all_inward_supply(
self, additional_fields=None, names=None, only_names=False
):
return InwardSupply(
company=self.company,
company_gstin=self.company_gstin,
from_date=self.inward_supply_from_date,
to_date=self.inward_supply_to_date,
Expand All @@ -651,6 +668,7 @@ def get_all_inward_supply(

def get_unmatched_inward_supply(self, category, amended_category):
return InwardSupply(
company=self.company,
company_gstin=self.company_gstin,
from_date=self.inward_supply_from_date,
to_date=self.inward_supply_to_date,
Expand All @@ -660,6 +678,7 @@ def get_unmatched_inward_supply(self, category, amended_category):

def query_inward_supply(self, additional_fields=None):
query = InwardSupply(
company=self.company,
company_gstin=self.company_gstin,
from_date=self.inward_supply_from_date,
to_date=self.inward_supply_to_date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_purchase_reconciliation_tool(self):
purchase_reconciliation_tool = frappe.get_doc("Purchase Reconciliation Tool")
purchase_reconciliation_tool.update(
{
"company": "_Test Indian Registered Company",
# Reconcile all companies
"company_gstin": "All",
"purchase_period": "Custom",
"purchase_from_date": "2023-11-01",
Expand Down
Loading