Esempio n. 1
0
	def calculate_totals(self):
		self.doc.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist 
			else self.doc.net_total, self.precision("grand_total"))
		self.doc.grand_total_import = flt(self.doc.grand_total / self.doc.conversion_rate,
			self.precision("grand_total_import"))

		self.doc.total_tax = flt(self.doc.grand_total - self.doc.net_total,
			self.precision("total_tax"))

		if self.meta.get_field("rounded_total"):
			self.doc.rounded_total = _round(self.doc.grand_total)
		
		if self.meta.get_field("rounded_total_import"):
			self.doc.rounded_total_import = _round(self.doc.grand_total_import)
				
		if self.meta.get_field("other_charges_added"):
			self.doc.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist 
				if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]), 
				self.precision("other_charges_added"))
				
		if self.meta.get_field("other_charges_deducted"):
			self.doc.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.tax_doclist 
				if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]), 
				self.precision("other_charges_deducted"))
				
		if self.meta.get_field("other_charges_added_import"):
			self.doc.other_charges_added_import = flt(self.doc.other_charges_added / 
				self.doc.conversion_rate, self.precision("other_charges_added_import"))
				
		if self.meta.get_field("other_charges_deducted_import"):
			self.doc.other_charges_deducted_import = flt(self.doc.other_charges_deducted / 
				self.doc.conversion_rate, self.precision("other_charges_deducted_import"))
