Skip to content

Commit

Permalink
fix: minor fixes in summary report and pi onload
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Jan 30, 2025
1 parent 0f36bc6 commit 3014b2a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ frappe.ui.form.on("Bill of Entry", {
},
};
};
frm.add_fetch("purchase_invoice", "supplier", "supplier");
frm.add_fetch("purchase_invoice", "posting_date", "posting_date");
frm.add_fetch("purchase_invoice", "base_grand_total", "grand_total");
},

refresh(frm) {
Expand Down
12 changes: 10 additions & 2 deletions india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,15 @@ def get_items_from_purchase_invoice(self):
frappe.has_permission("Bill Of Entry", "write")
frappe.has_permission("Purchase Invoice", "read")

existing_items = [item.pi_detail for item in self.get("items")]
existing_items = [
item.pi_detail for item in self.get("items") if item.pi_detail
]
purchase_invoices = [
pi.purchase_invoice for pi in self.get("purchase_invoices")
]
item_to_add = get_pi_items(purchase_invoices)

if not existing_items[0]:
if not existing_items:
self.items = []

for item in item_to_add:
Expand Down Expand Up @@ -429,6 +431,12 @@ def set_missing_values(source, target=None):
)

if not has_igst_tax:
valid_tax_row = {
tax_row.account_head for tax_row in target.taxes if tax_row.account_head
}
if not valid_tax_row:
target.taxes = []

target.append(
"taxes",
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"reqd": 1
},
{
"fetch_from": "purchase_invoice.supplier",
"fieldname": "supplier",
"fieldtype": "Link",
"in_list_view": 1,
Expand All @@ -29,13 +30,15 @@
"read_only": 1
},
{
"fetch_from": "purchase_invoice.posting_date",
"fieldname": "posting_date",
"fieldtype": "Date",
"in_list_view": 1,
"label": "Posting Date",
"read_only": 1
},
{
"fetch_from": "purchase_invoice.base_grand_total",
"fieldname": "grand_total",
"fieldtype": "Currency",
"in_list_view": 1,
Expand All @@ -46,7 +49,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2025-01-28 16:07:16.348294",
"modified": "2025-01-30 14:39:25.680566",
"modified_by": "Administrator",
"module": "GST India",
"name": "BOE Purchase Invoice",
Expand Down
9 changes: 5 additions & 4 deletions india_compliance/gst_india/overrides/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ def onload(doc, method=None):
return

if doc.gst_category == "Overseas":
bill_of_entry = frappe.db.get_value(
"BOE Purchase Invoice", {"purchase_invoice": doc.name}, "parent"
)

doc.set_onload(
"bill_of_entry_exists",
frappe.db.exists(
"Bill of Entry",
{"purchase_invoice": doc.name, "docstatus": 1},
),
frappe.db.exists("Bill of Entry", {"name": bill_of_entry, "docstatus": 1}),
)

if not doc.get("ewaybill"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def get_data(filters):
frappe.qb.from_(bill_of_entry)
.select(
bill_of_entry.name,
bill_of_entry.purchase_invoice,
bill_of_entry.bill_of_entry_no,
bill_of_entry.bill_of_entry_date,
bill_of_entry.bill_of_lading_no,
Expand Down Expand Up @@ -82,13 +81,14 @@ def update_journal_entry_for_payment(query):

def update_purchase_invoice_query(query):
bill_of_entry = frappe.qb.DocType("Bill of Entry")
purchase_invoice = frappe.qb.DocType("Purchase Invoice")
boe_purchase_invoice = frappe.qb.DocType("BOE Purchase Invoice")

return (
query.left_join(purchase_invoice)
.on(purchase_invoice.name == bill_of_entry.purchase_invoice)
query.left_join(boe_purchase_invoice)
.on(boe_purchase_invoice.parent == bill_of_entry.name)
.select(
purchase_invoice.supplier,
boe_purchase_invoice.purchase_invoice,
boe_purchase_invoice.supplier,
)
)

Expand Down

0 comments on commit 3014b2a

Please sign in to comment.