def get_item_details(self):
	
		items=webnotes.conn.sql(""" select item,quantity,description,warehouse from `tabItem Detail` 
					where parent=%s""",(self.doc.special_type_project),as_dict=1)
		employee=webnotes.conn.sql(""" select employee,employee_name,employee_contact_no from `tabEmployee Detail` 
					where parent=%s""",(self.doc.special_type_project),as_dict=1)
		#webnotes.errprint(milestone)
		for d in items:
			#self.doclist=self.doc.clear_table(self.doclist,'')

			ch = addchild(self.doc, 'item_details_table', 
					'Item Detail', self.doclist)
			#webnotes.errprint(t[0])
			ch.item = d.get('item')
			ch.quantity= d.get('quantity')
			ch.description=d.get('description')
			ch.warehouse=d.get('warehouse')
			#webnotes.errprint(ch)
		for t in employee:
			ch = addchild(self.doc, 'employee_details_table', 
				'Employee Detail', self.doclist)
				#webnotes.errprint(t[0])
			ch.employee=t.get('employee')
			ch.employee_name= t.get('employee_name')
			ch.employee_contact_no=t.get('employee_contact_no')
    def upload_accounts_transactions(self):
        import csv

        data = csv.reader(self.get_csv_data().splitlines())

        abbr = sql("select concat(' - ',abbr) as abbr from tabCompany where name=%s", self.doc.company)
        updated = 0
        jv_name = ""
        # 		jv = Document('Journal Voucher')
        global line, jv, name, jv_go
        for line in data:
            if len(line) >= 7:  # Minimum no of fields
                if line[3] != jv_name:  # Create JV
                    if jv_name != "":
                        jv_go = get_obj("Journal Voucher", name, with_children=1)
                        jv_go.validate()
                        jv_go.on_submit()

                    jv_name = line[3]
                    jv = Document("Journal Voucher")
                    jv.voucher_type = line[0]
                    jv.naming_series = line[1]
                    jv.voucher_date = formatdate(line[2])
                    jv.posting_date = formatdate(line[2])
                    # 					jv.name = line[3]
                    jv.fiscal_year = self.doc.fiscal_year
                    jv.company = self.doc.company
                    jv.remark = len(line) == 8 and line[3] + " " + line[7] or line[3] + " Uploaded Record"
                    jv.docstatus = 1
                    jv.save(1)
                    name = jv.name

                    jc = addchild(jv, "entries", "Journal Voucher Detail", 0)
                    jc.account = line[4] + abbr[0][0]
                    jc.cost_center = len(line) == 9 and line[8] or self.doc.default_cost_center
                    if line[5] != "":
                        jc.debit = line[5]
                    else:
                        jc.credit = line[6]
                    jc.save()

                else:  # Create JV Child
                    jc = addchild(jv, "entries", "Journal Voucher Detail", 0)
                    jc.account = line[4] + abbr[0][0]
                    jc.cost_center = len(line) == 9 and line[8] or self.doc.default_cost_center
                    if line[5] != "":
                        jc.debit = line[5]
                    else:
                        jc.credit = line[6]
                    jc.save()
            else:
                msgprint("[Ignored] Incorrect format: %s" % str(line))
        if jv_name != "":
            jv_go = get_obj("Journal Voucher", name, with_children=1)
            jv_go.validate()
            jv_go.on_submit()

        msgprint("<b>%s</b> items updated" % updated)
示例#3
0
def execute():
    import webnotes
    from webnotes.model import delete_doc
    from webnotes.model.code import get_obj
    from webnotes.model.doc import addchild

    # delete doctypes and tables
    for dt in [
        "TDS Payment",
        "TDS Return Acknowledgement",
        "Form 16A",
        "TDS Rate Chart",
        "TDS Category",
        "TDS Control",
        "TDS Detail",
        "TDS Payment Detail",
        "TDS Rate Detail",
        "TDS Category Account",
        "Form 16A Ack Detail",
        "Form 16A Tax Detail",
    ]:
        delete_doc("DocType", dt)

        webnotes.conn.commit()
        webnotes.conn.sql("drop table if exists `tab%s`" % dt)
        webnotes.conn.begin()

    delete_doc("Search Criteria", "tds_return")

    # Add tds entry in tax table for purchase invoice
    pi_list = webnotes.conn.sql(
        """select name from `tabPurchase Invoice` 
		where ifnull(tax_code, '')!='' and ifnull(ded_amount, 0)!=0"""
    )
    for pi in pi_list:
        piobj = get_obj("Purchase Invoice", pi[0], with_children=1)
        ch = addchild(piobj.doc, "taxes_and_charges", "Purchase Taxes and Charges")
        ch.charge_type = "Actual"
        ch.account_head = piobj.doc.tax_code
        ch.description = piobj.doc.tax_code
        ch.rate = -1 * piobj.doc.ded_amount
        ch.tax_amount = -1 * piobj.doc.ded_amount
        ch.category = "Total"
        ch.save(1)

        # Add tds entry in entries table for journal voucher
    jv_list = webnotes.conn.sql(
        """select name from `tabJournal Voucher` 
		where ifnull(tax_code, '')!='' and ifnull(ded_amount, 0)!=0"""
    )
    for jv in jv_list:
        jvobj = get_obj("Journal Voucher", jv[0], with_children=1)
        ch = addchild(jvobj.doc, "entries", "Journal Voucher Detail")
        ch.account = jvobj.doc.tax_code
        ch.credit = jvobj.doc.ded_amount
        ch.save(1)
	def fetch_gases(self):
		gases = webnotes.conn.sql("select name from tabGas where name!='TGC'")
		self.doclist=self.doc.clear_table(self.doclist,'dissolved_gas_detail')
		if gases:

			nl = addchild(self.doc, 'dissolved_gas_detail', 'Dissolved Gas Analysis Detail', self.doclist)
			nl.gas='TGC'
			for gas in gases:
				nl = addchild(self.doc, 'dissolved_gas_detail', 'Dissolved Gas Analysis Detail', self.doclist)
				nl.gas = gas
		else:
			webnotes.msgprint("There is no any Gas Recorded In Gas Table")
示例#5
0
	def add_roles(self, pr):
		roles_list = ['Accounts Manager', 'Accounts User', 'Blogger', 'HR Manager', 'HR User', 'Maintenance User', 'Maintenance Manager', 'Material Manager', 'Material User', 'Material Master Manager', 'Production Manager', 'Production User', 'Projects User', 'Purchase Manager', 'Purchase User', 'Purchase Master Manager', 'Quality Manager', 'Sales Manager', 'Sales User', 'Sales Master Manager', 'Support Manager', 'Support Team', 'System Manager', 'Website Manager']
		for r in roles_list:
			d = addchild(pr, 'userroles', 'UserRole', 1)
			d.role = r
			d.save(1)

		# Add roles to Administrator profile
		pr = Document('Profile','Administrator')
		for r in roles_list:
			d = addchild(pr,'userroles', 'UserRole', 1)
			d.role = r
			d.save(1)
示例#6
0
	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)
