Merge branch 'develop' into serialized-item-consumption
This commit is contained in:
commit
7bbc708e8a
@ -4,7 +4,7 @@ import frappe
|
|||||||
|
|
||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
|
|
||||||
__version__ = '13.9.0'
|
__version__ = '14.0.0-dev'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
0
erpnext/accounts/doctype/advance_tax/__init__.py
Normal file
0
erpnext/accounts/doctype/advance_tax/__init__.py
Normal file
56
erpnext/accounts/doctype/advance_tax/advance_tax.json
Normal file
56
erpnext/accounts/doctype/advance_tax/advance_tax.json
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2021-11-25 10:24:39.836195",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"reference_type",
|
||||||
|
"reference_name",
|
||||||
|
"reference_detail",
|
||||||
|
"account_head",
|
||||||
|
"allocated_amount"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "reference_type",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Reference Type",
|
||||||
|
"options": "DocType"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reference_name",
|
||||||
|
"fieldtype": "Dynamic Link",
|
||||||
|
"label": "Reference Name",
|
||||||
|
"options": "reference_type"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reference_detail",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Reference Detail"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "account_head",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Account Head",
|
||||||
|
"options": "Account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "allocated_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Allocated Amount",
|
||||||
|
"options": "party_account_currency"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-11-25 10:27:51.712286",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Advance Tax",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC"
|
||||||
|
}
|
9
erpnext/accounts/doctype/advance_tax/advance_tax.py
Normal file
9
erpnext/accounts/doctype/advance_tax/advance_tax.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
|
class AdvanceTax(Document):
|
||||||
|
pass
|
@ -25,8 +25,7 @@
|
|||||||
"allocated_amount",
|
"allocated_amount",
|
||||||
"column_break_13",
|
"column_break_13",
|
||||||
"base_tax_amount",
|
"base_tax_amount",
|
||||||
"base_total",
|
"base_total"
|
||||||
"base_allocated_amount"
|
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@ -168,12 +167,6 @@
|
|||||||
"label": "Allocated Amount",
|
"label": "Allocated Amount",
|
||||||
"options": "currency"
|
"options": "currency"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "base_allocated_amount",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Allocated Amount (Company Currency)",
|
|
||||||
"options": "Company:company:default_currency"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fetch_from": "account_head.account_currency",
|
"fetch_from": "account_head.account_currency",
|
||||||
"fieldname": "currency",
|
"fieldname": "currency",
|
||||||
@ -186,7 +179,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-09 11:46:58.373170",
|
"modified": "2021-11-25 11:10:10.945027",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Advance Taxes and Charges",
|
"name": "Advance Taxes and Charges",
|
||||||
|
@ -61,7 +61,6 @@
|
|||||||
"taxes_and_charges_section",
|
"taxes_and_charges_section",
|
||||||
"purchase_taxes_and_charges_template",
|
"purchase_taxes_and_charges_template",
|
||||||
"sales_taxes_and_charges_template",
|
"sales_taxes_and_charges_template",
|
||||||
"advance_tax_account",
|
|
||||||
"column_break_55",
|
"column_break_55",
|
||||||
"apply_tax_withholding_amount",
|
"apply_tax_withholding_amount",
|
||||||
"tax_withholding_category",
|
"tax_withholding_category",
|
||||||
@ -685,15 +684,6 @@
|
|||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hide_border": 1
|
"hide_border": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.apply_tax_withholding_amount",
|
|
||||||
"description": "Provisional tax account for advance tax. Taxes are parked in this account until payments are allocated to invoices",
|
|
||||||
"fieldname": "advance_tax_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Advance Tax Account",
|
|
||||||
"mandatory_depends_on": "eval:doc.apply_tax_withholding_amount",
|
|
||||||
"options": "Account"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"depends_on": "eval:doc.received_amount && doc.payment_type != 'Internal Transfer'",
|
"depends_on": "eval:doc.received_amount && doc.payment_type != 'Internal Transfer'",
|
||||||
"fieldname": "received_amount_after_tax",
|
"fieldname": "received_amount_after_tax",
|
||||||
@ -730,7 +720,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-10-22 17:50:24.632806",
|
"modified": "2021-11-24 18:58:24.919764",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Payment Entry",
|
"name": "Payment Entry",
|
||||||
|
@ -20,7 +20,7 @@ from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_ban
|
|||||||
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
|
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
|
||||||
get_party_tax_withholding_details,
|
get_party_tax_withholding_details,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.general_ledger import make_gl_entries
|
from erpnext.accounts.general_ledger import make_gl_entries, process_gl_map
|
||||||
from erpnext.accounts.party import get_party_account
|
from erpnext.accounts.party import get_party_account
|
||||||
from erpnext.accounts.utils import get_account_currency, get_balance_on, get_outstanding_invoices
|
from erpnext.accounts.utils import get_account_currency, get_balance_on, get_outstanding_invoices
|
||||||
from erpnext.controllers.accounts_controller import (
|
from erpnext.controllers.accounts_controller import (
|
||||||
@ -433,23 +433,12 @@ class PaymentEntry(AccountsController):
|
|||||||
if not self.apply_tax_withholding_amount:
|
if not self.apply_tax_withholding_amount:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.advance_tax_account:
|
|
||||||
frappe.throw(_("Advance TDS account is mandatory for advance TDS deduction"))
|
|
||||||
|
|
||||||
net_total = self.paid_amount
|
net_total = self.paid_amount
|
||||||
|
|
||||||
for reference in self.get("references"):
|
|
||||||
net_total_for_tds = 0
|
|
||||||
if reference.reference_doctype == 'Purchase Order':
|
|
||||||
net_total_for_tds += flt(frappe.db.get_value('Purchase Order', reference.reference_name, 'net_total'))
|
|
||||||
|
|
||||||
if net_total_for_tds:
|
|
||||||
net_total = net_total_for_tds
|
|
||||||
|
|
||||||
# Adding args as purchase invoice to get TDS amount
|
# Adding args as purchase invoice to get TDS amount
|
||||||
args = frappe._dict({
|
args = frappe._dict({
|
||||||
'company': self.company,
|
'company': self.company,
|
||||||
'doctype': 'Purchase Invoice',
|
'doctype': 'Payment Entry',
|
||||||
'supplier': self.party,
|
'supplier': self.party,
|
||||||
'posting_date': self.posting_date,
|
'posting_date': self.posting_date,
|
||||||
'net_total': net_total
|
'net_total': net_total
|
||||||
@ -461,7 +450,6 @@ class PaymentEntry(AccountsController):
|
|||||||
return
|
return
|
||||||
|
|
||||||
tax_withholding_details.update({
|
tax_withholding_details.update({
|
||||||
'add_deduct_tax': 'Add',
|
|
||||||
'cost_center': self.cost_center or erpnext.get_default_cost_center(self.company)
|
'cost_center': self.cost_center or erpnext.get_default_cost_center(self.company)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -689,6 +677,7 @@ class PaymentEntry(AccountsController):
|
|||||||
self.add_deductions_gl_entries(gl_entries)
|
self.add_deductions_gl_entries(gl_entries)
|
||||||
self.add_tax_gl_entries(gl_entries)
|
self.add_tax_gl_entries(gl_entries)
|
||||||
|
|
||||||
|
gl_entries = process_gl_map(gl_entries)
|
||||||
make_gl_entries(gl_entries, cancel=cancel, adv_adj=adv_adj)
|
make_gl_entries(gl_entries, cancel=cancel, adv_adj=adv_adj)
|
||||||
|
|
||||||
def add_party_gl_entries(self, gl_entries):
|
def add_party_gl_entries(self, gl_entries):
|
||||||
@ -752,7 +741,8 @@ class PaymentEntry(AccountsController):
|
|||||||
"against": self.party if self.payment_type=="Pay" else self.paid_to,
|
"against": self.party if self.payment_type=="Pay" else self.paid_to,
|
||||||
"credit_in_account_currency": self.paid_amount,
|
"credit_in_account_currency": self.paid_amount,
|
||||||
"credit": self.base_paid_amount,
|
"credit": self.base_paid_amount,
|
||||||
"cost_center": self.cost_center
|
"cost_center": self.cost_center,
|
||||||
|
"post_net_value": True
|
||||||
}, item=self)
|
}, item=self)
|
||||||
)
|
)
|
||||||
if self.payment_type in ("Receive", "Internal Transfer"):
|
if self.payment_type in ("Receive", "Internal Transfer"):
|
||||||
@ -782,14 +772,10 @@ class PaymentEntry(AccountsController):
|
|||||||
rev_dr_or_cr = "credit" if dr_or_cr == "debit" else "debit"
|
rev_dr_or_cr = "credit" if dr_or_cr == "debit" else "debit"
|
||||||
against = self.party or self.paid_to
|
against = self.party or self.paid_to
|
||||||
|
|
||||||
payment_or_advance_account = self.get_party_account_for_taxes()
|
payment_account = self.get_party_account_for_taxes()
|
||||||
tax_amount = d.tax_amount
|
tax_amount = d.tax_amount
|
||||||
base_tax_amount = d.base_tax_amount
|
base_tax_amount = d.base_tax_amount
|
||||||
|
|
||||||
if self.advance_tax_account:
|
|
||||||
tax_amount = -1 * tax_amount
|
|
||||||
base_tax_amount = -1 * base_tax_amount
|
|
||||||
|
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": d.account_head,
|
"account": d.account_head,
|
||||||
@ -798,19 +784,21 @@ class PaymentEntry(AccountsController):
|
|||||||
dr_or_cr + "_in_account_currency": base_tax_amount
|
dr_or_cr + "_in_account_currency": base_tax_amount
|
||||||
if account_currency==self.company_currency
|
if account_currency==self.company_currency
|
||||||
else d.tax_amount,
|
else d.tax_amount,
|
||||||
"cost_center": d.cost_center
|
"cost_center": d.cost_center,
|
||||||
|
"post_net_value": True,
|
||||||
}, account_currency, item=d))
|
}, account_currency, item=d))
|
||||||
|
|
||||||
if not d.included_in_paid_amount or self.advance_tax_account:
|
if not d.included_in_paid_amount:
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": payment_or_advance_account,
|
"account": payment_account,
|
||||||
"against": against,
|
"against": against,
|
||||||
rev_dr_or_cr: tax_amount,
|
rev_dr_or_cr: tax_amount,
|
||||||
rev_dr_or_cr + "_in_account_currency": base_tax_amount
|
rev_dr_or_cr + "_in_account_currency": base_tax_amount
|
||||||
if account_currency==self.company_currency
|
if account_currency==self.company_currency
|
||||||
else d.tax_amount,
|
else d.tax_amount,
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
|
"post_net_value": True,
|
||||||
}, account_currency, item=d))
|
}, account_currency, item=d))
|
||||||
|
|
||||||
def add_deductions_gl_entries(self, gl_entries):
|
def add_deductions_gl_entries(self, gl_entries):
|
||||||
@ -832,9 +820,7 @@ class PaymentEntry(AccountsController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_party_account_for_taxes(self):
|
def get_party_account_for_taxes(self):
|
||||||
if self.advance_tax_account:
|
if self.payment_type == 'Receive':
|
||||||
return self.advance_tax_account
|
|
||||||
elif self.payment_type == 'Receive':
|
|
||||||
return self.paid_to
|
return self.paid_to
|
||||||
elif self.payment_type in ('Pay', 'Internal Transfer'):
|
elif self.payment_type in ('Pay', 'Internal Transfer'):
|
||||||
return self.paid_from
|
return self.paid_from
|
||||||
@ -1599,13 +1585,6 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
|
|||||||
})
|
})
|
||||||
pe.set_difference_amount()
|
pe.set_difference_amount()
|
||||||
|
|
||||||
if doc.doctype == 'Purchase Order' and doc.apply_tds:
|
|
||||||
pe.apply_tax_withholding_amount = 1
|
|
||||||
pe.tax_withholding_category = doc.tax_withholding_category
|
|
||||||
|
|
||||||
if not pe.advance_tax_account:
|
|
||||||
pe.advance_tax_account = frappe.db.get_value('Company', pe.company, 'unrealized_profit_loss_account')
|
|
||||||
|
|
||||||
return pe
|
return pe
|
||||||
|
|
||||||
def get_bank_cash_account(doc, bank_account):
|
def get_bank_cash_account(doc, bank_account):
|
||||||
|
@ -130,6 +130,7 @@
|
|||||||
"allocate_advances_automatically",
|
"allocate_advances_automatically",
|
||||||
"get_advances",
|
"get_advances",
|
||||||
"advances",
|
"advances",
|
||||||
|
"advance_tax",
|
||||||
"payment_schedule_section",
|
"payment_schedule_section",
|
||||||
"payment_terms_template",
|
"payment_terms_template",
|
||||||
"ignore_default_payment_terms_template",
|
"ignore_default_payment_terms_template",
|
||||||
@ -1408,13 +1409,21 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "column_break_147",
|
"fieldname": "column_break_147",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "advance_tax",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Advance Tax",
|
||||||
|
"options": "Advance Tax",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-file-text",
|
"icon": "fa fa-file-text",
|
||||||
"idx": 204,
|
"idx": 204,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-10-12 20:55:16.145651",
|
"modified": "2021-11-25 13:31:02.716727",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice",
|
"name": "Purchase Invoice",
|
||||||
|
@ -427,6 +427,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
self.update_project()
|
self.update_project()
|
||||||
update_linked_doc(self.doctype, self.name, self.inter_company_invoice_reference)
|
update_linked_doc(self.doctype, self.name, self.inter_company_invoice_reference)
|
||||||
|
self.update_advance_tax_references()
|
||||||
|
|
||||||
self.process_common_party_accounting()
|
self.process_common_party_accounting()
|
||||||
|
|
||||||
@ -472,8 +473,6 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.make_exchange_gain_loss_gl_entries(gl_entries)
|
self.make_exchange_gain_loss_gl_entries(gl_entries)
|
||||||
self.make_internal_transfer_gl_entries(gl_entries)
|
self.make_internal_transfer_gl_entries(gl_entries)
|
||||||
|
|
||||||
self.allocate_advance_taxes(gl_entries)
|
|
||||||
|
|
||||||
gl_entries = make_regional_gl_entries(gl_entries, self)
|
gl_entries = make_regional_gl_entries(gl_entries, self)
|
||||||
|
|
||||||
gl_entries = merge_similar_entries(gl_entries)
|
gl_entries = merge_similar_entries(gl_entries)
|
||||||
@ -1074,6 +1073,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
unlink_inter_company_doc(self.doctype, self.name, self.inter_company_invoice_reference)
|
unlink_inter_company_doc(self.doctype, self.name, self.inter_company_invoice_reference)
|
||||||
self.ignore_linked_doctypes = ('GL Entry', 'Stock Ledger Entry', 'Repost Item Valuation')
|
self.ignore_linked_doctypes = ('GL Entry', 'Stock Ledger Entry', 'Repost Item Valuation')
|
||||||
|
self.update_advance_tax_references(cancel=1)
|
||||||
|
|
||||||
def update_project(self):
|
def update_project(self):
|
||||||
project_list = []
|
project_list = []
|
||||||
@ -1150,7 +1150,10 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if not self.tax_withholding_category:
|
if not self.tax_withholding_category:
|
||||||
return
|
return
|
||||||
|
|
||||||
tax_withholding_details = get_party_tax_withholding_details(self, self.tax_withholding_category)
|
tax_withholding_details, advance_taxes = get_party_tax_withholding_details(self, self.tax_withholding_category)
|
||||||
|
|
||||||
|
# Adjust TDS paid on advances
|
||||||
|
self.allocate_advance_tds(tax_withholding_details, advance_taxes)
|
||||||
|
|
||||||
if not tax_withholding_details:
|
if not tax_withholding_details:
|
||||||
return
|
return
|
||||||
@ -1174,6 +1177,39 @@ class PurchaseInvoice(BuyingController):
|
|||||||
# calculate totals again after applying TDS
|
# calculate totals again after applying TDS
|
||||||
self.calculate_taxes_and_totals()
|
self.calculate_taxes_and_totals()
|
||||||
|
|
||||||
|
def allocate_advance_tds(self, tax_withholding_details, advance_taxes):
|
||||||
|
self.set('advance_tax', [])
|
||||||
|
for tax in advance_taxes:
|
||||||
|
allocated_amount = 0
|
||||||
|
pending_amount = flt(tax.tax_amount - tax.allocated_amount)
|
||||||
|
if flt(tax_withholding_details.get('tax_amount')) >= pending_amount:
|
||||||
|
tax_withholding_details['tax_amount'] -= pending_amount
|
||||||
|
allocated_amount = pending_amount
|
||||||
|
elif flt(tax_withholding_details.get('tax_amount')) and flt(tax_withholding_details.get('tax_amount')) < pending_amount:
|
||||||
|
allocated_amount = tax_withholding_details['tax_amount']
|
||||||
|
tax_withholding_details['tax_amount'] = 0
|
||||||
|
|
||||||
|
self.append('advance_tax', {
|
||||||
|
'reference_type': 'Payment Entry',
|
||||||
|
'reference_name': tax.parent,
|
||||||
|
'reference_detail': tax.name,
|
||||||
|
'account_head': tax.account_head,
|
||||||
|
'allocated_amount': allocated_amount
|
||||||
|
})
|
||||||
|
|
||||||
|
def update_advance_tax_references(self, cancel=0):
|
||||||
|
for tax in self.get('advance_tax'):
|
||||||
|
at = frappe.qb.DocType("Advance Taxes and Charges").as_("at")
|
||||||
|
|
||||||
|
if cancel:
|
||||||
|
frappe.qb.update(at).set(
|
||||||
|
at.allocated_amount, at.allocated_amount - tax.allocated_amount
|
||||||
|
).where(at.name == tax.reference_detail).run()
|
||||||
|
else:
|
||||||
|
frappe.qb.update(at).set(
|
||||||
|
at.allocated_amount, at.allocated_amount + tax.allocated_amount
|
||||||
|
).where(at.name == tax.reference_detail).run()
|
||||||
|
|
||||||
def set_status(self, update=False, status=None, update_modified=True):
|
def set_status(self, update=False, status=None, update_modified=True):
|
||||||
if self.is_new():
|
if self.is_new():
|
||||||
if self.get('amended_from'):
|
if self.get('amended_from'):
|
||||||
|
@ -1160,25 +1160,21 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
# Create Purchase Order with TDS applied
|
# Create Purchase Order with TDS applied
|
||||||
po = create_purchase_order(do_not_save=1, supplier=supplier.name, rate=3000, item='_Test Non Stock Item',
|
po = create_purchase_order(do_not_save=1, supplier=supplier.name, rate=3000, item='_Test Non Stock Item',
|
||||||
posting_date='2021-09-15')
|
posting_date='2021-09-15')
|
||||||
po.apply_tds = 1
|
|
||||||
po.tax_withholding_category = 'TDS - 194 - Dividends - Individual'
|
|
||||||
po.save()
|
po.save()
|
||||||
po.submit()
|
po.submit()
|
||||||
|
|
||||||
# Update Unrealized Profit / Loss Account which is used as default advance tax account
|
|
||||||
frappe.db.set_value('Company', '_Test Company', 'unrealized_profit_loss_account', '_Test Account Excise Duty - _TC')
|
|
||||||
|
|
||||||
# Create Payment Entry Against the order
|
# Create Payment Entry Against the order
|
||||||
payment_entry = get_payment_entry(dt='Purchase Order', dn=po.name)
|
payment_entry = get_payment_entry(dt='Purchase Order', dn=po.name)
|
||||||
payment_entry.paid_from = 'Cash - _TC'
|
payment_entry.paid_from = 'Cash - _TC'
|
||||||
|
payment_entry.apply_tax_withholding_amount = 1
|
||||||
|
payment_entry.tax_withholding_category = 'TDS - 194 - Dividends - Individual'
|
||||||
payment_entry.save()
|
payment_entry.save()
|
||||||
payment_entry.submit()
|
payment_entry.submit()
|
||||||
|
|
||||||
# Check GLE for Payment Entry
|
# Check GLE for Payment Entry
|
||||||
expected_gle = [
|
expected_gle = [
|
||||||
['_Test Account Excise Duty - _TC', 3000, 0],
|
|
||||||
['Cash - _TC', 0, 27000],
|
['Cash - _TC', 0, 27000],
|
||||||
['Creditors - _TC', 27000, 0],
|
['Creditors - _TC', 30000, 0],
|
||||||
['TDS Payable - _TC', 0, 3000],
|
['TDS Payable - _TC', 0, 3000],
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1204,9 +1200,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
# Zero net effect on final TDS Payable on invoice
|
# Zero net effect on final TDS Payable on invoice
|
||||||
expected_gle = [
|
expected_gle = [
|
||||||
['_Test Account Cost for Goods Sold - _TC', 30000],
|
['_Test Account Cost for Goods Sold - _TC', 30000],
|
||||||
['_Test Account Excise Duty - _TC', -3000],
|
['Creditors - _TC', -30000]
|
||||||
['Creditors - _TC', -27000],
|
|
||||||
['TDS Payable - _TC', 0]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
gl_entries = frappe.db.sql("""select account, sum(debit - credit) as amount
|
gl_entries = frappe.db.sql("""select account, sum(debit - credit) as amount
|
||||||
@ -1219,6 +1213,14 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
self.assertEqual(expected_gle[i][0], gle.account)
|
self.assertEqual(expected_gle[i][0], gle.account)
|
||||||
self.assertEqual(expected_gle[i][1], gle.amount)
|
self.assertEqual(expected_gle[i][1], gle.amount)
|
||||||
|
|
||||||
|
payment_entry.load_from_db()
|
||||||
|
self.assertEqual(payment_entry.taxes[0].allocated_amount, 3000)
|
||||||
|
|
||||||
|
purchase_invoice.cancel()
|
||||||
|
|
||||||
|
payment_entry.load_from_db()
|
||||||
|
self.assertEqual(payment_entry.taxes[0].allocated_amount, 0)
|
||||||
|
|
||||||
def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
||||||
gl_entries = frappe.db.sql("""select account, debit, credit, posting_date
|
gl_entries = frappe.db.sql("""select account, debit, credit, posting_date
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
|
@ -842,8 +842,6 @@ class SalesInvoice(SellingController):
|
|||||||
self.make_exchange_gain_loss_gl_entries(gl_entries)
|
self.make_exchange_gain_loss_gl_entries(gl_entries)
|
||||||
self.make_internal_transfer_gl_entries(gl_entries)
|
self.make_internal_transfer_gl_entries(gl_entries)
|
||||||
|
|
||||||
self.allocate_advance_taxes(gl_entries)
|
|
||||||
|
|
||||||
self.make_item_gl_entries(gl_entries)
|
self.make_item_gl_entries(gl_entries)
|
||||||
self.make_discount_gl_entries(gl_entries)
|
self.make_discount_gl_entries(gl_entries)
|
||||||
|
|
||||||
|
@ -2397,6 +2397,32 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.db.set_value('Accounts Settings', None, 'acc_frozen_upto', None)
|
frappe.db.set_value('Accounts Settings', None, 'acc_frozen_upto', None)
|
||||||
|
|
||||||
|
def test_over_billing_case_against_delivery_note(self):
|
||||||
|
'''
|
||||||
|
Test a case where duplicating the item with qty = 1 in the invoice
|
||||||
|
allows overbilling even if it is disabled
|
||||||
|
'''
|
||||||
|
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
||||||
|
|
||||||
|
over_billing_allowance = frappe.db.get_single_value('Accounts Settings', 'over_billing_allowance')
|
||||||
|
frappe.db.set_value('Accounts Settings', None, 'over_billing_allowance', 0)
|
||||||
|
|
||||||
|
dn = create_delivery_note()
|
||||||
|
dn.submit()
|
||||||
|
|
||||||
|
si = make_sales_invoice(dn.name)
|
||||||
|
# make a copy of first item and add it to invoice
|
||||||
|
item_copy = frappe.copy_doc(si.items[0])
|
||||||
|
si.append('items', item_copy)
|
||||||
|
si.save()
|
||||||
|
|
||||||
|
with self.assertRaises(frappe.ValidationError) as err:
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
self.assertTrue("cannot overbill" in str(err.exception).lower())
|
||||||
|
|
||||||
|
frappe.db.set_value('Accounts Settings', None, 'over_billing_allowance', over_billing_allowance)
|
||||||
|
|
||||||
def get_sales_invoice_for_e_invoice():
|
def get_sales_invoice_for_e_invoice():
|
||||||
si = make_sales_invoice_for_ewaybill()
|
si = make_sales_invoice_for_ewaybill()
|
||||||
si.naming_series = 'INV-2020-.#####'
|
si.naming_series = 'INV-2020-.#####'
|
||||||
|
@ -95,7 +95,7 @@ def get_party_tax_withholding_details(inv, tax_withholding_category=None):
|
|||||||
frappe.throw(_('Tax Withholding Category {} against Company {} for Customer {} should have Cumulative Threshold value.')
|
frappe.throw(_('Tax Withholding Category {} against Company {} for Customer {} should have Cumulative Threshold value.')
|
||||||
.format(tax_withholding_category, inv.company, party))
|
.format(tax_withholding_category, inv.company, party))
|
||||||
|
|
||||||
tax_amount, tax_deducted = get_tax_amount(
|
tax_amount, tax_deducted, tax_deducted_on_advances = get_tax_amount(
|
||||||
party_type, parties,
|
party_type, parties,
|
||||||
inv, tax_details,
|
inv, tax_details,
|
||||||
posting_date, pan_no
|
posting_date, pan_no
|
||||||
@ -106,7 +106,10 @@ def get_party_tax_withholding_details(inv, tax_withholding_category=None):
|
|||||||
else:
|
else:
|
||||||
tax_row = get_tax_row_for_tcs(inv, tax_details, tax_amount, tax_deducted)
|
tax_row = get_tax_row_for_tcs(inv, tax_details, tax_amount, tax_deducted)
|
||||||
|
|
||||||
return tax_row
|
if inv.doctype == 'Purchase Invoice':
|
||||||
|
return tax_row, tax_deducted_on_advances
|
||||||
|
else:
|
||||||
|
return tax_row
|
||||||
|
|
||||||
def get_tax_withholding_details(tax_withholding_category, posting_date, company):
|
def get_tax_withholding_details(tax_withholding_category, posting_date, company):
|
||||||
tax_withholding = frappe.get_doc("Tax Withholding Category", tax_withholding_category)
|
tax_withholding = frappe.get_doc("Tax Withholding Category", tax_withholding_category)
|
||||||
@ -194,6 +197,10 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N
|
|||||||
advance_vouchers = get_advance_vouchers(parties, company=inv.company, from_date=tax_details.from_date,
|
advance_vouchers = get_advance_vouchers(parties, company=inv.company, from_date=tax_details.from_date,
|
||||||
to_date=tax_details.to_date, party_type=party_type)
|
to_date=tax_details.to_date, party_type=party_type)
|
||||||
taxable_vouchers = vouchers + advance_vouchers
|
taxable_vouchers = vouchers + advance_vouchers
|
||||||
|
tax_deducted_on_advances = 0
|
||||||
|
|
||||||
|
if inv.doctype == 'Purchase Invoice':
|
||||||
|
tax_deducted_on_advances = get_taxes_deducted_on_advances_allocated(inv, tax_details)
|
||||||
|
|
||||||
tax_deducted = 0
|
tax_deducted = 0
|
||||||
if taxable_vouchers:
|
if taxable_vouchers:
|
||||||
@ -223,7 +230,7 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N
|
|||||||
if cint(tax_details.round_off_tax_amount):
|
if cint(tax_details.round_off_tax_amount):
|
||||||
tax_amount = round(tax_amount)
|
tax_amount = round(tax_amount)
|
||||||
|
|
||||||
return tax_amount, tax_deducted
|
return tax_amount, tax_deducted, tax_deducted_on_advances
|
||||||
|
|
||||||
def get_invoice_vouchers(parties, tax_details, company, party_type='Supplier'):
|
def get_invoice_vouchers(parties, tax_details, company, party_type='Supplier'):
|
||||||
dr_or_cr = 'credit' if party_type == 'Supplier' else 'debit'
|
dr_or_cr = 'credit' if party_type == 'Supplier' else 'debit'
|
||||||
@ -281,6 +288,29 @@ def get_advance_vouchers(parties, company=None, from_date=None, to_date=None, pa
|
|||||||
|
|
||||||
return frappe.get_all('GL Entry', filters=filters, distinct=1, pluck='voucher_no') or [""]
|
return frappe.get_all('GL Entry', filters=filters, distinct=1, pluck='voucher_no') or [""]
|
||||||
|
|
||||||
|
def get_taxes_deducted_on_advances_allocated(inv, tax_details):
|
||||||
|
advances = [d.reference_name for d in inv.get('advances')]
|
||||||
|
tax_info = []
|
||||||
|
|
||||||
|
if advances:
|
||||||
|
pe = frappe.qb.DocType("Payment Entry").as_("pe")
|
||||||
|
at = frappe.qb.DocType("Advance Taxes and Charges").as_("at")
|
||||||
|
|
||||||
|
tax_info = frappe.qb.from_(at).inner_join(pe).on(
|
||||||
|
pe.name == at.parent
|
||||||
|
).select(
|
||||||
|
at.parent, at.name, at.tax_amount, at.allocated_amount
|
||||||
|
).where(
|
||||||
|
pe.tax_withholding_category == tax_details.get('tax_withholding_category')
|
||||||
|
).where(
|
||||||
|
at.parent.isin(advances)
|
||||||
|
).where(
|
||||||
|
at.account_head == tax_details.account_head
|
||||||
|
).run(as_dict=True)
|
||||||
|
|
||||||
|
return tax_info
|
||||||
|
|
||||||
|
|
||||||
def get_deducted_tax(taxable_vouchers, tax_details):
|
def get_deducted_tax(taxable_vouchers, tax_details):
|
||||||
# check if TDS / TCS account is already charged on taxable vouchers
|
# check if TDS / TCS account is already charged on taxable vouchers
|
||||||
filters = {
|
filters = {
|
||||||
|
@ -73,8 +73,28 @@ def process_gl_map(gl_map, merge_entries=True, precision=None):
|
|||||||
flt(entry.debit_in_account_currency) - flt(entry.credit_in_account_currency)
|
flt(entry.debit_in_account_currency) - flt(entry.credit_in_account_currency)
|
||||||
entry.credit_in_account_currency = 0.0
|
entry.credit_in_account_currency = 0.0
|
||||||
|
|
||||||
|
update_net_values(entry)
|
||||||
|
|
||||||
return gl_map
|
return gl_map
|
||||||
|
|
||||||
|
def update_net_values(entry):
|
||||||
|
# In some scenarios net value needs to be shown in the ledger
|
||||||
|
# This method updates net values as debit or credit
|
||||||
|
if entry.post_net_value and entry.debit and entry.credit:
|
||||||
|
if entry.debit > entry.credit:
|
||||||
|
entry.debit = entry.debit - entry.credit
|
||||||
|
entry.debit_in_account_currency = entry.debit_in_account_currency \
|
||||||
|
- entry.credit_in_account_currency
|
||||||
|
entry.credit = 0
|
||||||
|
entry.credit_in_account_currency = 0
|
||||||
|
else:
|
||||||
|
entry.credit = entry.credit - entry.debit
|
||||||
|
entry.credit_in_account_currency = entry.credit_in_account_currency \
|
||||||
|
- entry.debit_in_account_currency
|
||||||
|
|
||||||
|
entry.debit = 0
|
||||||
|
entry.debit_in_account_currency = 0
|
||||||
|
|
||||||
def merge_similar_entries(gl_map, precision=None):
|
def merge_similar_entries(gl_map, precision=None):
|
||||||
merged_gl_map = []
|
merged_gl_map = []
|
||||||
accounting_dimensions = get_accounting_dimensions()
|
accounting_dimensions = get_accounting_dimensions()
|
||||||
|
@ -11,7 +11,11 @@ from frappe.contacts.address_and_contact import (
|
|||||||
)
|
)
|
||||||
from frappe.model.naming import set_name_by_naming_series, set_name_from_naming_options
|
from frappe.model.naming import set_name_by_naming_series, set_name_from_naming_options
|
||||||
|
|
||||||
from erpnext.accounts.party import get_dashboard_info, validate_party_accounts
|
from erpnext.accounts.party import ( # noqa
|
||||||
|
get_dashboard_info,
|
||||||
|
get_timeline_data,
|
||||||
|
validate_party_accounts,
|
||||||
|
)
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,11 +145,6 @@ class AccountsController(TransactionBase):
|
|||||||
self.validate_party()
|
self.validate_party()
|
||||||
self.validate_currency()
|
self.validate_currency()
|
||||||
|
|
||||||
if self.doctype == 'Purchase Invoice':
|
|
||||||
self.calculate_paid_amount()
|
|
||||||
# apply tax withholding only if checked and applicable
|
|
||||||
self.set_tax_withholding()
|
|
||||||
|
|
||||||
if self.doctype in ['Purchase Invoice', 'Sales Invoice']:
|
if self.doctype in ['Purchase Invoice', 'Sales Invoice']:
|
||||||
pos_check_field = "is_pos" if self.doctype=="Sales Invoice" else "is_paid"
|
pos_check_field = "is_pos" if self.doctype=="Sales Invoice" else "is_paid"
|
||||||
if cint(self.allocate_advances_automatically) and not cint(self.get(pos_check_field)):
|
if cint(self.allocate_advances_automatically) and not cint(self.get(pos_check_field)):
|
||||||
@ -164,6 +159,11 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
self.set_inter_company_account()
|
self.set_inter_company_account()
|
||||||
|
|
||||||
|
if self.doctype == 'Purchase Invoice':
|
||||||
|
self.calculate_paid_amount()
|
||||||
|
# apply tax withholding only if checked and applicable
|
||||||
|
self.set_tax_withholding()
|
||||||
|
|
||||||
validate_regional(self)
|
validate_regional(self)
|
||||||
|
|
||||||
if self.doctype != 'Material Request':
|
if self.doctype != 'Material Request':
|
||||||
@ -524,7 +524,8 @@ class AccountsController(TransactionBase):
|
|||||||
'is_opening': self.get("is_opening") or "No",
|
'is_opening': self.get("is_opening") or "No",
|
||||||
'party_type': None,
|
'party_type': None,
|
||||||
'party': None,
|
'party': None,
|
||||||
'project': self.get("project")
|
'project': self.get("project"),
|
||||||
|
'post_net_value': args.get('post_net_value')
|
||||||
})
|
})
|
||||||
|
|
||||||
accounting_dimensions = get_accounting_dimensions()
|
accounting_dimensions = get_accounting_dimensions()
|
||||||
@ -805,7 +806,6 @@ class AccountsController(TransactionBase):
|
|||||||
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
|
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
|
||||||
|
|
||||||
if self.doctype in ["Sales Invoice", "Purchase Invoice"]:
|
if self.doctype in ["Sales Invoice", "Purchase Invoice"]:
|
||||||
self.update_allocated_advance_taxes_on_cancel()
|
|
||||||
if frappe.db.get_single_value('Accounts Settings', 'unlink_payment_on_cancellation_of_invoice'):
|
if frappe.db.get_single_value('Accounts Settings', 'unlink_payment_on_cancellation_of_invoice'):
|
||||||
unlink_ref_doc_from_payment_entries(self)
|
unlink_ref_doc_from_payment_entries(self)
|
||||||
|
|
||||||
@ -853,29 +853,6 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
return tax_map
|
return tax_map
|
||||||
|
|
||||||
def update_allocated_advance_taxes_on_cancel(self):
|
|
||||||
if self.get('advances'):
|
|
||||||
tax_accounts = [d.account_head for d in self.get('taxes')]
|
|
||||||
allocated_tax_map = frappe._dict(frappe.get_all('GL Entry', fields=['account', 'sum(credit - debit)'],
|
|
||||||
filters={'voucher_no': self.name, 'account': ('in', tax_accounts)},
|
|
||||||
group_by='account', as_list=1))
|
|
||||||
|
|
||||||
tax_map = self.get_tax_map()
|
|
||||||
|
|
||||||
for pe in self.get('advances'):
|
|
||||||
if pe.reference_type == 'Payment Entry':
|
|
||||||
pe = frappe.get_doc('Payment Entry', pe.reference_name)
|
|
||||||
for tax in pe.get('taxes'):
|
|
||||||
allocated_amount = tax_map.get(tax.account_head) - allocated_tax_map.get(tax.account_head)
|
|
||||||
if allocated_amount > tax.tax_amount:
|
|
||||||
allocated_amount = tax.tax_amount
|
|
||||||
|
|
||||||
if allocated_amount:
|
|
||||||
frappe.db.set_value('Advance Taxes and Charges', tax.name, 'allocated_amount',
|
|
||||||
tax.allocated_amount - allocated_amount)
|
|
||||||
tax_map[tax.account_head] -= allocated_amount
|
|
||||||
allocated_tax_map[tax.account_head] -= allocated_amount
|
|
||||||
|
|
||||||
def get_amount_and_base_amount(self, item, enable_discount_accounting):
|
def get_amount_and_base_amount(self, item, enable_discount_accounting):
|
||||||
amount = item.net_amount
|
amount = item.net_amount
|
||||||
base_amount = item.base_net_amount
|
base_amount = item.base_net_amount
|
||||||
@ -959,58 +936,10 @@ class AccountsController(TransactionBase):
|
|||||||
}, item=self)
|
}, item=self)
|
||||||
)
|
)
|
||||||
|
|
||||||
def allocate_advance_taxes(self, gl_entries):
|
|
||||||
tax_map = self.get_tax_map()
|
|
||||||
for pe in self.get("advances"):
|
|
||||||
if pe.reference_type == "Payment Entry" and \
|
|
||||||
frappe.db.get_value('Payment Entry', pe.reference_name, 'advance_tax_account'):
|
|
||||||
pe = frappe.get_doc("Payment Entry", pe.reference_name)
|
|
||||||
for tax in pe.get("taxes"):
|
|
||||||
account_currency = get_account_currency(tax.account_head)
|
|
||||||
|
|
||||||
if self.doctype == "Purchase Invoice":
|
|
||||||
dr_or_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
|
|
||||||
rev_dr_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
|
|
||||||
else:
|
|
||||||
dr_or_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
|
|
||||||
rev_dr_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
|
|
||||||
|
|
||||||
party = self.supplier if self.doctype == "Purchase Invoice" else self.customer
|
|
||||||
unallocated_amount = tax.tax_amount - tax.allocated_amount
|
|
||||||
if tax_map.get(tax.account_head):
|
|
||||||
amount = tax_map.get(tax.account_head)
|
|
||||||
if amount < unallocated_amount:
|
|
||||||
unallocated_amount = amount
|
|
||||||
|
|
||||||
gl_entries.append(
|
|
||||||
self.get_gl_dict({
|
|
||||||
"account": tax.account_head,
|
|
||||||
"against": party,
|
|
||||||
dr_or_cr: unallocated_amount,
|
|
||||||
dr_or_cr + "_in_account_currency": unallocated_amount
|
|
||||||
if account_currency==self.company_currency
|
|
||||||
else unallocated_amount,
|
|
||||||
"cost_center": tax.cost_center
|
|
||||||
}, account_currency, item=tax))
|
|
||||||
|
|
||||||
gl_entries.append(
|
|
||||||
self.get_gl_dict({
|
|
||||||
"account": pe.advance_tax_account,
|
|
||||||
"against": party,
|
|
||||||
rev_dr_cr: unallocated_amount,
|
|
||||||
rev_dr_cr + "_in_account_currency": unallocated_amount
|
|
||||||
if account_currency==self.company_currency
|
|
||||||
else unallocated_amount,
|
|
||||||
"cost_center": tax.cost_center
|
|
||||||
}, account_currency, item=tax))
|
|
||||||
|
|
||||||
frappe.db.set_value("Advance Taxes and Charges", tax.name, "allocated_amount",
|
|
||||||
tax.allocated_amount + unallocated_amount)
|
|
||||||
|
|
||||||
tax_map[tax.account_head] -= unallocated_amount
|
|
||||||
|
|
||||||
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
|
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
|
||||||
from erpnext.controllers.status_updater import get_allowance_for
|
from erpnext.controllers.status_updater import get_allowance_for
|
||||||
|
|
||||||
item_allowance = {}
|
item_allowance = {}
|
||||||
global_qty_allowance, global_amount_allowance = None, None
|
global_qty_allowance, global_amount_allowance = None, None
|
||||||
|
|
||||||
@ -1031,12 +960,7 @@ class AccountsController(TransactionBase):
|
|||||||
.format(item.item_code, ref_dt), title=_("Warning"), indicator="orange")
|
.format(item.item_code, ref_dt), title=_("Warning"), indicator="orange")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
already_billed = frappe.db.sql("""
|
already_billed = self.get_billed_amount_for_item(item, item_ref_dn, based_on)
|
||||||
select sum(%s)
|
|
||||||
from `tab%s`
|
|
||||||
where %s=%s and docstatus=1 and parent != %s
|
|
||||||
""" % (based_on, self.doctype + " Item", item_ref_dn, '%s', '%s'),
|
|
||||||
(item.get(item_ref_dn), self.name))[0][0]
|
|
||||||
|
|
||||||
total_billed_amt = flt(flt(already_billed) + flt(item.get(based_on)),
|
total_billed_amt = flt(flt(already_billed) + flt(item.get(based_on)),
|
||||||
self.precision(based_on, item))
|
self.precision(based_on, item))
|
||||||
@ -1064,6 +988,43 @@ class AccountsController(TransactionBase):
|
|||||||
frappe.msgprint(_("Overbilling of {} ignored because you have {} role.")
|
frappe.msgprint(_("Overbilling of {} ignored because you have {} role.")
|
||||||
.format(total_overbilled_amt, role_allowed_to_over_bill), indicator="orange", alert=True)
|
.format(total_overbilled_amt, role_allowed_to_over_bill), indicator="orange", alert=True)
|
||||||
|
|
||||||
|
def get_billed_amount_for_item(self, item, item_ref_dn, based_on):
|
||||||
|
'''
|
||||||
|
Returns Sum of Amount of
|
||||||
|
Sales/Purchase Invoice Items
|
||||||
|
that are linked to `item_ref_dn` (`dn_detail` / `pr_detail`)
|
||||||
|
that are submitted OR not submitted but are under current invoice
|
||||||
|
'''
|
||||||
|
|
||||||
|
from frappe.query_builder import Criterion
|
||||||
|
from frappe.query_builder.functions import Sum
|
||||||
|
|
||||||
|
item_doctype = frappe.qb.DocType(item.doctype)
|
||||||
|
based_on_field = frappe.qb.Field(based_on)
|
||||||
|
join_field = frappe.qb.Field(item_ref_dn)
|
||||||
|
|
||||||
|
result = (
|
||||||
|
frappe.qb.from_(item_doctype)
|
||||||
|
.select(Sum(based_on_field))
|
||||||
|
.where(
|
||||||
|
join_field == item.get(item_ref_dn)
|
||||||
|
).where(
|
||||||
|
Criterion.any([ # select all items from other invoices OR current invoices
|
||||||
|
Criterion.all([ # for selecting items from other invoices
|
||||||
|
item_doctype.docstatus == 1,
|
||||||
|
item_doctype.parent != self.name
|
||||||
|
]),
|
||||||
|
Criterion.all([ # for selecting items from current invoice, that are linked to same reference
|
||||||
|
item_doctype.docstatus == 0,
|
||||||
|
item_doctype.parent == self.name,
|
||||||
|
item_doctype.name != item.name
|
||||||
|
])
|
||||||
|
])
|
||||||
|
)
|
||||||
|
).run()
|
||||||
|
|
||||||
|
return result[0][0] if result else 0
|
||||||
|
|
||||||
def throw_overbill_exception(self, item, max_allowed_amt):
|
def throw_overbill_exception(self, item, max_allowed_amt):
|
||||||
frappe.throw(_("Cannot overbill for Item {0} in row {1} more than {2}. To allow over-billing, please set allowance in Accounts Settings")
|
frappe.throw(_("Cannot overbill for Item {0} in row {1} more than {2}. To allow over-billing, please set allowance in Accounts Settings")
|
||||||
.format(item.item_code, item.idx, max_allowed_amt))
|
.format(item.item_code, item.idx, max_allowed_amt))
|
||||||
|
@ -17,7 +17,7 @@ from erpnext.accounts.general_ledger import (
|
|||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
from erpnext.stock import get_warehouse_account_map
|
from erpnext.stock import get_warehouse_account_map
|
||||||
from erpnext.stock.stock_ledger import get_valuation_rate
|
from erpnext.stock.stock_ledger import get_items_to_be_repost, get_valuation_rate
|
||||||
|
|
||||||
|
|
||||||
class QualityInspectionRequiredError(frappe.ValidationError): pass
|
class QualityInspectionRequiredError(frappe.ValidationError): pass
|
||||||
@ -544,7 +544,12 @@ class StockController(AccountsController):
|
|||||||
"company": self.company
|
"company": self.company
|
||||||
})
|
})
|
||||||
if future_sle_exists(args):
|
if future_sle_exists(args):
|
||||||
create_repost_item_valuation_entry(args)
|
item_based_reposting = cint(frappe.db.get_single_value("Stock Reposting Settings", "item_based_reposting"))
|
||||||
|
if item_based_reposting:
|
||||||
|
create_item_wise_repost_entries(voucher_type=self.doctype, voucher_no=self.name)
|
||||||
|
else:
|
||||||
|
create_repost_item_valuation_entry(args)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_quality_inspections(doctype, docname, items):
|
def make_quality_inspections(doctype, docname, items):
|
||||||
@ -679,3 +684,35 @@ def create_repost_item_valuation_entry(args):
|
|||||||
repost_entry.flags.ignore_permissions = True
|
repost_entry.flags.ignore_permissions = True
|
||||||
repost_entry.save()
|
repost_entry.save()
|
||||||
repost_entry.submit()
|
repost_entry.submit()
|
||||||
|
|
||||||
|
|
||||||
|
def create_item_wise_repost_entries(voucher_type, voucher_no, allow_zero_rate=False):
|
||||||
|
"""Using a voucher create repost item valuation records for all item-warehouse pairs."""
|
||||||
|
|
||||||
|
stock_ledger_entries = get_items_to_be_repost(voucher_type, voucher_no)
|
||||||
|
|
||||||
|
distinct_item_warehouses = set()
|
||||||
|
repost_entries = []
|
||||||
|
|
||||||
|
for sle in stock_ledger_entries:
|
||||||
|
item_wh = (sle.item_code, sle.warehouse)
|
||||||
|
if item_wh in distinct_item_warehouses:
|
||||||
|
continue
|
||||||
|
distinct_item_warehouses.add(item_wh)
|
||||||
|
|
||||||
|
repost_entry = frappe.new_doc("Repost Item Valuation")
|
||||||
|
repost_entry.based_on = "Item and Warehouse"
|
||||||
|
repost_entry.voucher_type = voucher_type
|
||||||
|
repost_entry.voucher_no = voucher_no
|
||||||
|
|
||||||
|
repost_entry.item_code = sle.item_code
|
||||||
|
repost_entry.warehouse = sle.warehouse
|
||||||
|
repost_entry.posting_date = sle.posting_date
|
||||||
|
repost_entry.posting_time = sle.posting_time
|
||||||
|
repost_entry.allow_zero_rate = allow_zero_rate
|
||||||
|
repost_entry.flags.ignore_links = True
|
||||||
|
repost_entry.flags.ignore_permissions = True
|
||||||
|
repost_entry.submit()
|
||||||
|
repost_entries.append(repost_entry)
|
||||||
|
|
||||||
|
return repost_entries
|
||||||
|
@ -125,7 +125,7 @@ def get_student_guardians(student):
|
|||||||
|
|
||||||
:param student: Student.
|
:param student: Student.
|
||||||
"""
|
"""
|
||||||
guardians = frappe.get_list("Student Guardian", fields=["guardian"] ,
|
guardians = frappe.get_all("Student Guardian", fields=["guardian"] ,
|
||||||
filters={"parent": student})
|
filters={"parent": student})
|
||||||
return guardians
|
return guardians
|
||||||
|
|
||||||
@ -137,10 +137,10 @@ def get_student_group_students(student_group, include_inactive=0):
|
|||||||
:param student_group: Student Group.
|
:param student_group: Student Group.
|
||||||
"""
|
"""
|
||||||
if include_inactive:
|
if include_inactive:
|
||||||
students = frappe.get_list("Student Group Student", fields=["student", "student_name"] ,
|
students = frappe.get_all("Student Group Student", fields=["student", "student_name"] ,
|
||||||
filters={"parent": student_group}, order_by= "group_roll_number")
|
filters={"parent": student_group}, order_by= "group_roll_number")
|
||||||
else:
|
else:
|
||||||
students = frappe.get_list("Student Group Student", fields=["student", "student_name"] ,
|
students = frappe.get_all("Student Group Student", fields=["student", "student_name"] ,
|
||||||
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
|
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
|
||||||
return students
|
return students
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ def get_fee_components(fee_structure):
|
|||||||
:param fee_structure: Fee Structure.
|
:param fee_structure: Fee Structure.
|
||||||
"""
|
"""
|
||||||
if fee_structure:
|
if fee_structure:
|
||||||
fs = frappe.get_list("Fee Component", fields=["fees_category", "description", "amount"] , filters={"parent": fee_structure}, order_by= "idx")
|
fs = frappe.get_all("Fee Component", fields=["fees_category", "description", "amount"] , filters={"parent": fee_structure}, order_by= "idx")
|
||||||
return fs
|
return fs
|
||||||
|
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ def get_fee_schedule(program, student_category=None):
|
|||||||
:param program: Program.
|
:param program: Program.
|
||||||
:param student_category: Student Category
|
:param student_category: Student Category
|
||||||
"""
|
"""
|
||||||
fs = frappe.get_list("Program Fee", fields=["academic_term", "fee_structure", "due_date", "amount"] ,
|
fs = frappe.get_all("Program Fee", fields=["academic_term", "fee_structure", "due_date", "amount"] ,
|
||||||
filters={"parent": program, "student_category": student_category }, order_by= "idx")
|
filters={"parent": program, "student_category": student_category }, order_by= "idx")
|
||||||
return fs
|
return fs
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ def get_assessment_criteria(course):
|
|||||||
|
|
||||||
:param Course: Course
|
:param Course: Course
|
||||||
"""
|
"""
|
||||||
return frappe.get_list("Course Assessment Criteria", \
|
return frappe.get_all("Course Assessment Criteria",
|
||||||
fields=["assessment_criteria", "weightage"], filters={"parent": course}, order_by= "idx")
|
fields=["assessment_criteria", "weightage"], filters={"parent": course}, order_by= "idx")
|
||||||
|
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ def get_assessment_details(assessment_plan):
|
|||||||
|
|
||||||
:param Assessment Plan: Assessment Plan
|
:param Assessment Plan: Assessment Plan
|
||||||
"""
|
"""
|
||||||
return frappe.get_list("Assessment Plan Criteria", \
|
return frappe.get_all("Assessment Plan Criteria",
|
||||||
fields=["assessment_criteria", "maximum_score", "docstatus"], filters={"parent": assessment_plan}, order_by= "idx")
|
fields=["assessment_criteria", "maximum_score", "docstatus"], filters={"parent": assessment_plan}, order_by= "idx")
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,520 +1,143 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"actions": [],
|
||||||
"allow_guest_to_view": 0,
|
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 0,
|
|
||||||
"autoname": "naming_series:",
|
"autoname": "naming_series:",
|
||||||
"beta": 0,
|
|
||||||
"creation": "2015-09-09 16:34:04.960369",
|
"creation": "2015-09-09 16:34:04.960369",
|
||||||
"custom": 0,
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Document",
|
"document_type": "Document",
|
||||||
"editable_grid": 0,
|
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"student_group",
|
||||||
|
"instructor",
|
||||||
|
"instructor_name",
|
||||||
|
"column_break_2",
|
||||||
|
"naming_series",
|
||||||
|
"course",
|
||||||
|
"color",
|
||||||
|
"section_break_6",
|
||||||
|
"schedule_date",
|
||||||
|
"room",
|
||||||
|
"column_break_9",
|
||||||
|
"from_time",
|
||||||
|
"to_time",
|
||||||
|
"title"
|
||||||
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "student_group",
|
"fieldname": "student_group",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 1,
|
"in_global_search": 1,
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Student Group",
|
"label": "Student Group",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Student Group",
|
"options": "Student Group",
|
||||||
"permlevel": 0,
|
"reqd": 1
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "instructor",
|
"fieldname": "instructor",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Instructor",
|
"label": "Instructor",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Instructor",
|
"options": "Instructor",
|
||||||
"permlevel": 0,
|
"reqd": 1
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"fetch_from": "instructor.instructor_name",
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fetch_from": "instructor.Instructor_name",
|
|
||||||
"fieldname": "instructor_name",
|
"fieldname": "instructor_name",
|
||||||
"fieldtype": "Read Only",
|
"fieldtype": "Read Only",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 1,
|
"in_global_search": 1,
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Instructor Name",
|
"label": "Instructor Name",
|
||||||
"length": 0,
|
"read_only": 1
|
||||||
"no_copy": 0,
|
|
||||||
"options": "",
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 1,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "column_break_2",
|
"fieldname": "column_break_2",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break"
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"default": "",
|
|
||||||
"fieldname": "naming_series",
|
"fieldname": "naming_series",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Naming Series",
|
"label": "Naming Series",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "EDU-CSH-.YYYY.-",
|
"options": "EDU-CSH-.YYYY.-",
|
||||||
"permlevel": 0,
|
"set_only_once": 1
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 1,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "course",
|
"fieldname": "course",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 1,
|
"in_global_search": 1,
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Course",
|
"label": "Course",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Course",
|
"options": "Course",
|
||||||
"permlevel": 0,
|
"reqd": 1
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "color",
|
"fieldname": "color",
|
||||||
"fieldtype": "Color",
|
"fieldtype": "Color",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Color",
|
"label": "Color",
|
||||||
"length": 0,
|
"print_hide": 1
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 1,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "section_break_6",
|
"fieldname": "section_break_6",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break"
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"default": "Today",
|
"default": "Today",
|
||||||
"fieldname": "schedule_date",
|
"fieldname": "schedule_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"hidden": 0,
|
"label": "Schedule Date"
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Schedule Date",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "room",
|
"fieldname": "room",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Room",
|
"label": "Room",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Room",
|
"options": "Room",
|
||||||
"permlevel": 0,
|
"reqd": 1
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "column_break_9",
|
"fieldname": "column_break_9",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break"
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "from_time",
|
"fieldname": "from_time",
|
||||||
"fieldtype": "Time",
|
"fieldtype": "Time",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "From Time",
|
"label": "From Time",
|
||||||
"length": 0,
|
"reqd": 1
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "to_time",
|
"fieldname": "to_time",
|
||||||
"fieldtype": "Time",
|
"fieldtype": "Time",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "To Time",
|
"label": "To Time",
|
||||||
"length": 0,
|
"reqd": 1
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "title",
|
"fieldname": "title",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"ignore_user_permissions": 0,
|
"label": "Title"
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Title",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"links": [],
|
||||||
"hide_heading": 0,
|
"modified": "2021-11-24 11:57:08.164449",
|
||||||
"hide_toolbar": 0,
|
|
||||||
"idx": 0,
|
|
||||||
"image_view": 0,
|
|
||||||
"in_create": 0,
|
|
||||||
"is_submittable": 0,
|
|
||||||
"issingle": 0,
|
|
||||||
"istable": 0,
|
|
||||||
"max_attachments": 0,
|
|
||||||
"menu_index": 0,
|
|
||||||
"modified": "2018-08-21 14:44:51.827225",
|
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Education",
|
"module": "Education",
|
||||||
"name": "Course Schedule",
|
"name": "Course Schedule",
|
||||||
"name_case": "",
|
"naming_rule": "By \"Naming Series\" field",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "Academics User",
|
"role": "Academics User",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"read_only_onload": 0,
|
|
||||||
"restrict_to_domain": "Education",
|
"restrict_to_domain": "Education",
|
||||||
"show_name_in_global_search": 0,
|
|
||||||
"sort_field": "schedule_date",
|
"sort_field": "schedule_date",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"title_field": "title",
|
"title_field": "title"
|
||||||
"track_changes": 0,
|
|
||||||
"track_seen": 0,
|
|
||||||
"track_views": 0
|
|
||||||
}
|
}
|
@ -14,24 +14,36 @@ def get_student_attendance_records(based_on, date=None, student_group=None, cour
|
|||||||
student_list = []
|
student_list = []
|
||||||
student_attendance_list = []
|
student_attendance_list = []
|
||||||
|
|
||||||
if based_on=="Course Schedule":
|
if based_on == "Course Schedule":
|
||||||
student_group = frappe.db.get_value("Course Schedule", course_schedule, "student_group")
|
student_group = frappe.db.get_value("Course Schedule", course_schedule, "student_group")
|
||||||
if student_group:
|
if student_group:
|
||||||
student_list = frappe.get_list("Student Group Student", fields=["student", "student_name", "group_roll_number"] , \
|
student_list = frappe.get_all("Student Group Student", fields=["student", "student_name", "group_roll_number"],
|
||||||
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
|
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
|
||||||
|
|
||||||
if not student_list:
|
if not student_list:
|
||||||
student_list = frappe.get_list("Student Group Student", fields=["student", "student_name", "group_roll_number"] ,
|
student_list = frappe.get_all("Student Group Student", fields=["student", "student_name", "group_roll_number"],
|
||||||
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
|
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
|
||||||
|
|
||||||
|
table = frappe.qb.DocType("Student Attendance")
|
||||||
|
|
||||||
if course_schedule:
|
if course_schedule:
|
||||||
student_attendance_list= frappe.db.sql('''select student, status from `tabStudent Attendance` where \
|
student_attendance_list = (
|
||||||
course_schedule= %s''', (course_schedule), as_dict=1)
|
frappe.qb.from_(table)
|
||||||
|
.select(table.student, table.status)
|
||||||
|
.where(
|
||||||
|
(table.course_schedule == course_schedule)
|
||||||
|
)
|
||||||
|
).run(as_dict=True)
|
||||||
else:
|
else:
|
||||||
student_attendance_list= frappe.db.sql('''select student, status from `tabStudent Attendance` where \
|
student_attendance_list = (
|
||||||
student_group= %s and date= %s and \
|
frappe.qb.from_(table)
|
||||||
(course_schedule is Null or course_schedule='')''',
|
.select(table.student, table.status)
|
||||||
(student_group, date), as_dict=1)
|
.where(
|
||||||
|
(table.student_group == student_group)
|
||||||
|
& (table.date == date)
|
||||||
|
& (table.course_schedule == "") | (table.course_schedule.isnull())
|
||||||
|
)
|
||||||
|
).run(as_dict=True)
|
||||||
|
|
||||||
for attendance in student_attendance_list:
|
for attendance in student_attendance_list:
|
||||||
for student in student_list:
|
for student in student_list:
|
||||||
|
@ -238,6 +238,12 @@ frappe.ui.form.on('Production Plan', {
|
|||||||
method: "get_items",
|
method: "get_items",
|
||||||
freeze: true,
|
freeze: true,
|
||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
|
callback: function() {
|
||||||
|
frm.refresh_field("po_items");
|
||||||
|
if (frm.doc.sub_assembly_items.length > 0) {
|
||||||
|
frm.trigger("get_sub_assembly_items");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ frappe.ui.form.on("Work Order", {
|
|||||||
additional_operating_cost: function(frm) {
|
additional_operating_cost: function(frm) {
|
||||||
erpnext.work_order.calculate_cost(frm.doc);
|
erpnext.work_order.calculate_cost(frm.doc);
|
||||||
erpnext.work_order.calculate_total_cost(frm);
|
erpnext.work_order.calculate_total_cost(frm);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Work Order Item", {
|
frappe.ui.form.on("Work Order Item", {
|
||||||
|
@ -326,6 +326,7 @@
|
|||||||
"label": "Expected Delivery Date"
|
"label": "Expected Delivery Date"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"collapsible": 1,
|
||||||
"fieldname": "operations_section",
|
"fieldname": "operations_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Operations",
|
"label": "Operations",
|
||||||
@ -337,7 +338,7 @@
|
|||||||
"fieldname": "transfer_material_against",
|
"fieldname": "transfer_material_against",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Transfer Material Against",
|
"label": "Transfer Material Against",
|
||||||
"options": "\nWork Order\nJob Card"
|
"options": "Work Order\nJob Card"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "operations",
|
"fieldname": "operations",
|
||||||
@ -573,8 +574,7 @@
|
|||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"migration_hash": "a18118963f4fcdb7f9d326de5f4063ba",
|
"modified": "2021-11-08 17:36:07.016300",
|
||||||
"modified": "2021-10-29 15:12:32.203605",
|
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Work Order",
|
"name": "Work Order",
|
||||||
|
@ -6,27 +6,27 @@
|
|||||||
"field_order": [
|
"field_order": [
|
||||||
"details",
|
"details",
|
||||||
"operation",
|
"operation",
|
||||||
"bom",
|
|
||||||
"column_break_4",
|
|
||||||
"description",
|
|
||||||
"sequence_id",
|
|
||||||
"col_break1",
|
|
||||||
"completed_qty",
|
|
||||||
"status",
|
"status",
|
||||||
|
"completed_qty",
|
||||||
|
"column_break_4",
|
||||||
|
"bom",
|
||||||
"workstation",
|
"workstation",
|
||||||
|
"sequence_id",
|
||||||
|
"section_break_10",
|
||||||
|
"description",
|
||||||
"estimated_time_and_cost",
|
"estimated_time_and_cost",
|
||||||
"planned_start_time",
|
"planned_start_time",
|
||||||
"planned_end_time",
|
|
||||||
"column_break_10",
|
|
||||||
"time_in_mins",
|
|
||||||
"hour_rate",
|
"hour_rate",
|
||||||
|
"time_in_mins",
|
||||||
|
"column_break_10",
|
||||||
|
"planned_end_time",
|
||||||
"batch_size",
|
"batch_size",
|
||||||
"planned_operating_cost",
|
"planned_operating_cost",
|
||||||
"section_break_9",
|
"section_break_9",
|
||||||
"actual_start_time",
|
"actual_start_time",
|
||||||
"actual_end_time",
|
|
||||||
"column_break_11",
|
|
||||||
"actual_operation_time",
|
"actual_operation_time",
|
||||||
|
"column_break_11",
|
||||||
|
"actual_end_time",
|
||||||
"actual_operating_cost"
|
"actual_operating_cost"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
@ -42,7 +42,6 @@
|
|||||||
"oldfieldname": "operation_no",
|
"oldfieldname": "operation_no",
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"options": "Operation",
|
"options": "Operation",
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -52,20 +51,14 @@
|
|||||||
"label": "BOM",
|
"label": "BOM",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "BOM",
|
"options": "BOM",
|
||||||
"print_hide": 1,
|
"print_hide": 1
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "description",
|
"fieldname": "description",
|
||||||
"fieldtype": "Text Editor",
|
"fieldtype": "Text Editor",
|
||||||
"label": "Operation Description",
|
"label": "Operation Description",
|
||||||
"oldfieldname": "opn_description",
|
"oldfieldname": "opn_description",
|
||||||
"oldfieldtype": "Text",
|
"oldfieldtype": "Text"
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "col_break1",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": 1,
|
"columns": 1,
|
||||||
@ -74,19 +67,16 @@
|
|||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Completed Qty",
|
"label": "Completed Qty",
|
||||||
"no_copy": 1,
|
"no_copy": 1
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": 1,
|
"columns": 1,
|
||||||
"default": "Pending",
|
"default": "Pending",
|
||||||
"fieldname": "status",
|
"fieldname": "status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Pending\nWork in Progress\nCompleted",
|
"options": "Pending\nWork in Progress\nCompleted"
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "workstation",
|
"fieldname": "workstation",
|
||||||
@ -106,15 +96,13 @@
|
|||||||
"fieldname": "planned_start_time",
|
"fieldname": "planned_start_time",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"label": "Planned Start Time",
|
"label": "Planned Start Time",
|
||||||
"no_copy": 1,
|
"no_copy": 1
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "planned_end_time",
|
"fieldname": "planned_end_time",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"label": "Planned End Time",
|
"label": "Planned End Time",
|
||||||
"no_copy": 1,
|
"no_copy": 1
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_10",
|
"fieldname": "column_break_10",
|
||||||
@ -122,7 +110,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": 1,
|
"columns": 1,
|
||||||
"description": "in Minutes",
|
"description": "In Minutes",
|
||||||
"fieldname": "time_in_mins",
|
"fieldname": "time_in_mins",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
@ -152,6 +140,7 @@
|
|||||||
"label": "Actual Time and Cost"
|
"label": "Actual Time and Cost"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"description": "Updated via 'Time Log' (In Minutes)",
|
||||||
"fieldname": "actual_start_time",
|
"fieldname": "actual_start_time",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"label": "Actual Start Time",
|
"label": "Actual Start Time",
|
||||||
@ -159,7 +148,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Updated via 'Time Log'",
|
"description": "Updated via 'Time Log' (In Minutes)",
|
||||||
"fieldname": "actual_end_time",
|
"fieldname": "actual_end_time",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"label": "Actual End Time",
|
"label": "Actual End Time",
|
||||||
@ -171,7 +160,7 @@
|
|||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "in Minutes\nUpdated via 'Time Log'",
|
"description": "Updated via 'Time Log' (In Minutes)",
|
||||||
"fieldname": "actual_operation_time",
|
"fieldname": "actual_operation_time",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Actual Operation Time",
|
"label": "Actual Operation Time",
|
||||||
@ -190,25 +179,28 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "batch_size",
|
"fieldname": "batch_size",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Batch Size",
|
"label": "Batch Size"
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "sequence_id",
|
"fieldname": "sequence_id",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
|
"hidden": 1,
|
||||||
"label": "Sequence ID",
|
"label": "Sequence ID",
|
||||||
"print_hide": 1,
|
"print_hide": 1
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_4",
|
"fieldname": "column_break_4",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_10",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-24 14:36:12.835543",
|
"modified": "2021-11-24 04:52:54.295168",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Work Order Operation",
|
"name": "Work Order Operation",
|
||||||
@ -217,4 +209,4 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
@ -30,7 +29,6 @@ def get_data(report_filters):
|
|||||||
|
|
||||||
for row in job_cards:
|
for row in job_cards:
|
||||||
row.operating_cost = flt(row.hour_rate) * (flt(row.total_time_in_mins) / 60.0)
|
row.operating_cost = flt(row.hour_rate) * (flt(row.total_time_in_mins) / 60.0)
|
||||||
update_raw_material_cost(row, report_filters)
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -46,12 +44,6 @@ def get_filters(report_filters, operations):
|
|||||||
|
|
||||||
return filters
|
return filters
|
||||||
|
|
||||||
def update_raw_material_cost(row, filters):
|
|
||||||
row.rm_cost = 0.0
|
|
||||||
for data in frappe.get_all("Job Card Item", fields = ["amount"],
|
|
||||||
filters={"parent": row.name, "docstatus": 1}):
|
|
||||||
row.rm_cost += data.amount
|
|
||||||
|
|
||||||
def get_columns(filters):
|
def get_columns(filters):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -59,7 +51,7 @@ def get_columns(filters):
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"fieldname": "name",
|
"fieldname": "name",
|
||||||
"options": "Job Card",
|
"options": "Job Card",
|
||||||
"width": "100"
|
"width": "120"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Work Order"),
|
"label": _("Work Order"),
|
||||||
@ -111,18 +103,12 @@ def get_columns(filters):
|
|||||||
"label": _("Operating Cost"),
|
"label": _("Operating Cost"),
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"fieldname": "operating_cost",
|
"fieldname": "operating_cost",
|
||||||
"width": "100"
|
"width": "150"
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Raw Material Cost"),
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"fieldname": "rm_cost",
|
|
||||||
"width": "100"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Total Time (in Mins)"),
|
"label": _("Total Time (in Mins)"),
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"fieldname": "total_time_in_mins",
|
"fieldname": "total_time_in_mins",
|
||||||
"width": "100"
|
"width": "150"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -7,6 +7,7 @@ import frappe
|
|||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doc("setup", "doctype", "target_detail")
|
frappe.reload_doc("setup", "doctype", "target_detail")
|
||||||
|
frappe.reload_doc("core", "doctype", "prepared_report")
|
||||||
|
|
||||||
for d in ['Sales Person', 'Sales Partner', 'Territory']:
|
for d in ['Sales Person', 'Sales Partner', 'Territory']:
|
||||||
frappe.db.sql("""
|
frappe.db.sql("""
|
||||||
|
@ -193,7 +193,7 @@ def get_total_applicable_component_amount(employee, applicable_earnings_componen
|
|||||||
sal_slip = get_last_salary_slip(employee)
|
sal_slip = get_last_salary_slip(employee)
|
||||||
if not sal_slip:
|
if not sal_slip:
|
||||||
frappe.throw(_("No Salary Slip is found for Employee: {0}").format(bold(employee)))
|
frappe.throw(_("No Salary Slip is found for Employee: {0}").format(bold(employee)))
|
||||||
component_and_amounts = frappe.get_list("Salary Detail",
|
component_and_amounts = frappe.get_all("Salary Detail",
|
||||||
filters={
|
filters={
|
||||||
"docstatus": 1,
|
"docstatus": 1,
|
||||||
'parent': sal_slip,
|
'parent': sal_slip,
|
||||||
|
@ -48,7 +48,7 @@ class TestGratuity(unittest.TestCase):
|
|||||||
self.assertEqual(floor(experience), gratuity.current_work_experience)
|
self.assertEqual(floor(experience), gratuity.current_work_experience)
|
||||||
|
|
||||||
#amount Calculation
|
#amount Calculation
|
||||||
component_amount = frappe.get_list("Salary Detail",
|
component_amount = frappe.get_all("Salary Detail",
|
||||||
filters={
|
filters={
|
||||||
"docstatus": 1,
|
"docstatus": 1,
|
||||||
'parent': sal_slip,
|
'parent': sal_slip,
|
||||||
@ -84,7 +84,7 @@ class TestGratuity(unittest.TestCase):
|
|||||||
self.assertEqual(floor(experience), gratuity.current_work_experience)
|
self.assertEqual(floor(experience), gratuity.current_work_experience)
|
||||||
|
|
||||||
#amount Calculation
|
#amount Calculation
|
||||||
component_amount = frappe.get_list("Salary Detail",
|
component_amount = frappe.get_all("Salary Detail",
|
||||||
filters={
|
filters={
|
||||||
"docstatus": 1,
|
"docstatus": 1,
|
||||||
'parent': sal_slip,
|
'parent': sal_slip,
|
||||||
|
@ -18,7 +18,11 @@ from frappe.model.rename_doc import update_linked_doctypes
|
|||||||
from frappe.utils import cint, cstr, flt, get_formatted_email, today
|
from frappe.utils import cint, cstr, flt, get_formatted_email, today
|
||||||
from frappe.utils.user import get_users_with_role
|
from frappe.utils.user import get_users_with_role
|
||||||
|
|
||||||
from erpnext.accounts.party import get_dashboard_info, validate_party_accounts
|
from erpnext.accounts.party import ( # noqa
|
||||||
|
get_dashboard_info,
|
||||||
|
get_timeline_data,
|
||||||
|
validate_party_accounts,
|
||||||
|
)
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Queued\nIn Progress\nCompleted\nFailed",
|
"options": "Queued\nIn Progress\nCompleted\nSkipped\nFailed",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -177,7 +177,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-11-18 02:18:10.524560",
|
"modified": "2021-11-24 02:18:10.524560",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Repost Item Valuation",
|
"name": "Repost Item Valuation",
|
||||||
@ -228,4 +228,4 @@
|
|||||||
],
|
],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
@ -19,7 +18,7 @@ from erpnext.stock.stock_ledger import repost_future_sle
|
|||||||
|
|
||||||
class RepostItemValuation(Document):
|
class RepostItemValuation(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_status()
|
self.set_status(write=False)
|
||||||
self.reset_field_values()
|
self.reset_field_values()
|
||||||
self.set_company()
|
self.set_company()
|
||||||
|
|
||||||
@ -27,26 +26,27 @@ class RepostItemValuation(Document):
|
|||||||
if self.based_on == 'Transaction':
|
if self.based_on == 'Transaction':
|
||||||
self.item_code = None
|
self.item_code = None
|
||||||
self.warehouse = None
|
self.warehouse = None
|
||||||
else:
|
|
||||||
self.voucher_type = None
|
|
||||||
self.voucher_no = None
|
|
||||||
|
|
||||||
self.allow_negative_stock = self.allow_negative_stock or \
|
self.allow_negative_stock = self.allow_negative_stock or \
|
||||||
cint(frappe.db.get_single_value("Stock Settings", "allow_negative_stock"))
|
cint(frappe.db.get_single_value("Stock Settings", "allow_negative_stock"))
|
||||||
|
|
||||||
def set_company(self):
|
def set_company(self):
|
||||||
if self.voucher_type and self.voucher_no:
|
if self.based_on == "Transaction":
|
||||||
self.company = frappe.get_cached_value(self.voucher_type, self.voucher_no, "company")
|
self.company = frappe.get_cached_value(self.voucher_type, self.voucher_no, "company")
|
||||||
elif self.warehouse:
|
elif self.warehouse:
|
||||||
self.company = frappe.get_cached_value("Warehouse", self.warehouse, "company")
|
self.company = frappe.get_cached_value("Warehouse", self.warehouse, "company")
|
||||||
|
|
||||||
def set_status(self, status=None):
|
def set_status(self, status=None, write=True):
|
||||||
|
status = status or self.status
|
||||||
if not status:
|
if not status:
|
||||||
status = 'Queued'
|
self.status = 'Queued'
|
||||||
self.db_set('status', status)
|
else:
|
||||||
|
self.status = status
|
||||||
|
if write:
|
||||||
|
self.db_set('status', self.status)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if not frappe.flags.in_test:
|
if not frappe.flags.in_test or self.flags.dont_run_in_test:
|
||||||
return
|
return
|
||||||
|
|
||||||
frappe.enqueue(repost, timeout=1800, queue='long',
|
frappe.enqueue(repost, timeout=1800, queue='long',
|
||||||
@ -58,6 +58,37 @@ class RepostItemValuation(Document):
|
|||||||
frappe.enqueue(repost, timeout=1800, queue='long',
|
frappe.enqueue(repost, timeout=1800, queue='long',
|
||||||
job_name='repost_sle', now=True, doc=self)
|
job_name='repost_sle', now=True, doc=self)
|
||||||
|
|
||||||
|
def deduplicate_similar_repost(self):
|
||||||
|
""" Deduplicate similar reposts based on item-warehouse-posting combination."""
|
||||||
|
if self.based_on != "Item and Warehouse":
|
||||||
|
return
|
||||||
|
|
||||||
|
filters = {
|
||||||
|
"item_code": self.item_code,
|
||||||
|
"warehouse": self.warehouse,
|
||||||
|
"name": self.name,
|
||||||
|
"posting_date": self.posting_date,
|
||||||
|
"posting_time": self.posting_time,
|
||||||
|
}
|
||||||
|
|
||||||
|
frappe.db.sql("""
|
||||||
|
update `tabRepost Item Valuation`
|
||||||
|
set status = 'Skipped'
|
||||||
|
WHERE item_code = %(item_code)s
|
||||||
|
and warehouse = %(warehouse)s
|
||||||
|
and name != %(name)s
|
||||||
|
and TIMESTAMP(posting_date, posting_time) > TIMESTAMP(%(posting_date)s, %(posting_time)s)
|
||||||
|
and docstatus = 1
|
||||||
|
and status = 'Queued'
|
||||||
|
and based_on = 'Item and Warehouse'
|
||||||
|
""",
|
||||||
|
filters
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_doctype_update():
|
||||||
|
frappe.db.add_index("Repost Item Valuation", ["warehouse", "item_code"], "item_warehouse")
|
||||||
|
|
||||||
|
|
||||||
def repost(doc):
|
def repost(doc):
|
||||||
try:
|
try:
|
||||||
if not frappe.db.exists("Repost Item Valuation", doc.name):
|
if not frappe.db.exists("Repost Item Valuation", doc.name):
|
||||||
@ -134,7 +165,9 @@ def repost_entries():
|
|||||||
|
|
||||||
for row in riv_entries:
|
for row in riv_entries:
|
||||||
doc = frappe.get_doc('Repost Item Valuation', row.name)
|
doc = frappe.get_doc('Repost Item Valuation', row.name)
|
||||||
repost(doc)
|
if doc.status in ('Queued', 'In Progress'):
|
||||||
|
doc.deduplicate_similar_repost()
|
||||||
|
repost(doc)
|
||||||
|
|
||||||
riv_entries = get_repost_item_valuation_entries()
|
riv_entries = get_repost_item_valuation_entries()
|
||||||
if riv_entries:
|
if riv_entries:
|
||||||
|
@ -5,6 +5,8 @@ import unittest
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
|
from erpnext.controllers.stock_controller import create_item_wise_repost_entries
|
||||||
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt
|
||||||
from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation import (
|
from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation import (
|
||||||
in_configured_timeslot,
|
in_configured_timeslot,
|
||||||
)
|
)
|
||||||
@ -70,3 +72,69 @@ class TestRepostItemValuation(unittest.TestCase):
|
|||||||
in_configured_timeslot(repost_settings, case.get("current_time")),
|
in_configured_timeslot(repost_settings, case.get("current_time")),
|
||||||
msg=f"Exepcted false from : {case}",
|
msg=f"Exepcted false from : {case}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_create_item_wise_repost_item_valuation_entries(self):
|
||||||
|
pr = make_purchase_receipt(
|
||||||
|
company="_Test Company with perpetual inventory",
|
||||||
|
warehouse="Stores - TCP1",
|
||||||
|
get_multiple_items=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
rivs = create_item_wise_repost_entries(pr.doctype, pr.name)
|
||||||
|
self.assertGreaterEqual(len(rivs), 2)
|
||||||
|
self.assertIn("_Test Item", [d.item_code for d in rivs])
|
||||||
|
|
||||||
|
for riv in rivs:
|
||||||
|
self.assertEqual(riv.company, "_Test Company with perpetual inventory")
|
||||||
|
self.assertEqual(riv.warehouse, "Stores - TCP1")
|
||||||
|
|
||||||
|
def test_deduplication(self):
|
||||||
|
def _assert_status(doc, status):
|
||||||
|
doc.load_from_db()
|
||||||
|
self.assertEqual(doc.status, status)
|
||||||
|
|
||||||
|
riv_args = frappe._dict(
|
||||||
|
doctype="Repost Item Valuation",
|
||||||
|
item_code="_Test Item",
|
||||||
|
warehouse="_Test Warehouse - _TC",
|
||||||
|
based_on="Item and Warehouse",
|
||||||
|
voucher_type="Sales Invoice",
|
||||||
|
voucher_no="SI-1",
|
||||||
|
posting_date="2021-01-02",
|
||||||
|
posting_time="00:01:00",
|
||||||
|
)
|
||||||
|
|
||||||
|
# new repost without any duplicates
|
||||||
|
riv1 = frappe.get_doc(riv_args)
|
||||||
|
riv1.flags.dont_run_in_test = True
|
||||||
|
riv1.submit()
|
||||||
|
_assert_status(riv1, "Queued")
|
||||||
|
self.assertEqual(riv1.voucher_type, "Sales Invoice") # traceability
|
||||||
|
self.assertEqual(riv1.voucher_no, "SI-1")
|
||||||
|
|
||||||
|
# newer than existing duplicate - riv1
|
||||||
|
riv2 = frappe.get_doc(riv_args.update({"posting_date": "2021-01-03"}))
|
||||||
|
riv2.flags.dont_run_in_test = True
|
||||||
|
riv2.submit()
|
||||||
|
riv1.deduplicate_similar_repost()
|
||||||
|
_assert_status(riv2, "Skipped")
|
||||||
|
|
||||||
|
# older than exisitng duplicate - riv1
|
||||||
|
riv3 = frappe.get_doc(riv_args.update({"posting_date": "2021-01-01"}))
|
||||||
|
riv3.flags.dont_run_in_test = True
|
||||||
|
riv3.submit()
|
||||||
|
riv3.deduplicate_similar_repost()
|
||||||
|
_assert_status(riv3, "Queued")
|
||||||
|
_assert_status(riv1, "Skipped")
|
||||||
|
|
||||||
|
# unrelated reposts, shouldn't do anything to others.
|
||||||
|
riv4 = frappe.get_doc(riv_args.update({"warehouse": "Stores - _TC"}))
|
||||||
|
riv4.flags.dont_run_in_test = True
|
||||||
|
riv4.submit()
|
||||||
|
riv4.deduplicate_similar_repost()
|
||||||
|
_assert_status(riv4, "Queued")
|
||||||
|
_assert_status(riv3, "Queued")
|
||||||
|
|
||||||
|
# to avoid breaking other tests accidentaly
|
||||||
|
riv4.set_status("Skipped")
|
||||||
|
riv3.set_status("Skipped")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
|
"beta": 1,
|
||||||
"creation": "2021-10-01 10:56:30.814787",
|
"creation": "2021-10-01 10:56:30.814787",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
@ -10,7 +11,8 @@
|
|||||||
"limit_reposting_timeslot",
|
"limit_reposting_timeslot",
|
||||||
"start_time",
|
"start_time",
|
||||||
"end_time",
|
"end_time",
|
||||||
"limits_dont_apply_on"
|
"limits_dont_apply_on",
|
||||||
|
"item_based_reposting"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@ -44,12 +46,18 @@
|
|||||||
"fieldname": "limit_reposting_timeslot",
|
"fieldname": "limit_reposting_timeslot",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Limit timeslot for Stock Reposting"
|
"label": "Limit timeslot for Stock Reposting"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "item_based_reposting",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Use Item based reposting"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-10-01 11:27:28.981594",
|
"modified": "2021-11-02 01:22:45.155841",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Reposting Settings",
|
"name": "Stock Reposting Settings",
|
||||||
|
@ -10,23 +10,8 @@ frappe.query_reports["Total Stock Summary"] = {
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"width": "80",
|
"width": "80",
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"options": ["", "Warehouse", "Company"],
|
"options": ["Warehouse", "Company"],
|
||||||
"change": function() {
|
"default": "Warehouse",
|
||||||
let group_by = frappe.query_report.get_filter_value("group_by")
|
|
||||||
let company_filter = frappe.query_report.get_filter("company")
|
|
||||||
if (group_by == "Company") {
|
|
||||||
company_filter.df.reqd = 0;
|
|
||||||
company_filter.df.hidden = 1;
|
|
||||||
frappe.query_report.set_filter_value("company", "");
|
|
||||||
company_filter.refresh();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
company_filter.df.reqd = 1;
|
|
||||||
company_filter.df.hidden = 0;
|
|
||||||
company_filter.refresh();
|
|
||||||
frappe.query_report.refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "company",
|
"fieldname": "company",
|
||||||
@ -34,8 +19,9 @@ frappe.query_reports["Total Stock Summary"] = {
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"width": "80",
|
"width": "80",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
|
"reqd": 1,
|
||||||
"default": frappe.defaults.get_user_default("Company"),
|
"default": frappe.defaults.get_user_default("Company"),
|
||||||
"reqd": 1
|
"depends_on": "eval: doc.group_by != 'Company'",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@ from frappe import _
|
|||||||
|
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
|
||||||
validate_filters(filters)
|
if not filters:
|
||||||
|
filters = {}
|
||||||
columns = get_columns()
|
columns = get_columns()
|
||||||
stock = get_total_stock(filters)
|
stock = get_total_stock(filters)
|
||||||
|
|
||||||
@ -53,9 +54,3 @@ def get_total_stock(filters):
|
|||||||
ON warehouse.name = ledger.warehouse
|
ON warehouse.name = ledger.warehouse
|
||||||
WHERE
|
WHERE
|
||||||
ledger.actual_qty != 0 %s""" % (columns, conditions))
|
ledger.actual_qty != 0 %s""" % (columns, conditions))
|
||||||
|
|
||||||
def validate_filters(filters):
|
|
||||||
if filters.get("group_by") == 'Company' and \
|
|
||||||
filters.get("company"):
|
|
||||||
|
|
||||||
frappe.throw(_("Please set Company filter blank if Group By is 'Company'"))
|
|
||||||
|
@ -46,8 +46,8 @@ def execute(filters=None):
|
|||||||
item_balance.setdefault((item, item_map[item]["item_group"]), [])
|
item_balance.setdefault((item, item_map[item]["item_group"]), [])
|
||||||
total_stock_value = 0.00
|
total_stock_value = 0.00
|
||||||
for wh in warehouse_list:
|
for wh in warehouse_list:
|
||||||
row += [qty_dict.bal_qty] if wh.name in warehouse else [0.00]
|
row += [qty_dict.bal_qty] if wh.name == warehouse else [0.00]
|
||||||
total_stock_value += qty_dict.bal_val if wh.name in warehouse else 0.00
|
total_stock_value += qty_dict.bal_val if wh.name == warehouse else 0.00
|
||||||
|
|
||||||
item_balance[(item, item_map[item]["item_group"])].append(row)
|
item_balance[(item, item_map[item]["item_group"])].append(row)
|
||||||
item_value.setdefault((item, item_map[item]["item_group"]),[])
|
item_value.setdefault((item, item_map[item]["item_group"]),[])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user