Esempio n. 2
0
	def calculate_totals(self):
		self.doc.grand_total = flt(self.tax_doclist and \
			self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
		self.doc.grand_total_export = flt(self.doc.grand_total / self.doc.conversion_rate, 
			self.precision("grand_total_export"))
			
		self.doc.other_charges_total = flt(self.doc.grand_total - self.doc.net_total,
			self.precision("other_charges_total"))
		self.doc.other_charges_total_export = flt(self.doc.grand_total_export - self.doc.net_total_export,
			self.precision("other_charges_total_export"))
		
		self.doc.rounded_total = _round(self.doc.grand_total)
		self.doc.rounded_total_export = _round(self.doc.grand_total_export)
Esempio n. 3
0
	def calculate_totals(self):
		self.doc.grand_total = flt(self.tax_doclist and \
			self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
		self.doc.grand_total_export = flt(self.doc.grand_total / self.doc.conversion_rate, 
			self.precision("grand_total_export"))
			
		self.doc.other_charges_total = flt(self.doc.grand_total - self.doc.net_total,
			self.precision("other_charges_total"))
		self.doc.other_charges_total_export = flt(self.doc.grand_total_export - self.doc.net_total_export,
			self.precision("other_charges_total_export"))
		
		self.doc.rounded_total = _round(self.doc.grand_total)
		self.doc.rounded_total_export = _round(self.doc.grand_total_export)
	def calculate_totals(self):
		self.doc.grand_total = flt(self.tax_doclist and \
			self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
		self.doc.grand_total_import = flt(self.doc.grand_total / self.doc.conversion_rate,
			self.precision("grand_total_import"))

		self.doc.total_tax = flt(self.doc.grand_total - self.doc.net_total,
			self.precision("total_tax"))

		if self.meta.get_field("rounded_total"):
			self.doc.rounded_total = _round(self.doc.grand_total)
		
		if self.meta.get_field("rounded_total_import"):
			self.doc.rounded_total_import = _round(self.doc.grand_total_import)
Esempio n. 5
0
    def calculate_totals(self):
        self.doc.grand_total = flt(self.tax_doclist and \
         self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
        self.doc.grand_total_import = flt(
            self.doc.grand_total / self.doc.conversion_rate,
            self.precision("grand_total_import"))

        self.doc.total_tax = flt(self.doc.grand_total - self.doc.net_total,
                                 self.precision("total_tax"))

        if self.meta.get_field("rounded_total"):
            self.doc.rounded_total = _round(self.doc.grand_total)

        if self.meta.get_field("rounded_total_import"):
            self.doc.rounded_total_import = _round(self.doc.grand_total_import)
Esempio n. 6
0
	def calculate_ded_total(self):
		self.doc.total_deduction = 0
		qry=webnotes.conn.sql(" select name from `tabEmployee Loan` where employee_id=%s", self.doc.employee ,as_list=1)
		#webnotes.errprint(qry)
		r=0
		if len(qry)!=0:
			qr=webnotes.conn.sql("select date_of_installment from `tabLoan Installment Details` where parent=%s",qry[0][0],as_list=1)
			for i in qr:
				t=getdate(i[0]).month
				if t == cint(self.doc.month):
					q=webnotes.conn.sql("select amount_to_be_paid from `tabLoan Installment Details` where date_of_installment=%s and parent=%s",(getdate(i[0]),qry[0][0]),as_list=1)
					w=webnotes.conn.sql("Update `tabLoan Installment Details` set status='Paid' where date_of_installment=%s",getdate(i[0]))
					#webnotes.errprint(q)
					r=q[0][0]
					self.doc.loan_amount=r
		m=0.0
		for d in getlist(self.doclist, 'deduction_details'):
			if cint(d.d_depends_on_lwp) == 1:
				d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days) 
					/ cint(self.doc.total_days_in_month), 2)
			elif not self.doc.payment_days:
				d.d_modified_amount = 0
			else:
				d.d_modified_amount = d.d_amount
			m+=flt(d.d_modified_amount)	
		#m+=flt(d.d_modified_amount)
		self.doc.total_deduction= m+flt(r)
Esempio n. 7
0
    def calculate_totals(self):
        self.doc.grand_total = flt(
            self.tax_doclist[-1].total
            if self.tax_doclist else self.doc.net_total,
            self.precision("grand_total"))
        self.doc.grand_total_import = flt(
            self.doc.grand_total / self.doc.conversion_rate,
            self.precision("grand_total_import"))

        self.doc.total_tax = flt(self.doc.grand_total - self.doc.net_total,
                                 self.precision("total_tax"))

        if self.meta.get_field("rounded_total"):
            self.doc.rounded_total = _round(self.doc.grand_total)

        if self.meta.get_field("rounded_total_import"):
            self.doc.rounded_total_import = _round(self.doc.grand_total_import)

        if self.meta.get_field("other_charges_added"):
            self.doc.other_charges_added = flt(
                sum([
                    flt(d.tax_amount) for d in self.tax_doclist
                    if d.add_deduct_tax == "Add"
                    and d.category in ["Valuation and Total", "Total"]
                ]), self.precision("other_charges_added"))

        if self.meta.get_field("other_charges_deducted"):
            self.doc.other_charges_deducted = flt(
                sum([
                    flt(d.tax_amount) for d in self.tax_doclist
                    if d.add_deduct_tax == "Deduct"
                    and d.category in ["Valuation and Total", "Total"]
                ]), self.precision("other_charges_deducted"))

        if self.meta.get_field("other_charges_added_import"):
            self.doc.other_charges_added_import = flt(
                self.doc.other_charges_added / self.doc.conversion_rate,
                self.precision("other_charges_added_import"))

        if self.meta.get_field("other_charges_deducted_import"):
            self.doc.other_charges_deducted_import = flt(
                self.doc.other_charges_deducted / self.doc.conversion_rate,
                self.precision("other_charges_deducted_import"))
Esempio n. 8
0
	def calculate_earning_total(self):
		self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount)
		for d in self.doclist.get({"parentfield": "earning_details"}):
			if cint(d.e_depends_on_lwp) == 1:
				d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days)
					/ cint(self.doc.total_days_in_month), 2)
			elif not self.doc.payment_days:
				d.e_modified_amount = 0
			else:
				d.e_modified_amount = d.e_amount
			self.doc.gross_pay += flt(d.e_modified_amount)