示例#7
0
    def get_purchase_tax_details(self, obj, default=0):
        obj.doclist = self.doc.clear_table(obj.doclist, 'purchase_tax_details')

        if default: add_cond = " and ifnull(t2.is_default,0) = 1"
        else:
            add_cond = " and t1.parent = '" + cstr(
                obj.doc.purchase_other_charges) + "'"

        other_charge = sql("""
			select t1.*
			from `tabPurchase Taxes and Charges` t1, `tabPurchase Taxes and Charges Master` t2
			where t1.parent = t2.name %s
			order by t1.idx
		""" % add_cond,
                           as_dict=1)

        idx = 0
        for other in other_charge:
            d = addchild(obj.doc, 'purchase_tax_details',
                         'Purchase Taxes and Charges', obj.doclist)
            d.category = other['category']
            d.add_deduct_tax = other['add_deduct_tax']
            d.charge_type = other['charge_type']
            d.row_id = other['row_id']
            d.description = other['description']
            d.account_head = other['account_head']
            d.rate = flt(other['rate'])
            d.tax_amount = flt(other['tax_amount'])
            d.idx = idx
            idx += 1
        return obj.doclist
示例#8
0
    def update_against_doc(self, d, jv_obj):
        """
			Updates against document, if partial amount splits into rows
		"""

        webnotes.conn.sql("""
			update `tabJournal Voucher Detail` t1, `tabJournal Voucher` t2	
			set t1.%(dr_or_cr)s = '%(allocated_amt)s', t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now() 
			where t1.name = '%(voucher_detail_no)s' and t1.parent = t2.name""" % d)

        if d['allocated_amt'] < d['unadjusted_amt']:
            jvd = webnotes.conn.sql(
                "select cost_center, balance, against_account, is_advance from `tabJournal Voucher Detail` where name = '%s'"
                % d['voucher_detail_no'])
            # new entry with balance amount
            ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', 1)
            ch.account = d['account']
            ch.cost_center = cstr(jvd[0][0])
            ch.balance = cstr(jvd[0][1])
            ch.fields[d['dr_or_cr']] = flt(d['unadjusted_amt']) - flt(
                d['allocated_amt'])
            ch.fields[d['dr_or_cr'] == 'debit' and 'credit' or 'debit'] = 0
            ch.against_account = cstr(jvd[0][2])
            ch.is_advance = cstr(jvd[0][3])
            ch.docstatus = 1
            ch.save(1)
示例#9
0
    def add_extra_entry(self, jv_obj, jv, jv_detail_no, allocate, account_head,
                        doctype, dr_or_cr, against_document_no):
        # get old entry details

        jvd = webnotes.conn.sql(
            "select %s, cost_center, balance, against_account from `tabJournal Voucher Detail` where name = '%s'"
            % (dr_or_cr, jv_detail_no))
        advance = jvd and flt(jvd[0][0]) or 0
        balance = flt(advance) - flt(allocate)

        # update old entry
        webnotes.conn.sql(
            "update `tabJournal Voucher Detail` set %s = '%s', %s = '%s' where name = '%s'"
            % (dr_or_cr, flt(allocate),
               doctype == "Purchase Invoice" and 'against_voucher'
               or 'against_invoice', cstr(against_document_no), jv_detail_no))

        # new entry with balance amount
        add = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', 1,
                       jv_obj.doclist)
        add.account = account_head
        add.cost_center = cstr(jvd[0][1])
        add.balance = cstr(jvd[0][2])
        add.fields[dr_or_cr] = balance
        add.against_account = cstr(jvd[0][3])
        add.is_advance = 'Yes'
        add.save(1)
 def update_warranty_amc_history(self, submit = 1):
   if submit:
     for d in getlist(self.doclist, 'delivery_note_details'):
       if d.serial_no:
         serial_nos = self.get_sr_no_list(d.serial_no)
         for s in serial_nos:
           sr = Document('Serial No', s)
           child = addchild(sr, 'warranty_amc_history', 'Warranty AMC History', 0)
           child.from_date = self.doc.transaction_date
           child.to_date = d.warranty_expiry_date
           child.status = 'Under Warranty'
           child.against_doctype = self.doc.doctype
           child.against_docname = self.doc.name
           child.customer = self.doc.customer
           child.territory = self.doc.territory
           child.save()
           sr.warranty_amc_status = 'Under Warranty'
           sr.warranty_expiry_date = d.warranty_expiry_date
           sr.save()
   else:
     sql("delete from `tabWarranty AMC History` where against_doctype = %s and against_docname = %s", (self.doc.doctype, self.doc.name))
     sr_list = []
     for d in getlist(self.doclist, 'service_order_details'):
       if d.serial_no:
         serial_nos = self.get_sr_no_list(d.serial_no)
         for s in serial_nos:
           sql("update `tabSerial No` set warranty_expiry_date = '' where name = '%s'" % (s))
           sr_list.append(s)
     self.update_serial_no_warranty_amc_status(serial_no_list = sr_list) 
示例#11
0
 def add_to_replace_bom_utility_detail(self, pbom, t_fname):
     for d in pbom:
         br_child = addchild(self.doc, t_fname,
                             'BOM Replace Utility Detail', 0, self.doclist)
         br_child.parent_bom = d[0]
         br_child.save()
     self.doc.save()
示例#12
0
	def get_other_charges(self,obj, default=0):
		obj.doclist = obj.doc.clear_table(obj.doclist, 'other_charges')
		if not getlist(obj.doclist, 'other_charges'):
			if default: add_cond = 'ifnull(t2.is_default,0) = 1'
			else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
			idx = 0
			other_charge = webnotes.conn.sql("""\
				select t1.*
				from
					`tabSales Taxes and Charges` t1,
					`tabSales Taxes and Charges Master` t2
				where
					t1.parent = t2.name and
					t2.company = '%s' and
					%s
				order by t1.idx""" % (obj.doc.company, add_cond), as_dict=1)
			from webnotes.model import default_fields
			for other in other_charge:
				# remove default fields like parent, parenttype etc.
				# from query results
				for field in default_fields:
					if field in other: del other[field]

				d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges',
					obj.doclist)
				d.fields.update(other)
				d.rate = flt(d.rate)
				d.tax_amount = flt(d.tax_rate)
				d.included_in_print_rate = cint(d.included_in_print_rate)
				d.idx = idx
				idx += 1
		return obj.doclist
示例#13
0
    def add_charges_in_pr(self):
        """ Add additional charges in selected pr proportionately"""
        total_amt = self.get_total_amt()

        for pr in self.selected_pr:
            pr_obj = get_obj('Purchase Receipt', pr, with_children=1)
            cumulative_grand_total = flt(pr_obj.doc.grand_total)

            for lc in getlist(self.doclist, 'landed_cost_details'):
                amt = flt(lc.amount) * flt(
                    pr_obj.doc.net_total) / flt(total_amt)
                self.prwise_cost[pr] = self.prwise_cost.get(pr, 0) + amt
                cumulative_grand_total += amt

                pr_oc_row = sql(
                    "select name from `tabPurchase Taxes and Charges` where parent = %s and category = 'Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s",
                    (pr, lc.account_head))
                if not pr_oc_row:  # add if not exists
                    ch = addchild(pr_obj.doc, 'purchase_tax_details',
                                  'Purchase Taxes and Charges')
                    ch.category = 'Valuation'
                    ch.add_deduct_tax = 'Add'
                    ch.charge_type = 'Actual'
                    ch.description = lc.description
                    ch.account_head = lc.account_head
                    ch.rate = amt
                    ch.tax_amount = amt
                    ch.total = cumulative_grand_total
                    ch.docstatus = 1
                    ch.idx = 500  # add at the end
                    ch.save(1)
                else:  # overwrite if exists
                    sql(
                        "update `tabPurchase Taxes and Charges` set rate = %s, tax_amount = %s where name = %s and parent = %s ",
                        (amt, amt, pr_oc_row[0][0], pr))
