本文整理汇总了Python中webnotes.utils.get_first_day函数的典型用法代码示例。如果您正苦于以下问题:Python get_first_day函数的具体用法?Python get_first_day怎么用?Python get_first_day使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_first_day函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: define_periods
def define_periods(self, year, period):
# get year start date
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", year)
ysd = ysd and ysd[0][0] or ''
self.ysd = ysd
# year
if period == 'Annual':
pn = 'FY'+year
self.period_list.append(pn)
self.period_start_date[pn] = ysd
self.period_end_date[pn] = get_last_day(get_first_day(ysd,0,11))
# quarter
if period == 'Quarterly':
for i in range(4):
pn = 'Q'+str(i+1)
self.period_list.append(pn)
self.period_start_date[pn] = get_first_day(ysd,0,i*3)
self.period_end_date[pn] = get_last_day(get_first_day(ysd,0,((i+1)*3)-1))
# month
if period == 'Monthly':
mlist = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
for i in range(12):
fd = get_first_day(ysd,0,i)
pn = mlist[fd.month-1]
self.period_list.append(pn)
self.period_start_date[pn] = fd
self.period_end_date[pn] = get_last_day(fd)
开发者ID:Coalas,项目名称:erpnext,代码行数:34,代码来源:mis_control.py
示例2: define_periods
def define_periods(self, year, period):
# get year start date
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", year)
ysd = ysd and ysd[0][0] or ""
self.ysd = ysd
# year
if period == "Annual":
pn = "FY" + year
self.period_list.append(pn)
self.period_start_date[pn] = ysd
self.period_end_date[pn] = get_last_day(get_first_day(ysd, 0, 11))
# quarter
if period == "Quarterly":
for i in range(4):
pn = "Q" + str(i + 1)
self.period_list.append(pn)
self.period_start_date[pn] = get_first_day(ysd, 0, i * 3)
self.period_end_date[pn] = get_last_day(get_first_day(ysd, 0, ((i + 1) * 3) - 1))
# month
if period == "Monthly":
mlist = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
for i in range(12):
fd = get_first_day(ysd, 0, i)
pn = mlist[fd.month - 1]
self.period_list.append(pn)
self.period_start_date[pn] = fd
self.period_end_date[pn] = get_last_day(fd)
开发者ID:hbkfabio,项目名称:erpnext,代码行数:34,代码来源:mis_control.py
示例3: bl
def bl(self, acc, company):
dt = getdate(nowdate())
r = []
# cur
r.append(self.get_cur_balance(acc, company))
# this month
r.append(self.get_balance(acc, get_first_day(dt), get_last_day(dt), company, self.fiscal_year))
# last month
r.append(self.get_balance(acc, get_first_day(dt,0,-1), get_last_day(get_first_day(dt,0,-1)), company, self.fiscal_year))
return r
开发者ID:Coalas,项目名称:erpnext,代码行数:11,代码来源:mis_control.py
示例4: make_new_invoice
def make_new_invoice(ref_wrapper, posting_date):
from webnotes.model.bean import clone
from accounts.utils import get_fiscal_year
new_invoice = clone(ref_wrapper)
mcount = month_map[ref_wrapper.doc.recurring_type]
invoice_period_from_date = get_next_date(ref_wrapper.doc.invoice_period_from_date, mcount)
# get last day of the month to maintain period if the from date is first day of its own month
# and to date is the last day of its own month
if (cstr(get_first_day(ref_wrapper.doc.invoice_period_from_date)) == \
cstr(ref_wrapper.doc.invoice_period_from_date)) and \
(cstr(get_last_day(ref_wrapper.doc.invoice_period_to_date)) == \
cstr(ref_wrapper.doc.invoice_period_to_date)):
invoice_period_to_date = get_last_day(get_next_date(ref_wrapper.doc.invoice_period_to_date,
mcount))
else:
invoice_period_to_date = get_next_date(ref_wrapper.doc.invoice_period_to_date, mcount)
new_invoice.doc.fields.update({
"posting_date": posting_date,
"aging_date": posting_date,
"due_date": add_days(posting_date, cint(date_diff(ref_wrapper.doc.due_date,
ref_wrapper.doc.posting_date))),
"invoice_period_from_date": invoice_period_from_date,
"invoice_period_to_date": invoice_period_to_date,
"fiscal_year": get_fiscal_year(posting_date)[0],
"owner": ref_wrapper.doc.owner,
})
new_invoice.submit()
return new_invoice
开发者ID:rajatkapoor,项目名称:erpnext,代码行数:34,代码来源:sales_invoice.py
示例5: on_update
def on_update(self):
"""update defaults"""
self.validate_session_expiry()
for key in keydict:
webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
# update year start date and year end date from fiscal_year
ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year`
where name=%s""", self.doc.current_fiscal_year)
ysd = ysd and ysd[0][0] or ''
from webnotes.utils import get_first_day, get_last_day
if ysd:
webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
webnotes.conn.set_default('year_end_date', \
get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
# enable default currency
if self.doc.default_currency:
webnotes.conn.set_value("Currency", self.doc.default_currency, "enabled", 1)
# clear cache
webnotes.clear_cache()
开发者ID:MiteshC,项目名称:erpnext,代码行数:25,代码来源:global_defaults.py
示例6: set_system_default
def set_system_default(self, defkey, defvalue):
set_default(defkey, defvalue)
if defkey == 'fiscal_year':
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", cstr(defvalue))
ysd = ysd and ysd[0][0] or ''
if ysd:
set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
set_default('year_end_date', get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
开发者ID:calvinfroedge,项目名称:erpnext,代码行数:9,代码来源:manage_account.py
示例7: bl_bs
def bl_bs(self, acc, company, sd):
dt = getdate(nowdate())
r = []
# cur
r.append(self.get_cur_balance(acc, company))
# last month
r.append(self.get_balance(acc, sd, get_last_day(get_first_day(dt,0,-1)), company, self.fiscal_year))
# opening
r.append(self.get_balance(acc, sd, sd, company, self.fiscal_year))
return r
开发者ID:Coalas,项目名称:erpnext,代码行数:10,代码来源:mis_control.py
示例8: validate_posting_date
def validate_posting_date(self):
fy = sql("select docstatus, year_start_date from `tabFiscal Year` where name=%s ", self.doc.fiscal_year)
ysd = fy[0][1]
yed = get_last_day(get_first_day(ysd,0,11))
pd = getdate(self.doc.posting_date)
if fy[0][0] == 2:
msgprint("Fiscal Year is not active. You can restore it from Trash")
raise Exception
if pd < ysd or pd > yed:
msgprint("Posting date must be in the Selected Financial Year")
raise Exception
开发者ID:Coalas,项目名称:erpnext,代码行数:11,代码来源:gl_entry.py
示例9: on_update
def on_update(self):
"""update defaults"""
for key in keydict:
webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
# update year start date and year end date from fiscal_year
ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year`
where name=%s""", self.doc.current_fiscal_year)
ysd = ysd and ysd[0][0] or ''
from webnotes.utils import get_first_day, get_last_day
if ysd:
webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
webnotes.conn.set_default('year_end_date', \
get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
开发者ID:smilekk,项目名称:erpnext,代码行数:16,代码来源:global_defaults.py
示例10: on_update
def on_update(self):
# fiscal year
set_default('fiscal_year', self.doc.current_fiscal_year)
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", self.doc.current_fiscal_year, as_dict = 1)
set_default('year_start_date', ysd[0]['year_start_date'].strftime('%Y-%m-%d'))
set_default('year_end_date', get_last_day(get_first_day(ysd[0]['year_start_date'],0,11)).strftime('%Y-%m-%d'))
# company
set_default('company', self.doc.default_company)
set_default('stock_valuation', self.doc.stock_valuation or 'Moving Average')
set_default('default_currency', self.doc.default_currency or 'INR')
# Purchase in transit
if self.doc.purchase_in_transit_account:
set_default('purchase_in_transit_account', self.doc.purchase_in_transit_account)
开发者ID:ravidey,项目名称:erpnext,代码行数:17,代码来源:erp_setup.py
示例11: test_recurring_invoice
def test_recurring_invoice(self):
from webnotes.utils import now_datetime, get_first_day, get_last_day, add_to_date
today = now_datetime().date()
base_si = webnotes.bean(copy=test_records[0])
base_si.doc.fields.update({
"convert_into_recurring_invoice": 1,
"recurring_type": "Monthly",
"notification_email_address": "[email protected], [email protected], [email protected]",
"repeat_on_day_of_month": today.day,
"posting_date": today,
"invoice_period_from_date": get_first_day(today),
"invoice_period_to_date": get_last_day(today)
})
# monthly
si1 = webnotes.bean(copy=base_si.doclist)
si1.insert()
si1.submit()
self._test_recurring_invoice(si1, True)
# monthly without a first and last day period
si2 = webnotes.bean(copy=base_si.doclist)
si2.doc.fields.update({
"invoice_period_from_date": today,
"invoice_period_to_date": add_to_date(today, days=30)
})
si2.insert()
si2.submit()
self._test_recurring_invoice(si2, False)
# quarterly
si3 = webnotes.bean(copy=base_si.doclist)
si3.doc.fields.update({
"recurring_type": "Quarterly",
"invoice_period_from_date": get_first_day(today),
"invoice_period_to_date": get_last_day(add_to_date(today, months=3))
})
si3.insert()
si3.submit()
self._test_recurring_invoice(si3, True)
# quarterly without a first and last day period
si4 = webnotes.bean(copy=base_si.doclist)
si4.doc.fields.update({
"recurring_type": "Quarterly",
"invoice_period_from_date": today,
"invoice_period_to_date": add_to_date(today, months=3)
})
si4.insert()
si4.submit()
self._test_recurring_invoice(si4, False)
# yearly
si5 = webnotes.bean(copy=base_si.doclist)
si5.doc.fields.update({
"recurring_type": "Yearly",
"invoice_period_from_date": get_first_day(today),
"invoice_period_to_date": get_last_day(add_to_date(today, years=1))
})
si5.insert()
si5.submit()
self._test_recurring_invoice(si5, True)
# yearly without a first and last day period
si6 = webnotes.bean(copy=base_si.doclist)
si6.doc.fields.update({
"recurring_type": "Yearly",
"invoice_period_from_date": today,
"invoice_period_to_date": add_to_date(today, years=1)
})
si6.insert()
si6.submit()
self._test_recurring_invoice(si6, False)
# change posting date but keep recuring day to be today
si7 = webnotes.bean(copy=base_si.doclist)
si7.doc.fields.update({
"posting_date": add_to_date(today, days=-3)
})
si7.insert()
si7.submit()
# setting so that _test function works
si7.doc.posting_date = today
self._test_recurring_invoice(si7, True)
开发者ID:BillTheBest,项目名称:erpnext,代码行数:86,代码来源:test_sales_invoice.py
示例12: on_update
def on_update(self):
set_default('fiscal_year', self.doc.current_fiscal_year)
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", self.doc.current_fiscal_year)[0][0]
set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
set_default('year_end_date', get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
开发者ID:ravidey,项目名称:erpnext,代码行数:5,代码来源:accounts_setup.py
注:本文中的webnotes.utils.get_first_day函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论