本文整理汇总了Python中webnotes.utils.nowdate函数的典型用法代码示例。如果您正苦于以下问题:Python nowdate函数的具体用法?Python nowdate怎么用?Python nowdate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nowdate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_journal_voucher
def test_save_journal_voucher(self):
expense_ac_balance = get_balance_on(get_name("Test Expense"), nowdate())
supplier_ac_balance = get_balance_on(get_name("Test Supplier"), nowdate())
dl = webnotes.model.insert(data["journal_voucher"])
dl.submit()
dl.load_from_db()
# test submitted jv
self.assertTrue(webnotes.conn.exists("Journal Voucher", dl.doclist[0].name))
for d in dl.doclist[1:]:
self.assertEquals(webnotes.conn.get_value("Journal Voucher Detail",
d.name, "parent"), dl.doclist[0].name)
# test gl entry
gle = webnotes.conn.sql("""select account, debit, credit
from `tabGL Entry` where voucher_no = %s order by account""",
dl.doclist[0].name)
self.assertEquals((gle[0][0], flt(gle[0][1]), flt(gle[0][2])),
('Test Expense - %s' % abbr, 5000.0, 0.0))
self.assertEquals((gle[1][0], flt(gle[1][1]), flt(gle[1][2])),
('Test Supplier - %s' % abbr, 0.0, 5000.0))
# check balance as on today
self.assertEqual(get_balance_on(get_name("Test Expense"), nowdate()),
expense_ac_balance + 5000)
self.assertEqual(get_balance_on(get_name("Test Supplier"), nowdate()),
supplier_ac_balance + 5000)
# check previous balance
self.assertEqual(get_balance_on(get_name("Test Expense"), add_days(nowdate(), -1)), 0)
示例2: create_feed_and_todo
def create_feed_and_todo(self):
"""update activty feed and create todo for creation of item, customer, vendor"""
import home
home.make_feed('Comment', 'ToDo', '', webnotes.session['user'],
'<i>"' + 'Setup Complete. Please check your <a href="#!todo">\
To Do List</a>' + '"</i>', '#6B24B3')
d = Document('ToDo')
d.description = 'Create your first Customer'
d.priority = 'High'
d.date = nowdate()
d.reference_type = 'Customer'
d.save(1)
d = Document('ToDo')
d.description = 'Create your first Item'
d.priority = 'High'
d.date = nowdate()
d.reference_type = 'Item'
d.save(1)
d = Document('ToDo')
d.description = 'Create your first Supplier'
d.priority = 'High'
d.date = nowdate()
d.reference_type = 'Supplier'
d.save(1)
示例3: make_stock_ledger_entry
def make_stock_ledger_entry(self, update_stock):
from webnotes.model.code import get_obj
values = [
{
"item_code": self.doc.item_code,
"warehouse": self.doc.warehouse,
"transaction_date": nowdate(),
"posting_date": self.doc.purchase_date
or (self.doc.creation and self.doc.creation.split(" ")[0])
or nowdate(),
"posting_time": self.doc.purchase_time or "00:00",
"voucher_type": "Serial No",
"voucher_no": self.doc.name,
"voucher_detail_no": "",
"actual_qty": 1,
"stock_uom": webnotes.conn.get_value("Item", self.doc.item_code, "stock_uom"),
"incoming_rate": self.doc.purchase_rate,
"company": self.doc.company,
"fiscal_year": self.doc.fiscal_year,
"is_cancelled": update_stock and "No" or "Yes",
"batch_no": "",
"serial_no": self.doc.name,
}
]
get_obj("Stock Ledger", "Stock Ledger").update_stock(values)
示例4: manage_recurring_invoices
def manage_recurring_invoices():
"""
Create recurring invoices on specific date by copying the original one
and notify the concerned people
"""
rv = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` \
where ifnull(convert_into_recurring_invoice, 0) = 1 and next_date = %s \
and next_date <= ifnull(end_date, '2199-12-31') and docstatus=1""", nowdate())
exception_list = []
for d in rv:
if not webnotes.conn.sql("""select name from `tabSales Invoice` \
where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])):
try:
prev_rv = get_obj('Sales Invoice', d[0], with_children=1)
new_rv = create_new_invoice(prev_rv)
send_notification(new_rv)
webnotes.conn.commit()
except Exception, e:
webnotes.conn.rollback()
webnotes.conn.begin()
webnotes.conn.sql("update `tabSales Invoice` set \
convert_into_recurring_invoice = 0 where name = %s", d[0])
notify_errors(d[0], prev_rv.doc.owner)
webnotes.conn.commit()
exception_list.append(e)
finally:
示例5: create_auto_indent
def create_auto_indent(self, i , doc_type, doc_name, cur_qty):
""" Create indent on reaching reorder level """
indent = Document('Purchase Request')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = "This is an auto generated Purchase Request. It was raised because the (actual + ordered + indented - reserved) quantity reaches re-order level when %s %s was created"%(doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item',0)
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse
indent_details_child.schedule_date= add_days(nowdate(),cint(i['lead_time_days']))
indent_details_child.item_name = i['item_name']
indent_details_child.description = i['description']
indent_details_child.item_group = i['item_group']
indent_details_child.qty = i['re_order_qty'] or (flt(i['re_order_level']) - flt(cur_qty))
indent_details_child.brand = i['brand']
indent_details_child.save()
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_obj.validate()
set(indent_obj.doc,'docstatus',1)
indent_obj.on_submit()
msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Purchase Request %s raised. It was generated from %s %s"%(indent.name,doc_type, doc_name ))
if(i['email_notify']):
send_email_notification(doc_type,doc_name)
示例6: get_balance_on
def get_balance_on(account=None, date=None):
if not account and webnotes.form_dict.get("account"):
account = webnotes.form_dict.get("account")
date = webnotes.form_dict.get("date")
cond = []
if date:
cond.append("posting_date <= '%s'" % date)
else:
# get balance of all entries that exist
date = nowdate()
try:
year_start_date = get_fiscal_year(date, verbose=0)[1]
except FiscalYearError, e:
from webnotes.utils import getdate
if getdate(date) > getdate(nowdate()):
# if fiscal year not found and the date is greater than today
# get fiscal year for today's date and its corresponding year start date
year_start_date = get_fiscal_year(nowdate(), verbose=1)[1]
else:
# this indicates that it is a date older than any existing fiscal year.
# hence, assuming balance as 0.0
return 0.0
示例7: manage_recurring_invoices
def manage_recurring_invoices():
"""
Create recurring invoices on specific date by copying the original one
and notify the concerned people
"""
recurring_invoices = webnotes.conn.sql("""select name, recurring_id
from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0)=1
and docstatus=1 and next_date=%s
and next_date <= ifnull(end_date, '2199-12-31')""", nowdate())
exception_list = []
for ref_invoice, recurring_id in recurring_invoices:
if not webnotes.conn.sql("""select name from `tabSales Invoice`
where posting_date=%s and recurring_id=%s and docstatus=1""",
(nowdate(), recurring_id)):
try:
ref_wrapper = webnotes.model_wrapper('Sales Invoice', ref_invoice)
new_invoice_wrapper = make_new_invoice(ref_wrapper)
send_notification(new_invoice_wrapper)
webnotes.conn.commit()
except Exception, e:
webnotes.conn.rollback()
webnotes.conn.begin()
webnotes.conn.sql("update `tabSales Invoice` set \
convert_into_recurring_invoice = 0 where name = %s", ref_invoice)
notify_errors(ref_invoice, ref_wrapper.doc.owner)
webnotes.conn.commit()
exception_list.append(webnotes.getTraceback())
finally:
示例8: reorder_indent
def reorder_indent(self,i,item_reorder_level,doc_type,doc_name,email_notify=1):
indent = Document('Indent')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = "This is an auto generated Indent. It was raised because the projected quantity has fallen below the minimum re-order level when %s %s was created"%(doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Indent',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Indent Detail',0)
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse
indent_details_child.schedule_date= add_days(nowdate(),cint(i['lead_time_days']))
indent_details_child.item_name = i['item_name']
indent_details_child.description = i['description']
indent_details_child.item_group = i['item_group']
if (i['min_order_qty'] < ( flt(item_reorder_level)-flt(self.doc.projected_qty) )):
indent_details_child.qty =flt(flt(item_reorder_level)-flt(self.doc.projected_qty))
else:
indent_details_child.qty = i['min_order_qty']
indent_details_child.brand = i['brand']
indent_details_child.save()
indent_obj = get_obj('Indent',indent.name,with_children=1)
indent_obj.validate()
set(indent_obj.doc,'docstatus',1)
indent_obj.on_submit()
msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Indent %s raised.Was generated from %s %s"%(indent.name,doc_type, doc_name ))
if(email_notify):
send_email_notification(doc_type,doc_name)
示例9: create_material_request
def create_material_request(material_requests):
""" Create indent on reaching reorder level """
mr_list = []
defaults = webnotes.defaults.get_defaults()
exceptions_list = []
for request_type in material_requests:
for company in material_requests[request_type]:
try:
items = material_requests[request_type][company]
if not items:
continue
mr = [{
"doctype": "Material Request",
"company": company,
"fiscal_year": defaults.fiscal_year,
"transaction_date": nowdate(),
"material_request_type": request_type
}]
for d in items:
item = webnotes.doc("Item", d.item_code)
mr.append({
"doctype": "Material Request Item",
"parenttype": "Material Request",
"parentfield": "indent_details",
"item_code": d.item_code,
"schedule_date": add_days(nowdate(),cint(item.lead_time_days)),
"uom": item.stock_uom,
"warehouse": d.warehouse,
"item_name": item.item_name,
"description": item.description,
"item_group": item.item_group,
"qty": d.reorder_qty,
"brand": item.brand,
})
mr_bean = webnotes.bean(mr)
mr_bean.insert()
mr_bean.submit()
mr_list.append(mr_bean)
except:
if webnotes.local.message_log:
exceptions_list.append([] + webnotes.local.message_log)
webnotes.local.message_log = []
else:
exceptions_list.append(webnotes.getTraceback())
if mr_list:
if getattr(webnotes.local, "reorder_email_notify", None) is None:
webnotes.local.reorder_email_notify = cint(webnotes.conn.get_value('Stock Settings', None,
'reorder_email_notify'))
if(webnotes.local.reorder_email_notify):
send_email_notification(mr_list)
if exceptions_list:
notify_errors(exceptions_list)
示例10: execute
def execute():
item_map = {}
for item in webnotes.conn.sql("""select * from tabItem""", as_dict=1):
item_map.setdefault(item.name, item)
warehouse_map = get_warehosue_map()
naming_series = "STE/13/"
for company in webnotes.conn.sql("select name from tabCompany"):
stock_entry = [{
"doctype": "Stock Entry",
"naming_series": naming_series,
"posting_date": nowdate(),
"posting_time": nowtime(),
"purpose": "Material Transfer",
"company": company[0],
"remarks": "Material Transfer to activate perpetual inventory",
"fiscal_year": get_fiscal_year(nowdate())[0]
}]
expense_account = "Cost of Goods Sold - NISL"
cost_center = "Default CC Ledger - NISL"
for bin in webnotes.conn.sql("""select * from tabBin bin where ifnull(item_code, '')!=''
and ifnull(warehouse, '') in (%s) and ifnull(actual_qty, 0) != 0
and (select company from tabWarehouse where name=bin.warehouse)=%s""" %
(', '.join(['%s']*len(warehouse_map)), '%s'),
(warehouse_map.keys() + [company[0]]), as_dict=1):
item_details = item_map[bin.item_code]
new_warehouse = warehouse_map[bin.warehouse].get("fixed_asset_warehouse") \
if cstr(item_details.is_asset_item) == "Yes" \
else warehouse_map[bin.warehouse].get("current_asset_warehouse")
if item_details.has_serial_no == "Yes":
serial_no = "\n".join([d[0] for d in webnotes.conn.sql("""select name
from `tabSerial No` where item_code = %s and warehouse = %s
and status in ('Available', 'Sales Returned')""",
(bin.item_code, bin.warehouse))])
else:
serial_no = None
stock_entry.append({
"doctype": "Stock Entry Detail",
"parentfield": "mtn_details",
"s_warehouse": bin.warehouse,
"t_warehouse": new_warehouse,
"item_code": bin.item_code,
"description": item_details.description,
"qty": bin.actual_qty,
"transfer_qty": bin.actual_qty,
"uom": item_details.stock_uom,
"stock_uom": item_details.stock_uom,
"conversion_factor": 1,
"expense_account": expense_account,
"cost_center": cost_center,
"serial_no": serial_no
})
webnotes.bean(stock_entry).insert()
示例11: execute
def execute(filters=None):
if not filters: filters = {}
supplier_naming_by = webnotes.conn.get_value("Buying Settings", None, "supp_master_name")
columns = get_columns(supplier_naming_by)
entries = get_gl_entries(filters)
account_map = dict(((r.name, r) for r in webnotes.conn.sql("""select acc.name,
supp.supplier_name, supp.name as supplier
from `tabAccount` acc, `tabSupplier` supp
where acc.master_type="Supplier" and supp.name=acc.master_name""", as_dict=1)))
entries_after_report_date = [[gle.voucher_type, gle.voucher_no]
for gle in get_gl_entries(filters, before_report_date=False)]
account_supplier_type_map = get_account_supplier_type_map()
voucher_detail_map = get_voucher_details()
# Age of the invoice on this date
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
and nowdate() or filters.get("report_date")
data = []
for gle in entries:
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
voucher_details = voucher_detail_map.get(gle.voucher_type, {}).get(gle.voucher_no, {})
invoiced_amount = gle.credit > 0 and gle.credit or 0
outstanding_amount = get_outstanding_amount(gle,
filters.get("report_date") or nowdate())
if abs(flt(outstanding_amount)) > 0.01:
paid_amount = invoiced_amount - outstanding_amount
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
voucher_details.get("due_date", ""), voucher_details.get("bill_no", ""),
voucher_details.get("bill_date", ""), invoiced_amount,
paid_amount, outstanding_amount]
# Ageing
if filters.get("ageing_based_on") == "Due Date":
ageing_based_on_date = voucher_details.get("due_date", "")
else:
ageing_based_on_date = gle.posting_date
row += get_ageing_data(age_on, ageing_based_on_date, outstanding_amount) + \
[account_map.get(gle.account).get("supplier") or ""]
if supplier_naming_by == "Naming Series":
row += [account_map.get(gle.account).get("supplier_name") or ""]
row += [account_supplier_type_map.get(gle.account), gle.remarks]
data.append(row)
for i in range(0, len(data)):
data[i].insert(4, """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
% ("/".join(["#Form", data[i][2], data[i][3]]),))
return columns, data
示例12: execute
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
entries = get_gl_entries(filters)
entries_after_report_date = [[gle.voucher_type, gle.voucher_no]
for gle in get_gl_entries(filters, before_report_date=False)]
account_supplier_type_map = get_account_supplier_type_map()
pi_map = get_pi_map()
# Age of the invoice on this date
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
and nowdate() or filters.get("report_date")
data = []
total_invoiced_amount = total_paid = total_outstanding = 0
for gle in entries:
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
if gle.voucher_type == "Purchase Invoice":
pi_info = pi_map.get(gle.voucher_no)
due_date = pi_info.get("due_date")
bill_no = pi_info.get("bill_no")
bill_date = pi_info.get("bill_date")
else:
due_date = bill_no = bill_date = ""
invoiced_amount = gle.credit > 0 and gle.credit or 0
paid_amount = get_paid_amount(gle, filters.get("report_date") or nowdate(),
entries_after_report_date)
outstanding_amount = invoiced_amount - paid_amount
if abs(flt(outstanding_amount)) > 0.01:
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
gle.remarks, account_supplier_type_map.get(gle.account), due_date, bill_no,
bill_date, invoiced_amount, paid_amount, outstanding_amount]
# Ageing
if filters.get("ageing_based_on") == "Due Date":
ageing_based_on_date = due_date
else:
ageing_based_on_date = gle.posting_date
row += get_ageing_data(ageing_based_on_date, age_on, outstanding_amount)
# Add to total
total_invoiced_amount += flt(invoiced_amount)
total_paid += flt(paid_amount)
total_outstanding += flt(outstanding_amount)
data.append(row)
if data:
data.append(["", "", "", "", "", "", "", "Total", "", total_invoiced_amount, total_paid,
total_outstanding, "", "", "", ""])
return columns, data
示例13: update_acc_bal
def update_acc_bal(self,args):
args = eval(args)
self.doc.credit_balance = cint(self.doc.credit_balance) + cint(args.get('net_cr'))
self.doc.total_users = cint(self.doc.total_users) + cint(args.get('total_users'))
if cint(self.doc.is_trial_account) == 1:
if not self.doc.account_start_date:
self.doc.account_start_date = nowdate()
self.doc.is_trial_account = 0
self.doc.billing_cycle_date = nowdate()
self.doc.last_deduction_date = nowdate()
self.doc.save()
示例14: check_late_submission
def check_late_submission(self):
current_month = nowdate().split('-')[1]
current_day = nowdate().split('-')[2]
to_date_month = self.doc.end_date.split('-')[1]
if flt(current_day) > 5 and flt(current_month) != flt(to_date_month):
self.doc.status = 'Late'
msgprint("Late Submission")
if not self.doc.reason_for_late_submission:
msgprint("Please Enter the reason for LATE Submission")
raise Exception
else:
self.doc.status = 'On Time'
示例15: declare_completed
def declare_completed(self):
if self.doc.status == 'Open':
self.validate_for_pending_review()
self.doc.review_date = nowdate()
else:
self.validate_with_timesheet_dates()
self.validate_for_closed()
self.doc.closing_date = nowdate()
set(self.doc, 'status', 'Closed')
set(self.doc, 'docstatus', 1)
self.doc.save()
return cstr('true')