示例#14
0
    def generate_schedule(self):
        self.doclist = self.doc.clear_table(self.doclist,
                                            'maintenance_schedule_detail')
        count = 0
        webnotes.conn.sql(
            "delete from `tabMaintenance Schedule Detail` where parent='%s'" %
            (self.doc.name))
        for d in getlist(self.doclist, 'item_maintenance_detail'):
            self.validate_maintenance_detail()
            s_list = []
            s_list = self.create_schedule_list(d.start_date, d.end_date,
                                               d.no_of_visits)
            for i in range(d.no_of_visits):
                child = addchild(self.doc, 'maintenance_schedule_detail',
                                 'Maintenance Schedule Detail', self.doclist)
                child.item_code = d.item_code
                child.item_name = d.item_name
                child.scheduled_date = s_list[i].strftime('%Y-%m-%d')
                if d.serial_no:
                    child.serial_no = d.serial_no
                child.idx = count
                count = count + 1
                child.incharge_name = d.incharge_name
                child.save(1)

        self.on_update()
def execute():
    import webnotes
    from webnotes.model.doc import addchild
    from webnotes.model.code import get_obj

    webnotes.conn.sql(
        "delete from `tabDocPerm` where role = 'All' and parent = 'Address'")

    role1 = [
        'Sales User', 'Purchase User', 'Accounts User', 'Maintenance User'
    ]
    role2 = [
        'Sales Manager', 'Sales Master Manager', 'Purchase Manager',
        'Purchase Master Manager', 'Accounts Manager', 'Maintenance Manager'
    ]

    addr = get_obj('DocType', 'Address', with_children=1)
    for d in role1 + role2:
        ch = addchild(addr.doc, 'permissions', 'DocPerm')
        ch.role = d
        ch.read = 1
        ch.write = 1
        ch.create = 1
        if d in role2:
            ch.cancel = 1

        ch.save()
示例#16
0
	def get_balance(self):
		if not getlist(self.doclist,'entries'):
			msgprint("Please enter atleast 1 entry in 'GL Entries' table")
		else:
			flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0
			diff = flt(self.doc.difference, 2)
			
			# If any row without amount, set the diff on that row
			for d in getlist(self.doclist,'entries'):
				if not d.credit and not d.debit and diff != 0:
					if diff>0:
						d.credit = diff
					elif diff<0:
						d.debit = diff
					flag = 1
					
			# Set the diff in a new row
			if flag == 0 and diff != 0:
				jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
				if diff>0:
					jd.credit = abs(diff)
				elif diff<0:
					jd.debit = abs(diff)
					
			# Set the total debit, total credit and difference
			for d in getlist(self.doclist,'entries'):
				self.doc.total_debit += flt(d.debit, 2)
				self.doc.total_credit += flt(d.credit, 2)

			self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2)
示例#17
0
 def get_other_charges(self, obj, default=0):
     obj.doc.clear_table(obj.doclist, 'other_charges')
     if not getlist(obj.doclist, 'other_charges'):
         if default: add_cond = 'ifnull(t2.is_default,0) = 1'
         else: add_cond = 't1.parent = "' + cstr(obj.doc.charge) + '"'
         idx = 0
         other_charge = webnotes.conn.sql(
             "select t1.charge_type,t1.row_id,t1.description,t1.account_head,t1.rate,t1.tax_amount,t1.included_in_print_rate, t1.cost_center_other_charges from `tabRV Tax Detail` t1, `tabOther Charges` t2 where t1.parent = t2.name and t2.company = '%s' and %s order by t1.idx"
             % (obj.doc.company, add_cond),
             as_dict=1)
         for other in other_charge:
             d = addchild(obj.doc, 'other_charges', 'RV Tax Detail', 1,
                          obj.doclist)
             d.charge_type = other['charge_type']
             d.row_id = other['row_id']
             d.description = other['description']
             d.account_head = other['account_head']
             d.cost_center_other_charges = other[
                 'cost_center_other_charges']
             d.rate = flt(other['rate'])
             d.tax_amount = flt(other['tax_amount'])
             d.included_in_print_rate = cint(
                 other['included_in_print_rate'])
             d.idx = idx
             idx += 1
示例#18
0
	def add_to_stock_entry_detail(self, item_dict, bom_no=None, idx=None):
		if not idx:	idx = 1
		expense_account, cost_center = webnotes.conn.get_values("Company", self.doc.company, \
			["default_expense_account", "cost_center"])[0]

		for d in item_dict:
			se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail',
				self.doclist)
			se_child.idx = idx
			se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse)
			se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse)
			se_child.item_code = cstr(d)
			se_child.item_name = item_dict[d]["item_name"]
			se_child.description = item_dict[d]["description"]
			se_child.uom = item_dict[d]["stock_uom"]
			se_child.stock_uom = item_dict[d]["stock_uom"]
			se_child.qty = flt(item_dict[d]["qty"])
			se_child.expense_account = item_dict[d]["expense_account"] or expense_account
			se_child.cost_center = item_dict[d]["cost_center"] or cost_center

			# in stock uom
			se_child.transfer_qty = flt(item_dict[d]["qty"])
			se_child.conversion_factor = 1.00

			# to be assigned for finished item
			se_child.bom_no = bom_no

			# increment idx by 1
			idx += 1
		return idx
示例#19
0
	def update_packing_list_item(self,obj, packing_item_code, qty, warehouse, line):
		bin = self.get_bin_qty(packing_item_code, warehouse)
		item = self.get_packing_item_details(packing_item_code)

		# check if exists
		exists = 0
		for d in getlist(obj.doclist, 'packing_details'):
			if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name:
				pi, exists = d, 1
				break

		if not exists:
			pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Item', 
				obj.doclist)

		pi.parent_item = line.item_code
		pi.item_code = packing_item_code
		pi.item_name = item['item_name']
		pi.parent_detail_docname = line.name
		pi.description = item['description']
		pi.uom = item['stock_uom']
		pi.qty = flt(qty)
		pi.actual_qty = bin and flt(bin['actual_qty']) or 0
		pi.projected_qty = bin and flt(bin['projected_qty']) or 0
		pi.prevdoc_doctype = line.prevdoc_doctype
		if not pi.warehouse:
			pi.warehouse = warehouse
		if not pi.batch_no:
			pi.batch_no = cstr(line.batch_no)
		pi.idx = self.packing_list_idx
		
		# saved, since this function is called on_update of delivery note
		pi.save()
		
		self.packing_list_idx += 1
