当前位置: 首页>>代码示例>>Python>>正文


Python Document.debit方法代码示例

本文整理汇总了Python中webnotes.model.doc.Document.debit方法的典型用法代码示例。如果您正苦于以下问题:Python Document.debit方法的具体用法?Python Document.debit怎么用?Python Document.debit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webnotes.model.doc.Document的用法示例。


在下文中一共展示了Document.debit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_bank_voucher

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
	def make_bank_voucher(self):
		self.set_flag()
		"""
			get default bank account,default salary acount from company
		"""
		#amt = self.get_total_salary()
		com = webnotes.conn.sql("""select default_bank_account, default_expense_account from `tabCompany` 
			where name = '%s'""" % self.doc.company,as_list=1)		

		if not com[0][0] or not com[0][1]:
			msgprint("You can set Default Bank Account in Company master.")
		if not self.doc.jv:
			jv = Document('Journal Voucher')
			jv.voucher_type = 'Bank Voucher'
			jv.user_remark = 'Referrals Payment'
			jv.fiscal_year = '2013-14'
			jv.total_credit = jv.total_debit = self.doc.total_amount
			jv.company = self.doc.company
			jv.posting_date = nowdate()
			jv.save()
		
			jvd = Document('Journal Voucher Detail')
			jvd.account = com and com[0][0] or ''
			jvd.credit =  self.doc.total_amount
			jvd.parent = jv.name
			jvd.save()

			jvd1 = Document('Journal Voucher Detail')
			jvd1.account = com and com[0][1] or ''
			jvd1.debit = self.doc.total_amount
			jvd1.parent = jv.name
			jvd1.save()
		
			self.doc.jv = jv.name	
			self.doc.save()
开发者ID:saurabh6790,项目名称:alert-med-app,代码行数:37,代码来源:referrals_payment.py

示例2: create_account_balances

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
	def create_account_balances(self):
		# get periods
		period_list = self.get_period_list()
		cnt = 0
		
		# get accounts
		al = sql("select name from tabAccount")
		
		for a in al:
			# check
			if sql("select count(*) from `tabAccount Balance` where fiscal_year=%s and account=%s", (self.doc.name, a[0]))[0][0] < 13:
				for p in period_list:
					# check if missing
					if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.name)):
						d = Document('Account Balance')
						d.account = a[0]
						d.period = p[0]
						d.start_date = p[1].strftime('%Y-%m-%d')
						d.end_date = p[2].strftime('%Y-%m-%d')
						d.fiscal_year = p[3]
						d.debit = 0
						d.credit = 0
						d.opening = 0
						d.balance = 0
						d.save(1)
						cnt += 1
				if cnt % 100 == 0:
					sql("commit")
					sql("start transaction")
		return cnt
开发者ID:ravidey,项目名称:erpnext,代码行数:32,代码来源:fiscal_year.py

示例3: create_advance_entry

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
def create_advance_entry(advance_amount, customer_name, debit_to, company):
	jv = Document('Journal Voucher')
	jv.voucher_type = 'Cash Voucher'
	jv.user_remark = 'Advance Payment'
	jv.fiscal_year = webnotes.conn.get_value('Global Defaults',None,'current_fiscal_year')
	jv.user_remark = "Advance from patient %s"%customer_name
	jv.remark = "User Remark : Advance from patient %s"%customer_name
	jv.company = company
	jv.posting_date = nowdate()
	jv.docstatus=1
	jv.save()

	chld1 = Document('Journal Voucher Detail')
	chld1.parent = jv.name
	chld1.account = debit_to
	chld1.cost_center = webnotes.conn.get_value('Company',company,'cost_center')
	chld1.credit = advance_amount
	chld1.is_advance = 'Yes'
	chld1.save()

	chld2 = Document('Journal Voucher Detail')
	chld2.parent = jv.name
	chld2.account = webnotes.conn.get_value('Company',company,'default_cash_account')
	chld2.cost_center = webnotes.conn.get_value('Company',company,'cost_center')
	chld2.debit = advance_amount
	chld2.save()

	create_gl_entry(jv.name, jv.user_remark, company)
开发者ID:saurabh6790,项目名称:OFF-RISAPP,代码行数:30,代码来源:utils.py

示例4: set_year_balance

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
	def set_year_balance(self):
		p = sql("select name, start_date, end_date, fiscal_year from `tabPeriod` where docstatus != 2 and period_type in ('Month', 'Year')")
		for d in p:
			if not sql("select name from `tabAccount Balance` where account=%s and period=%s", (self.doc.name, d[0])):
				ac = Document('Account Balance')
				ac.account = self.doc.name
				ac.period = d[0]
				ac.start_date = d[1].strftime('%Y-%m-%d')
				ac.end_date = d[2].strftime('%Y-%m-%d')
				ac.fiscal_year = d[3]
				ac.opening = 0
				ac.debit = 0
				ac.credit = 0
				ac.balance = 0
				ac.save(1)
