Merge branch 'develop' into so-to-wo-bom
This commit is contained in:
commit
fafdaff4d4
@ -1444,7 +1444,7 @@ def get_negative_outstanding_invoices(
|
||||
voucher_type = "Sales Invoice" if party_type == "Customer" else "Purchase Invoice"
|
||||
supplier_condition = ""
|
||||
if voucher_type == "Purchase Invoice":
|
||||
supplier_condition = "and (release_date is null or release_date <= CURDATE())"
|
||||
supplier_condition = "and (release_date is null or release_date <= CURRENT_DATE)"
|
||||
if party_account_currency == company_currency:
|
||||
grand_total_field = "base_grand_total"
|
||||
rounded_total_field = "base_rounded_total"
|
||||
|
@ -100,7 +100,7 @@ def get_sales_details(filters):
|
||||
sales_data = frappe.db.sql(
|
||||
"""
|
||||
select s.territory, s.customer, si.item_group, si.item_code, si.qty, {date_field} as last_order_date,
|
||||
DATEDIFF(CURDATE(), {date_field}) as days_since_last_order
|
||||
DATEDIFF(CURRENT_DATE, {date_field}) as days_since_last_order
|
||||
from `tab{doctype}` s, `tab{doctype} Item` si
|
||||
where s.name = si.parent and s.docstatus = 1
|
||||
order by days_since_last_order """.format( # nosec
|
||||
|
@ -330,7 +330,7 @@ class TestPurchaseOrder(FrappeTestCase):
|
||||
else:
|
||||
# update valid from
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabItem Tax` set valid_from = CURDATE()
|
||||
"""UPDATE `tabItem Tax` set valid_from = CURRENT_DATE
|
||||
where parent = %(item)s and item_tax_template = %(tax)s""",
|
||||
{"item": item, "tax": tax_template},
|
||||
)
|
||||
|
@ -691,7 +691,7 @@ def get_doctype_wise_filters(filters):
|
||||
def get_batch_numbers(doctype, txt, searchfield, start, page_len, filters):
|
||||
query = """select batch_id from `tabBatch`
|
||||
where disabled = 0
|
||||
and (expiry_date >= CURDATE() or expiry_date IS NULL)
|
||||
and (expiry_date >= CURRENT_DATE or expiry_date IS NULL)
|
||||
and name like {txt}""".format(
|
||||
txt=frappe.db.escape("%{0}%".format(txt))
|
||||
)
|
||||
|
@ -8,7 +8,8 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.email.inbox import link_communication_to_document
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.query_builder import DocType
|
||||
from frappe.query_builder import DocType, Interval
|
||||
from frappe.query_builder.functions import Now
|
||||
from frappe.utils import cint, flt, get_fullname
|
||||
|
||||
from erpnext.crm.utils import add_link_in_communication, copy_comments
|
||||
@ -398,15 +399,17 @@ def auto_close_opportunity():
|
||||
frappe.db.get_single_value("CRM Settings", "close_opportunity_after_days") or 15
|
||||
)
|
||||
|
||||
opportunities = frappe.db.sql(
|
||||
""" select name from tabOpportunity where status='Replied' and
|
||||
modified<DATE_SUB(CURDATE(), INTERVAL %s DAY) """,
|
||||
(auto_close_after_days),
|
||||
as_dict=True,
|
||||
)
|
||||
table = frappe.qb.DocType("Opportunity")
|
||||
opportunities = (
|
||||
frappe.qb.from_(table)
|
||||
.select(table.name)
|
||||
.where(
|
||||
(table.modified < (Now() - Interval(days=auto_close_after_days))) & (table.status == "Replied")
|
||||
)
|
||||
).run(pluck=True)
|
||||
|
||||
for opportunity in opportunities:
|
||||
doc = frappe.get_doc("Opportunity", opportunity.get("name"))
|
||||
doc = frappe.get_doc("Opportunity", opportunity)
|
||||
doc.status = "Closed"
|
||||
doc.flags.ignore_permissions = True
|
||||
doc.flags.ignore_mandatory = True
|
||||
|
@ -216,7 +216,7 @@ def make_payment_entry(advance):
|
||||
def make_employee_advance(employee_name, args=None):
|
||||
doc = frappe.new_doc("Employee Advance")
|
||||
doc.employee = employee_name
|
||||
doc.company = "_Test company"
|
||||
doc.company = "_Test Company"
|
||||
doc.purpose = "For site visit"
|
||||
doc.currency = erpnext.get_company_currency("_Test company")
|
||||
doc.exchange_rate = 1
|
||||
|
@ -28,7 +28,7 @@ def daily_reminder():
|
||||
for drafts in draft:
|
||||
number_of_drafts = drafts[0]
|
||||
update = frappe.db.sql(
|
||||
"""SELECT name,date,time,progress,progress_details FROM `tabProject Update` WHERE `tabProject Update`.project = %s AND date = DATE_ADD(CURDATE(), INTERVAL -1 DAY);""",
|
||||
"""SELECT name,date,time,progress,progress_details FROM `tabProject Update` WHERE `tabProject Update`.project = %s AND date = DATE_ADD(CURRENT_DATE, INTERVAL -1 DAY);""",
|
||||
project_name,
|
||||
)
|
||||
email_sending(project_name, frequency, date_start, date_end, progress, number_of_drafts, update)
|
||||
@ -39,7 +39,7 @@ def email_sending(
|
||||
):
|
||||
|
||||
holiday = frappe.db.sql(
|
||||
"""SELECT holiday_date FROM `tabHoliday` where holiday_date = CURDATE();"""
|
||||
"""SELECT holiday_date FROM `tabHoliday` where holiday_date = CURRENT_DATE;"""
|
||||
)
|
||||
msg = (
|
||||
"<p>Project Name: "
|
||||
|
@ -296,7 +296,7 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.quotaion_to=='Customer' && doc.party_name",
|
||||
"depends_on": "eval:doc.quotation_to=='Customer' && doc.party_name",
|
||||
"fieldname": "col_break98",
|
||||
"fieldtype": "Column Break",
|
||||
"width": "50%"
|
||||
@ -316,7 +316,7 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.quotaion_to=='Customer' && doc.party_name",
|
||||
"depends_on": "eval:doc.quotation_to=='Customer' && doc.party_name",
|
||||
"fieldname": "customer_group",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
@ -1084,4 +1084,4 @@
|
||||
"states": [],
|
||||
"timeline_field": "party_name",
|
||||
"title_field": "title"
|
||||
}
|
||||
}
|
||||
|
@ -644,7 +644,7 @@ class TestSalesOrder(FrappeTestCase):
|
||||
else:
|
||||
# update valid from
|
||||
frappe.db.sql(
|
||||
"""UPDATE `tabItem Tax` set valid_from = CURDATE()
|
||||
"""UPDATE `tabItem Tax` set valid_from = CURRENT_DATE
|
||||
where parent = %(item)s and item_tax_template = %(tax)s""",
|
||||
{"item": item, "tax": tax_template},
|
||||
)
|
||||
|
@ -31,13 +31,13 @@ def execute(filters=None):
|
||||
def get_sales_details(doctype):
|
||||
cond = """sum(so.base_net_total) as 'total_order_considered',
|
||||
max(so.posting_date) as 'last_order_date',
|
||||
DATEDIFF(CURDATE(), max(so.posting_date)) as 'days_since_last_order' """
|
||||
DATEDIFF(CURRENT_DATE, max(so.posting_date)) as 'days_since_last_order' """
|
||||
if doctype == "Sales Order":
|
||||
cond = """sum(if(so.status = "Stopped",
|
||||
so.base_net_total * so.per_delivered/100,
|
||||
so.base_net_total)) as 'total_order_considered',
|
||||
max(so.transaction_date) as 'last_order_date',
|
||||
DATEDIFF(CURDATE(), max(so.transaction_date)) as 'days_since_last_order'"""
|
||||
DATEDIFF(CURRENT_DATE, max(so.transaction_date)) as 'days_since_last_order'"""
|
||||
|
||||
return frappe.db.sql(
|
||||
"""select
|
||||
|
@ -64,7 +64,7 @@ def get_data(conditions, filters):
|
||||
soi.delivery_date as delivery_date,
|
||||
so.name as sales_order,
|
||||
so.status, so.customer, soi.item_code,
|
||||
DATEDIFF(CURDATE(), soi.delivery_date) as delay_days,
|
||||
DATEDIFF(CURRENT_DATE, soi.delivery_date) as delay_days,
|
||||
IF(so.status in ('Completed','To Bill'), 0, (SELECT delay_days)) as delay,
|
||||
soi.qty, soi.delivered_qty,
|
||||
(soi.qty - soi.delivered_qty) AS pending_qty,
|
||||
|
@ -854,7 +854,7 @@ class EmailDigest(Document):
|
||||
|
||||
sql_po = """select {fields} from `tabPurchase Order Item`
|
||||
left join `tabPurchase Order` on `tabPurchase Order`.name = `tabPurchase Order Item`.parent
|
||||
where status<>'Closed' and `tabPurchase Order Item`.docstatus=1 and curdate() > `tabPurchase Order Item`.schedule_date
|
||||
where status<>'Closed' and `tabPurchase Order Item`.docstatus=1 and CURRENT_DATE > `tabPurchase Order Item`.schedule_date
|
||||
and received_qty < qty order by `tabPurchase Order Item`.parent DESC,
|
||||
`tabPurchase Order Item`.schedule_date DESC""".format(
|
||||
fields=fields_po
|
||||
@ -862,7 +862,7 @@ class EmailDigest(Document):
|
||||
|
||||
sql_poi = """select {fields} from `tabPurchase Order Item`
|
||||
left join `tabPurchase Order` on `tabPurchase Order`.name = `tabPurchase Order Item`.parent
|
||||
where status<>'Closed' and `tabPurchase Order Item`.docstatus=1 and curdate() > `tabPurchase Order Item`.schedule_date
|
||||
where status<>'Closed' and `tabPurchase Order Item`.docstatus=1 and CURRENT_DATE > `tabPurchase Order Item`.schedule_date
|
||||
and received_qty < qty order by `tabPurchase Order Item`.idx""".format(
|
||||
fields=fields_poi
|
||||
)
|
||||
|
@ -335,7 +335,7 @@ def get_batches(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
||||
on (`tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no )
|
||||
where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s
|
||||
and `tabStock Ledger Entry`.is_cancelled = 0
|
||||
and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL) {0}
|
||||
and (`tabBatch`.expiry_date >= CURRENT_DATE or `tabBatch`.expiry_date IS NULL) {0}
|
||||
group by batch_id
|
||||
order by `tabBatch`.expiry_date ASC, `tabBatch`.creation ASC
|
||||
""".format(
|
||||
|
@ -24,7 +24,7 @@ class TestLandedCostVoucher(FrappeTestCase):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
get_multiple_items=True,
|
||||
get_taxes_and_charges=True,
|
||||
)
|
||||
@ -195,7 +195,7 @@ class TestLandedCostVoucher(FrappeTestCase):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
get_multiple_items=True,
|
||||
get_taxes_and_charges=True,
|
||||
do_not_submit=True,
|
||||
@ -280,7 +280,7 @@ class TestLandedCostVoucher(FrappeTestCase):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
do_not_save=True,
|
||||
)
|
||||
pr.items[0].cost_center = "Main - TCP1"
|
||||
|
@ -276,7 +276,7 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
get_multiple_items=True,
|
||||
get_taxes_and_charges=True,
|
||||
)
|
||||
@ -486,13 +486,13 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
)
|
||||
|
||||
return_pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
is_return=1,
|
||||
return_against=pr.name,
|
||||
qty=-2,
|
||||
@ -573,13 +573,13 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
)
|
||||
|
||||
return_pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
is_return=1,
|
||||
return_against=pr.name,
|
||||
qty=-5,
|
||||
@ -615,7 +615,7 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
qty=2,
|
||||
rejected_qty=2,
|
||||
rejected_warehouse=rejected_warehouse,
|
||||
@ -624,7 +624,7 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
return_pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
is_return=1,
|
||||
return_against=pr.name,
|
||||
qty=-2,
|
||||
@ -951,7 +951,7 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
cost_center=cost_center,
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
)
|
||||
|
||||
stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse)
|
||||
@ -975,7 +975,7 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
pr = make_purchase_receipt(
|
||||
company="_Test Company with perpetual inventory",
|
||||
warehouse="Stores - TCP1",
|
||||
supplier_warehouse="Work in Progress - TCP1",
|
||||
supplier_warehouse="Work In Progress - TCP1",
|
||||
)
|
||||
|
||||
stock_in_hand_account = get_inventory_account(pr.company, pr.get("items")[0].warehouse)
|
||||
|
@ -11,6 +11,8 @@ from frappe.core.utils import get_parent_doc
|
||||
from frappe.email.inbox import link_communication_to_document
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.query_builder import Interval
|
||||
from frappe.query_builder.functions import Now
|
||||
from frappe.utils import date_diff, get_datetime, now_datetime, time_diff_in_seconds
|
||||
from frappe.utils.user import is_website_user
|
||||
|
||||
@ -190,15 +192,17 @@ def auto_close_tickets():
|
||||
frappe.db.get_value("Support Settings", "Support Settings", "close_issue_after_days") or 7
|
||||
)
|
||||
|
||||
issues = frappe.db.sql(
|
||||
""" select name from tabIssue where status='Replied' and
|
||||
modified<DATE_SUB(CURDATE(), INTERVAL %s DAY) """,
|
||||
(auto_close_after_days),
|
||||
as_dict=True,
|
||||
)
|
||||
table = frappe.qb.DocType("Issue")
|
||||
issues = (
|
||||
frappe.qb.from_(table)
|
||||
.select(table.name)
|
||||
.where(
|
||||
(table.modified < (Now() - Interval(days=auto_close_after_days))) & (table.status == "Replied")
|
||||
)
|
||||
).run(pluck=True)
|
||||
|
||||
for issue in issues:
|
||||
doc = frappe.get_doc("Issue", issue.get("name"))
|
||||
doc = frappe.get_doc("Issue", issue)
|
||||
doc.status = "Closed"
|
||||
doc.flags.ignore_permissions = True
|
||||
doc.flags.ignore_mandatory = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user