示例#20
0
	def get_balance(self):
		if not getlist(self.doclist,'entries'):
			msgprint("Please enter atleast 1 entry in 'GL Entries' table")
		else:
			flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0
			diff = flt(self.doc.difference, 2)
			
			# If any row without amount, set the diff on that row
			for d in getlist(self.doclist,'entries'):
				if not d.credit and not d.debit and diff != 0:
					if diff>0:
						d.credit = diff
					elif diff<0:
						d.debit = diff
					flag = 1
					
			# Set the diff in a new row
			if flag == 0 and diff != 0:
				jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
				if diff>0:
					jd.credit = abs(diff)
				elif diff<0:
					jd.debit = abs(diff)
					
			# Set the total debit, total credit and difference
			for d in getlist(self.doclist,'entries'):
				self.doc.total_debit += flt(d.debit, 2)
				self.doc.total_credit += flt(d.credit, 2)

			self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2)
示例#21
0
 def add_in_follow_up(self, message, type):
     import datetime
     child = addchild(self.doc, 'follow_up', 'Follow up', 1, self.doclist)
     child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
     child.notes = message
     child.follow_up_type = type
     child.save()
 def get_tc_details(self):
   self.doc.clear_table(self.doclist,'tc_details')
   tc_detail = sql("select terms,description from `tabTC Detail` where parent = '%s'" %(self.doc.tc_name), as_dict = 1)
   for tc in tc_detail:
     d =  addchild(self.doc, 'tc_details', 'TC Detail', 1, self.doclist)
     d.terms = tc['terms']
     d.description = tc['description']
示例#23
0
 def add_in_follow_up(self,message,type):
   import datetime
   child = addchild( self.doc, 'follow_up', 'Follow up', 1, self.doclist)
   child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
   child.notes = message
   child.follow_up_type = type
   child.save()
示例#24
0
	def get_purchase_tax_details(self,obj, default = 0):
		obj.doclist = self.doc.clear_table(obj.doclist,'purchase_tax_details')
		
		if default: add_cond = " and ifnull(t2.is_default,0) = 1"
		else: add_cond = " and t1.parent = '"+cstr(obj.doc.purchase_other_charges)+"'"

		other_charge = sql("""
			select t1.*
			from `tabPurchase Taxes and Charges` t1, `tabPurchase Taxes and Charges Master` t2
			where t1.parent = t2.name %s
			order by t1.idx
		"""% add_cond, as_dict = 1)
		
		idx = 0
		for other in other_charge:
			d =	addchild(obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1, obj.doclist)
			d.category = other['category']
			d.add_deduct_tax = other['add_deduct_tax']
			d.charge_type = other['charge_type']
			d.row_id = other['row_id']
			d.description = other['description']
			d.account_head = other['account_head']
			d.rate = flt(other['rate'])
			d.tax_amount = flt(other['tax_amount'])
			d.idx = idx
			idx += 1
		return obj.doclist
示例#25
0
  def get_balance(self):
    if not getlist(self.doclist,'entries'):
      msgprint("Please enter atleast 1 entry in 'GL Entries' table")
    else:
      flag, self.doc.total_debit, self.doc.total_credit = 0,0,0
      diff = flt(self.doc.difference)
      
      # If any row without amount, set the diff on that row
      for d in getlist(self.doclist,'entries'):
        if (d.credit==0 or d.credit is None) and (d.debit==0 or d.debit is None) and (flt(diff) != 0):
          if diff>0:
            d.credit = flt(diff)
          elif diff<0:
            d.debit = flt(diff)
          flag = 1
          
      # Set the diff in a new row
      if flag == 0 and (flt(diff) != 0):
        jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist)
        if diff>0:
          jd.credit = flt(diff)
        elif diff<0:
          jd.debit = flt(diff)
          
      # Set the total debit, total credit and difference
      for d in getlist(self.doclist,'entries'):
        self.doc.total_debit += flt(d.debit)
        self.doc.total_credit += flt(d.credit)

      if self.doc.tds_applicable == 'Yes':
        self.doc.total_credit = flt(self.doc.total_credit) + flt(self.doc.ded_amount)

      self.doc.difference = flt(self.doc.total_debit) - flt(self.doc.total_credit)
示例#26
0
	def update_packing_list_item(self,obj, packing_item_code, qty, warehouse, line):
		bin = self.get_bin_qty(packing_item_code, warehouse)
		item = self.get_packing_item_details(packing_item_code)

		# check if exists
		exists = 0
		for d in getlist(obj.doclist, 'packing_details'):
			if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name:
				pi, exists = d, 1
				break

		if not exists:
			pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Item', 
				obj.doclist)

		pi.parent_item = line.item_code
		pi.item_code = packing_item_code
		pi.item_name = item['item_name']
		pi.parent_detail_docname = line.name
		pi.description = item['description']
		pi.uom = item['stock_uom']
		pi.qty = flt(qty)
		pi.actual_qty = bin and flt(bin['actual_qty']) or 0
		pi.projected_qty = bin and flt(bin['projected_qty']) or 0
		pi.prevdoc_doctype = line.prevdoc_doctype
		if not pi.warehouse:
			pi.warehouse = warehouse
		if not pi.batch_no:
			pi.batch_no = cstr(line.batch_no)
		pi.idx = self.packing_list_idx
		
		# saved, since this function is called on_update of delivery note
		pi.save()
		
		self.packing_list_idx += 1
示例#27
0
文件: bin.py 项目: NorrWing/erpnext
	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)
示例#28
0
	def add_charges_in_pr(self):
		""" Add additional charges in selected pr proportionately"""
		total_amt = self.get_total_amt()
		
		for pr in self.selected_pr:
			pr_obj = get_obj('Purchase Receipt', pr, with_children = 1)
			cumulative_grand_total = flt(pr_obj.doc.grand_total)
			
			for lc in getlist(self.doclist, 'landed_cost_details'):
				amt = flt(lc.amount) * flt(pr_obj.doc.net_total)/ flt(total_amt)
				self.prwise_cost[pr] = self.prwise_cost.get(pr, 0) + amt
				cumulative_grand_total += amt
				
				pr_oc_row = sql("select name from `tabPurchase Taxes and Charges` where parent = %s and category = 'Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s",(pr, lc.account_head))
				if not pr_oc_row:	# add if not exists
					ch = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1)
					ch.category = 'Valuation'
					ch.add_deduct_tax = 'Add'
					ch.charge_type = 'Actual'
					ch.description = lc.description
					ch.account_head = lc.account_head
					ch.rate = amt
					ch.tax_amount = amt
					ch.total = cumulative_grand_total
					ch.docstatus = 1
					ch.idx = 500 # add at the end
					ch.save(1)
				else:	# overwrite if exists
					sql("update `tabPurchase Taxes and Charges` set rate = %s, tax_amount = %s where name = %s and parent = %s ", (amt, amt, pr_oc_row[0][0], pr))