Esempio n. 9
0
	def calculate_ded_total(self):
		self.doc.total_deduction = 0
		for d in getlist(self.doclist, 'deduction_details'):
			if cint(d.d_depends_on_lwp) == 1:
				d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days) 
					/ cint(self.doc.total_days_in_month), 2)
			elif not self.doc.payment_days:
				d.d_modified_amount = 0
			else:
				d.d_modified_amount = d.d_amount
			
			self.doc.total_deduction += flt(d.d_modified_amount)
Esempio n. 10
0
	def calculate_ded_total(self):
		self.doc.total_deduction = 0
		qry=webnotes.conn.sql(" select name from `tabEmployee Loan` where employee_name=%s", self.doc.employee ,as_list=1)
		#webnotes.errprint(qry)
		if len(qry)!=0:
			qr=webnotes.conn.sql("select date_of_installment from `tabLoan Installment Details` where parent=%s",qry[0][0],as_list=1)
			#webnotes.errprint(qr)
			r=0
			for i in qr:
				t=getdate(i[0]).month
				#webnotes.errprint(t)
				#webnotes.errprint(self.doc.month)
				webnotes.errprint(t == cint(self.doc.month))
				if t == cint(self.doc.month):
					webnotes.errprint("in if loop")
					#webnotes.errprint(getdate(i[0]))
					q=webnotes.conn.sql("select amount_to_be_paid from `tabLoan Installment Details` where date_of_installment=%s and parent=%s",(getdate(i[0]),qry[0][0]),as_list=1)
					w=webnotes.conn.sql("Update `tabLoan Installment Details` set status='Paid' where date_of_installment=%s",getdate(i[0]))
					#webnotes.errprint(q)
					r=q[0][0]
					#ch = addchild(self.doc, 'deduction_details', 
					#'Salary Slip Deduction', self.doclist)
					#ch.d_type='Loan'
					#ch.d_amount=r
					#ch.d_modified_amount=r
					#ch.save(new=1)						
					self.doc.loan_amount=r
					#webnotes.errprint(ch) 
					#return{
					#	'd_type':ch.d_type
						#'ch.d_amount':r
						#'ch.d_modified_amount':r
					#}
					#webnotes.errprint(self.doc.loan_amount)
		m=0.0
		for d in getlist(self.doclist, 'deduction_details'):
			if cint(d.d_depends_on_lwp) == 1:
				d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days) 
					/ cint(self.doc.total_days_in_month), 2)
			elif not self.doc.payment_days:
				d.d_modified_amount = 0
			else:
				d.d_modified_amount = d.d_amount
			m+=flt(d.d_modified_amount)
		if self.doc.loan_amount:
			ch = addchild(self.doc, 'deduction_details', 'Salary Slip Deduction', self.doclist)
               		ch.d_type='Loan'
                	ch.d_amount=cstr(self.doc.loan_amount)
                	ch.d_modified_amount=cstr(self.doc.loan_amount)
			ch.parent=self.doc.name
			ch.parentfield='deduction_details'
			ch.parenttype='Salary Slip'
		self.doc.total_deduction= m+flt(self.doc.loan_amount)
Esempio n. 11
0
    def calculate_ded_total(self):
        self.doc.total_deduction = 0
        for d in getlist(self.doclist, 'deduction_details'):
            if cint(d.d_depends_on_lwp) == 1:
                d.d_modified_amount = _round(
                    flt(d.d_amount) * flt(self.doc.payment_days) /
                    cint(self.doc.total_days_in_month), 2)
            elif not self.doc.payment_days:
                d.d_modified_amount = 0
            else:
                d.d_modified_amount = d.d_amount

            self.doc.total_deduction += flt(d.d_modified_amount)