开发者ID:ravidey,项目名称:erpnext,代码行数:17,代码来源:account.py

示例5: create_gl

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
	def create_gl(self,data):
		for r in data:
			gl=Document("GL Entry")
			gl.account=r['account']
			gl.debit=r['debit']
			gl.credit=r['credit']
			gl.against=r['against']
			gl.against_voucher_type=r['against_voucher_type']
			gl.voucher_type=r['voucher_type']
			gl.against_voucher=r['against_voucher']
			gl.voucher_no=r['voucher_no']
			gl.cost_center=r['cost_center']
			gl.posting_date=nowdate()
			gl.aging_date=nowdate()
			gl.fiscal_year=webnotes.conn.get_value("Global Defaults",None,"current_fiscal_year")
			gl.company='InnoWorth'
			gl.is_opening='No'
			gl.save()
开发者ID:rohitw1991,项目名称:innoworth-app,代码行数:20,代码来源:cgi.py

示例6: create_new_balances

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
	def create_new_balances(self, det):
		# check
		if sql("select count(t1.name) from `tabAccount Balance` t1, tabAccount t2 where t1.fiscal_year=%s and t2.lft <= %s and t2.rgt >= %s and t2.name = t1.account", (self.doc.fiscal_year, det[0][0], det[0][1]))[0][0] < 13*(cint(det[0][1]) - cint(det[0][0]) +1)/2:
			period_list = self.get_period_list()
			accounts = sql("select name from tabAccount where lft <= %s and rgt >= %s" % (det[0][0], det[0][1]))

			for p in period_list:
				for a in accounts:
					# check if missing
					if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.fiscal_year)):
						d = Document('Account Balance')
						d.account = a[0]
						d.period = p[0]
						d.start_date = p[1].strftime('%Y-%m-%d')
						d.end_date = p[2].strftime('%Y-%m-%d')
						d.fiscal_year = self.doc.fiscal_year
						d.debit = 0
						d.credit = 0
						d.opening = 0
						d.balance = 0
						d.save(1)
开发者ID:Coalas,项目名称:erpnext,代码行数:23,代码来源:gl_entry.py

示例7: save_entries

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
def save_entries(gl_map, cancel, adv_adj, update_outstanding):
    total_debit = total_credit = 0.0

    def _swap(gle):
        gle.debit, gle.credit = abs(flt(gle.credit)), abs(flt(gle.debit))

    for entry in gl_map:
        gle = Document("GL Entry", fielddata=entry)

        # round off upto 2 decimal
        gle.debit = flt(gle.debit, 2)
        gle.credit = flt(gle.credit, 2)

        # toggle debit, credit if negative entry
        if flt(gle.debit) < 0 or flt(gle.credit) < 0:
            _swap(gle)

            # toggled debit/credit in two separate condition because
            # both should be executed at the
            # time of cancellation when there is negative amount (tax discount)
        if cancel:
            _swap(gle)

        gle_obj = webnotes.get_obj(doc=gle)
        # validate except on_cancel
        if not cancel:
            gle_obj.validate()

            # save
        gle.save(1)
        gle_obj.on_update(adv_adj, cancel, update_outstanding)

        # update total debit / credit
        total_debit += flt(gle.debit)
        total_credit += flt(gle.credit)

        # print gle.account, gle.debit, gle.credit, total_debit, total_credit

    if not cancel:
        validate_total_debit_credit(total_debit, total_credit)
开发者ID:rohitw1991,项目名称:latestadberp,代码行数:42,代码来源:general_ledger.py

示例8: make_JV1

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
	def make_JV1(self,sum_patient_amt,debit_to,patient_credit_to,company):
		jv=Document('Journal Voucher')
                jv.voucher_type='Bank Voucher'
                jv.posting_date=nowdate()
                jv.user_remark ='Payment Entry against '+self.doc.name
                jv.fiscal_year = '2013-14'
                jv.total_credit = jv.total_debit = sum_patient_amt
                jv.company = company
                jv.save()

                jvd = Document('Journal Voucher Detail')
                jvd.account = debit_to
                jvd.credit =  sum_patient_amt
		jvd.against_invoice=self.doc.name
                jvd.parent = jv.name
                jvd.save()

                jvd1 = Document('Journal Voucher Detail')
                jvd1.account = patient_credit_to
                jvd1.debit = sum_patient_amt
                jvd1.parent = jv.name
                jvd1.save()