示例#29
0
	def add_to_stock_entry_detail(self, item_dict, bom_no=None, idx=None):
		if not idx:	idx = 1
		expense_account, cost_center = webnotes.conn.get_values("Company", self.doc.company, \
			["default_expense_account", "cost_center"])[0]

		for d in item_dict:
			se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 
				self.doclist)
			se_child.idx = idx
			se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse)
			se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse)
			se_child.item_code = cstr(d)
			se_child.item_name = item_dict[d]["item_name"]
			se_child.description = item_dict[d]["description"]
			se_child.uom = item_dict[d]["stock_uom"]
			se_child.stock_uom = item_dict[d]["stock_uom"]
			se_child.qty = flt(item_dict[d]["qty"])
			se_child.expense_account = item_dict[d]["expense_account"] or expense_account
			se_child.cost_center = item_dict[d]["cost_center"] or cost_center
			
			# in stock uom
			se_child.transfer_qty = flt(item_dict[d]["qty"])
			se_child.conversion_factor = 1.00
			
			# to be assigned for finished item
			se_child.bom_no = bom_no

			# increment idx by 1
			idx += 1
		return idx
示例#30
0
  def get_open_sales_order(self):
    if not (self.doc.from_date and self.doc.to_date):
      msgprint("From Date and To Date are Mandatory")
      return
    
    cond = ''  
    if self.doc.customer:
      cond += " AND t1.customer = '%s' " % self.doc.customer
    if self.doc.sales_order:
      cond += " AND t1.name = '%s' " % self.doc.sales_order
    if self.doc.territory:
      cond += " AND t1.territory = '%s' " %self.doc.territory

    dl = sql("select distinct t1.name, t1.customer,  t1.delivery_date, t1.territory, t1.rounded_total from `tabSales Order` t1, `tabSales Order Detail` t2 where  t1.transaction_date >= '%s' and t1.transaction_date <= '%s' and t1.docstatus=1 and t1.status != 'Completed' and t1.name = t2.parent and t2.docstatus =1 and t2.qty > t2.delivered_qty and (t2.confirmation_date is null or t2.confirmation_date= '' or t2.confirmation_date='0000-00-00') %s"% (self.doc.from_date, self.doc.to_date, cond)) 
    self.doc.clear_table(self.doclist, 'entries')
    count = 0 
    for d in dl:
      nl = addchild(self.doc, 'entries', 'Update Delivery Date Detail', 1, self.doclist)
      nl.sales_order_no = str(d[0])
      nl.customer = str(d[1])
      nl.territory = str(d[3])
      nl.rounded_total = str(d[4])
      nl.delivery_date = str(d[2])
      count = count +1
    if not count:
      msgprint("No Sales Order found as per filters set.")
示例#31
0
def update_against_doc(d, jv_obj):
	"""
		Updates against document, if partial amount splits into rows
	"""

	webnotes.conn.sql("""
		update `tabJournal Voucher Detail` t1, `tabJournal Voucher` t2	
		set t1.%(dr_or_cr)s = '%(allocated_amt)s', 
		t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now() 
		where t1.name = '%(voucher_detail_no)s' and t1.parent = t2.name""" % d)
	
	if d['allocated_amt'] < d['unadjusted_amt']:
		jvd = webnotes.conn.sql("""select cost_center, balance, against_account, is_advance 
			from `tabJournal Voucher Detail` where name = %s""", d['voucher_detail_no'])
		# new entry with balance amount
		ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail')
		ch.account = d['account']
		ch.cost_center = cstr(jvd[0][0])
		ch.balance = cstr(jvd[0][1])
		ch.fields[d['dr_or_cr']] = flt(d['unadjusted_amt']) - flt(d['allocated_amt'])
		ch.fields[d['dr_or_cr']== 'debit' and 'credit' or 'debit'] = 0
		ch.against_account = cstr(jvd[0][2])
		ch.is_advance = cstr(jvd[0][3])
		ch.docstatus = 1
		ch.save(1)
示例#32
0
    def update_ref_rate(self, i):
        ref_rate = 0
        if self.doc.price_list:
            if not cstr(self.doc.currency):
                msgprint("Please enter Currency.")
                raise Exception
            for d in getlist(self.doclist, "sales_bom_items"):
                item_rate = sql(
                    "select ref_rate,ref_currency from `tabItem Price` where price_list_name=%s and parent=%s",
                    (self.doc.price_list, d.item_code),
                )
                ref_rate += flt(d.qty) * (item_rate and flt(item_rate[0][0]) or 0)

            if ref_rate:
                # clear old rates
                sql(
                    "delete from `tabItem Price` where parent=%s and price_list_name = %s",
                    (i.name, self.doc.price_list),
                )

                pld = addchild(i, "ref_rate_details", "Item Price")
                pld.price_list_name = self.doc.price_list
                pld.ref_rate = flt(ref_rate)
                pld.ref_currency = self.doc.currency
                pld.save()
