blob: d2f29b273efe60867e8634a65b76c3fc95de18e2 [file] [log] [blame]
Nabin Hait2df4d542013-01-29 11:34:39 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from __future__ import unicode_literals
18import webnotes
Nabin Hait2df4d542013-01-29 11:34:39 +053019
Nabin Haitbf495c92013-01-30 12:49:08 +053020from utilities.transaction_base import TransactionBase
Nabin Hait2df4d542013-01-29 11:34:39 +053021
Nabin Haitbf495c92013-01-30 12:49:08 +053022class AccountsController(TransactionBase):
Nabin Hait2df4d542013-01-29 11:34:39 +053023 def get_gl_dict(self, args, cancel):
24 """this method populates the common properties of a gl entry record"""
25 gl_dict = {
26 'company': self.doc.company,
27 'posting_date': self.doc.posting_date,
28 'voucher_type': self.doc.doctype,
29 'voucher_no': self.doc.name,
30 'aging_date': self.doc.fields.get("aging_date") or self.doc.posting_date,
31 'remarks': self.doc.remarks,
32 'is_cancelled': cancel and "Yes" or "No",
33 'fiscal_year': self.doc.fiscal_year,
34 'debit': 0,
35 'credit': 0,
36 'is_opening': self.doc.fields.get("is_opening") or "No",
37 }
38 gl_dict.update(args)
39 return gl_dict
40
41 def get_company_abbr(self):
42 return webnotes.conn.get_value("Company", self.doc.company, "abbr")
43
44 def get_stock_in_hand_account(self):
45 stock_in_hand = webnotes.conn.get_value("Company", self.doc.company, "stock_in_hand")
46
47 if not stock_in_hand:
48 webnotes.msgprint("""Please specify "Stock In Hand" account
49 for company: %s""" % (self.doc.company,), raise_exception=1)
50
51 return stock_in_hand