开发者ID:saurabh6790,项目名称:OFF-RISAPP,代码行数:24,代码来源:sales_invoice.py

示例9: make_JV

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
	def make_JV(self,amount,referrer_physician_credit_to,referrer_physician_debit_to,company):
		
		jv=Document('Journal Voucher')
		jv.voucher_type='Bank Voucher'
		jv.posting_date=nowdate()
		jv.user_remark = 'Referrals Payment against bill '+ self.doc.name
		jv.fiscal_year = '2013-14'
		jv.total_credit = jv.total_debit = amount
		jv.company = company
		jv.against_bill = self.doc.name
		jv.save()

		jvd = Document('Journal Voucher Detail')
		jvd.account = referrer_physician_credit_to
		jvd.debit =  amount
		jvd.parent = jv.name
		jvd.save()

		jvd1 = Document('Journal Voucher Detail')
		jvd1.account = referrer_physician_debit_to
		jvd1.credit = amount
		jvd1.parent = jv.name
		jvd1.save()
开发者ID:saurabh6790,项目名称:alert-med-app,代码行数:25,代码来源:sales_invoice.py

示例10: import_vouchers

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
def import_vouchers(common_values, data, start_idx, import_type):
	from webnotes.model.doc import Document
	from webnotes.model.bean import Bean
	from accounts.utils import get_fiscal_year
	from webnotes.utils.dateutils import parse_date
	messages = []
	
	def get_account_details(account):
		acc_details = webnotes.conn.sql("""select is_pl_account, 
			master_name from tabAccount where name=%s""", account, as_dict=1)
		if not acc_details:
			webnotes.msgprint("%s is not an Account" % account, raise_exception=1)
		return acc_details[0]

	def apply_cost_center_and_against_invoice(detail, d):
		account = get_account_details(detail.account)

		if account.is_pl_account=="Yes":
			detail.cost_center = d.cost_center
		
		if account.master_name:
			map_fields(["against_sales_invoice:against_invoice", 
				"against_purhase_invoice:against_voucher", 
				"against_journal_voucher:against_jv"], d, detail.fields)
	
	webnotes.conn.commit()
	try:
		jv = Document("Journal Voucher")
		
		webnotes.conn.begin()
		for i in xrange(len(data)):
			jv = Document("Journal Voucher")
			
			d = data[i][0]
			if import_type == "Voucher Import: Two Accounts" and flt(d.get("amount")) == 0:
				webnotes.message_log = ["Amount not specified"]
				raise Exception
			elif import_type == "Voucher Import: Multiple Accounts" and \
			 		(flt(d.get("total_debit")) == 0 or flt(d.get("total_credit")) == 0):
				webnotes.message_log = ["Total Debit and Total Credit amount can not be zero"]
				raise Exception
			else:
				d.posting_date = parse_date(d.posting_date)
				d.due_date = d.due_date and parse_date(d.due_date) or None
				
				if d.ref_number:
					if not d.ref_date:
						webnotes.msgprint(_("Ref Date is Mandatory if Ref Number is specified"), 
							raise_exception=1)
							
					d.ref_date = parse_date(d.ref_date)
				
				d.company = common_values.company
						
				map_fields(["voucher_type", "posting_date", "naming_series", 
					"remarks:user_remark", "ref_number:cheque_no", "ref_date:cheque_date",
					"is_opening", "due_date", "company"], d, jv.fields)

				jv.fiscal_year = get_fiscal_year(jv.posting_date)[0]

				details = []
				if import_type == "Voucher Import: Two Accounts":
					map_fields(["amount:total_debit", "amount:total_credit"], d, jv.fields)
					
					detail1 = Document("Journal Voucher Detail")
					detail1.parent = True
					detail1.parentfield = "entries"
					map_fields(["debit_account:account","amount:debit"], d, detail1.fields)
					apply_cost_center_and_against_invoice(detail1, d)
		

					detail2 = Document("Journal Voucher Detail")
					detail2.parent = True
					detail2.parentfield = "entries"
					map_fields(["credit_account:account","amount:credit"], d, detail2.fields)
					apply_cost_center_and_against_invoice(detail2, d)
				
					details = [detail1, detail2]
				elif import_type == "Voucher Import: Multiple Accounts":
					map_fields(["total_debit", "total_credit"], d, jv.fields)
					accounts = data[i][1]
					for acc in accounts:
						detail = Document("Journal Voucher Detail")
						detail.parent = True
						detail.parentfield = "entries"
						detail.account = acc
						detail.debit = flt(accounts[acc]) > 0 and flt(accounts[acc]) or 0
						detail.credit = flt(accounts[acc]) < 0 and -1*flt(accounts[acc]) or 0
						apply_cost_center_and_against_invoice(detail, d)
						details.append(detail)
								
				if not details:
					webnotes.message_log = ["""No accounts found. 
						If you entered accounts correctly, please check template once"""]
					raise Exception
					
				doclist = Bean([jv]+details)
				
				# validate datatype
				from core.page.data_import_tool.data_import_tool import check_record