示例#33
0
文件: item.py 项目: ravidey/erpnext
	def on_update(self):
		bin = sql("select stock_uom from `tabBin` where item_code = '%s' " % self.doc.item_code)
		if bin and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
			msgprint("Please Update Stock UOM with the help of Stock UOM Replace Utility.")
			raise Exception
		check_list = []
		for d in getlist(self.doclist,'uom_conversion_details'):
			if not self.doc.stock_uom:
				msgprint("Please enter Stock UOM first.")
				raise Exception
			
			if cstr(d.uom) in check_list:
				msgprint("UOM %s has been entered more than once in Conversion Factor Details." % cstr(d.uom))
				raise Exception
			
			if not cstr(d.uom) in check_list:
				check_list.append(cstr(d.uom))
							
			if cstr(d.uom) == cstr(self.doc.stock_uom):
				if flt(d.conversion_factor) != 1:
					msgprint("Conversion Fator of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
					raise Exception
				# else set uom_exist as true
				uom_exist='true'
			elif cstr(d.uom) != cstr(self.doc.stock_uom) and flt(d.conversion_factor) == 1:
				msgprint("Conversion Factor of UOM : %s should not be equal to 1. As UOM : %s is not Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
				raise Exception
		
		if not cstr(self.doc.stock_uom) in check_list :
			child = addchild( self.doc, 'uom_conversion_details', 'UOM Conversion Detail', 1, self.doclist)
			child.uom = self.doc.stock_uom
			child.conversion_factor = 1
			child.save()
  def set_exemption_values(self,ann_hra):
    ret = convert_to_lists(sql("select name, exemption_limit from `tabEarning Type` where taxable = 'No' and docstatus !=2"))
    
    if ret:
      for r in ret:

        ch = addchild(self.doc,'exe_declaration_details','Declaration Detail',0, self.doclist)
        ch.particulars1 = r[0]
        ch.under_section1 = "U/Sec 10 & 17"
        
        if r[0] == 'House Rent Allowance':
          if (self.doc.ann_rent <= 0.00):
            ch.max_limit1 = 0.00
            
          else:
            hra1=0.00
            if(self.doc.metro == 'Yes'):
              hra1 = flt(self.doc.basic)*50/100
            elif(self.doc.metro == 'No'):
              hra1 = flt(self.doc.basic)*40/100
            hra2 = flt(ann_hra)
            hra3 = flt(self.doc.ann_rent) - (flt(self.doc.basic)/10)


            if hra1 <= 0 or hra2 <=0 or hra3 <=0:
              ch.max_limit1 = 0
            else:
              ch.max_limit1=min(hra1,min(hra2,hra3))
        else:    
          ch.max_limit1 = r[1]
        
        ch.actual_amount1 = 0.00
        ch.eligible_amount1 = 0.00
        ch.modified_amount1 = 0.00
示例#35
0
 def get_accessories_details(self, item):
     #webnotes.errprint(item)
     qry = webnotes.conn.sql(
         "select default_warehouse,stock_uom from `tabItem` where name='" +
         item + "'")
     #webnotes.errprint(qry[0][1])
     q = webnotes.conn.sql(
         "select description from `tabItem` where name='" + item + "'")
     #webnotes.errprint(q[0][0])
     qr = webnotes.conn.sql(
         "select sum(actual_qty) from `tabStock Ledger Entry` where item_code='"
         + item + "' and warehouse='" + qry[0][0] + "'")
     #webnotes.errprint(qr)
     ch = addchild(self.doc, 'sales_order_details', 'Sales Order Item',
                   self.doclist)
     #webnotes.errprint(ch)
     ch.item_code = item
     ch.item_name = item
     ch.description = q[0][0]
     ch.qty = 1.00
     ch.export_rate = 0.00
     ch.reserved_warehouse = qry[0][0]
     ch.stock_uom = qry[0][1]
     ch.actual_qty = qr[0][0]
     ch.adj_rate = 0.00
     ch.save(new=1)
示例#36
0
        def get_weekly_off_date_list(self, year_start_date, year_end_date):
                from webnotes.utils import getdate
                year_start_date, year_end_date = getdate(year_start_date), getdate(year_end_date)

                from dateutil import relativedelta
                from datetime import timedelta
                import calendar

                date_list = []
                date_list1 = []
                if self.doc.weekly_off=='3rd Saturday':
                        webnotes.errprint(self.doc.weekly_off)
                        weekday = getattr(calendar, ('Saturday').upper())
                        reference_date = year_start_date + relativedelta.relativedelta(weekday=weekday)
                        while reference_date <= year_end_date:
                                date_list1.append(reference_date)
                                reference_date += timedelta(days=7)
                        for dt in date_list1:
                                if dt.day>14 :
                                        if dt.day <22:
                                                #webnotes.errprint(dt)
                                                ch = addchild(self.doc, 'holiday_list_details', 'Holiday', self.doclist)
                                                ch.description = self.doc.weekly_off
                                                ch.holiday_date = dt
                        return date_list
                else:
                        weekday = getattr(calendar, (self.doc.weekly_off).upper())
                        reference_date = year_start_date + relativedelta.relativedelta(weekday=weekday)
                        while reference_date <= year_end_date:
                                date_list.append(reference_date)
                                reference_date += timedelta(days=7)
                        return date_list
示例#37
0
    def update_ref_rate(self, i):
        ref_rate, count, p, currency = 0, 0, self.doc.price_list, self.doc.currency
        if not cstr(self.doc.price_list):
            msgprint("Please enter Price List.")
            raise Exception
        if not cstr(self.doc.currency):
            msgprint("Please enter Currency.")
            raise Exception
        for d in getlist(self.doclist, "sales_bom_items"):
            item_rate = sql(
                "select ref_rate,ref_currency from `tabRef Rate Detail` where price_list_name=%s and parent=%s",
                (p, d.item_code),
            )
            if not item_rate:
                msgprint(
                    "Item %s does not have a rate for Price List %s. Did not update rates for this Price List"
                    % (d.item_code, p)
                )
                raise Exception
            # if count == 0 : currency = cstr(item_rate[0][1])
            if not cstr(currency) == cstr(item_rate[0][1]):
                msgprint(
                    "Item %s currency %s does not match with other items currency i.e. %s "
                    % (d.item_code, item_rate[0][1], currency)
                )
                raise Exception
            count += 1
            ref_rate += flt(d.qty) * flt(item_rate[0][0])

        pld = addchild(i, "ref_rate_details", "Ref Rate Detail")
        pld.price_list_name = p
        pld.ref_rate = flt(ref_rate)
        pld.ref_currency = currency
        pld.save()
示例#38
0
    def get_tds(self):
        self.doc.clear_table(self.doclist, "form_16A_tax_details")
        import datetime

        if self.doc.from_date and self.doc.to_date and self.doc.tds_category:
            tot = 0.0
            party_tds_list = sql(
                "select t2.amount_paid,t2.date_of_payment,t2.tds_amount,t2.cess_on_tds, t2.total_tax_amount, t1.cheque_no, t1.bsr_code, t1.date_of_receipt, t1.challan_no from `tabTDS Payment` t1, `tabTDS Payment Detail` t2 where t1.tds_category='%s' and t2.party_name='%s' and t1.from_date >= '%s' and t1.to_date <= '%s' and t2.total_tax_amount>0 and t2.parent=t1.name and t1.docstatus=1"
                % (self.doc.tds_category, self.doc.party_name, self.doc.from_date, self.doc.to_date)
            )
            for s in party_tds_list:
                child = addchild(self.doc, "form_16A_tax_details", "Form 16A Tax Detail", 1, self.doclist)
                child.amount_paid = s and flt(s[0]) or ""
                child.date_of_payment = s and s[1].strftime("%Y-%m-%d") or ""
                child.tds_main = s and flt(s[2]) or ""
                child.surcharge = 0
                child.cess_on_tds = s and flt(s[3]) or ""
                child.total_tax_deposited = s and flt(s[4]) or ""
                child.cheque_no = s and s[5] or ""
                child.bsr_code = s and s[6] or ""
                child.tax_deposited_date = s and s[7].strftime("%Y-%m-%d") or ""
                child.challan_no = s and s[8] or ""
                tot = flt(tot) + flt(s[4])
            self.doc.total_amount = flt(tot)
        else:
            msgprint("Plaese enter from date, to date and TDS category")
示例#39
0
	def fill_sample_alloacation_detail(self, sample_details, sample_id):
		if self.doc.sample_id:
			self.doclist=self.doc.clear_table(self.doclist,'sample_allocation_detail')
		for sample in sample_details:
			nl = addchild(self.doc, 'sample_allocation_detail', 'Sample Allocation Detail', self.doclist)
			nl.sample_no = sample_id
			nl.test = sample[0]
示例#40
0
def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packing_list_idx):
	bin = get_bin_qty(packing_item_code, warehouse)
	item = get_packing_item_details(packing_item_code)

	# check if exists
	exists = 0
	for d in getlist(obj.doclist, 'packing_details'):
		if d.parent_item == line.item_code and d.item_code == packing_item_code and d.parent_detail_docname == line.name:
			pi, exists = d, 1
			break

	if not exists:
		pi = addchild(obj.doc, 'packing_details', 'Packed Item', obj.doclist)

	pi.parent_item = line.item_code
	pi.item_code = packing_item_code
	pi.item_name = item['item_name']
	pi.parent_detail_docname = line.name
	pi.description = item['description']
	pi.uom = item['stock_uom']
	pi.qty = flt(qty)
	pi.actual_qty = bin and flt(bin['actual_qty']) or 0
	pi.projected_qty = bin and flt(bin['projected_qty']) or 0
	if not pi.warehouse:
		pi.warehouse = warehouse
	if not pi.batch_no:
		pi.batch_no = cstr(line.batch_no)
	pi.idx = packing_list_idx
	
	packing_list_idx += 1
示例#41
0
	def get_loan_details(self):
		end= self.doc.doi_closing
		list1 = []	
		#list1.append(self.doc.doi_start)
		#webnotes.errprint(start)
		#webnotes.errprint(number)
		#webnotes.errprint((cstr(self.doc.doi_start) + datetime.timedelta(12*365/12)).isoformat())
		#self.doc.doi_closing=(self.doc.doi_start + datetime.timedelta(12*365/12)).isformat()
		#webnotes.errprint(self.doc.doi_closing)
		#j=0
		j=self.doc.number_of_installments
		dt=self.doc.doi_start
		for j in range(0,j):
			date=add_months(getdate(dt),1)
			#ebnotes.errprint(["j",date])
		 	#ebnotes.errprint(["hii",end])
			if date<=getdate(end):
				list1.append(date)
			dt=date
			#webnotes.errprint(date)
			#ebnotes.errprint(list1)
			self.doclist=self.doc.clear_table(self.doclist,'installment')

		for i in list1:
			#ebnotes.errprint("in for loop")
			#self.doclist=self.doc.clear_table(self.doclist,'installment')
			ch = addchild(self.doc, 'installment', 
					'Loan Installment Details', self.doclist)
			ch.date_of_installment = i
			ch.amount_to_be_paid =self.doc.amount_per_month 
			ch.status='Unpaid'			
示例#42
0
	def get_other_charges(self,obj, default=0):
		obj.doclist = obj.doc.clear_table(obj.doclist, 'other_charges')
		if not getlist(obj.doclist, 'other_charges'):
			if default: add_cond = 'ifnull(t2.is_default,0) = 1'
			else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
			idx = 0
			other_charge = webnotes.conn.sql("""\
				select t1.*
				from
					`tabSales Taxes and Charges` t1,
					`tabSales Taxes and Charges Master` t2
				where
					t1.parent = t2.name and
					t2.company = '%s' and
					%s
				order by t1.idx""" % (obj.doc.company, add_cond), as_dict=1)
			from webnotes.model import default_fields
			for other in other_charge:
				# remove default fields like parent, parenttype etc.
				# from query results
				for field in default_fields:
					if field in other: del other[field]

				d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges',
					obj.doclist)
				d.fields.update(other)
				d.rate = flt(d.rate)
				d.tax_amount = flt(d.tax_rate)
				d.included_in_print_rate = cint(d.included_in_print_rate)
				d.idx = idx
				idx += 1
		return obj.doclist
 def update_warranty_amc_history(self, submit = 1):
   if self.doc.order_type in ['AMC', 'OTS (One Time Service)']:
     sr_list = []
     if submit:
       for d in getlist(self.doclist, 'service_order_details'):
         sr = Document('Serial No', d.serial_no)
         child = addchild(sr, 'warranty_amc_history', 'Warranty AMC History', 0)
         child.from_date = d.start_date
         child.to_date = d.end_date
         child.status = (self.doc.order_type == 'AMC') and 'Under AMC' or 'OTS (One Time Service)'
         child.against_doctype = self.doc.doctype
         child.against_docname = self.doc.name
         child.customer = self.doc.customer
         child.territory = self.doc.territory
         child.save()
         sr.warranty_amc_status = (self.doc.order_type == 'AMC') and 'Under AMC' or 'OTS (One Time Service)'
         sr.amc_expiry_date = d.end_date
         sr.save()
         sr_list.append(d.serial_no)
     else:
       sql("delete from `tabWarranty AMC History` where against_doctype = %s and against_docname = %s", (self.doc.doctype, self.doc.name))
       for d in getlist(self.doclist, 'service_order_details'):
         sql("update `tabSerial No` set amc_expiry_date = '' where name = '%s'" % (d.serial_no))
         sr_list.append(d.serial_no)
     self.update_serial_no_warranty_amc_status(serial_no_list = sr_list)
