def before_submit(self, *args, **kwargs):
     credit_account = frappe.get_doc("Account", self.credit_account)
     credit_account.credit(self.amount)
     debit_account = frappe.get_doc("Account", self.debit_account)
     debit_account.debit(self.amount)
     GeneralLedger.make_double_entry(credit_account=credit_account,
                                     debit_account=debit_account,
                                     amount=self.amount,
                                     txn_type="Journal Entry",
                                     txn_id=self.name)
Esempio n. 2
0
 def before_cancel(self, *args, **kwargs):
     supplier = frappe.get_doc("Supplier", self.supplier)
     supplier_account = frappe.get_doc("Account", supplier.supplier_account)
     stock_expense_account = frappe.get_doc("Account", "Stock Expense")
     supplier_account.debit(self.total)
     stock_expense_account.credit(self.total)
     GeneralLedger.make_double_entry(credit_account=stock_expense_account,
                                     debit_account=supplier_account,
                                     amount=self.total,
                                     txn_type="Purchase Invoice",
                                     txn_id=self.name)
 def before_cancel(self):
     customer = frappe.get_doc("Customer", self.customer)
     customer_account = frappe.get_doc("Account", customer.customer_account)
     sales_account = frappe.get_doc("Account", "Sales Income")
     customer_account.credit(self.total)
     sales_account.debit(self.total)
     GeneralLedger.make_double_entry(credit_account=customer_account,
                                     debit_account=sales_account,
                                     amount=self.total,
                                     txn_id=self.name,
                                     txn_type="Sales Invoice")
	def before_cancel(self):
		invoice = frappe.get_doc(self.payment_type,self.against_invoice)
		cash_account = frappe.get_doc("Account","Cash")
		if self.payment_type == "Sales Invoice":
			credit_account = frappe.get_doc("Account",invoice.customer)
			debit_account = cash_account
		elif self.payment_type == "Purchase Invoice":
			debit_account = frappe.get_doc("Account",invoice.supplier)
			credit_account = cash_account
		credit_account.debit(self.payment_amount)
		debit_account.credit(self.payment_amount)
		GeneralLedger.make_double_entry(credit_account=debit_account,debit_account=credit_account,amount=self.payment_amount,txn_type="Payment Entry",txn_id=self.name)
Esempio n. 5
0
 def before_submit(self, *args, **kwargs):
     total = 0
     for item in self.items:
         total += item.item_total
     if total != self.total:
         frappe.throw("Items totals and Invoice total doesn't match")
     supplier = frappe.get_doc("Supplier", self.supplier)
     supplier_account = frappe.get_doc("Account", supplier.supplier_account)
     stock_expense_account = frappe.get_doc("Account", "Stock Expense")
     supplier_account.credit(self.total)
     stock_expense_account.debit(self.total)
     GeneralLedger.make_double_entry(credit_account=supplier_account,
                                     debit_account=stock_expense_account,
                                     amount=self.total,
                                     txn_type="Purchase Invoice",
                                     txn_id=self.name)
 def before_submit(self, *args, **kwargs):
     total = 0
     for item in self.items:
         total += item.item_total
     if total != self.total:
         frappe.throw("Items totals and Invoice total doesn't match")
     customer = frappe.get_doc("Customer", self.customer)
     customer_account = frappe.get_doc("Account", customer.customer_account)
     sales_account = frappe.get_doc("Account", "Sales Income")
     customer_account.debit(self.total)
     sales_account.credit(self.total)
     GeneralLedger.make_double_entry(credit_account=sales_account,
                                     debit_account=customer_account,
                                     amount=self.total,
                                     txn_id=self.name,
                                     txn_type="Sales Invoice")
	def before_submit(self,*args,**kwargs):
		invoice = frappe.get_doc(self.payment_type,self.against_invoice)
		cash_account = frappe.get_doc("Account","Cash")

		entries = frappe.get_list('Payment Entry',fields=['name','payment_amount'],filters=[["against_invoice","=",self.against_invoice],["docstatus","=",1]])
		print(entries)
		total = 0
		for entry in entries:
			total+= entry.payment_amount
		pending_amount = invoice.total - total
		print("pending amount:"+str(pending_amount))
		if pending_amount < self.payment_amount:
			frappe.throw("Don't overpay bruh")
		if self.payment_type == "Sales Invoice":
			credit_account = frappe.get_doc("Account",invoice.customer)
			debit_account = cash_account
		elif self.payment_type == "Purchase Invoice":
			debit_account = frappe.get_doc("Account",invoice.supplier)
			credit_account = cash_account
		credit_account.credit(self.payment_amount)
		debit_account.debit(self.payment_amount)	
		GeneralLedger.make_double_entry(credit_account=credit_account,debit_account=debit_account,amount=self.payment_amount,txn_type="Payment Entry",txn_id=self.name)