#.........这里部分代码省略.........
开发者ID:BANSALJEE,项目名称:erpnext,代码行数:103,代码来源:voucher_import_tool.py

示例11: import_vouchers

# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import debit [as 别名]
def import_vouchers(common_values, data, start_idx, import_type):
	from webnotes.model.doc import Document
	from webnotes.model.doclist import DocList
	from webnotes.model.code import get_obj
	from accounts.utils import get_fiscal_year
	from webnotes.utils.dateutils import parse_date

	messages = []
		
	def get_account_details(account):
		acc_details = webnotes.conn.sql("""select is_pl_account, 
			master_name from tabAccount where name=%s""", account, as_dict=1)
		if not acc_details:
			webnotes.msgprint("%s is not an Account" % account, raise_exception=1)
		return acc_details[0]

	def apply_cost_center_and_against_invoice(detail, d):
		account = get_account_details(detail.account)

		if account.is_pl_account=="Yes":
			detail.cost_center = d.cost_center
		
		if account.master_name:
			map_fields(["against_sales_invoice:against_invoice", 
				"against_purhase_invoice:against_voucher", 
				"against_journal_voucher:against_jv"], d, detail.fields)
	
	webnotes.conn.commit()
	for i in xrange(len(data)):
		d = data[i][0]
		jv = webnotes.DictObj()

		try:
			d.posting_date = parse_date(d.posting_date)
			d.due_date = d.due_date and parse_date(d.due_date) or None
			
			if d.ref_number:
				if not d.ref_date:
					raise webnotes.ValidationError, \
						"""Ref Date is Mandatory if Ref Number is specified"""
				d.ref_date = parse_date(d.ref_date)
				
			d.company = common_values.company
						
			jv = Document("Journal Voucher")
			map_fields(["voucher_type", "posting_date", "naming_series", "remarks:user_remark",
				"ref_number:cheque_no", "ref_date:cheque_date", "is_opening",
				"amount:total_debit", "amount:total_credit", "due_date", "company"], d, jv.fields)

			jv.fiscal_year = get_fiscal_year(jv.posting_date)[0]

			details = []
			if import_type == "Voucher Import: Two Accounts":
				detail1 = Document("Journal Voucher Detail")
				detail1.parent = True
				detail1.parentfield = "entries"
				map_fields(["debit_account:account","amount:debit"], d, detail1.fields)
				apply_cost_center_and_against_invoice(detail1, d)
		

				detail2 = Document("Journal Voucher Detail")
				detail2.parent = True
				detail2.parentfield = "entries"
				map_fields(["credit_account:account","amount:credit"], d, detail2.fields)
				apply_cost_center_and_against_invoice(detail2, d)
				
				details = [detail1, detail2]
			elif import_type == "Voucher Import: Multiple Accounts":
				accounts = data[i][1]
				for acc in accounts:
					detail = Document("Journal Voucher Detail")
					detail.parent = True
					detail.parentfield = "entries"
					detail.account = acc
					detail.debit = flt(accounts[acc]) > 0 and flt(accounts[acc]) or 0
					detail.credit = flt(accounts[acc]) < 0 and -1*flt(accounts[acc]) or 0
					apply_cost_center_and_against_invoice(detail, d)
					details.append(detail)
								
			if not details:
				messages.append("""<p style='color: red'>No accounts found. 
					If you entered accounts correctly, please check template once</p>""")
				return
			webnotes.conn.begin()
			doclist = DocList([jv]+details)
			doclist.submit()
			webnotes.conn.commit()
			
			messages.append("""<p style='color: green'>[row #%s] 
				<a href=\"#Form/Journal Voucher/%s\">%s</a> imported</p>""" \
				% ((start_idx + 1) + i, jv.name, jv.name))
			
		except Exception, e:
			webnotes.conn.rollback()
			err_msg = webnotes.message_log and webnotes.message_log[0] or unicode(e)
			messages.append("<p style='color: red'>[row #%s] %s failed: %s</p>" \
				% ((start_idx + 1) + i, jv.name or "", err_msg or "No message"))
			webnotes.errprint(webnotes.getTraceback())

		webnotes.message_log = []
开发者ID:trycatcher,项目名称:erpnext,代码行数:102,代码来源:voucher_import_tool.py


注:本文中的webnotes.model.doc.Document.debit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。