Exemple #1
0
    def make_gl_entries(self,
                        gl_entries=None,
                        repost_future_gle=True,
                        from_repost=False):
        if self.docstatus == 2:
            delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)

        if cint(epaas.is_perpetual_inventory_enabled(self.company)):
            warehouse_account = get_warehouse_account_map(self.company)

            if self.docstatus == 1:
                if not gl_entries:
                    gl_entries = self.get_gl_entries(warehouse_account)
                make_gl_entries(gl_entries, from_repost=from_repost)

            if repost_future_gle:
                items, warehouses = self.get_items_and_warehouses()
                update_gl_entries_after(self.posting_date,
                                        self.posting_time,
                                        warehouses,
                                        items,
                                        warehouse_account,
                                        company=self.company)
        elif self.doctype in ['Purchase Receipt', 'Purchase Invoice'
                              ] and self.docstatus == 1:
            gl_entries = []
            gl_entries = self.get_asset_gl_entry(gl_entries)
            make_gl_entries(gl_entries, from_repost=from_repost)
Exemple #2
0
 def make_gl_entries(self):
     if not self.grand_total:
         return
     student_gl_entries = self.get_gl_dict({
         "account":
         self.receivable_account,
         "party_type":
         "Student",
         "party":
         self.student,
         "against":
         self.income_account,
         "debit":
         self.grand_total,
         "debit_in_account_currency":
         self.grand_total,
         "against_voucher":
         self.name,
         "against_voucher_type":
         self.doctype
     })
     fee_gl_entry = self.get_gl_dict({
         "account": self.income_account,
         "against": self.student,
         "credit": self.grand_total,
         "credit_in_account_currency": self.grand_total,
         "cost_center": self.cost_center
     })
     from epaas.accounts.general_ledger import make_gl_entries
     make_gl_entries([student_gl_entries, fee_gl_entry],
                     cancel=(self.docstatus == 2),
                     update_outstanding="Yes",
                     merge_entries=False)
Exemple #3
0
    def make_gl_entries(self):
        gl_entries = []

        if ((self.purchase_receipt or
             (self.purchase_invoice and dataent.db.get_value(
                 'Purchase Invoice', self.purchase_invoice, 'update_stock')))
                and self.purchase_receipt_amount
                and self.available_for_use_date <= nowdate()):
            fixed_aseet_account = get_asset_category_account(
                self.name,
                'fixed_asset_account',
                asset_category=self.asset_category,
                company=self.company)

            cwip_account = get_asset_account(
                "capital_work_in_progress_account", self.name,
                self.asset_category, self.company)

            gl_entries.append(
                self.get_gl_dict({
                    "account":
                    cwip_account,
                    "against":
                    fixed_aseet_account,
                    "remarks":
                    self.get("remarks") or _("Accounting Entry for Asset"),
                    "posting_date":
                    self.available_for_use_date,
                    "credit":
                    self.purchase_receipt_amount,
                    "credit_in_account_currency":
                    self.purchase_receipt_amount
                }))

            gl_entries.append(
                self.get_gl_dict({
                    "account":
                    fixed_aseet_account,
                    "against":
                    cwip_account,
                    "remarks":
                    self.get("remarks") or _("Accounting Entry for Asset"),
                    "posting_date":
                    self.available_for_use_date,
                    "debit":
                    self.purchase_receipt_amount,
                    "debit_in_account_currency":
                    self.purchase_receipt_amount
                }))

        if gl_entries:
            from epaas.accounts.general_ledger import make_gl_entries

            make_gl_entries(gl_entries)
            self.db_set('booked_fixed_asset', 1)
Exemple #4
0
    def make_adjustment_entry(self, expected_gle, voucher_obj):
        from epaas.accounts.utils import get_stock_and_account_difference
        account_list = [d.account for d in expected_gle]
        acc_diff = get_stock_and_account_difference(
            account_list, expected_gle[0].posting_date, self.company)

        cost_center = self.get_company_default("cost_center")
        stock_adjustment_account = self.get_company_default(
            "stock_adjustment_account")

        gl_entries = []
        for account, diff in acc_diff.items():
            if diff:
                gl_entries.append([
                    # stock in hand account
                    voucher_obj.get_gl_dict({
                        "account":
                        account,
                        "against":
                        stock_adjustment_account,
                        "debit":
                        diff,
                        "remarks":
                        "Adjustment Accounting Entry for Stock",
                    }),

                    # account against stock in hand
                    voucher_obj.get_gl_dict({
                        "account":
                        stock_adjustment_account,
                        "against":
                        account,
                        "credit":
                        diff,
                        "cost_center":
                        cost_center or None,
                        "remarks":
                        "Adjustment Accounting Entry for Stock",
                    }),
                ])

        if gl_entries:
            from epaas.accounts.general_ledger import make_gl_entries
            make_gl_entries(gl_entries)
    def make_gl_entries(self):
        gl_entries = []
        net_pl_balance = 0
        pl_accounts = self.get_pl_balances()

        for acc in pl_accounts:
            if flt(acc.balance_in_company_currency):
                gl_entries.append(self.get_gl_dict({
                 "account": acc.account,
                 "cost_center": acc.cost_center,
                 "account_currency": acc.account_currency,
                 "debit_in_account_currency": abs(flt(acc.balance_in_account_currency)) \
                  if flt(acc.balance_in_account_currency) < 0 else 0,
                 "debit": abs(flt(acc.balance_in_company_currency)) \
                  if flt(acc.balance_in_company_currency) < 0 else 0,
                 "credit_in_account_currency": abs(flt(acc.balance_in_account_currency)) \
                  if flt(acc.balance_in_account_currency) > 0 else 0,
                 "credit": abs(flt(acc.balance_in_company_currency)) \
                  if flt(acc.balance_in_company_currency) > 0 else 0
                }))

                net_pl_balance += flt(acc.balance_in_company_currency)

        if net_pl_balance:
            cost_center = dataent.db.get_value("Company", self.company,
                                               "cost_center")
            gl_entries.append(
                self.get_gl_dict({
                    "account":
                    self.closing_account_head,
                    "debit_in_account_currency":
                    abs(net_pl_balance) if net_pl_balance > 0 else 0,
                    "debit":
                    abs(net_pl_balance) if net_pl_balance > 0 else 0,
                    "credit_in_account_currency":
                    abs(net_pl_balance) if net_pl_balance < 0 else 0,
                    "credit":
                    abs(net_pl_balance) if net_pl_balance < 0 else 0,
                    "cost_center":
                    cost_center
                }))

        from epaas.accounts.general_ledger import make_gl_entries
        make_gl_entries(gl_entries)