示例#44
0
 def get_months(self):
   month_list = ['January','February','March','April','May','June','July','August','September','October','November','December']
   idx =1
   for m in month_list:
     mnth = addchild(self.doc,'budget_distribution_details','Budget Distribution Detail',1,self.doclist)
     mnth.month = m or ''
     mnth.idx = idx
     idx += 1
示例#45
0
 def get_weekly_off_dates(self):
   self.validate_values()
   yr_start_date, yr_end_date = self.get_fy_start_end_dates()
   date_list = self.get_weekly_off_date_list(yr_start_date, yr_end_date)
   for d in date_list:
     ch = addchild(self.doc, 'holiday_list_details', 'Holiday', 1, self.doclist)
     ch.description = self.doc.weekly_off
     ch.holiday_date = d
示例#46
0
def execute():
    import webnotes
    from webnotes.model import delete_doc
    from webnotes.model.code import get_obj
    from webnotes.model.doc import addchild

    # delete doctypes and tables
    for dt in [
            "TDS Payment", "TDS Return Acknowledgement", "Form 16A",
            "TDS Rate Chart", "TDS Category", "TDS Control", "TDS Detail",
            "TDS Payment Detail", "TDS Rate Detail", "TDS Category Account",
            "Form 16A Ack Detail", "Form 16A Tax Detail"
    ]:
        delete_doc("DocType", dt)

        webnotes.conn.commit()
        webnotes.conn.sql("drop table if exists `tab%s`" % dt)
        webnotes.conn.begin()

    delete_doc("Search Criteria", "tds_return")

    # Add tds entry in tax table for purchase invoice
    pi_list = webnotes.conn.sql("""select name from `tabPurchase Invoice` 
		where ifnull(tax_code, '')!='' and ifnull(ded_amount, 0)!=0""")
    for pi in pi_list:
        piobj = get_obj("Purchase Invoice", pi[0], with_children=1)
        ch = addchild(piobj.doc, 'taxes_and_charges',
                      'Purchase Taxes and Charges')
        ch.charge_type = "Actual"
        ch.account_head = piobj.doc.tax_code
        ch.description = piobj.doc.tax_code
        ch.rate = -1 * piobj.doc.ded_amount
        ch.tax_amount = -1 * piobj.doc.ded_amount
        ch.category = "Total"
        ch.save(1)

    # Add tds entry in entries table for journal voucher
    jv_list = webnotes.conn.sql("""select name from `tabJournal Voucher` 
		where ifnull(tax_code, '')!='' and ifnull(ded_amount, 0)!=0""")
    for jv in jv_list:
        jvobj = get_obj("Journal Voucher", jv[0], with_children=1)
        ch = addchild(jvobj.doc, 'entries', 'Journal Voucher Detail')
        ch.account = jvobj.doc.tax_code
        ch.credit = jvobj.doc.ded_amount
        ch.save(1)
