本文整理汇总了Python中webnotes.utils.get_last_day函数的典型用法代码示例。如果您正苦于以下问题:Python get_last_day函数的具体用法?Python get_last_day怎么用?Python get_last_day使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_last_day函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例2: 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
示例3: 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)
示例4: 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
示例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()
示例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'))
示例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
示例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
示例9: _test
def _test(i):
self.assertEquals(
i + 1,
webnotes.conn.sql(
"""select count(*) from `tabSales Invoice`
where recurring_id=%s and docstatus=1""",
base_si.doc.recurring_id,
)[0][0],
)
next_date = add_months(base_si.doc.posting_date, no_of_months)
manage_recurring_invoices(next_date=next_date, commit=False)
recurred_invoices = webnotes.conn.sql(
"""select name from `tabSales Invoice`
where recurring_id=%s and docstatus=1 order by name desc""",
base_si.doc.recurring_id,
)
self.assertEquals(i + 2, len(recurred_invoices))
new_si = webnotes.bean("Sales Invoice", recurred_invoices[0][0])
for fieldname in [
"convert_into_recurring_invoice",
"recurring_type",
"repeat_on_day_of_month",
"notification_email_address",
]:
self.assertEquals(base_si.doc.fields.get(fieldname), new_si.doc.fields.get(fieldname))
self.assertEquals(new_si.doc.posting_date, unicode(next_date))
self.assertEquals(
new_si.doc.invoice_period_from_date,
unicode(add_months(base_si.doc.invoice_period_from_date, no_of_months)),
)
if first_and_last_day:
self.assertEquals(
new_si.doc.invoice_period_to_date,
unicode(get_last_day(add_months(base_si.doc.invoice_period_to_date, no_of_months))),
)
else:
self.assertEquals(
new_si.doc.invoice_period_to_date,
unicode(add_months(base_si.doc.invoice_period_to_date, no_of_months)),
)
return new_si
示例10: 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'))
示例11: 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)
示例12: schedule
def schedule(_type='POST'):
regn=webnotes.conn.sql("select name from `tabFranchise Visiting Schedule` where name in (select distinct region from `tabFranchise`) and name in (select distinct region from `tabSub Franchise`)",as_list=1)
webnotes.errprint(regn)
for r in regn:
details=webnotes.conn.sql("select visiting_frequency,frequency,start_date from `tabFranchise Visiting Schedule` where name='"+r[0]+"'",as_list=1)
k=webnotes.conn.sql("select account_id from `tabFranchise` where region='"+r[0]+"'",as_list=1)
s=webnotes.conn.sql("select sf_name from `tabSub Franchise` where region='"+r[0]+"'",as_list=1)
bb=get_last_day(details[0][2])
j=0
from webnotes.utils import nowdate
dd = nowdate()
if details[0][0]=='Weekly':
m = 4
j = m * cint(details[0][1])
elif details[0][0]=='Fortnightly':
m = 2
j = m * cint(details[0][1])
elif details[0][0]=='Monthly':
m = 1
j = m * cint(details[0][1])
list1 = []
list1.append(details[0][2])
dt=details[0][2]
for j in range(0,j):
for ls in s:
for i in range(len(list1)):
d=Document('Sub Franchise Visiting Schedule')
d.account_id=k[0][0]
d.region=r[0]
d.sf_name=ls[0]
if details[0][0]=='Weekly':
d.weekly=details[0][1]
elif details[0][0]=='Fortnightly':
d.forth_nightly=details[0][1]
elif details[0][0]=='Monthly':
d.monthly=details[0][1]
d.save()
webnotes.conn.commit()
webnotes.errprint("Done")
示例13: 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)
示例14: get_date_details
def get_date_details(self):
bb=get_last_day(self.doc.start_date)
#webnotes.errprint(bb)
#webnotes.errprint("hii")
return bb
示例15: 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'))