Exemple #6
0
def make_gl_entries(doc, credit_account, debit_account, against,
	amount, base_amount, posting_date, project, account_currency, cost_center, voucher_detail_no):
	# GL Entry for crediting the amount in the deferred expense
	from epaas.accounts.general_ledger import make_gl_entries

	gl_entries = []
	gl_entries.append(
		doc.get_gl_dict({
			"account": credit_account,
			"against": against,
			"credit": base_amount,
			"credit_in_account_currency": amount,
			"cost_center": cost_center,
			"voucher_detail_no": voucher_detail_no,
			'posting_date': posting_date,
			'project': project
		}, account_currency)
	)
	# GL Entry to debit the amount from the expense
	gl_entries.append(
		doc.get_gl_dict({
			"account": debit_account,
			"against": against,
			"debit": base_amount,
			"debit_in_account_currency": amount,
			"cost_center": cost_center,
			"voucher_detail_no": voucher_detail_no,
			'posting_date': posting_date,
			'project': project
		}, account_currency)
	)

	if gl_entries:
		try:
			make_gl_entries(gl_entries, cancel=(doc.docstatus == 2), merge_entries=True)
			dataent.db.commit()
		except:
			dataent.db.rollback()
			title = _("Error while processing deferred accounting for {0}").format(doc.name)
			traceback = dataent.get_traceback()
			dataent.log_error(message=traceback , title=title)
			sendmail_to_system_managers(title, traceback)
Exemple #7
0
	def _book_deferred_revenue_or_expense(item):
		start_date, end_date, last_gl_entry = get_booking_dates(doc, item, posting_date=posting_date)
		if not (start_date and end_date): return

		account_currency = get_account_currency(item.expense_account)
		if doc.doctype == "Sales Invoice":
			against, project = doc.customer, doc.project
			credit_account, debit_account = item.income_account, item.deferred_revenue_account
		else:
			against, project = doc.supplier, item.project
			credit_account, debit_account = item.deferred_expense_account, item.expense_account

		total_days = date_diff(item.service_end_date, item.service_start_date) + 1
		total_booking_days = date_diff(end_date, start_date) + 1

		amount, base_amount = calculate_amount(doc, item, last_gl_entry,
			total_days, total_booking_days, account_currency)

		make_gl_entries(doc, credit_account, debit_account, against,
			amount, base_amount, end_date, project, account_currency, item.cost_center, item.name)

		if getdate(end_date) < getdate(posting_date) and not last_gl_entry:
			_book_deferred_revenue_or_expense(item)
Exemple #8
0
	def make_gl_entries(self, gl_entries=None, repost_future_gle=True, from_repost=False):
		if not self.grand_total:
			return
		if not gl_entries:
			gl_entries = self.get_gl_entries()

		if gl_entries:
			update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes"

			make_gl_entries(gl_entries,  cancel=(self.docstatus == 2),
				update_outstanding=update_outstanding, merge_entries=False)

			if update_outstanding == "No":
				update_outstanding_amt(self.credit_to, "Supplier", self.supplier,
					self.doctype, self.return_against if cint(self.is_return) and self.return_against else self.name)

			if repost_future_gle and cint(self.update_stock) and self.auto_accounting_for_stock:
				from epaas.controllers.stock_controller import update_gl_entries_after
				items, warehouses = self.get_items_and_warehouses()
				update_gl_entries_after(self.posting_date, self.posting_time,
					warehouses, items, company = self.company)

		elif self.docstatus == 2 and cint(self.update_stock) and self.auto_accounting_for_stock:
			delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
Exemple #9
0
 def make_gl_entries(self, cancel=False):
     if flt(self.total_sanctioned_amount) > 0:
         gl_entries = self.get_gl_entries()
         make_gl_entries(gl_entries, cancel)