updated code of prajakta block,payment, gst
This commit is contained in:
78
model/GST.py
78
model/GST.py
@@ -1,55 +1,51 @@
|
||||
import config
|
||||
from model.ItemCRUD import ItemCRUD
|
||||
from model.Utilities import ItemCRUDType
|
||||
|
||||
class GST:
|
||||
|
||||
@staticmethod
|
||||
def get_unreleased_gst():
|
||||
# Use ItemCRUD for Invoices
|
||||
invoice_crud = ItemCRUD(itemType=ItemCRUDType.Invoice)
|
||||
invoices_rows = invoice_crud.GetAllData(storedproc="GetAllInvoicesBasic")
|
||||
|
||||
connection = config.get_db_connection()
|
||||
cursor = connection.cursor(dictionary=True)
|
||||
if not invoice_crud.isSuccess:
|
||||
return [] # Could also log invoice_crud.resultMessage
|
||||
|
||||
try:
|
||||
# ----------- Invoices -----------
|
||||
cursor.callproc('GetAllInvoicesBasic')
|
||||
invoices = []
|
||||
for result in cursor.stored_results():
|
||||
invoices = result.fetchall()
|
||||
invoices = [
|
||||
dict(
|
||||
Invoice_No=row[1],
|
||||
GST_SD_Amount=float(row[2]) if row[2] is not None else 0
|
||||
)
|
||||
for row in invoices_rows
|
||||
]
|
||||
|
||||
# Use ItemCRUD for GST Releases
|
||||
gst_crud = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||
gst_rows = gst_crud.GetAllData(storedproc="GetAllGSTReleasesBasic")
|
||||
|
||||
# ----------- GST Releases -----------
|
||||
cursor.callproc('GetAllGSTReleasesBasic')
|
||||
gst_releases = []
|
||||
for result in cursor.stored_results():
|
||||
gst_releases = result.fetchall()
|
||||
if not gst_crud.isSuccess:
|
||||
return [] # Could also log gst_crud.resultMessage
|
||||
|
||||
gst_invoice_nos = {
|
||||
g['Invoice_No']
|
||||
for g in gst_releases
|
||||
if g['Invoice_No']
|
||||
}
|
||||
gst_invoice_nos = {
|
||||
g[2] # Invoice_No is at index 2
|
||||
for g in gst_rows
|
||||
if g[2]
|
||||
}
|
||||
|
||||
gst_basic_amounts = {
|
||||
float(g['Basic_Amount'])
|
||||
for g in gst_releases
|
||||
if g['Basic_Amount'] is not None
|
||||
}
|
||||
gst_basic_amounts = {
|
||||
float(g[3]) # Basic_Amount at index 3
|
||||
for g in gst_rows
|
||||
if g[3] is not None
|
||||
}
|
||||
|
||||
unreleased = []
|
||||
# Filter unreleased invoices
|
||||
unreleased = []
|
||||
for inv in invoices:
|
||||
match_by_invoice = inv['Invoice_No'] in gst_invoice_nos
|
||||
match_by_gst_amount = inv['GST_SD_Amount'] in gst_basic_amounts
|
||||
|
||||
for inv in invoices:
|
||||
if not (match_by_invoice or match_by_gst_amount):
|
||||
unreleased.append(inv)
|
||||
|
||||
match_by_invoice = inv['Invoice_No'] in gst_invoice_nos
|
||||
|
||||
match_by_gst_amount = float(
|
||||
inv.get('GST_SD_Amount') or 0
|
||||
) in gst_basic_amounts
|
||||
|
||||
if not (match_by_invoice or match_by_gst_amount):
|
||||
unreleased.append(inv)
|
||||
|
||||
return unreleased
|
||||
|
||||
finally:
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
return unreleased
|
||||
Reference in New Issue
Block a user