示例#47
0
 def show_sites(self):
     self.doclist = self.doc.clear_table(self.doclist,
                                         'site_status_details')
     for filename in os.listdir(self.doc.sites_path):
         sites = addchild(self.doc, 'site_status_details',
                          'Site Status Details', self.doclist)
         sites.site_name = filename
         if filename[-1] != '1':
             sites.status = '1'
示例#48
0
	def get_landed_cost_master_details(self):
		""" pull details from landed cost master"""
		self.doclist = self.doc.clear_table(self.doclist, 'landed_cost_details')
		idx = 0
		landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1)
		for cost in landed_cost:
			lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Item', 1, self.doclist)
			lct.account_head = cost['account_head']
			lct.description = cost['description']
示例#49
0
	def get_item_specification_details(self):
		self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details')
		specification = sql("select specification, value from `tabItem Quality Inspection Parameter` \
			where parent = '%s' order by idx" % (self.doc.item_code))
		for d in specification:
			child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', 1, self.doclist)
			child.specification = d[0]
			child.value = d[1]
			child.status = 'Accepted'
示例#50
0
	def get_return_ack_details(self):
		self.doclist = self.doc.clear_table(self.doclist, 'form_16A_ack_details')
		if not (self.doc.from_date and self.doc.to_date):
			msgprint("Please enter From Date, To Date")
		else:
			ack = sql("select quarter, acknowledgement_no from `tabTDS Return Acknowledgement` where date_of_receipt>='%s' and date_of_receipt<='%s' and tds_category = '%s' order by date_of_receipt ASC" % (self.doc.from_date, self.doc.to_date, self.doc.tds_category))
			for d in ack:
				ch = addchild(self.doc, 'form_16A_ack_details', 'Form 16A Ack Detail', 1, self.doclist)
				ch.quarter = d[0]
				ch.ack_no = d[1]
示例#51
0
文件: item.py 项目: shygoly/erpnext
 def add_default_uom_in_conversion_factor_table(self):
     uom_conv_list = [
         d.uom for d in self.doclist.get(
             {"parentfield": "uom_conversion_details"})
     ]
     if self.doc.stock_uom not in uom_conv_list:
         ch = addchild(self.doc, 'uom_conversion_details',
                       'UOM Conversion Detail', self.doclist)
         ch.uom = self.doc.stock_uom
         ch.conversion_factor = 1
示例#52
0
文件: bom.py 项目: masums/erpnext
	def add_to_flat_bom_detail(self, is_submit = 0):
		"Add items to Flat BOM table"
		self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
		for d in self.cur_flat_bom_items:
			ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', 1, self.doclist)
			for i in d.keys():
				ch.fields[i] = d[i]
			ch.docstatus = is_submit
			ch.save(1)
		self.doc.save()
示例#53
0
文件: bom.py 项目: rohitw1991/erpnext
 def add_exploded_items(self):
     "Add items to Flat BOM table"
     self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details',
                                         1)
     for d in self.cur_exploded_items:
         ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item',
                       self.doclist)
         for i in d.keys():
             ch.fields[i] = d[i]
         ch.docstatus = self.doc.docstatus
         ch.save(1)
示例#54
0
	def get_outstanding_invoices(self):
		self.doclist = self.doc.clear_table(self.doclist, 'entries')
		total = 0
		for d in self.get_values():
			total += flt(d[2])
			jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist)
			jd.account = cstr(d[1])
			if self.doc.write_off_based_on == 'Accounts Receivable':
				jd.credit = flt(d[2])
				jd.against_invoice = cstr(d[0])
			elif self.doc.write_off_based_on == 'Accounts Payable':
				jd.debit = flt(d[2])
				jd.against_voucher = cstr(d[0])
			jd.save(1)
		jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist)
		if self.doc.write_off_based_on == 'Accounts Receivable':
			jd.debit = total
		elif self.doc.write_off_based_on == 'Accounts Payable':
			jd.credit = total
		jd.save(1)
示例#55
0
	def get_sales_person(self, name):			
		self.doclist = self.doc.clear_table(self.doclist,'sales_team')
		idx = 0
		for d in webnotes.conn.sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % name):
			ch = addchild(self.doc, 'sales_team', 'Sales Team', self.doclist)
			ch.sales_person = d and cstr(d[0]) or ''
			ch.allocated_percentage = d and flt(d[1]) or 0
			ch.allocated_amount = d and flt(d[2]) or 0
			ch.incentives = d and flt(d[3]) or 0
			ch.idx = idx
			idx += 1
示例#56
0
	def add_exploded_items(self):
		"Add items to Flat BOM table"
		self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
		for d in self.cur_exploded_items:
			ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', self.doclist)
			for i in self.cur_exploded_items[d].keys():
				ch.fields[i] = self.cur_exploded_items[d][i]
			ch.amount = flt(ch.qty) * flt(ch.rate)
			ch.qty_consumed_per_unit = flt(ch.qty) / flt(self.doc.quantity)
			ch.docstatus = self.doc.docstatus
			ch.save(1)
示例#57
0
def execute():
    existing = webnotes.conn.sql("""select name from `tabDocPerm`
		where permlevel=0 and parent='Event' and role='System Manager'
		and cancel=1""")
    if not existing:
        ev_obj = get_obj("DocType", "Event", with_children=1)
        ch = addchild(ev_obj.doc, "permissions", "DocPerm")
        ch.permlevel = 0
        ch.role = 'System Manager'
        ch.read = ch.write = ch.create = ch.cancel = 1
        ch.save()
示例#58
0
 def make_table(self, doct_name, tab_fname, tab_name):
     list1 = sql("select name from `tab%s` where docstatus != 2" %
                 doct_name)
     for li in list1:
         child = addchild(self.doc, tab_fname, tab_name, 1, self.doclist)
         if (tab_fname == 'earning_details'):
             child.e_type = cstr(li[0])
             child.modified_value = 0
         elif (tab_fname == 'deduction_details'):
             child.d_type = cstr(li[0])
             child.d_modified_amt = 0
示例#59
0
	def get_weekly_off_dates(self):
		self.validate_values()
		yr_start_date, yr_end_date = self.get_fy_start_end_dates()
		date_list = self.get_weekly_off_date_list(yr_start_date, yr_end_date)
		last_idx = max([cint(d.idx) for d in self.doclist.get(
			{"parentfield": "holiday_list_details"})] or [0,])
		for i, d in enumerate(date_list):
			ch = addchild(self.doc, 'holiday_list_details', 'Holiday', self.doclist)
			ch.description = self.doc.weekly_off
			ch.holiday_date = d
			ch.idx = last_idx + i + 1
	def create_payment_table(self, gle):
		for d in gle:
			ch = addchild(self.doc, 'ir_payment_details', 'Payment to Invoice Matching Tool Detail', 1, self.doclist)
			ch.voucher_no = d.get('voucher_no')
			ch.posting_date = d.get('posting_date')
			ch.amt_due =  self.acc_type == 'debit' and flt(d.get('amt_due')) or -1*flt(d.get('amt_due'))
			ch.total_amt = flt(d.get('total_amt'))
			ch.against_account = d.get('against_account')
			ch.remarks = d.get('remark')
			ch.amt_to_be_reconciled = flt(ch.amt_due)
			ch.voucher_detail_no = d.get('voucher_detail_no')