Esempio n. 12
0
 def calculate_earning_total(self):
     self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(
         self.doc.leave_encashment_amount)
     for d in self.doclist.get({"parentfield": "earning_details"}):
         if cint(d.e_depends_on_lwp) == 1:
             d.e_modified_amount = _round(
                 flt(d.e_amount) * flt(self.doc.payment_days) /
                 cint(self.doc.total_days_in_month), 2)
         elif not self.doc.payment_days:
             d.e_modified_amount = 0
         else:
             d.e_modified_amount = d.e_amount
         self.doc.gross_pay += flt(d.e_modified_amount)
Esempio n. 13
0
 def calculate_ded_total(self):
     self.doc.total_deduction = 0
     qry = webnotes.conn.sql(
         " select name from `tabEmployee Loan` where employee_id=%s",
         self.doc.employee,
         as_list=1)
     #webnotes.errprint(qry)
     r = 0
     if len(qry) != 0:
         qr = webnotes.conn.sql(
             "select date_of_installment from `tabLoan Installment Details` where parent=%s",
             qry[0][0],
             as_list=1)
         for i in qr:
             t = getdate(i[0]).month
             if t == cint(self.doc.month):
                 q = webnotes.conn.sql(
                     "select amount_to_be_paid from `tabLoan Installment Details` where date_of_installment=%s and parent=%s",
                     (getdate(i[0]), qry[0][0]),
                     as_list=1)
                 w = webnotes.conn.sql(
                     "Update `tabLoan Installment Details` set status='Paid' where date_of_installment=%s",
                     getdate(i[0]))
                 #webnotes.errprint(q)
                 r = q[0][0]
                 self.doc.loan_amount = r
     m = 0.0
     for d in getlist(self.doclist, 'deduction_details'):
         if cint(d.d_depends_on_lwp) == 1:
             d.d_modified_amount = _round(
                 flt(d.d_amount) * flt(self.doc.payment_days) /
                 cint(self.doc.total_days_in_month), 2)
         elif not self.doc.payment_days:
             d.d_modified_amount = 0
         else:
             d.d_modified_amount = d.d_amount
         m += flt(d.d_modified_amount)
     #m+=flt(d.d_modified_amount)
     self.doc.total_deduction = m + flt(r)
Esempio n. 14
0
	def calculate_net_pay(self):
		self.calculate_earning_total()
		self.calculate_ded_total()
		self.doc.net_pay = flt(self.doc.gross_pay) - flt(self.doc.total_deduction)
		self.doc.rounded_total = _round(self.doc.net_pay)		
Esempio n. 15
0
 def calculate_net_pay(self):
     self.calculate_earning_total()
     self.calculate_ded_total()
     self.doc.net_pay = flt(self.doc.gross_pay) - flt(
         self.doc.total_deduction)
     self.doc.rounded_total = _round(self.doc.net_pay)
Esempio n. 16
0
	def calculate_earning_total(self):
	        self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount)
		s_date = e_date = ''
		        #webnotes.errprint("in sales target")
		if cint(self.doc.month)%3 == 0:
                	s_date, e_date = self.get_dates(cint(self.doc.month))
                #m=cint(self.doc.month)
              		#webnotes.errprint(m)
	        m_name=calendar.month_name[cint(self.doc.month)]
                webnotes.errprint(m_name)
                
		# if m==3 or m==6 or m==9 or m==12:

	 #                if  m==3:
	 #                        s_date, e_date = self.get_dates(m)
	 #                        # webnotes.errprint("in first")
  #       	                # s_date='2014-01-01'
  #               	        # e_date='2014-03-31'
  #                       	# webnotes.errprint(s_date)
	 #                        # webnotes.errprint(e_date)
  #       	        elif  m==6:
  #       	        	    s_date, e_date = self.get_dates(m)
  #               	        # webnotes.errprint("in second")
  #                       	# s_date='2014-04-01'
	 #                        # e_date='2014-06-30'
		# 		# webnotes.errprint(s_date)
  #               	        # webnotes.errprint(e_date)

	 #                elif  m==9:
	 #                	    s_date, e_date = self.get_dates(m)
  #       	                # webnotes.errprint("in third")
  #               	        # s_date='2014-07-01'
  #                       	# e_date='2014-09-30'
	 #                elif m==12:
	 #                	    s_date, e_date = self.get_dates(m)
        	                # webnotes.errprint("in forth")
                	        # s_date='2014-07-01'
                        	# e_date='2014-12-31'
			 #webnotes.errprint([select parent,target_amount ,variable_pay from `tabTarget Detail` where parent in  (select sales_person from `tabSales Team` where parent in 
                         #               (select name from `tabSales Order` where transaction_date between %s and %s  
                         #             group by sales_person)) ,(s_date,e_date)])
		if s_date and e_date:
			qry1=webnotes.conn.sql("""select parent,target_amount ,variable_pay from `tabTarget Detail` where parent in  (select sales_person from `tabSales Team` where parent in 
                                        (select name from `tabSales Order` where transaction_date between %s and %s
                                       group by sales_person)) """,(s_date,e_date) ,debug=1)
			webnotes.errprint(qry1)
                #list1=[]
               		for i in qry1:
				webnotes.errprint("in for loop")
				name=webnotes.conn.sql("""select employee from `tabSales Person` where name=%s """,i[0],as_list=1)
				webnotes.errprint(name)
		                if name[0][0] == self.doc.employee:
					webnotes.errprint(name[0][0])

                        #webnotes.errprint(i[0])                
		                       	qr=webnotes.conn.sql("""select distribution_id  from `tabSales Person` where name=%s""",i[0],as_list=1)
       	                #webnotes.errprint(qr)
               		        	if m_name=='January' or m_name=='February' or m_name=='March':
                       		        	month='January-March'
                        		elif m_name=='April' or m_name=='May' or m_name=='June':
       	                        		month='April-June'
					
	               	        	elif m_name=='July' or m_name=='August' or m_name=='September':
        	               	        	month='July-September'
                	        	else:
       	                	        	month='October-December'
              	        		webnotes.errprint(month)
					if qr:
						webnotes.errprint("percentage allocation")
		                       		qt=webnotes.conn.sql(""" select percentage_allocation/100 from `tabBudget Distribution Detail` where 
        	                               	        month=%s and parent=%s""",(month,qr[0][0]))
        		               		webnotes.errprint(qt[0][0])
                       #webnotes.errprint(qt[0][0]*i[1])
                		       		amt=qt[0][0]*i[1]
                       				webnotes.errprint(amt)
                       				qry=webnotes.conn.sql(""" select sum(allocated_amount) as amount from `tabSales Team` where parent in 
                               		       		(select name from `tabSales Order` where transaction_date between %s and %s and docstatus=1) 
                                    			and  sales_person=%s """,(s_date,e_date,i[0]))
	                       			webnotes.errprint(qry)
			#name=webnotes.conn.sql("""select employee from `tabSales Person` where name=%s """,i[0],as_list=1)
                        #webnotes.errprint(name[0][0])
                        #webnotes.errprint(["pay",i[2]])
						if qry:

	                	       			t= ((flt(qry[0][0])/amt)*100)/(100)
        		               			webnotes.errprint(t)
					#webnotes.msgprint(i[2])
                	       				pay= (i[2]/4)*t
					#webnotes.msgprint(pay)
							self.doc.variable_pay=pay
        	               				webnotes.errprint(self.doc.variable_pay)
	
	

		for d in self.doclist.get({"parentfield": "earning_details"}):
			if cint(d.e_depends_on_lwp) == 1:
				d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days)
					/ cint(self.doc.total_days_in_month), 2)
			elif not self.doc.payment_days:
				d.e_modified_amount = 0
			else:
				d.e_modified_amount = d.e_amount
			self.doc.gross_pay += flt(d.e_modified_amount)
		self.doc.gross_pay +=flt(self.doc.variable_pay)