commit
ddd2b8a398
@ -3,7 +3,6 @@ include requirements.txt
|
|||||||
include *.json
|
include *.json
|
||||||
include *.md
|
include *.md
|
||||||
include *.py
|
include *.py
|
||||||
include *.txt
|
|
||||||
recursive-include erpnext *.css
|
recursive-include erpnext *.css
|
||||||
recursive-include erpnext *.csv
|
recursive-include erpnext *.csv
|
||||||
recursive-include erpnext *.html
|
recursive-include erpnext *.html
|
||||||
@ -14,5 +13,4 @@ recursive-include erpnext *.md
|
|||||||
recursive-include erpnext *.png
|
recursive-include erpnext *.png
|
||||||
recursive-include erpnext *.py
|
recursive-include erpnext *.py
|
||||||
recursive-include erpnext *.svg
|
recursive-include erpnext *.svg
|
||||||
recursive-include erpnext *.txt
|
|
||||||
recursive-exclude * *.pyc
|
recursive-exclude * *.pyc
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"creation": "2012-04-11 13:16:56.000000",
|
||||||
|
"doc_type": "Journal Voucher",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Print Format",
|
||||||
|
"html": "<!-- p.big {line-height: 200%} .noborder td { border: 0px solid #fff; } -->\n<div style=\"position: relative;\">\n<h3><script>doc.company</script><br /> <br /> \n<hr />\nPAYMENT ADVICE</h3>\n<table class=\"noborder\" style=\"width: 100%;\">\n<tbody>\n<tr>\n<td style=\"vertical-align: top;\" width=\"50%\">To :<br />\n<script type=\"text/javascript\">// <![CDATA[\ndoc.pay_to_recd_from\n// ]]></script>\n</td>\n<td width=\"50%\">\n<table class=\"noborder\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"30%\">Voucher No :</td>\n<td width=\"70%\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.name\n// ]]></script>\n</td>\n</tr>\n<tr>\n<td width=\"30%\">Voucher Date :</td>\n<td width=\"70%\">\n<script type=\"text/javascript\">// <![CDATA[\ndate.str_to_user(doc.voucher_date)\n// ]]></script>\n</td>\n</tr>\n<tr>\n<td width=\"30%\">Cheque No :</td>\n<td width=\"70%\">\n<script type=\"text/javascript\">// <![CDATA[\ndate.str_to_user(doc.cheque_no)\n// ]]></script>\n</td>\n</tr>\n<tr>\n<td width=\"30%\">Cheque Date :</td>\n<td width=\"70%\">\n<script type=\"text/javascript\">// <![CDATA[\ndate.str_to_user(doc.cheque_date)\n// ]]></script>\n</td>\n</tr>\n</tbody>\n</table>\n</td>\n</tr>\n</tbody>\n</table>\n<br /> <strong>We are pleased to enclose our cheque in full/part Settlement of your under noted bills</strong> <br /> \n<hr />\n<table class=\"noborder\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"70%\"> </td>\n<td width=\"15%\">Total :</td>\n<td class=\"pos_left\" width=\"15%\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.total_amount\n// ]]></script>\n</td>\n</tr>\n<tr>\n<td colspan=\"3\">Narration :\n<script type=\"text/javascript\">// <![CDATA[\nreplace_newlines(doc.remark)\n// ]]></script>\n<br /><br /><br /></td>\n</tr>\n</tbody>\n</table>\n<div style=\"position: absolute; top: 14cm; left: 0cm;\">Prepared By</div>\n<div style=\"position: absolute; top: 14cm; left: 5.5cm;\">Authorised Signatory</div>\n<div style=\"position: absolute; top: 14cm; left: 11cm;\">Received Payment as Above</div>\n<div style=\"position: absolute; top: 16.4cm; left: 5.9cm;\"><strong>_____________</strong></div>\n<div style=\"position: absolute; top: 16.7cm; left: 6cm;\"><strong>A/c Payee</strong></div>\n<div style=\"position: absolute; top: 16.7cm; left: 5.9cm;\"><strong>_____________</strong></div>\n<div style=\"position: absolute; top: 16.9cm; left: 12cm;\">\n<script type=\"text/javascript\">// <![CDATA[\ndate.str_to_user(doc.cheque_date)\n// ]]></script>\n</div>\n<div style=\"position: absolute; top: 17.9cm; left: 1cm;\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.pay_to_recd_from\n// ]]></script>\n</div>\n<div style=\"position: absolute; top: 18.6cm; left: 1cm; width: 7cm;\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.total_amount_in_words\n// ]]></script>\n</div>\n<div style=\"position: absolute; top: 19.7cm; left: 12cm;\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.total_amount\n// ]]></script>\n</div>\n</div>",
|
||||||
|
"idx": 1,
|
||||||
|
"modified": "2012-04-13 12:24:20.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Cheque Printing Format",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"standard": "Yes"
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"owner": "Administrator",
|
|
||||||
"docstatus": 0,
|
|
||||||
"creation": "2012-04-11 13:16:56",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"modified": "2012-04-13 12:24:20"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doc_type": "Journal Voucher",
|
|
||||||
"name": "__common__",
|
|
||||||
"module": "Accounts",
|
|
||||||
"doctype": "Print Format",
|
|
||||||
"html": "<!-- p.big {line-height: 200%} .noborder td { border: 0px solid #fff; } -->\n<div style=\"position: relative;\">\n<h3><script>doc.company</script><br /> <br /> \n<hr />\nPAYMENT ADVICE</h3>\n<table class=\"noborder\" style=\"width: 100%;\">\n<tbody>\n<tr>\n<td style=\"vertical-align: top;\" width=\"50%\">To :<br />\n<script type=\"text/javascript\">// <![CDATA[\ndoc.pay_to_recd_from\n// ]]></script>\n</td>\n<td width=\"50%\">\n<table class=\"noborder\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"30%\">Voucher No :</td>\n<td width=\"70%\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.name\n// ]]></script>\n</td>\n</tr>\n<tr>\n<td width=\"30%\">Voucher Date :</td>\n<td width=\"70%\">\n<script type=\"text/javascript\">// <![CDATA[\ndate.str_to_user(doc.voucher_date)\n// ]]></script>\n</td>\n</tr>\n<tr>\n<td width=\"30%\">Cheque No :</td>\n<td width=\"70%\">\n<script type=\"text/javascript\">// <![CDATA[\ndate.str_to_user(doc.cheque_no)\n// ]]></script>\n</td>\n</tr>\n<tr>\n<td width=\"30%\">Cheque Date :</td>\n<td width=\"70%\">\n<script type=\"text/javascript\">// <![CDATA[\ndate.str_to_user(doc.cheque_date)\n// ]]></script>\n</td>\n</tr>\n</tbody>\n</table>\n</td>\n</tr>\n</tbody>\n</table>\n<br /> <strong>We are pleased to enclose our cheque in full/part Settlement of your under noted bills</strong> <br /> \n<hr />\n<table class=\"noborder\" width=\"100%\">\n<tbody>\n<tr>\n<td width=\"70%\"> </td>\n<td width=\"15%\">Total :</td>\n<td class=\"pos_left\" width=\"15%\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.total_amount\n// ]]></script>\n</td>\n</tr>\n<tr>\n<td colspan=\"3\">Narration :\n<script type=\"text/javascript\">// <![CDATA[\nreplace_newlines(doc.remark)\n// ]]></script>\n<br /><br /><br /></td>\n</tr>\n</tbody>\n</table>\n<div style=\"position: absolute; top: 14cm; left: 0cm;\">Prepared By</div>\n<div style=\"position: absolute; top: 14cm; left: 5.5cm;\">Authorised Signatory</div>\n<div style=\"position: absolute; top: 14cm; left: 11cm;\">Received Payment as Above</div>\n<div style=\"position: absolute; top: 16.4cm; left: 5.9cm;\"><strong>_____________</strong></div>\n<div style=\"position: absolute; top: 16.7cm; left: 6cm;\"><strong>A/c Payee</strong></div>\n<div style=\"position: absolute; top: 16.7cm; left: 5.9cm;\"><strong>_____________</strong></div>\n<div style=\"position: absolute; top: 16.9cm; left: 12cm;\">\n<script type=\"text/javascript\">// <![CDATA[\ndate.str_to_user(doc.cheque_date)\n// ]]></script>\n</div>\n<div style=\"position: absolute; top: 17.9cm; left: 1cm;\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.pay_to_recd_from\n// ]]></script>\n</div>\n<div style=\"position: absolute; top: 18.6cm; left: 1cm; width: 7cm;\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.total_amount_in_words\n// ]]></script>\n</div>\n<div style=\"position: absolute; top: 19.7cm; left: 12cm;\">\n<script type=\"text/javascript\">// <![CDATA[\ndoc.total_amount\n// ]]></script>\n</div>\n</div>",
|
|
||||||
"standard": "Yes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Cheque Printing Format",
|
|
||||||
"doctype": "Print Format"
|
|
||||||
}
|
|
||||||
]
|
|
15
erpnext/accounts/Print Format/POS Invoice/POS Invoice.json
Normal file
15
erpnext/accounts/Print Format/POS Invoice/POS Invoice.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"creation": "2012-05-01 12:46:31.000000",
|
||||||
|
"doc_type": "Journal Voucher",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Print Format",
|
||||||
|
"html": "<h3 align=\"center\"><script>doc.select_print_heading || \"Payment Receipt Note\"</script></h3>\n\n<table class='simpletable'>\n<tr>\n<td><b> Receipt No.: </b></td>\n<td><script>doc.name</script></td>\n</tr>\n<tr>\n<td><b> Date : </b></td>\n<td><script>date.str_to_user(doc.voucher_date)</script></td>\n</tr> \n<tr>\n<td><b> Remark: </b></td>\n<td><script> doc.remark </script></td>\n</tr>\n<tr>\n<td><b> Received From: </b></td>\n<td><b><script> doc.pay_to_recd_from </script></b></td>\n</tr>\n</table>\n<br>\n\n<div><b><script>doc.total_amount</script></b> </td></div><br>\n<div style=\"text-align:left\"><b><script>doc.total_amount_in_words</script></b></div><br>\n<br>\n<table class=\"noborder\">\n<tr>\n<td style = \"text-align = right;\"><h3>For <script>doc.company</script>,</h3><br><div>(Authorised Signatory)</div></td>\n</tr>\n</table>",
|
||||||
|
"idx": 1,
|
||||||
|
"modified": "2013-01-21 18:40:20.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Payment Receipt Voucher",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"standard": "Yes"
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2012-05-01 12:46:31",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-01-21 18:40:20",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doc_type": "Journal Voucher",
|
|
||||||
"doctype": "Print Format",
|
|
||||||
"html": "<h3 align=\"center\"><script>doc.select_print_heading || \"Payment Receipt Note\"</script></h3>\n\n<table class='simpletable'>\n<tr>\n<td><b> Receipt No.: </b></td>\n<td><script>doc.name</script></td>\n</tr>\n<tr>\n<td><b> Date : </b></td>\n<td><script>date.str_to_user(doc.voucher_date)</script></td>\n</tr> \n<tr>\n<td><b> Remark: </b></td>\n<td><script> doc.remark </script></td>\n</tr>\n<tr>\n<td><b> Received From: </b></td>\n<td><b><script> doc.pay_to_recd_from </script></b></td>\n</tr>\n</table>\n<br>\n\n<div><b><script>doc.total_amount</script></b> </td></div><br>\n<div style=\"text-align:left\"><b><script>doc.total_amount_in_words</script></b></div><br>\n<br>\n<table class=\"noborder\">\n<tr>\n<td style = \"text-align = right;\"><h3>For <script>doc.company</script>,</h3><br><div>(Authorised Signatory)</div></td>\n</tr>\n</table>",
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"standard": "Yes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Print Format",
|
|
||||||
"name": "Payment Receipt Voucher"
|
|
||||||
}
|
|
||||||
]
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -65,7 +65,7 @@
|
|||||||
<th>Basic Rate</th>
|
<th>Basic Rate</th>
|
||||||
<th>Amount</th>
|
<th>Amount</th>
|
||||||
</tr>
|
</tr>
|
||||||
{%- for row in doclist.get({"doctype":"Sales Invoice Item"}) %}
|
{%- for row in doc.get({"doctype":"Sales Invoice Item"}) %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 3%;">{{ row.idx }}</td>
|
<td style="width: 3%;">{{ row.idx }}</td>
|
||||||
<td style="width: 20%;">{{ row.item_name }}</td>
|
<td style="width: 20%;">{{ row.item_name }}</td>
|
||||||
@ -106,7 +106,7 @@
|
|||||||
utils.fmt_money(doc.net_total_export, currency=doc.currency)
|
utils.fmt_money(doc.net_total_export, currency=doc.currency)
|
||||||
}}</td>
|
}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{%- for charge in doclist.get({"doctype":"Sales Taxes and Charges"}) -%}
|
{%- for charge in doc.get({"doctype":"Sales Taxes and Charges"}) -%}
|
||||||
{%- if not charge.included_in_print_rate -%}
|
{%- if not charge.included_in_print_rate -%}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ charge.description }}</td>
|
<td>{{ charge.description }}</td>
|
||||||
|
13
erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.json
Normal file
13
erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"creation": "2013-03-21 15:24:28.000000",
|
||||||
|
"doc_type": "Sales Invoice",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Print Format",
|
||||||
|
"idx": 1,
|
||||||
|
"modified": "2013-03-21 15:26:21.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "SalesInvoice",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"standard": "Yes"
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-03-21 15:24:28",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-03-21 15:26:21",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doc_type": "Sales Invoice",
|
|
||||||
"doctype": "Print Format",
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"standard": "Yes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Print Format",
|
|
||||||
"name": "SalesInvoice"
|
|
||||||
}
|
|
||||||
]
|
|
@ -18,7 +18,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
if(doc.group_or_ledger=='Ledger') {
|
if(doc.group_or_ledger=='Ledger') {
|
||||||
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
|
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
|
||||||
var accounts_settings = frappe.model.get_doc("Accounts Settings", name);
|
var accounts_settings = frappe.get_doc("Accounts Settings", name);
|
||||||
var display = accounts_settings["frozen_accounts_modifier"]
|
var display = accounts_settings["frozen_accounts_modifier"]
|
||||||
&& in_list(user_roles, accounts_settings["frozen_accounts_modifier"]);
|
&& in_list(user_roles, accounts_settings["frozen_accounts_modifier"]);
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
||||||
return $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) {
|
return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) {
|
||||||
if(r.message == 1) {
|
if(r.message == 1) {
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
|
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
|
||||||
return $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) {
|
return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) {
|
||||||
if(r.message == 1) {
|
if(r.message == 1) {
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
|
326
erpnext/accounts/doctype/account/account.json
Normal file
326
erpnext/accounts/doctype/account/account.json
Normal file
@ -0,0 +1,326 @@
|
|||||||
|
{
|
||||||
|
"allow_copy": 1,
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2013-01-30 12:49:46.000000",
|
||||||
|
"description": "Heads (or groups) against which Accounting Entries are made and balances are maintained.",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "Master",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "properties",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Account Details",
|
||||||
|
"oldfieldtype": "Section Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break0",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "account_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Account Name",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "account_name",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "level",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Level",
|
||||||
|
"oldfieldname": "level",
|
||||||
|
"oldfieldtype": "Int",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Ledger",
|
||||||
|
"fieldname": "group_or_ledger",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Group or Ledger",
|
||||||
|
"oldfieldname": "group_or_ledger",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "\nLedger\nGroup",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Company",
|
||||||
|
"oldfieldname": "company",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "parent_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"ignore_restrictions": 1,
|
||||||
|
"label": "Parent Account",
|
||||||
|
"oldfieldname": "parent_account",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "report_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Report Type",
|
||||||
|
"options": "\nBalance Sheet\nProfit and Loss",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Setting Account Type helps in selecting this Account in transactions.",
|
||||||
|
"fieldname": "account_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Account Type",
|
||||||
|
"oldfieldname": "account_type",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "Bank\nCash\nTax\nChargeable\nWarehouse\nReceivable\nPayable\nEquity\nFixed Asset\nCost of Goods Sold\nExpense Account\nIncome Account\nStock Received But Not Billed\nExpenses Included In Valuation\nStock Adjustment",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Rate at which this tax is applied",
|
||||||
|
"fieldname": "tax_rate",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Rate",
|
||||||
|
"oldfieldname": "tax_rate",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "If the account is frozen, entries are allowed to restricted users.",
|
||||||
|
"fieldname": "freeze_account",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Frozen",
|
||||||
|
"oldfieldname": "freeze_account",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "No\nYes",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "credit_days",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Credit Days",
|
||||||
|
"oldfieldname": "credit_days",
|
||||||
|
"oldfieldtype": "Int",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "credit_limit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Credit Limit",
|
||||||
|
"oldfieldname": "credit_limit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "If this Account represents a Customer, Supplier or Employee, set it here.",
|
||||||
|
"fieldname": "master_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Master Type",
|
||||||
|
"oldfieldname": "master_type",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "\nSupplier\nCustomer\nEmployee",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "master_name",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Master Name",
|
||||||
|
"oldfieldname": "master_name",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "[Select]",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "balance_must_be",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Balance must be",
|
||||||
|
"options": "\nDebit\nCredit",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "lft",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Lft",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "rgt",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Rgt",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "old_parent",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Old Parent",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-money",
|
||||||
|
"idx": 1,
|
||||||
|
"in_create": 1,
|
||||||
|
"modified": "2014-03-19 12:07:27.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Account",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Auditor",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Sales User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Purchase User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"permlevel": 2,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Auditor",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 0,
|
||||||
|
"import": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"restrict": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"permlevel": 2,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"permlevel": 2,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"search_fields": "group_or_ledger"
|
||||||
|
}
|
@ -3,26 +3,19 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt, fmt_money, cstr, cint
|
from frappe.utils import flt, fmt_money, cstr, cint
|
||||||
from frappe import msgprint, throw, _
|
from frappe import msgprint, throw, _
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
get_value = frappe.db.get_value
|
class Account(Document):
|
||||||
|
nsm_parent_field = 'parent_account'
|
||||||
class DocType:
|
|
||||||
def __init__(self,d,dl):
|
|
||||||
self.doc, self.doclist = d,dl
|
|
||||||
self.nsm_parent_field = 'parent_account'
|
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
self.doc.name = self.doc.account_name.strip() + ' - ' + \
|
self.name = self.account_name.strip() + ' - ' + \
|
||||||
frappe.db.get_value("Company", self.doc.company, "abbr")
|
frappe.db.get_value("Company", self.company, "abbr")
|
||||||
|
|
||||||
def get_address(self):
|
def get_address(self):
|
||||||
return {
|
return {'address': frappe.db.get_value(self.master_type, self.master_name, "address")}
|
||||||
'address': frappe.db.get_value(self.doc.master_type,
|
|
||||||
self.doc.master_name, "address")
|
|
||||||
}
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_master_name()
|
self.validate_master_name()
|
||||||
@ -33,54 +26,48 @@ class DocType:
|
|||||||
self.validate_warehouse_account()
|
self.validate_warehouse_account()
|
||||||
self.validate_frozen_accounts_modifier()
|
self.validate_frozen_accounts_modifier()
|
||||||
|
|
||||||
if not self.doc.parent_account:
|
|
||||||
self.doc.parent_account = ''
|
|
||||||
|
|
||||||
def validate_master_name(self):
|
def validate_master_name(self):
|
||||||
"""Remind to add master name"""
|
if self.master_type in ('Customer', 'Supplier') or self.account_type == "Warehouse":
|
||||||
if self.doc.master_type in ('Customer', 'Supplier') or self.doc.account_type == "Warehouse":
|
if not self.master_name:
|
||||||
if not self.doc.master_name:
|
|
||||||
msgprint(_("Please enter Master Name once the account is created."))
|
msgprint(_("Please enter Master Name once the account is created."))
|
||||||
elif not frappe.db.exists(self.doc.master_type or self.doc.account_type,
|
elif not frappe.db.exists(self.master_type or self.account_type, self.master_name):
|
||||||
self.doc.master_name):
|
|
||||||
throw(_("Invalid Master Name"))
|
throw(_("Invalid Master Name"))
|
||||||
|
|
||||||
def validate_parent(self):
|
def validate_parent(self):
|
||||||
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
||||||
if self.doc.parent_account:
|
if self.parent_account:
|
||||||
par = frappe.db.sql("""select name, group_or_ledger, report_type
|
par = frappe.db.get_value("Account", self.parent_account,
|
||||||
from tabAccount where name =%s""", self.doc.parent_account, as_dict=1)
|
["name", "group_or_ledger", "report_type"], as_dict=1)
|
||||||
if not par:
|
if not par:
|
||||||
throw(_("Parent account does not exists"))
|
throw(_("Parent account does not exists"))
|
||||||
elif par[0]["name"] == self.doc.name:
|
elif par["name"] == self.name:
|
||||||
throw(_("You can not assign itself as parent account"))
|
throw(_("You can not assign itself as parent account"))
|
||||||
elif par[0]["group_or_ledger"] != 'Group':
|
elif par["group_or_ledger"] != 'Group':
|
||||||
throw(_("Parent account can not be a ledger"))
|
throw(_("Parent account can not be a ledger"))
|
||||||
|
|
||||||
if par[0]["report_type"]:
|
if par["report_type"]:
|
||||||
self.doc.report_type = par[0]["report_type"]
|
self.report_type = par["report_type"]
|
||||||
|
|
||||||
def validate_duplicate_account(self):
|
def validate_duplicate_account(self):
|
||||||
if self.doc.fields.get('__islocal') or not self.doc.name:
|
if self.get('__islocal') or not self.name:
|
||||||
company_abbr = frappe.db.get_value("Company", self.doc.company, "abbr")
|
company_abbr = frappe.db.get_value("Company", self.company, "abbr")
|
||||||
if frappe.db.sql("""select name from tabAccount where name=%s""",
|
if frappe.db.exists("Account", (self.account_name + " - " + company_abbr)):
|
||||||
(self.doc.account_name + " - " + company_abbr)):
|
throw("{name}: {acc_name} {exist}, {rename}".format(**{
|
||||||
throw("{name}: {acc_name} {exist}, {rename}".format(**{
|
"name": _("Account Name"),
|
||||||
"name": _("Account Name"),
|
"acc_name": self.account_name,
|
||||||
"acc_name": self.doc.account_name,
|
"exist": _("already exists"),
|
||||||
"exist": _("already exists"),
|
"rename": _("please rename")
|
||||||
"rename": _("please rename")
|
}))
|
||||||
}))
|
|
||||||
|
|
||||||
def validate_root_details(self):
|
def validate_root_details(self):
|
||||||
#does not exists parent
|
#does not exists parent
|
||||||
if frappe.db.exists("Account", self.doc.name):
|
if frappe.db.exists("Account", self.name):
|
||||||
if not frappe.db.get_value("Account", self.doc.name, "parent_account"):
|
if not frappe.db.get_value("Account", self.name, "parent_account"):
|
||||||
throw(_("Root cannot be edited."))
|
throw(_("Root cannot be edited."))
|
||||||
|
|
||||||
def validate_frozen_accounts_modifier(self):
|
def validate_frozen_accounts_modifier(self):
|
||||||
old_value = frappe.db.get_value("Account", self.doc.name, "freeze_account")
|
old_value = frappe.db.get_value("Account", self.name, "freeze_account")
|
||||||
if old_value and old_value != self.doc.freeze_account:
|
if old_value and old_value != self.freeze_account:
|
||||||
frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,
|
frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,
|
||||||
'frozen_accounts_modifier')
|
'frozen_accounts_modifier')
|
||||||
if not frozen_accounts_modifier or \
|
if not frozen_accounts_modifier or \
|
||||||
@ -91,50 +78,50 @@ class DocType:
|
|||||||
if self.check_if_child_exists():
|
if self.check_if_child_exists():
|
||||||
throw("{acc}: {account_name} {child}. {msg}".format(**{
|
throw("{acc}: {account_name} {child}. {msg}".format(**{
|
||||||
"acc": _("Account"),
|
"acc": _("Account"),
|
||||||
"account_name": self.doc.name,
|
"account_name": self.name,
|
||||||
"child": _("has existing child"),
|
"child": _("has existing child"),
|
||||||
"msg": _("You can not convert this account to ledger")
|
"msg": _("You can not convert this account to ledger")
|
||||||
}))
|
}))
|
||||||
elif self.check_gle_exists():
|
elif self.check_gle_exists():
|
||||||
throw(_("Account with existing transaction can not be converted to ledger."))
|
throw(_("Account with existing transaction can not be converted to ledger."))
|
||||||
else:
|
else:
|
||||||
self.doc.group_or_ledger = 'Ledger'
|
self.group_or_ledger = 'Ledger'
|
||||||
self.doc.save()
|
self.save()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def convert_ledger_to_group(self):
|
def convert_ledger_to_group(self):
|
||||||
if self.check_gle_exists():
|
if self.check_gle_exists():
|
||||||
throw(_("Account with existing transaction can not be converted to group."))
|
throw(_("Account with existing transaction can not be converted to group."))
|
||||||
elif self.doc.master_type or self.doc.account_type:
|
elif self.master_type or self.account_type:
|
||||||
throw(_("Cannot covert to Group because Master Type or Account Type is selected."))
|
throw(_("Cannot covert to Group because Master Type or Account Type is selected."))
|
||||||
else:
|
else:
|
||||||
self.doc.group_or_ledger = 'Group'
|
self.group_or_ledger = 'Group'
|
||||||
self.doc.save()
|
self.save()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Check if any previous balance exists
|
# Check if any previous balance exists
|
||||||
def check_gle_exists(self):
|
def check_gle_exists(self):
|
||||||
return frappe.db.get_value("GL Entry", {"account": self.doc.name})
|
return frappe.db.get_value("GL Entry", {"account": self.name})
|
||||||
|
|
||||||
def check_if_child_exists(self):
|
def check_if_child_exists(self):
|
||||||
return frappe.db.sql("""select name from `tabAccount` where parent_account = %s
|
return frappe.db.sql("""select name from `tabAccount` where parent_account = %s
|
||||||
and docstatus != 2""", self.doc.name)
|
and docstatus != 2""", self.name)
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
if not self.doc.report_type:
|
if not self.report_type:
|
||||||
throw(_("Report Type is mandatory"))
|
throw(_("Report Type is mandatory"))
|
||||||
|
|
||||||
def validate_warehouse_account(self):
|
def validate_warehouse_account(self):
|
||||||
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.doc.account_type == "Warehouse":
|
if self.account_type == "Warehouse":
|
||||||
old_warehouse = cstr(frappe.db.get_value("Account", self.doc.name, "master_name"))
|
old_warehouse = cstr(frappe.db.get_value("Account", self.name, "master_name"))
|
||||||
if old_warehouse != cstr(self.doc.master_name):
|
if old_warehouse != cstr(self.master_name):
|
||||||
if old_warehouse:
|
if old_warehouse:
|
||||||
self.validate_warehouse(old_warehouse)
|
self.validate_warehouse(old_warehouse)
|
||||||
if self.doc.master_name:
|
if self.master_name:
|
||||||
self.validate_warehouse(self.doc.master_name)
|
self.validate_warehouse(self.master_name)
|
||||||
else:
|
else:
|
||||||
throw(_("Master Name is mandatory if account type is Warehouse"))
|
throw(_("Master Name is mandatory if account type is Warehouse"))
|
||||||
|
|
||||||
@ -163,10 +150,10 @@ class DocType:
|
|||||||
credit_limit_from = 'Customer'
|
credit_limit_from = 'Customer'
|
||||||
|
|
||||||
cr_limit = frappe.db.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
|
cr_limit = frappe.db.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
|
||||||
where t2.name=%s and t1.name = t2.master_name""", self.doc.name)
|
where t2.name=%s and t1.name = t2.master_name""", self.name)
|
||||||
credit_limit = cr_limit and flt(cr_limit[0][0]) or 0
|
credit_limit = cr_limit and flt(cr_limit[0][0]) or 0
|
||||||
if not credit_limit:
|
if not credit_limit:
|
||||||
credit_limit = frappe.db.get_value('Company', self.doc.company, 'credit_limit')
|
credit_limit = frappe.db.get_value('Company', self.company, 'credit_limit')
|
||||||
credit_limit_from = 'Company'
|
credit_limit_from = 'Company'
|
||||||
|
|
||||||
# If outstanding greater than credit limit and not authorized person raise exception
|
# If outstanding greater than credit limit and not authorized person raise exception
|
||||||
@ -175,11 +162,11 @@ class DocType:
|
|||||||
throw("""Total Outstanding amount (%s) for <b>%s</b> can not be \
|
throw("""Total Outstanding amount (%s) for <b>%s</b> can not be \
|
||||||
greater than credit limit (%s). To change your credit limit settings, \
|
greater than credit limit (%s). To change your credit limit settings, \
|
||||||
please update in the <b>%s</b> master""" % (fmt_money(total_outstanding),
|
please update in the <b>%s</b> master""" % (fmt_money(total_outstanding),
|
||||||
self.doc.name, fmt_money(credit_limit), credit_limit_from))
|
self.name, fmt_money(credit_limit), credit_limit_from))
|
||||||
|
|
||||||
def validate_trash(self):
|
def validate_trash(self):
|
||||||
"""checks gl entries and if child exists"""
|
"""checks gl entries and if child exists"""
|
||||||
if not self.doc.parent_account:
|
if not self.parent_account:
|
||||||
throw(_("Root account can not be deleted"))
|
throw(_("Root account can not be deleted"))
|
||||||
|
|
||||||
if self.check_gle_exists():
|
if self.check_gle_exists():
|
||||||
@ -195,7 +182,7 @@ class DocType:
|
|||||||
def before_rename(self, old, new, merge=False):
|
def before_rename(self, old, new, merge=False):
|
||||||
# Add company abbr if not provided
|
# Add company abbr if not provided
|
||||||
from erpnext.setup.doctype.company.company import get_name_with_abbr
|
from erpnext.setup.doctype.company.company import get_name_with_abbr
|
||||||
new_account = get_name_with_abbr(new, self.doc.company)
|
new_account = get_name_with_abbr(new, self.company)
|
||||||
|
|
||||||
# Validate properties before merging
|
# Validate properties before merging
|
||||||
if merge:
|
if merge:
|
||||||
@ -205,7 +192,7 @@ class DocType:
|
|||||||
val = list(frappe.db.get_value("Account", new_account,
|
val = list(frappe.db.get_value("Account", new_account,
|
||||||
["group_or_ledger", "report_type", "company"]))
|
["group_or_ledger", "report_type", "company"]))
|
||||||
|
|
||||||
if val != [self.doc.group_or_ledger, self.doc.report_type, self.doc.company]:
|
if val != [self.group_or_ledger, self.report_type, self.company]:
|
||||||
throw(_("""Merging is only possible if following \
|
throw(_("""Merging is only possible if following \
|
||||||
properties are same in both records.
|
properties are same in both records.
|
||||||
Group or Ledger, Report Type, Company"""))
|
Group or Ledger, Report Type, Company"""))
|
||||||
|
@ -1,317 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-01-30 12:49:46",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-03-19 12:07:27",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_copy": 1,
|
|
||||||
"allow_rename": 1,
|
|
||||||
"description": "Heads (or groups) against which Accounting Entries are made and balances are maintained.",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "Master",
|
|
||||||
"icon": "icon-money",
|
|
||||||
"in_create": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"search_fields": "group_or_ledger"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Account",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Account",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"submit": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Account"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "properties",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Account Details",
|
|
||||||
"oldfieldtype": "Section Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break0",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "account_name",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Account Name",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "account_name",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "level",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Level",
|
|
||||||
"oldfieldname": "level",
|
|
||||||
"oldfieldtype": "Int",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "Ledger",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "group_or_ledger",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Group or Ledger",
|
|
||||||
"oldfieldname": "group_or_ledger",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "\nLedger\nGroup",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Company",
|
|
||||||
"oldfieldname": "company",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Company",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break1",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "parent_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"ignore_restrictions": 1,
|
|
||||||
"label": "Parent Account",
|
|
||||||
"oldfieldname": "parent_account",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Account",
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "report_type",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Report Type",
|
|
||||||
"options": "\nBalance Sheet\nProfit and Loss"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Setting Account Type helps in selecting this Account in transactions.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "account_type",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Account Type",
|
|
||||||
"oldfieldname": "account_type",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "Bank\nCash\nTax\nChargeable\nWarehouse\nReceivable\nPayable\nEquity\nFixed Asset\nCost of Goods Sold\nExpense Account\nIncome Account\nStock Received But Not Billed\nExpenses Included In Valuation\nStock Adjustment",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Rate at which this tax is applied",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "tax_rate",
|
|
||||||
"fieldtype": "Float",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "Rate",
|
|
||||||
"oldfieldname": "tax_rate",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "If the account is frozen, entries are allowed to restricted users.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "freeze_account",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Frozen",
|
|
||||||
"oldfieldname": "freeze_account",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "No\nYes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "credit_days",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Credit Days",
|
|
||||||
"oldfieldname": "credit_days",
|
|
||||||
"oldfieldtype": "Int",
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "credit_limit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Credit Limit",
|
|
||||||
"oldfieldname": "credit_limit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "If this Account represents a Customer, Supplier or Employee, set it here.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "master_type",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Master Type",
|
|
||||||
"oldfieldname": "master_type",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "\nSupplier\nCustomer\nEmployee"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "master_name",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Master Name",
|
|
||||||
"oldfieldname": "master_name",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "[Select]"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "balance_must_be",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Balance must be",
|
|
||||||
"options": "\nDebit\nCredit"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "lft",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Lft",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "rgt",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Rgt",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "old_parent",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Old Parent",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"role": "Accounts User",
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"role": "Auditor",
|
|
||||||
"write": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"role": "Sales User",
|
|
||||||
"write": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"role": "Purchase User",
|
|
||||||
"write": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"permlevel": 2,
|
|
||||||
"role": "Auditor",
|
|
||||||
"write": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"export": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"restrict": 1,
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"permlevel": 2,
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"permlevel": 2,
|
|
||||||
"role": "Accounts User",
|
|
||||||
"write": 0
|
|
||||||
}
|
|
||||||
]
|
|
@ -9,38 +9,39 @@ def _make_test_records(verbose):
|
|||||||
|
|
||||||
accounts = [
|
accounts = [
|
||||||
# [account_name, parent_account, group_or_ledger]
|
# [account_name, parent_account, group_or_ledger]
|
||||||
["_Test Account Bank Account", "Bank Accounts", "Ledger"],
|
["_Test Account Bank Account", "Bank Accounts", "Ledger", "Bank"],
|
||||||
|
|
||||||
["_Test Account Stock Expenses", "Direct Expenses", "Group"],
|
["_Test Account Stock Expenses", "Direct Expenses", "Group", None],
|
||||||
["_Test Account Shipping Charges", "_Test Account Stock Expenses", "Ledger"],
|
["_Test Account Shipping Charges", "_Test Account Stock Expenses", "Ledger", "Chargeable"],
|
||||||
["_Test Account Customs Duty", "_Test Account Stock Expenses", "Ledger"],
|
["_Test Account Customs Duty", "_Test Account Stock Expenses", "Ledger", "Tax"],
|
||||||
|
|
||||||
|
|
||||||
["_Test Account Tax Assets", "Current Assets", "Group"],
|
["_Test Account Tax Assets", "Current Assets", "Group", None],
|
||||||
["_Test Account VAT", "_Test Account Tax Assets", "Ledger"],
|
["_Test Account VAT", "_Test Account Tax Assets", "Ledger", "Tax"],
|
||||||
["_Test Account Service Tax", "_Test Account Tax Assets", "Ledger"],
|
["_Test Account Service Tax", "_Test Account Tax Assets", "Ledger", "Tax"],
|
||||||
|
|
||||||
["_Test Account Reserves and Surplus", "Current Liabilities", "Ledger"],
|
["_Test Account Reserves and Surplus", "Current Liabilities", "Ledger", None],
|
||||||
|
|
||||||
["_Test Account Cost for Goods Sold", "Expenses", "Ledger"],
|
["_Test Account Cost for Goods Sold", "Expenses", "Ledger", None],
|
||||||
["_Test Account Excise Duty", "_Test Account Tax Assets", "Ledger"],
|
["_Test Account Excise Duty", "_Test Account Tax Assets", "Ledger", "Tax"],
|
||||||
["_Test Account Education Cess", "_Test Account Tax Assets", "Ledger"],
|
["_Test Account Education Cess", "_Test Account Tax Assets", "Ledger", "Tax"],
|
||||||
["_Test Account S&H Education Cess", "_Test Account Tax Assets", "Ledger"],
|
["_Test Account S&H Education Cess", "_Test Account Tax Assets", "Ledger", "Tax"],
|
||||||
["_Test Account CST", "Direct Expenses", "Ledger"],
|
["_Test Account CST", "Direct Expenses", "Ledger", "Tax"],
|
||||||
["_Test Account Discount", "Direct Expenses", "Ledger"],
|
["_Test Account Discount", "Direct Expenses", "Ledger", None],
|
||||||
|
|
||||||
# related to Account Inventory Integration
|
# related to Account Inventory Integration
|
||||||
["_Test Account Stock In Hand", "Current Assets", "Ledger"],
|
["_Test Account Stock In Hand", "Current Assets", "Ledger", None],
|
||||||
["_Test Account Fixed Assets", "Current Assets", "Ledger"],
|
["_Test Account Fixed Assets", "Current Assets", "Ledger", None],
|
||||||
]
|
]
|
||||||
|
|
||||||
for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]:
|
for company, abbr in [["_Test Company", "_TC"], ["_Test Company 1", "_TC1"]]:
|
||||||
test_objects = make_test_objects("Account", [[{
|
test_objects = make_test_objects("Account", [{
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
"account_name": account_name,
|
"account_name": account_name,
|
||||||
"parent_account": parent_account + " - " + abbr,
|
"parent_account": parent_account + " - " + abbr,
|
||||||
"company": company,
|
"company": company,
|
||||||
"group_or_ledger": group_or_ledger
|
"group_or_ledger": group_or_ledger,
|
||||||
}] for account_name, parent_account, group_or_ledger in accounts])
|
"account_type": account_type
|
||||||
|
} for account_name, parent_account, group_or_ledger, account_type in accounts])
|
||||||
|
|
||||||
return test_objects
|
return test_objects
|
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"creation": "2013-06-24 15:49:57.000000",
|
||||||
|
"description": "Settings for Accounts",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"description": "If enabled, the system will post accounting entries for inventory automatically.",
|
||||||
|
"fieldname": "auto_accounting_for_stock",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Make Accounting Entry For Every Stock Movement",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.",
|
||||||
|
"fieldname": "acc_frozen_upto",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Accounts Frozen Upto",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Users with this role are allowed to create / modify accounting entry before frozen date",
|
||||||
|
"fieldname": "bde_auth_role",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Allowed Role to Edit Entries Before Frozen Date",
|
||||||
|
"options": "Role",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Users with this role are allowed to set frozen accounts and create / modify accounting entries against frozen accounts",
|
||||||
|
"fieldname": "frozen_accounts_modifier",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Frozen Accounts Modifier",
|
||||||
|
"options": "Role",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Role that is allowed to submit transactions that exceed credit limits set.",
|
||||||
|
"fieldname": "credit_controller",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Credit Controller",
|
||||||
|
"options": "Role",
|
||||||
|
"permlevel": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-cog",
|
||||||
|
"idx": 1,
|
||||||
|
"issingle": 1,
|
||||||
|
"modified": "2013-12-20 19:22:52.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Accounts Settings",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -7,18 +7,16 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class DocType:
|
class AccountsSettings(Document):
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
frappe.db.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)
|
frappe.db.set_default("auto_accounting_for_stock", self.auto_accounting_for_stock)
|
||||||
|
|
||||||
if cint(self.doc.auto_accounting_for_stock):
|
if cint(self.auto_accounting_for_stock):
|
||||||
# set default perpetual account in company
|
# set default perpetual account in company
|
||||||
for company in frappe.db.sql("select name from tabCompany"):
|
for company in frappe.db.sql("select name from tabCompany"):
|
||||||
frappe.bean("Company", company[0]).save()
|
frappe.get_doc("Company", company[0]).save()
|
||||||
|
|
||||||
# Create account head for warehouses
|
# Create account head for warehouses
|
||||||
warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1)
|
warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1)
|
||||||
@ -27,5 +25,5 @@ class DocType:
|
|||||||
frappe.throw(_("Company is missing in following warehouses") + ": \n" +
|
frappe.throw(_("Company is missing in following warehouses") + ": \n" +
|
||||||
"\n".join(warehouse_with_no_company))
|
"\n".join(warehouse_with_no_company))
|
||||||
for wh in warehouse_list:
|
for wh in warehouse_list:
|
||||||
wh_bean = frappe.bean("Warehouse", wh.name)
|
wh_doc = frappe.get_doc("Warehouse", wh.name)
|
||||||
wh_bean.save()
|
wh_doc.save()
|
@ -1,85 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-06-24 15:49:57",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:22:52",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Settings for Accounts",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"icon": "icon-cog",
|
|
||||||
"issingle": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Accounts Settings",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Accounts Settings",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Accounts Settings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "1",
|
|
||||||
"description": "If enabled, the system will post accounting entries for inventory automatically.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "auto_accounting_for_stock",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Make Accounting Entry For Every Stock Movement"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "acc_frozen_upto",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Accounts Frozen Upto"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Users with this role are allowed to create / modify accounting entry before frozen date",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "bde_auth_role",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Allowed Role to Edit Entries Before Frozen Date",
|
|
||||||
"options": "Role"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Users with this role are allowed to set frozen accounts and create / modify accounting entries against frozen accounts",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "frozen_accounts_modifier",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Frozen Accounts Modifier",
|
|
||||||
"options": "Role"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Role that is allowed to submit transactions that exceed credit limits set.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "credit_controller",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Credit Controller",
|
|
||||||
"options": "Role"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm"
|
|
||||||
}
|
|
||||||
]
|
|
@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"allow_copy": 1,
|
||||||
|
"allow_email": 1,
|
||||||
|
"allow_print": 1,
|
||||||
|
"creation": "2013-01-10 16:34:05.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"description": "Select account head of the bank where cheque was deposited.",
|
||||||
|
"fieldname": "bank_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Bank Account",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Company",
|
||||||
|
"options": "Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "from_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "From Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "to_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "To Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "get_non_reconciled_entries",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Get Non Reconciled Entries",
|
||||||
|
"options": "get_details",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "entries",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Entries",
|
||||||
|
"options": "Bank Reconciliation Detail",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "update_clearance_date",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Update Clearance Date",
|
||||||
|
"options": "update_details",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hide_heading": 1,
|
||||||
|
"hide_toolbar": 1,
|
||||||
|
"icon": "icon-check",
|
||||||
|
"idx": 1,
|
||||||
|
"issingle": 1,
|
||||||
|
"modified": "2013-07-05 14:26:22.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Bank Reconciliation",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"read": 1,
|
||||||
|
"report": 0,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"read_only": 1
|
||||||
|
}
|
@ -3,32 +3,31 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.utils import cstr, flt, getdate, nowdate
|
||||||
|
from frappe import msgprint, _
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, getdate, now, nowdate
|
class BankReconciliation(Document):
|
||||||
from frappe.model import db_exists
|
|
||||||
from frappe.model.doc import addchild
|
|
||||||
from frappe.model.bean import getlist, copy_doclist
|
|
||||||
from frappe import msgprint
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
|
||||||
|
|
||||||
def get_details(self):
|
def get_details(self):
|
||||||
if not (self.doc.bank_account and self.doc.from_date and self.doc.to_date):
|
if not (self.bank_account and self.from_date and self.to_date):
|
||||||
msgprint("Bank Account, From Date and To Date are Mandatory")
|
msgprint("Bank Account, From Date and To Date are Mandatory")
|
||||||
return
|
return
|
||||||
|
|
||||||
dl = frappe.db.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
|
dl = frappe.db.sql("""select t1.name, t1.cheque_no, t1.cheque_date, t2.debit,
|
||||||
|
t2.credit, t1.posting_date, t2.against_account
|
||||||
|
from
|
||||||
|
`tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
|
||||||
|
where
|
||||||
|
t2.parent = t1.name and t2.account = %s
|
||||||
|
and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '')
|
||||||
|
and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1""",
|
||||||
|
(self.bank_account, self.from_date, self.to_date))
|
||||||
|
|
||||||
self.doclist = self.doc.clear_table(self.doclist, 'entries')
|
self.set('entries', [])
|
||||||
self.doc.total_amount = 0.0
|
self.total_amount = 0.0
|
||||||
|
|
||||||
for d in dl:
|
for d in dl:
|
||||||
nl = addchild(self.doc, 'entries', 'Bank Reconciliation Detail', self.doclist)
|
nl = self.append('entries', {})
|
||||||
nl.posting_date = cstr(d[5])
|
nl.posting_date = cstr(d[5])
|
||||||
nl.voucher_id = cstr(d[0])
|
nl.voucher_id = cstr(d[0])
|
||||||
nl.cheque_number = cstr(d[1])
|
nl.cheque_number = cstr(d[1])
|
||||||
@ -36,22 +35,21 @@ class DocType:
|
|||||||
nl.debit = flt(d[3])
|
nl.debit = flt(d[3])
|
||||||
nl.credit = flt(d[4])
|
nl.credit = flt(d[4])
|
||||||
nl.against_account = cstr(d[6])
|
nl.against_account = cstr(d[6])
|
||||||
self.doc.total_amount += flt(flt(d[4]) - flt(d[3]))
|
self.total_amount += flt(flt(d[4]) - flt(d[3]))
|
||||||
|
|
||||||
def update_details(self):
|
def update_details(self):
|
||||||
vouchers = []
|
vouchers = []
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in self.get('entries'):
|
||||||
if d.clearance_date:
|
if d.clearance_date:
|
||||||
if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
|
if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
|
||||||
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %
|
frappe.throw("Clearance Date can not be before Cheque Date (Row #%s)" % d.idx)
|
||||||
d.idx, raise_exception=1)
|
|
||||||
|
|
||||||
frappe.db.sql("""update `tabJournal Voucher`
|
frappe.db.set_value("Journal Voucher", d.voucher_id, "clearance_date", d.clearance_date)
|
||||||
set clearance_date = %s, modified = %s where name=%s""",
|
frappe.db.sql("""update `tabJournal Voucher` set clearance_date = %s, modified = %s
|
||||||
(d.clearance_date, nowdate(), d.voucher_id))
|
where name=%s""", (d.clearance_date, nowdate(), d.voucher_id))
|
||||||
vouchers.append(d.voucher_id)
|
vouchers.append(d.voucher_id)
|
||||||
|
|
||||||
if vouchers:
|
if vouchers:
|
||||||
msgprint("Clearance Date updated in %s" % ", ".join(vouchers))
|
msgprint("Clearance Date updated in %s" % ", ".join(vouchers))
|
||||||
else:
|
else:
|
||||||
msgprint("Clearance Date not mentioned")
|
msgprint(_("Clearance Date not mentioned"))
|
@ -1,115 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-01-10 16:34:05",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-07-05 14:26:22",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_copy": 1,
|
|
||||||
"allow_email": 1,
|
|
||||||
"allow_print": 1,
|
|
||||||
"doctype": "DocType",
|
|
||||||
"hide_heading": 1,
|
|
||||||
"hide_toolbar": 1,
|
|
||||||
"icon": "icon-check",
|
|
||||||
"issingle": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Bank Reconciliation",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Bank Reconciliation",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"read": 1,
|
|
||||||
"report": 0,
|
|
||||||
"role": "Accounts User",
|
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Bank Reconciliation"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Select account head of the bank where cheque was deposited.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "bank_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Bank Account",
|
|
||||||
"options": "Account",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Company",
|
|
||||||
"options": "Company",
|
|
||||||
"print_hide": 1,
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "from_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "From Date",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "to_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "To Date",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "get_non_reconciled_entries",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"label": "Get Non Reconciled Entries",
|
|
||||||
"options": "get_details"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "entries",
|
|
||||||
"fieldtype": "Table",
|
|
||||||
"label": "Entries",
|
|
||||||
"options": "Bank Reconciliation Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "update_clearance_date",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"label": "Update Clearance Date",
|
|
||||||
"options": "update_details"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_amount",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Total Amount",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm"
|
|
||||||
}
|
|
||||||
]
|
|
@ -0,0 +1,109 @@
|
|||||||
|
{
|
||||||
|
"creation": "2013-02-22 01:27:37.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_id",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Voucher ID",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "voucher_id",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Journal Voucher",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_account",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Against Account",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "against_account",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "posting_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Posting Date",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "posting_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "clearance_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Clearance Date",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "clearance_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "cheque_number",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Cheque Number",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "cheque_number",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "cheque_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Cheque Date",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "cheque_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "debit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Debit",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "debit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "credit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Credit",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "credit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"modified": "2013-12-20 19:22:55.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Bank Reconciliation Detail",
|
||||||
|
"owner": "Administrator"
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class DocType:
|
class BankReconciliationDetail(Document):
|
||||||
def __init__(self, d, dl):
|
pass
|
||||||
self.doc, self.doclist = d, dl
|
|
@ -1,108 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-02-22 01:27:37",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:22:55",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"istable": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"no_copy": 0,
|
|
||||||
"parent": "Bank Reconciliation Detail",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Bank Reconciliation Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_id",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Voucher ID",
|
|
||||||
"oldfieldname": "voucher_id",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Journal Voucher"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against_account",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Against Account",
|
|
||||||
"oldfieldname": "against_account",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "posting_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Posting Date",
|
|
||||||
"oldfieldname": "posting_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "clearance_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Clearance Date",
|
|
||||||
"oldfieldname": "clearance_date",
|
|
||||||
"oldfieldtype": "Date"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cheque_number",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Cheque Number",
|
|
||||||
"oldfieldname": "cheque_number",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cheque_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Cheque Date",
|
|
||||||
"oldfieldname": "cheque_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "debit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Debit",
|
|
||||||
"oldfieldname": "debit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "credit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Credit",
|
|
||||||
"oldfieldname": "credit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
}
|
|
||||||
]
|
|
52
erpnext/accounts/doctype/budget_detail/budget_detail.json
Normal file
52
erpnext/accounts/doctype/budget_detail/budget_detail.json
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"autoname": "CBD/.######",
|
||||||
|
"creation": "2013-03-07 11:55:04.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Account",
|
||||||
|
"oldfieldname": "account",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "budget_allocated",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Budget Allocated",
|
||||||
|
"oldfieldname": "budget_allocated",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fiscal_year",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Fiscal Year",
|
||||||
|
"oldfieldname": "fiscal_year",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "link:Fiscal Year",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"modified": "2013-12-20 19:22:59.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Budget Detail",
|
||||||
|
"owner": "Administrator"
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class DocType:
|
class BudgetDetail(Document):
|
||||||
def __init__(self, d, dl):
|
pass
|
||||||
self.doc, self.doclist = d, dl
|
|
@ -1,61 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-03-07 11:55:04",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:22:59",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "CBD/.######",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"istable": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Budget Detail",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Budget Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Account",
|
|
||||||
"oldfieldname": "account",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Account",
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "budget_allocated",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Budget Allocated",
|
|
||||||
"oldfieldname": "budget_allocated",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "fiscal_year",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Fiscal Year",
|
|
||||||
"oldfieldname": "fiscal_year",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "link:Fiscal Year",
|
|
||||||
"search_index": 1
|
|
||||||
}
|
|
||||||
]
|
|
@ -7,8 +7,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
|
|||||||
refresh_field('budget_distribution_details');
|
refresh_field('budget_distribution_details');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $c('runserverobj',args={'method' : 'get_months', 'docs' :
|
return $c('runserverobj',args={'method':'get_months', 'docs':doc}, callback1);
|
||||||
frappe.model.compress(make_doclist(doc.doctype, doc.name))},callback1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"autoname": "field:distribution_id",
|
||||||
|
"creation": "2013-01-10 16:34:05.000000",
|
||||||
|
"description": "**Budget Distribution** helps you distribute your budget across months if you have seasonality in your business.\n\nTo distribute a budget using this distribution, set this **Budget Distribution** in the **Cost Center**",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"description": "Name of the Budget Distribution",
|
||||||
|
"fieldname": "distribution_id",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Distribution Name",
|
||||||
|
"oldfieldname": "distribution_id",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fiscal_year",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Fiscal Year",
|
||||||
|
"oldfieldname": "fiscal_year",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "link:Fiscal Year",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "budget_distribution_details",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Budget Distribution Details",
|
||||||
|
"oldfieldname": "budget_distribution_details",
|
||||||
|
"oldfieldtype": "Table",
|
||||||
|
"options": "Budget Distribution Detail",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "trash_reason",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Trash Reason",
|
||||||
|
"oldfieldname": "trash_reason",
|
||||||
|
"oldfieldtype": "Small Text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-bar-chart",
|
||||||
|
"idx": 1,
|
||||||
|
"modified": "2014-01-20 17:48:27.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Budget Distribution",
|
||||||
|
"name_case": "Title Case",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cancel": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"permlevel": 2,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -3,30 +3,23 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from frappe.model.doc import addchild
|
from frappe import _
|
||||||
from frappe.model.bean import getlist
|
from frappe.model.document import Document
|
||||||
from frappe import msgprint, _
|
|
||||||
|
|
||||||
class DocType:
|
|
||||||
def __init__(self,doc,doclist=[]):
|
|
||||||
self.doc,self.doclist = doc,doclist
|
|
||||||
|
|
||||||
|
class BudgetDistribution(Document):
|
||||||
def get_months(self):
|
def get_months(self):
|
||||||
month_list = ['January','February','March','April','May','June','July','August','September',
|
month_list = ['January','February','March','April','May','June','July','August','September',
|
||||||
'October','November','December']
|
'October','November','December']
|
||||||
idx =1
|
idx =1
|
||||||
for m in month_list:
|
for m in month_list:
|
||||||
mnth = addchild(self.doc, 'budget_distribution_details',
|
mnth = self.append('budget_distribution_details')
|
||||||
'Budget Distribution Detail', self.doclist)
|
mnth.month = m
|
||||||
mnth.month = m or ''
|
|
||||||
mnth.idx = idx
|
mnth.idx = idx
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
total = sum([flt(d.percentage_allocation, 2) for d in self.doclist.get(
|
total = sum([flt(d.percentage_allocation) for d in self.get("budget_distribution_details")])
|
||||||
{"parentfield": "budget_distribution_details"})])
|
|
||||||
|
|
||||||
if total != 100.0:
|
if total != 100.0:
|
||||||
msgprint(_("Percentage Allocation should be equal to ") + "100%", raise_exception=1)
|
frappe.throw(_("Percentage Allocation should be equal to ") + "100%")
|
@ -1,96 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-01-10 16:34:05",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-01-20 17:48:27",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "field:distribution_id",
|
|
||||||
"description": "**Budget Distribution** helps you distribute your budget across months if you have seasonality in your business.\n\nTo distribute a budget using this distribution, set this **Budget Distribution** in the **Cost Center**",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"icon": "icon-bar-chart",
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"name_case": "Title Case"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Budget Distribution",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cancel": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Budget Distribution",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"submit": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Budget Distribution"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Name of the Budget Distribution",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "distribution_id",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Distribution Name",
|
|
||||||
"oldfieldname": "distribution_id",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "fiscal_year",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Fiscal Year",
|
|
||||||
"oldfieldname": "fiscal_year",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "link:Fiscal Year",
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "budget_distribution_details",
|
|
||||||
"fieldtype": "Table",
|
|
||||||
"label": "Budget Distribution Details",
|
|
||||||
"oldfieldname": "budget_distribution_details",
|
|
||||||
"oldfieldtype": "Table",
|
|
||||||
"options": "Budget Distribution Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "trash_reason",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"label": "Trash Reason",
|
|
||||||
"oldfieldname": "trash_reason",
|
|
||||||
"oldfieldtype": "Small Text",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"permlevel": 2
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,70 +1,6 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
test_records = [
|
|
||||||
[{
|
import frappe
|
||||||
"doctype": "Budget Distribution",
|
test_records = frappe.get_test_records('Budget Distribution')
|
||||||
"distribution_id": "_Test Distribution",
|
|
||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "January",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "February",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "March",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "April",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "May",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "June",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "July",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "August",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "September",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "October",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "November",
|
|
||||||
"percentage_allocation": "10"
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Distribution Detail",
|
|
||||||
"parentfield": "budget_distribution_details",
|
|
||||||
"month": "December",
|
|
||||||
"percentage_allocation": "10"
|
|
||||||
}]
|
|
||||||
]
|
|
@ -0,0 +1,44 @@
|
|||||||
|
[{
|
||||||
|
"doctype": "Budget Distribution",
|
||||||
|
"distribution_id": "_Test Distribution",
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
|
"budget_distribution_details": [
|
||||||
|
{
|
||||||
|
"month": "January",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "February",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "March",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "April",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "May",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "June",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "July",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "August",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "September",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "October",
|
||||||
|
"percentage_allocation": "8"
|
||||||
|
}, {
|
||||||
|
"month": "November",
|
||||||
|
"percentage_allocation": "10"
|
||||||
|
}, {
|
||||||
|
"month": "December",
|
||||||
|
"percentage_allocation": "10"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"autoname": "BDD/.#####",
|
||||||
|
"creation": "2013-02-22 01:27:38.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "month",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Month",
|
||||||
|
"oldfieldname": "month",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "percentage_allocation",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Percentage Allocation",
|
||||||
|
"oldfieldname": "percentage_allocation",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"permlevel": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"modified": "2013-12-20 19:22:59.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Budget Distribution Detail",
|
||||||
|
"owner": "Administrator"
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class DocType:
|
class BudgetDistributionDetail(Document):
|
||||||
def __init__(self, d, dl):
|
pass
|
||||||
self.doc, self.doclist = d, dl
|
|
@ -1,47 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-02-22 01:27:38",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:22:59",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "BDD/.#####",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"istable": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Budget Distribution Detail",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Budget Distribution Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "month",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Month",
|
|
||||||
"oldfieldname": "month",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "percentage_allocation",
|
|
||||||
"fieldtype": "Float",
|
|
||||||
"label": "Percentage Allocation",
|
|
||||||
"oldfieldname": "percentage_allocation",
|
|
||||||
"oldfieldtype": "Currency"
|
|
||||||
}
|
|
||||||
]
|
|
178
erpnext/accounts/doctype/c_form/c_form.json
Normal file
178
erpnext/accounts/doctype/c_form/c_form.json
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
{
|
||||||
|
"allow_attach": 1,
|
||||||
|
"autoname": "naming_series:",
|
||||||
|
"creation": "2013-03-07 11:55:06.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "column_break0",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "50%",
|
||||||
|
"read_only": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "naming_series",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Series",
|
||||||
|
"options": "\nC-FORM/",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "c_form_no",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "C-Form No",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "received_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Received Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "customer",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Customer",
|
||||||
|
"options": "Customer",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "50%",
|
||||||
|
"read_only": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Company",
|
||||||
|
"options": "link:Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fiscal_year",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Fiscal Year",
|
||||||
|
"options": "link:Fiscal Year",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "quarter",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Quarter",
|
||||||
|
"options": "\nI\nII\nIII\nIV",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "state",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "State",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break0",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "invoice_details",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Invoice Details",
|
||||||
|
"options": "C-Form Invoice Detail",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_invoiced_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total Invoiced Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "amended_from",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"ignore_restrictions": 1,
|
||||||
|
"label": "Amended From",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "C-Form",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-file-text",
|
||||||
|
"idx": 1,
|
||||||
|
"is_submittable": 1,
|
||||||
|
"max_attachments": 3,
|
||||||
|
"modified": "2013-12-20 19:23:58.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "C-Form",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"permlevel": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "All",
|
||||||
|
"submit": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -3,35 +3,32 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt, getdate
|
from frappe.utils import flt
|
||||||
from frappe.model.bean import getlist
|
from frappe import _
|
||||||
|
from frappe.model.document import Document
|
||||||
class DocType:
|
|
||||||
def __init__(self,d,dl):
|
|
||||||
self.doc, self.doclist = d,dl
|
|
||||||
|
|
||||||
|
class CForm(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
"""Validate invoice that c-form is applicable
|
"""Validate invoice that c-form is applicable
|
||||||
and no other c-form is received for that"""
|
and no other c-form is received for that"""
|
||||||
|
|
||||||
for d in getlist(self.doclist, 'invoice_details'):
|
for d in self.get('invoice_details'):
|
||||||
if d.invoice_no:
|
if d.invoice_no:
|
||||||
inv = frappe.db.sql("""select c_form_applicable, c_form_no from
|
inv = frappe.db.sql("""select c_form_applicable, c_form_no from
|
||||||
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
|
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
|
||||||
|
|
||||||
if not inv:
|
if not inv:
|
||||||
frappe.msgprint("""Invoice: %s is not exists in the system or
|
frappe.throw("""Invoice: %s is not exists in the system or
|
||||||
is not submitted, please check.""" % d.invoice_no, raise_exception=1)
|
is not submitted, please check.""" % d.invoice_no)
|
||||||
|
|
||||||
elif inv[0][0] != 'Yes':
|
elif inv[0][0] != 'Yes':
|
||||||
frappe.msgprint("C-form is not applicable for Invoice: %s" %
|
frappe.throw("C-form is not applicable for Invoice: %s" % d.invoice_no)
|
||||||
d.invoice_no, raise_exception=1)
|
|
||||||
|
|
||||||
elif inv[0][1] and inv[0][1] != self.doc.name:
|
elif inv[0][1] and inv[0][1] != self.name:
|
||||||
frappe.msgprint("""Invoice %s is tagged in another C-form: %s.
|
frappe.throw("""Invoice %s is tagged in another C-form: %s.
|
||||||
If you want to change C-form no for this invoice,
|
If you want to change C-form no for this invoice,
|
||||||
please remove invoice no from the previous c-form and then try again""" %
|
please remove invoice no from the previous c-form and then try again""" %
|
||||||
(d.invoice_no, inv[0][1]), raise_exception=1)
|
(d.invoice_no, inv[0][1]))
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
""" Update C-Form No on invoices"""
|
""" Update C-Form No on invoices"""
|
||||||
@ -42,37 +39,34 @@ class DocType:
|
|||||||
|
|
||||||
def before_cancel(self):
|
def before_cancel(self):
|
||||||
# remove cform reference
|
# remove cform reference
|
||||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no=null
|
frappe.db.sql("""update `tabSales Invoice` set c_form_no=null where c_form_no=%s""", self.name)
|
||||||
where c_form_no=%s""", self.doc.name)
|
|
||||||
|
|
||||||
def set_cform_in_sales_invoices(self):
|
def set_cform_in_sales_invoices(self):
|
||||||
inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')]
|
inv = [d.invoice_no for d in self.get('invoice_details')]
|
||||||
if inv:
|
if inv:
|
||||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s
|
frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s where name in (%s)""" %
|
||||||
where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))),
|
('%s', '%s', ', '.join(['%s'] * len(inv))), tuple([self.name, self.modified] + inv))
|
||||||
tuple([self.doc.name, self.doc.modified] + inv))
|
|
||||||
|
|
||||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
|
frappe.db.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
|
||||||
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
|
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
|
||||||
('%s', ', '.join(['%s']*len(inv)), '%s'),
|
('%s', ', '.join(['%s']*len(inv)), '%s'), tuple([self.modified] + inv + [self.name]))
|
||||||
tuple([self.doc.modified] + inv + [self.doc.name]))
|
|
||||||
else:
|
else:
|
||||||
frappe.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1)
|
frappe.throw(_("Please enter atleast 1 invoice in the table"))
|
||||||
|
|
||||||
def set_total_invoiced_amount(self):
|
def set_total_invoiced_amount(self):
|
||||||
total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')])
|
total = sum([flt(d.grand_total) for d in self.get('invoice_details')])
|
||||||
frappe.db.set(self.doc, 'total_invoiced_amount', total)
|
frappe.db.set(self, 'total_invoiced_amount', total)
|
||||||
|
|
||||||
def get_invoice_details(self, invoice_no):
|
def get_invoice_details(self, invoice_no):
|
||||||
""" Pull details from invoices for referrence """
|
""" Pull details from invoices for referrence """
|
||||||
|
|
||||||
inv = frappe.db.sql("""select posting_date, territory, net_total, grand_total
|
inv = frappe.db.get_value("Sales Invoice", invoice_no,
|
||||||
from `tabSales Invoice` where name = %s""", invoice_no)
|
["posting_date", "territory", "net_total", "grand_total"], as_dict=True)
|
||||||
return {
|
return {
|
||||||
'invoice_date' : inv and getdate(inv[0][0]).strftime('%Y-%m-%d') or '',
|
'invoice_date' : inv.posting_date,
|
||||||
'territory' : inv and inv[0][1] or '',
|
'territory' : inv.territory,
|
||||||
'net_total' : inv and flt(inv[0][2]) or '',
|
'net_total' : inv.net_total,
|
||||||
'grand_total' : inv and flt(inv[0][3]) or ''
|
'grand_total' : inv.grand_total
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_invoice_nos(doctype, txt, searchfield, start, page_len, filters):
|
def get_invoice_nos(doctype, txt, searchfield, start, page_len, filters):
|
||||||
|
@ -1,193 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-03-07 11:55:06",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:23:58",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_attach": 1,
|
|
||||||
"autoname": "naming_series:",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"icon": "icon-file-text",
|
|
||||||
"is_submittable": 1,
|
|
||||||
"max_attachments": 3,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "C-Form",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "C-Form",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"submit": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "C-Form"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break0",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"print_width": "50%",
|
|
||||||
"read_only": 0,
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "naming_series",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Series",
|
|
||||||
"options": "\nC-FORM/",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "c_form_no",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "C-Form No",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "received_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Received Date",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "customer",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Customer",
|
|
||||||
"options": "Customer",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break1",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"print_width": "50%",
|
|
||||||
"read_only": 0,
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Company",
|
|
||||||
"options": "link:Company",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "fiscal_year",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Fiscal Year",
|
|
||||||
"options": "link:Fiscal Year",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "quarter",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Quarter",
|
|
||||||
"options": "\nI\nII\nIII\nIV",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_amount",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Total Amount",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "state",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "State",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "section_break0",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "invoice_details",
|
|
||||||
"fieldtype": "Table",
|
|
||||||
"label": "Invoice Details",
|
|
||||||
"options": "C-Form Invoice Detail",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_invoiced_amount",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Total Invoiced Amount",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"print_hide": 0,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "amended_from",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"ignore_restrictions": 1,
|
|
||||||
"label": "Amended From",
|
|
||||||
"no_copy": 1,
|
|
||||||
"options": "C-Form",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"role": "Accounts User",
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"permlevel": 1,
|
|
||||||
"role": "All"
|
|
||||||
}
|
|
||||||
]
|
|
@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"creation": "2013-02-22 01:27:38.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "invoice_no",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Invoice No",
|
||||||
|
"options": "Sales Invoice",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "160px",
|
||||||
|
"width": "160px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "invoice_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Invoice Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "120px",
|
||||||
|
"read_only": 1,
|
||||||
|
"width": "120px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
|
||||||
|
"fieldname": "territory",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Territory",
|
||||||
|
"options": "Territory",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "120px",
|
||||||
|
"read_only": 1,
|
||||||
|
"width": "120px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "net_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Net Total",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "120px",
|
||||||
|
"read_only": 1,
|
||||||
|
"width": "120px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "grand_total",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Grand Total",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "120px",
|
||||||
|
"read_only": 1,
|
||||||
|
"width": "120px"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"modified": "2013-12-20 19:23:00.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "C-Form Invoice Detail",
|
||||||
|
"owner": "Administrator"
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class DocType:
|
class CFormInvoiceDetail(Document):
|
||||||
def __init__(self, d, dl):
|
pass
|
||||||
self.doc, self.doclist = d, dl
|
|
@ -1,77 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-02-22 01:27:38",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:23:00",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"istable": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "C-Form Invoice Detail",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "C-Form Invoice Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "invoice_no",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Invoice No",
|
|
||||||
"options": "Sales Invoice",
|
|
||||||
"print_width": "160px",
|
|
||||||
"width": "160px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "invoice_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Invoice Date",
|
|
||||||
"print_width": "120px",
|
|
||||||
"read_only": 1,
|
|
||||||
"width": "120px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "territory",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Territory",
|
|
||||||
"options": "Territory",
|
|
||||||
"print_width": "120px",
|
|
||||||
"read_only": 1,
|
|
||||||
"width": "120px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "net_total",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Net Total",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"print_width": "120px",
|
|
||||||
"read_only": 1,
|
|
||||||
"width": "120px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "grand_total",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Grand Total",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"print_width": "120px",
|
|
||||||
"read_only": 1,
|
|
||||||
"width": "120px"
|
|
||||||
}
|
|
||||||
]
|
|
@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"autoname": "field:chart_name",
|
||||||
|
"creation": "2014-03-05 14:11:31.000000",
|
||||||
|
"description": "Financial Chart of Accounts. Imported from file.",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "Master",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "chart_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Chart Name",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "country",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Country",
|
||||||
|
"options": "Country",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "preview",
|
||||||
|
"fieldtype": "HTML",
|
||||||
|
"label": "Preview",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "source_file",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Source File",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 1,
|
||||||
|
"in_create": 1,
|
||||||
|
"modified": "2014-03-05 14:51:05.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Chart of Accounts",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"export": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -5,21 +5,17 @@ from __future__ import unicode_literals
|
|||||||
import frappe, os, json
|
import frappe, os, json
|
||||||
from frappe.utils import cstr
|
from frappe.utils import cstr
|
||||||
from unidecode import unidecode
|
from unidecode import unidecode
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class ChartofAccounts(Document):
|
||||||
class DocType:
|
no_report_type = False
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
|
||||||
self.no_report_type = False
|
|
||||||
|
|
||||||
def create_accounts(self, company):
|
def create_accounts(self, company):
|
||||||
chart = {}
|
chart = {}
|
||||||
with open(os.path.join(os.path.dirname(__file__), "charts",
|
with open(os.path.join(os.path.dirname(__file__), "charts", self.source_file), "r") as f:
|
||||||
self.doc.source_file), "r") as f:
|
|
||||||
chart = json.loads(f.read())
|
chart = json.loads(f.read())
|
||||||
|
|
||||||
from erpnext.accounts.doctype.chart_of_accounts.charts.account_properties \
|
from erpnext.accounts.doctype.chart_of_accounts.charts.account_properties import account_properties
|
||||||
import account_properties
|
|
||||||
|
|
||||||
if chart:
|
if chart:
|
||||||
accounts = []
|
accounts = []
|
||||||
@ -33,10 +29,9 @@ class DocType:
|
|||||||
count = accounts.count(account_name_in_db)
|
count = accounts.count(account_name_in_db)
|
||||||
account_name = account_name + " " + cstr(count)
|
account_name = account_name + " " + cstr(count)
|
||||||
|
|
||||||
child.update(account_properties.get(chart.get("name"), {})\
|
child.update(account_properties.get(chart.get("name"), {}).get(account_name, {}))
|
||||||
.get(account_name, {}))
|
|
||||||
|
|
||||||
account = frappe.bean({
|
account = frappe.get_doc({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
"account_name": account_name,
|
"account_name": account_name,
|
||||||
"company": company,
|
"company": company,
|
||||||
@ -49,19 +44,19 @@ class DocType:
|
|||||||
accounts.append(account_name_in_db)
|
accounts.append(account_name_in_db)
|
||||||
|
|
||||||
# set report_type for all parents where blank
|
# set report_type for all parents where blank
|
||||||
if not account.doc.report_type or account.doc.report_type == 'None':
|
if not account.report_type or account.report_type == 'None':
|
||||||
self.no_report_type = True
|
self.no_report_type = True
|
||||||
elif self.no_report_type:
|
elif self.no_report_type:
|
||||||
frappe.db.sql("""update tabAccount set report_type=%s
|
frappe.db.sql("""update tabAccount set report_type=%s
|
||||||
where lft<=%s and rgt>=%s and ifnull(report_type, '')=''""",
|
where lft<=%s and rgt>=%s and ifnull(report_type, '')=''""",
|
||||||
(account.doc.report_type, account.doc.lft, account.doc.rgt))
|
(account.report_type, account.lft, account.rgt))
|
||||||
|
|
||||||
if child.get("children"):
|
if child.get("children"):
|
||||||
_import_accounts(child.get("children"), account.doc.name)
|
_import_accounts(child.get("children"), account.name)
|
||||||
|
|
||||||
_import_accounts(chart.get("root").get("children"), None)
|
_import_accounts(chart.get("root").get("children"), None)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_charts_for_country(country):
|
def get_charts_for_country(country):
|
||||||
return frappe.db.sql_list("select chart_name from `tabChart of Accounts` where country=%s",
|
return frappe.db.sql_list("""select chart_name from `tabChart of Accounts`
|
||||||
country)
|
where country=%s""", country)
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2014-03-05 14:11:31",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-03-05 14:51:05",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "field:chart_name",
|
|
||||||
"description": "Financial Chart of Accounts. Imported from file.",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "Master",
|
|
||||||
"in_create": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Chart of Accounts",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"export": 0,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Chart of Accounts",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"role": "Accounts Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Chart of Accounts"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "chart_name",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_list_view": 0,
|
|
||||||
"label": "Chart Name",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "country",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Country",
|
|
||||||
"options": "Country",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "preview",
|
|
||||||
"fieldtype": "HTML",
|
|
||||||
"label": "Preview"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "source_file",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Source File",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm"
|
|
||||||
}
|
|
||||||
]
|
|
@ -13,13 +13,13 @@ def import_charts():
|
|||||||
chart = json.loads(f.read())
|
chart = json.loads(f.read())
|
||||||
country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]})
|
country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]})
|
||||||
if country:
|
if country:
|
||||||
bean = frappe.bean({
|
doc = frappe.get_doc({
|
||||||
"doctype":"Chart of Accounts",
|
"doctype":"Chart of Accounts",
|
||||||
"chart_name": chart.get("name"),
|
"chart_name": chart.get("name"),
|
||||||
"source_file": fname,
|
"source_file": fname,
|
||||||
"country": country
|
"country": country
|
||||||
}).insert()
|
}).insert()
|
||||||
print bean.doc.name.encode("utf-8")
|
print doc.name.encode("utf-8")
|
||||||
else:
|
else:
|
||||||
print "No chart for: " + chart.get("name").encode("utf-8")
|
print "No chart for: " + chart.get("name").encode("utf-8")
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
||||||
return $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) {
|
return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) {
|
||||||
if(r.message == 1) {
|
if(r.message == 1) {
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
|
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
|
||||||
return $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) {
|
return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) {
|
||||||
if(r.message == 1) {
|
if(r.message == 1) {
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
|
190
erpnext/accounts/doctype/cost_center/cost_center.json
Normal file
190
erpnext/accounts/doctype/cost_center/cost_center.json
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
{
|
||||||
|
"allow_copy": 1,
|
||||||
|
"allow_import": 1,
|
||||||
|
"allow_rename": 1,
|
||||||
|
"autoname": "field:cost_center_name",
|
||||||
|
"creation": "2013-01-23 19:57:17.000000",
|
||||||
|
"description": "Track separate Income and Expense for product verticals or divisions.",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "Master",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "sb0",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Cost Center Details",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "trash_reason",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Trash Reason",
|
||||||
|
"oldfieldname": "trash_reason",
|
||||||
|
"oldfieldtype": "Small Text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "cost_center_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_filter": 0,
|
||||||
|
"label": "Cost Center Name",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "cost_center_name",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "parent_cost_center",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"ignore_restrictions": 1,
|
||||||
|
"label": "Parent Cost Center",
|
||||||
|
"oldfieldname": "parent_cost_center",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Cost Center",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Company",
|
||||||
|
"oldfieldname": "company_name",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "cb0",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "group_or_ledger",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Group or Ledger",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "group_or_ledger",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "\nGroup\nLedger",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"report_hide": 1,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Define Budget for this Cost Center. To set budget action, see <a href=\"#!List/Company\">Company Master</a>",
|
||||||
|
"fieldname": "sb1",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Budget",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Select Budget Distribution, if you want to track based on seasonality.",
|
||||||
|
"fieldname": "distribution_id",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Distribution Id",
|
||||||
|
"oldfieldname": "distribution_id",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Budget Distribution",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Add rows to set annual budgets on Accounts.",
|
||||||
|
"fieldname": "budget_details",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Budget Details",
|
||||||
|
"oldfieldname": "budget_details",
|
||||||
|
"oldfieldtype": "Table",
|
||||||
|
"options": "Budget Detail",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "lft",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"hidden": 1,
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "lft",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "lft",
|
||||||
|
"oldfieldtype": "Int",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"report_hide": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "rgt",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"hidden": 1,
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "rgt",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "rgt",
|
||||||
|
"oldfieldtype": "Int",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"report_hide": 1,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "old_parent",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 1,
|
||||||
|
"ignore_restrictions": 1,
|
||||||
|
"label": "old_parent",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "old_parent",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"options": "Cost Center",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"report_hide": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-money",
|
||||||
|
"idx": 1,
|
||||||
|
"in_create": 1,
|
||||||
|
"modified": "2014-01-20 17:48:30.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Cost Center",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"search_fields": "name,parent_cost_center"
|
||||||
|
}
|
@ -3,59 +3,56 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
from frappe.utils.nestedset import DocTypeNestedSet
|
from frappe.utils.nestedset import NestedSet
|
||||||
|
|
||||||
class DocType(DocTypeNestedSet):
|
class CostCenter(NestedSet):
|
||||||
def __init__(self,d,dl):
|
nsm_parent_field = 'parent_cost_center'
|
||||||
self.doc, self.doclist = d,dl
|
|
||||||
self.nsm_parent_field = 'parent_cost_center'
|
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
company_abbr = frappe.db.sql("select abbr from tabCompany where name=%s",
|
self.name = self.cost_center_name.strip() + ' - ' + \
|
||||||
self.doc.company)[0][0]
|
frappe.db.get_value("Company", self.company, "abbr")
|
||||||
self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr
|
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
if not self.doc.group_or_ledger:
|
if not self.group_or_ledger:
|
||||||
msgprint("Please select Group or Ledger value", raise_exception=1)
|
msgprint("Please select Group or Ledger value", raise_exception=1)
|
||||||
|
|
||||||
if self.doc.cost_center_name != self.doc.company and not self.doc.parent_cost_center:
|
if self.cost_center_name != self.company and not self.parent_cost_center:
|
||||||
msgprint("Please enter parent cost center", raise_exception=1)
|
msgprint("Please enter parent cost center", raise_exception=1)
|
||||||
elif self.doc.cost_center_name == self.doc.company and self.doc.parent_cost_center:
|
elif self.cost_center_name == self.company and self.parent_cost_center:
|
||||||
msgprint(_("Root cannot have a parent cost center"), raise_exception=1)
|
msgprint(_("Root cannot have a parent cost center"), raise_exception=1)
|
||||||
|
|
||||||
def convert_group_to_ledger(self):
|
def convert_group_to_ledger(self):
|
||||||
if self.check_if_child_exists():
|
if self.check_if_child_exists():
|
||||||
msgprint("Cost Center: %s has existing child. You can not convert this cost center to ledger" % (self.doc.name), raise_exception=1)
|
msgprint("Cost Center: %s has existing child. You can not convert this cost center to ledger" % (self.name), raise_exception=1)
|
||||||
elif self.check_gle_exists():
|
elif self.check_gle_exists():
|
||||||
msgprint("Cost Center with existing transaction can not be converted to ledger.", raise_exception=1)
|
msgprint("Cost Center with existing transaction can not be converted to ledger.", raise_exception=1)
|
||||||
else:
|
else:
|
||||||
self.doc.group_or_ledger = 'Ledger'
|
self.group_or_ledger = 'Ledger'
|
||||||
self.doc.save()
|
self.save()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def convert_ledger_to_group(self):
|
def convert_ledger_to_group(self):
|
||||||
if self.check_gle_exists():
|
if self.check_gle_exists():
|
||||||
msgprint("Cost Center with existing transaction can not be converted to group.", raise_exception=1)
|
msgprint("Cost Center with existing transaction can not be converted to group.", raise_exception=1)
|
||||||
else:
|
else:
|
||||||
self.doc.group_or_ledger = 'Group'
|
self.group_or_ledger = 'Group'
|
||||||
self.doc.save()
|
self.save()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def check_gle_exists(self):
|
def check_gle_exists(self):
|
||||||
return frappe.db.get_value("GL Entry", {"cost_center": self.doc.name})
|
return frappe.db.get_value("GL Entry", {"cost_center": self.name})
|
||||||
|
|
||||||
def check_if_child_exists(self):
|
def check_if_child_exists(self):
|
||||||
return frappe.db.sql("select name from `tabCost Center` where \
|
return frappe.db.sql("select name from `tabCost Center` where \
|
||||||
parent_cost_center = %s and docstatus != 2", self.doc.name)
|
parent_cost_center = %s and docstatus != 2", self.name)
|
||||||
|
|
||||||
def validate_budget_details(self):
|
def validate_budget_details(self):
|
||||||
check_acc_list = []
|
check_acc_list = []
|
||||||
for d in getlist(self.doclist, 'budget_details'):
|
for d in self.get('budget_details'):
|
||||||
if self.doc.group_or_ledger=="Group":
|
if self.group_or_ledger=="Group":
|
||||||
msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1)
|
msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1)
|
||||||
|
|
||||||
if [d.account, d.fiscal_year] in check_acc_list:
|
if [d.account, d.fiscal_year] in check_acc_list:
|
||||||
@ -67,7 +64,7 @@ class DocType(DocTypeNestedSet):
|
|||||||
"""
|
"""
|
||||||
Cost Center name must be unique
|
Cost Center name must be unique
|
||||||
"""
|
"""
|
||||||
if (self.doc.fields.get("__islocal") or not self.doc.name) and frappe.db.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.doc.cost_center_name, self.doc.company)):
|
if (self.get("__islocal") or not self.name) and frappe.db.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.cost_center_name, self.company)):
|
||||||
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
|
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
|
||||||
|
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
@ -76,10 +73,10 @@ class DocType(DocTypeNestedSet):
|
|||||||
def before_rename(self, olddn, newdn, merge=False):
|
def before_rename(self, olddn, newdn, merge=False):
|
||||||
# Add company abbr if not provided
|
# Add company abbr if not provided
|
||||||
from erpnext.setup.doctype.company.company import get_name_with_abbr
|
from erpnext.setup.doctype.company.company import get_name_with_abbr
|
||||||
new_cost_center = get_name_with_abbr(newdn, self.doc.company)
|
new_cost_center = get_name_with_abbr(newdn, self.company)
|
||||||
|
|
||||||
# Validate properties before merging
|
# Validate properties before merging
|
||||||
super(DocType, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger")
|
super(CostCenter, self).before_rename(olddn, new_cost_center, merge, "group_or_ledger")
|
||||||
|
|
||||||
return new_cost_center
|
return new_cost_center
|
||||||
|
|
||||||
@ -88,5 +85,5 @@ class DocType(DocTypeNestedSet):
|
|||||||
frappe.db.set_value("Cost Center", newdn, "cost_center_name",
|
frappe.db.set_value("Cost Center", newdn, "cost_center_name",
|
||||||
" - ".join(newdn.split(" - ")[:-1]))
|
" - ".join(newdn.split(" - ")[:-1]))
|
||||||
else:
|
else:
|
||||||
super(DocType, self).after_rename(olddn, newdn, merge)
|
super(CostCenter, self).after_rename(olddn, newdn, merge)
|
||||||
|
|
||||||
|
@ -1,202 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-01-23 19:57:17",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-01-20 17:48:30",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_copy": 1,
|
|
||||||
"allow_import": 1,
|
|
||||||
"allow_rename": 1,
|
|
||||||
"autoname": "field:cost_center_name",
|
|
||||||
"description": "Track separate Income and Expense for product verticals or divisions.",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "Master",
|
|
||||||
"icon": "icon-money",
|
|
||||||
"in_create": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"search_fields": "name,parent_cost_center"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Cost Center",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Cost Center",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"submit": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Cost Center"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "sb0",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Cost Center Details"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "trash_reason",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"label": "Trash Reason",
|
|
||||||
"oldfieldname": "trash_reason",
|
|
||||||
"oldfieldtype": "Small Text",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cost_center_name",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_filter": 0,
|
|
||||||
"label": "Cost Center Name",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "cost_center_name",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "parent_cost_center",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"ignore_restrictions": 1,
|
|
||||||
"label": "Parent Cost Center",
|
|
||||||
"oldfieldname": "parent_cost_center",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Cost Center",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Company",
|
|
||||||
"oldfieldname": "company_name",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Company",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cb0",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "group_or_ledger",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "Group or Ledger",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "group_or_ledger",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "\nGroup\nLedger",
|
|
||||||
"print_hide": 1,
|
|
||||||
"report_hide": 1,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Define Budget for this Cost Center. To set budget action, see <a href=\"#!List/Company\">Company Master</a>",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "sb1",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Budget"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Select Budget Distribution, if you want to track based on seasonality.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "distribution_id",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Distribution Id",
|
|
||||||
"oldfieldname": "distribution_id",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Budget Distribution"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Add rows to set annual budgets on Accounts.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "budget_details",
|
|
||||||
"fieldtype": "Table",
|
|
||||||
"label": "Budget Details",
|
|
||||||
"oldfieldname": "budget_details",
|
|
||||||
"oldfieldtype": "Table",
|
|
||||||
"options": "Budget Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "lft",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"hidden": 1,
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "lft",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "lft",
|
|
||||||
"oldfieldtype": "Int",
|
|
||||||
"print_hide": 1,
|
|
||||||
"report_hide": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "rgt",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"hidden": 1,
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "rgt",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "rgt",
|
|
||||||
"oldfieldtype": "Int",
|
|
||||||
"print_hide": 1,
|
|
||||||
"report_hide": 1,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "old_parent",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"hidden": 1,
|
|
||||||
"ignore_restrictions": 1,
|
|
||||||
"label": "old_parent",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "old_parent",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"options": "Cost Center",
|
|
||||||
"print_hide": 1,
|
|
||||||
"report_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts User",
|
|
||||||
"write": 0
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,19 +1,6 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
test_records = [
|
|
||||||
[{
|
import frappe
|
||||||
"doctype": "Cost Center",
|
test_records = frappe.get_test_records('Cost Center')
|
||||||
"cost_center_name": "_Test Cost Center",
|
|
||||||
"parent_cost_center": "_Test Company - _TC",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"group_or_ledger": "Ledger",
|
|
||||||
"distribution_id": "_Test Distribution",
|
|
||||||
}, {
|
|
||||||
"doctype": "Budget Detail",
|
|
||||||
"parentfield": "budget_details",
|
|
||||||
"account": "_Test Account Cost for Goods Sold - _TC",
|
|
||||||
"budget_allocated": 100000,
|
|
||||||
"fiscal_year": "_Test Fiscal Year 2013"
|
|
||||||
}],
|
|
||||||
]
|
|
19
erpnext/accounts/doctype/cost_center/test_records.json
Normal file
19
erpnext/accounts/doctype/cost_center/test_records.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"budget_details": [
|
||||||
|
{
|
||||||
|
"account": "_Test Account Cost for Goods Sold - _TC",
|
||||||
|
"budget_allocated": 100000,
|
||||||
|
"doctype": "Budget Detail",
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
|
"parentfield": "budget_details"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"company": "_Test Company",
|
||||||
|
"cost_center_name": "_Test Cost Center",
|
||||||
|
"distribution_id": "_Test Distribution",
|
||||||
|
"doctype": "Cost Center",
|
||||||
|
"group_or_ledger": "Ledger",
|
||||||
|
"parent_cost_center": "_Test Company - _TC"
|
||||||
|
}
|
||||||
|
]
|
82
erpnext/accounts/doctype/fiscal_year/fiscal_year.json
Normal file
82
erpnext/accounts/doctype/fiscal_year/fiscal_year.json
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"allow_import": 1,
|
||||||
|
"autoname": "field:year",
|
||||||
|
"creation": "2013-01-22 16:50:25.000000",
|
||||||
|
"description": "**Fiscal Year** represents a Financial Year. All accounting entries and other major transactions are tracked against **Fiscal Year**.",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "Master",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"description": "For e.g. 2012, 2012-13",
|
||||||
|
"fieldname": "year",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Year Name",
|
||||||
|
"oldfieldname": "year",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "year_start_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Year Start Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "year_start_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "year_end_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Year End Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "No",
|
||||||
|
"description": "Entries are not allowed against this Fiscal Year if the year is closed.",
|
||||||
|
"fieldname": "is_fiscal_year_closed",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Year Closed",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "is_fiscal_year_closed",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "\nNo\nYes",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-calendar",
|
||||||
|
"idx": 1,
|
||||||
|
"modified": "2014-01-20 17:48:46.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Fiscal Year",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"delete": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"role": "All"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -6,40 +6,40 @@ import frappe
|
|||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
class DocType:
|
from frappe.model.document import Document
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
class FiscalYear(Document):
|
||||||
|
|
||||||
def set_as_default(self):
|
def set_as_default(self):
|
||||||
frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
|
frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.name)
|
||||||
frappe.get_obj("Global Defaults").on_update()
|
frappe.get_doc("Global Defaults").on_update()
|
||||||
|
|
||||||
# clear cache
|
# clear cache
|
||||||
frappe.clear_cache()
|
frappe.clear_cache()
|
||||||
|
|
||||||
msgprint(self.doc.name + _(""" is now the default Fiscal Year. \
|
msgprint(self.name + _(""" is now the default Fiscal Year. \
|
||||||
Please refresh your browser for the change to take effect."""))
|
Please refresh your browser for the change to take effect."""))
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
year_start_end_dates = frappe.db.sql("""select year_start_date, year_end_date
|
year_start_end_dates = frappe.db.sql("""select year_start_date, year_end_date
|
||||||
from `tabFiscal Year` where name=%s""", (self.doc.name))
|
from `tabFiscal Year` where name=%s""", (self.name))
|
||||||
|
|
||||||
if year_start_end_dates:
|
if year_start_end_dates:
|
||||||
if getdate(self.doc.year_start_date) != year_start_end_dates[0][0] or getdate(self.doc.year_end_date) != year_start_end_dates[0][1]:
|
if getdate(self.year_start_date) != year_start_end_dates[0][0] or getdate(self.year_end_date) != year_start_end_dates[0][1]:
|
||||||
frappe.throw(_("Cannot change Year Start Date and Year End Date once the Fiscal Year is saved."))
|
frappe.throw(_("Cannot change Year Start Date and Year End Date once the Fiscal Year is saved."))
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
# validate year start date and year end date
|
# validate year start date and year end date
|
||||||
if getdate(self.doc.year_start_date) > getdate(self.doc.year_end_date):
|
if getdate(self.year_start_date) > getdate(self.year_end_date):
|
||||||
frappe.throw(_("Year Start Date should not be greater than Year End Date"))
|
frappe.throw(_("Year Start Date should not be greater than Year End Date"))
|
||||||
|
|
||||||
if (getdate(self.doc.year_end_date) - getdate(self.doc.year_start_date)).days > 366:
|
if (getdate(self.year_end_date) - getdate(self.year_start_date)).days > 366:
|
||||||
frappe.throw(_("Year Start Date and Year End Date are not within Fiscal Year."))
|
frappe.throw(_("Year Start Date and Year End Date are not within Fiscal Year."))
|
||||||
|
|
||||||
year_start_end_dates = frappe.db.sql("""select name, year_start_date, year_end_date
|
year_start_end_dates = frappe.db.sql("""select name, year_start_date, year_end_date
|
||||||
from `tabFiscal Year` where name!=%s""", (self.doc.name))
|
from `tabFiscal Year` where name!=%s""", (self.name))
|
||||||
|
|
||||||
for fiscal_year, ysd, yed in year_start_end_dates:
|
for fiscal_year, ysd, yed in year_start_end_dates:
|
||||||
if (getdate(self.doc.year_start_date) == ysd and getdate(self.doc.year_end_date) == yed) \
|
if (getdate(self.year_start_date) == ysd and getdate(self.year_end_date) == yed) \
|
||||||
and (not frappe.flags.in_test):
|
and (not frappe.flags.in_test):
|
||||||
frappe.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year)
|
frappe.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year)
|
@ -1,98 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-01-22 16:50:25",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-01-20 17:48:46",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_import": 1,
|
|
||||||
"autoname": "field:year",
|
|
||||||
"description": "**Fiscal Year** represents a Financial Year. All accounting entries and other major transactions are tracked against **Fiscal Year**.",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "Master",
|
|
||||||
"icon": "icon-calendar",
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Fiscal Year",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Fiscal Year",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Fiscal Year"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "For e.g. 2012, 2012-13",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "year",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Year Name",
|
|
||||||
"oldfieldname": "year",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "year_start_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Year Start Date",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "year_start_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "year_end_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Year End Date",
|
|
||||||
"no_copy": 1,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "No",
|
|
||||||
"description": "Entries are not allowed against this Fiscal Year if the year is closed.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "is_fiscal_year_closed",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Year Closed",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "is_fiscal_year_closed",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "\nNo\nYes",
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"report": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "All"
|
|
||||||
}
|
|
||||||
]
|
|
@ -3,35 +3,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
test_records = [
|
import frappe
|
||||||
[{
|
|
||||||
"doctype": "Fiscal Year",
|
test_records = frappe.get_test_records('Fiscal Year')
|
||||||
"year": "_Test Fiscal Year 2012",
|
|
||||||
"year_start_date": "2012-01-01",
|
|
||||||
"year_end_date": "2012-12-31"
|
|
||||||
}],
|
|
||||||
[{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2013",
|
|
||||||
"year_start_date": "2013-01-01",
|
|
||||||
"year_end_date": "2013-12-31"
|
|
||||||
}],
|
|
||||||
[{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2014",
|
|
||||||
"year_start_date": "2014-01-01",
|
|
||||||
"year_end_date": "2014-12-31"
|
|
||||||
}],
|
|
||||||
[{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2015",
|
|
||||||
"year_start_date": "2015-01-01",
|
|
||||||
"year_end_date": "2015-12-31"
|
|
||||||
}],
|
|
||||||
[{
|
|
||||||
"doctype": "Fiscal Year",
|
|
||||||
"year": "_Test Fiscal Year 2016",
|
|
||||||
"year_start_date": "2016-01-01",
|
|
||||||
"year_end_date": "2016-12-31"
|
|
||||||
}],
|
|
||||||
]
|
|
32
erpnext/accounts/doctype/fiscal_year/test_records.json
Normal file
32
erpnext/accounts/doctype/fiscal_year/test_records.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"doctype": "Fiscal Year",
|
||||||
|
"year": "_Test Fiscal Year 2012",
|
||||||
|
"year_end_date": "2012-12-31",
|
||||||
|
"year_start_date": "2012-01-01"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Fiscal Year",
|
||||||
|
"year": "_Test Fiscal Year 2013",
|
||||||
|
"year_end_date": "2013-12-31",
|
||||||
|
"year_start_date": "2013-01-01"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Fiscal Year",
|
||||||
|
"year": "_Test Fiscal Year 2014",
|
||||||
|
"year_end_date": "2014-12-31",
|
||||||
|
"year_start_date": "2014-01-01"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Fiscal Year",
|
||||||
|
"year": "_Test Fiscal Year 2015",
|
||||||
|
"year_end_date": "2015-12-31",
|
||||||
|
"year_start_date": "2015-01-01"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Fiscal Year",
|
||||||
|
"year": "_Test Fiscal Year 2016",
|
||||||
|
"year_end_date": "2016-12-31",
|
||||||
|
"year_start_date": "2016-01-01"
|
||||||
|
}
|
||||||
|
]
|
229
erpnext/accounts/doctype/gl_entry/gl_entry.json
Normal file
229
erpnext/accounts/doctype/gl_entry/gl_entry.json
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
{
|
||||||
|
"autoname": "GL.#######",
|
||||||
|
"creation": "2013-01-10 16:34:06.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "posting_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Posting Date",
|
||||||
|
"oldfieldname": "posting_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "transaction_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Transaction Date",
|
||||||
|
"oldfieldname": "transaction_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "aging_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Aging Date",
|
||||||
|
"oldfieldname": "aging_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Account",
|
||||||
|
"oldfieldname": "account",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "cost_center",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Cost Center",
|
||||||
|
"oldfieldname": "cost_center",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Cost Center",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "debit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Debit Amt",
|
||||||
|
"oldfieldname": "debit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "credit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Credit Amt",
|
||||||
|
"oldfieldname": "credit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against",
|
||||||
|
"fieldtype": "Text",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Against",
|
||||||
|
"oldfieldname": "against",
|
||||||
|
"oldfieldtype": "Text",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_voucher",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Against Voucher",
|
||||||
|
"oldfieldname": "against_voucher",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_voucher_type",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_filter": 0,
|
||||||
|
"label": "Against Voucher Type",
|
||||||
|
"oldfieldname": "against_voucher_type",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Voucher Type",
|
||||||
|
"oldfieldname": "voucher_type",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "Journal Voucher\nSales Invoice\nPurchase Invoice",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_no",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Voucher No",
|
||||||
|
"oldfieldname": "voucher_no",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "remarks",
|
||||||
|
"fieldtype": "Text",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Remarks",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "remarks",
|
||||||
|
"oldfieldtype": "Text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "is_opening",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Is Opening",
|
||||||
|
"oldfieldname": "is_opening",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "No\nYes",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "is_advance",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 0,
|
||||||
|
"label": "Is Advance",
|
||||||
|
"oldfieldname": "is_advance",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "No\nYes",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fiscal_year",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Fiscal Year",
|
||||||
|
"oldfieldname": "fiscal_year",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "link:Fiscal Year",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Company",
|
||||||
|
"oldfieldname": "company",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"search_index": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-list",
|
||||||
|
"idx": 1,
|
||||||
|
"in_create": 1,
|
||||||
|
"modified": "2013-12-20 19:24:08.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "GL Entry",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"search_fields": "voucher_no,account,posting_date,against_voucher"
|
||||||
|
}
|
@ -7,9 +7,9 @@ import frappe
|
|||||||
from frappe.utils import flt, fmt_money, getdate
|
from frappe.utils import flt, fmt_money, getdate
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
class DocType:
|
from frappe.model.document import Document
|
||||||
def __init__(self,d,dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
class GLEntry(Document):
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.check_mandatory()
|
self.check_mandatory()
|
||||||
@ -20,42 +20,42 @@ class DocType:
|
|||||||
|
|
||||||
def on_update_with_args(self, adv_adj, update_outstanding = 'Yes'):
|
def on_update_with_args(self, adv_adj, update_outstanding = 'Yes'):
|
||||||
self.validate_account_details(adv_adj)
|
self.validate_account_details(adv_adj)
|
||||||
validate_frozen_account(self.doc.account, adv_adj)
|
validate_frozen_account(self.account, adv_adj)
|
||||||
check_freezing_date(self.doc.posting_date, adv_adj)
|
check_freezing_date(self.posting_date, adv_adj)
|
||||||
validate_balance_type(self.doc.account, adv_adj)
|
validate_balance_type(self.account, adv_adj)
|
||||||
|
|
||||||
# Update outstanding amt on against voucher
|
# Update outstanding amt on against voucher
|
||||||
if self.doc.against_voucher and self.doc.against_voucher_type != "POS" \
|
if self.against_voucher and self.against_voucher_type != "POS" \
|
||||||
and update_outstanding == 'Yes':
|
and update_outstanding == 'Yes':
|
||||||
update_outstanding_amt(self.doc.account, self.doc.against_voucher_type,
|
update_outstanding_amt(self.account, self.against_voucher_type,
|
||||||
self.doc.against_voucher)
|
self.against_voucher)
|
||||||
|
|
||||||
def check_mandatory(self):
|
def check_mandatory(self):
|
||||||
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
|
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
|
||||||
for k in mandatory:
|
for k in mandatory:
|
||||||
if not self.doc.fields.get(k):
|
if not self.get(k):
|
||||||
frappe.throw(k + _(" is mandatory for GL Entry"))
|
frappe.throw(k + _(" is mandatory for GL Entry"))
|
||||||
|
|
||||||
# Zero value transaction is not allowed
|
# Zero value transaction is not allowed
|
||||||
if not (flt(self.doc.debit) or flt(self.doc.credit)):
|
if not (flt(self.debit) or flt(self.credit)):
|
||||||
frappe.throw(_("GL Entry: Debit or Credit amount is mandatory for ") +
|
frappe.throw(_("GL Entry: Debit or Credit amount is mandatory for ") +
|
||||||
self.doc.account)
|
self.account)
|
||||||
|
|
||||||
def pl_must_have_cost_center(self):
|
def pl_must_have_cost_center(self):
|
||||||
if frappe.db.get_value("Account", self.doc.account, "report_type") == "Profit and Loss":
|
if frappe.db.get_value("Account", self.account, "report_type") == "Profit and Loss":
|
||||||
if not self.doc.cost_center and self.doc.voucher_type != 'Period Closing Voucher':
|
if not self.cost_center and self.voucher_type != 'Period Closing Voucher':
|
||||||
frappe.throw(_("Cost Center must be specified for Profit and Loss type account: ")
|
frappe.throw(_("Cost Center must be specified for Profit and Loss type account: ")
|
||||||
+ self.doc.account)
|
+ self.account)
|
||||||
elif self.doc.cost_center:
|
elif self.cost_center:
|
||||||
self.doc.cost_center = None
|
self.cost_center = None
|
||||||
|
|
||||||
def validate_posting_date(self):
|
def validate_posting_date(self):
|
||||||
from erpnext.accounts.utils import validate_fiscal_year
|
from erpnext.accounts.utils import validate_fiscal_year
|
||||||
validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, "Posting Date")
|
validate_fiscal_year(self.posting_date, self.fiscal_year, "Posting Date")
|
||||||
|
|
||||||
def check_pl_account(self):
|
def check_pl_account(self):
|
||||||
if self.doc.is_opening=='Yes' and \
|
if self.is_opening=='Yes' and \
|
||||||
frappe.db.get_value("Account", self.doc.account, "report_type")=="Profit and Loss":
|
frappe.db.get_value("Account", self.account, "report_type")=="Profit and Loss":
|
||||||
frappe.throw(_("For opening balance entry, account can not be \
|
frappe.throw(_("For opening balance entry, account can not be \
|
||||||
a Profit and Loss type account"))
|
a Profit and Loss type account"))
|
||||||
|
|
||||||
@ -63,32 +63,32 @@ class DocType:
|
|||||||
"""Account must be ledger, active and not freezed"""
|
"""Account must be ledger, active and not freezed"""
|
||||||
|
|
||||||
ret = frappe.db.sql("""select group_or_ledger, docstatus, company
|
ret = frappe.db.sql("""select group_or_ledger, docstatus, company
|
||||||
from tabAccount where name=%s""", self.doc.account, as_dict=1)[0]
|
from tabAccount where name=%s""", self.account, as_dict=1)[0]
|
||||||
|
|
||||||
if ret.group_or_ledger=='Group':
|
if ret.group_or_ledger=='Group':
|
||||||
frappe.throw(_("Account") + ": " + self.doc.account + _(" is not a ledger"))
|
frappe.throw(_("Account") + ": " + self.account + _(" is not a ledger"))
|
||||||
|
|
||||||
if ret.docstatus==2:
|
if ret.docstatus==2:
|
||||||
frappe.throw(_("Account") + ": " + self.doc.account + _(" is not active"))
|
frappe.throw(_("Account") + ": " + self.account + _(" is not active"))
|
||||||
|
|
||||||
if ret.company != self.doc.company:
|
if ret.company != self.company:
|
||||||
frappe.throw(_("Account") + ": " + self.doc.account +
|
frappe.throw(_("Account") + ": " + self.account +
|
||||||
_(" does not belong to the company") + ": " + self.doc.company)
|
_(" does not belong to the company") + ": " + self.company)
|
||||||
|
|
||||||
def validate_cost_center(self):
|
def validate_cost_center(self):
|
||||||
if not hasattr(self, "cost_center_company"):
|
if not hasattr(self, "cost_center_company"):
|
||||||
self.cost_center_company = {}
|
self.cost_center_company = {}
|
||||||
|
|
||||||
def _get_cost_center_company():
|
def _get_cost_center_company():
|
||||||
if not self.cost_center_company.get(self.doc.cost_center):
|
if not self.cost_center_company.get(self.cost_center):
|
||||||
self.cost_center_company[self.doc.cost_center] = frappe.db.get_value(
|
self.cost_center_company[self.cost_center] = frappe.db.get_value(
|
||||||
"Cost Center", self.doc.cost_center, "company")
|
"Cost Center", self.cost_center, "company")
|
||||||
|
|
||||||
return self.cost_center_company[self.doc.cost_center]
|
return self.cost_center_company[self.cost_center]
|
||||||
|
|
||||||
if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
|
if self.cost_center and _get_cost_center_company() != self.company:
|
||||||
frappe.throw(_("Cost Center") + ": " + self.doc.cost_center +
|
frappe.throw(_("Cost Center") + ": " + self.cost_center +
|
||||||
_(" does not belong to the company") + ": " + self.doc.company)
|
_(" does not belong to the company") + ": " + self.company)
|
||||||
|
|
||||||
def validate_balance_type(account, adv_adj=False):
|
def validate_balance_type(account, adv_adj=False):
|
||||||
if not adv_adj and account:
|
if not adv_adj and account:
|
||||||
|
@ -1,234 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-01-10 16:34:06",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:24:08",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "GL.#######",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"icon": "icon-list",
|
|
||||||
"in_create": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"search_fields": "voucher_no,account,posting_date,against_voucher"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "GL Entry",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "GL Entry",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "GL Entry"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "posting_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Posting Date",
|
|
||||||
"oldfieldname": "posting_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "transaction_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Transaction Date",
|
|
||||||
"oldfieldname": "transaction_date",
|
|
||||||
"oldfieldtype": "Date"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "aging_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Aging Date",
|
|
||||||
"oldfieldname": "aging_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Account",
|
|
||||||
"oldfieldname": "account",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Account",
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cost_center",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Cost Center",
|
|
||||||
"oldfieldname": "cost_center",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Cost Center",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "debit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Debit Amt",
|
|
||||||
"oldfieldname": "debit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "credit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Credit Amt",
|
|
||||||
"oldfieldname": "credit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against",
|
|
||||||
"fieldtype": "Text",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Against",
|
|
||||||
"oldfieldname": "against",
|
|
||||||
"oldfieldtype": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against_voucher",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Against Voucher",
|
|
||||||
"oldfieldname": "against_voucher",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against_voucher_type",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_filter": 0,
|
|
||||||
"label": "Against Voucher Type",
|
|
||||||
"oldfieldname": "against_voucher_type",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_type",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Voucher Type",
|
|
||||||
"oldfieldname": "voucher_type",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "Journal Voucher\nSales Invoice\nPurchase Invoice",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_no",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Voucher No",
|
|
||||||
"oldfieldname": "voucher_no",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "remarks",
|
|
||||||
"fieldtype": "Text",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Remarks",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "remarks",
|
|
||||||
"oldfieldtype": "Text",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "is_opening",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Is Opening",
|
|
||||||
"oldfieldname": "is_opening",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "No\nYes",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "is_advance",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 0,
|
|
||||||
"label": "Is Advance",
|
|
||||||
"oldfieldname": "is_advance",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "No\nYes",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "fiscal_year",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Fiscal Year",
|
|
||||||
"oldfieldname": "fiscal_year",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "link:Fiscal Year",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Company",
|
|
||||||
"oldfieldname": "company",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Company",
|
|
||||||
"search_index": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts User"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "System Manager"
|
|
||||||
}
|
|
||||||
]
|
|
@ -12,8 +12,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
load_defaults: function() {
|
load_defaults: function() {
|
||||||
if(this.frm.doc.__islocal && this.frm.doc.company) {
|
if(this.frm.doc.__islocal && this.frm.doc.company) {
|
||||||
frappe.model.set_default_values(this.frm.doc);
|
frappe.model.set_default_values(this.frm.doc);
|
||||||
$.each(frappe.model.get_doclist(this.frm.doc.doctype,
|
$.each(this.frm.doc.entries || [], function(i, jvd) {
|
||||||
this.frm.doc.name, {parentfield: "entries"}), function(i, jvd) {
|
|
||||||
frappe.model.set_default_values(jvd);
|
frappe.model.set_default_values(jvd);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -40,7 +39,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
|
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
|
||||||
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
|
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
|
||||||
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
|
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
|
||||||
var jvd = frappe.model.get_doc(cdt, cdn);
|
var jvd = frappe.get_doc(cdt, cdn);
|
||||||
frappe.model.validate_missing(jvd, "account");
|
frappe.model.validate_missing(jvd, "account");
|
||||||
return {
|
return {
|
||||||
filters: [
|
filters: [
|
||||||
@ -53,7 +52,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
|
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
|
||||||
var jvd = frappe.model.get_doc(cdt, cdn);
|
var jvd = frappe.get_doc(cdt, cdn);
|
||||||
frappe.model.validate_missing(jvd, "account");
|
frappe.model.validate_missing(jvd, "account");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -64,7 +63,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
against_voucher: function(doc, cdt, cdn) {
|
against_voucher: function(doc, cdt, cdn) {
|
||||||
var d = frappe.model.get_doc(cdt, cdn);
|
var d = frappe.get_doc(cdt, cdn);
|
||||||
if (d.against_voucher && !flt(d.debit)) {
|
if (d.against_voucher && !flt(d.debit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Purchase Invoice',
|
'doctype': 'Purchase Invoice',
|
||||||
@ -74,7 +73,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
against_invoice: function(doc, cdt, cdn) {
|
against_invoice: function(doc, cdt, cdn) {
|
||||||
var d = frappe.model.get_doc(cdt, cdn);
|
var d = frappe.get_doc(cdt, cdn);
|
||||||
if (d.against_invoice && !flt(d.credit)) {
|
if (d.against_invoice && !flt(d.credit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Sales Invoice',
|
'doctype': 'Sales Invoice',
|
||||||
@ -84,7 +83,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
against_jv: function(doc, cdt, cdn) {
|
against_jv: function(doc, cdt, cdn) {
|
||||||
var d = frappe.model.get_doc(cdt, cdn);
|
var d = frappe.get_doc(cdt, cdn);
|
||||||
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
|
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Journal Voucher',
|
'doctype': 'Journal Voucher',
|
||||||
@ -139,7 +138,7 @@ cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
cur_frm.cscript.update_totals = function(doc) {
|
cur_frm.cscript.update_totals = function(doc) {
|
||||||
var td=0.0; var tc =0.0;
|
var td=0.0; var tc =0.0;
|
||||||
var el = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
var el = doc.entries || [];
|
||||||
for(var i in el) {
|
for(var i in el) {
|
||||||
td += flt(el[i].debit, 2);
|
td += flt(el[i].debit, 2);
|
||||||
tc += flt(el[i].credit, 2);
|
tc += flt(el[i].credit, 2);
|
||||||
@ -156,7 +155,7 @@ cur_frm.cscript.credit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc
|
|||||||
|
|
||||||
cur_frm.cscript.get_balance = function(doc,dt,dn) {
|
cur_frm.cscript.get_balance = function(doc,dt,dn) {
|
||||||
cur_frm.cscript.update_totals(doc);
|
cur_frm.cscript.update_totals(doc);
|
||||||
return $c_obj(make_doclist(dt,dn), 'get_balance', '', function(r, rt){
|
return $c_obj(cur_frm.doc, 'get_balance', '', function(r, rt){
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -194,8 +193,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher");
|
cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher");
|
||||||
cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher");
|
cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher");
|
||||||
|
|
||||||
if(frappe.model.get("Journal Voucher Detail", {"parent":doc.name}).length!==0 // too late
|
if((doc.entries || []).length!==0 || !doc.company) // too early
|
||||||
|| !doc.company) // too early
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var update_jv_details = function(doc, r) {
|
var update_jv_details = function(doc, r) {
|
||||||
|
492
erpnext/accounts/doctype/journal_voucher/journal_voucher.json
Normal file
492
erpnext/accounts/doctype/journal_voucher/journal_voucher.json
Normal file
@ -0,0 +1,492 @@
|
|||||||
|
{
|
||||||
|
"allow_import": 1,
|
||||||
|
"autoname": "naming_series:",
|
||||||
|
"creation": "2013-03-25 10:53:52.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_type_and_date",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Voucher Type and Date",
|
||||||
|
"options": "icon-flag",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break0",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "naming_series",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Series",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "naming_series",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "JV",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Voucher Type",
|
||||||
|
"oldfieldname": "voucher_type",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher\nOpening Entry",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "posting_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Posting Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "posting_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "2_add_edit_gl_entries",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Journal Entries",
|
||||||
|
"oldfieldtype": "Section Break",
|
||||||
|
"options": "icon-table",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"fieldname": "entries",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Entries",
|
||||||
|
"oldfieldname": "entries",
|
||||||
|
"oldfieldtype": "Table",
|
||||||
|
"options": "Journal Voucher Detail",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break99",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_debit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Total Debit",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "total_debit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_credit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Total Credit",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "total_credit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break99",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "difference",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Difference",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "difference",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "get_balance",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Make Difference Entry",
|
||||||
|
"oldfieldtype": "Button",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reference",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Reference",
|
||||||
|
"options": "icon-pushpin",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "eg. Cheque Number",
|
||||||
|
"fieldname": "cheque_no",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Reference Number",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "cheque_no",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "cheque_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Reference Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "cheque_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "clearance_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Clearance Date",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "clearance_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break98",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "user_remark",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "User Remark",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "user_remark",
|
||||||
|
"oldfieldtype": "Small Text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "User Remark will be added to Auto Remark",
|
||||||
|
"fieldname": "remark",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Remark",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "remark",
|
||||||
|
"oldfieldtype": "Small Text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "bill_no",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Bill No",
|
||||||
|
"oldfieldname": "bill_no",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "bill_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Bill Date",
|
||||||
|
"oldfieldname": "bill_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "due_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Due Date",
|
||||||
|
"oldfieldname": "due_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "addtional_info",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "More Info",
|
||||||
|
"oldfieldtype": "Section Break",
|
||||||
|
"options": "icon-file-text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break2",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "No",
|
||||||
|
"description": "Considered as Opening Balance",
|
||||||
|
"fieldname": "is_opening",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Is Opening",
|
||||||
|
"oldfieldname": "is_opening",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "No\nYes",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Actual Posting Date",
|
||||||
|
"fieldname": "aging_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Aging Date",
|
||||||
|
"no_copy": 0,
|
||||||
|
"oldfieldname": "aging_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Accounts Receivable",
|
||||||
|
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
|
||||||
|
"fieldname": "write_off_based_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Write Off Based On",
|
||||||
|
"options": "Accounts Receivable\nAccounts Payable",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
|
||||||
|
"fieldname": "write_off_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Write Off Amount <=",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
|
||||||
|
"fieldname": "get_outstanding_invoices",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Get Outstanding Invoices",
|
||||||
|
"options": "get_outstanding_invoices",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "letter_head",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Letter Head",
|
||||||
|
"options": "Letter Head",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break3",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "pay_to_recd_from",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Pay To / Recd From",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_amount",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Total Amount",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1,
|
||||||
|
"report_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_amount_in_words",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Total Amount in Words",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1,
|
||||||
|
"report_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fiscal_year",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Fiscal Year",
|
||||||
|
"oldfieldname": "fiscal_year",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "link:Fiscal Year",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Company",
|
||||||
|
"oldfieldname": "company",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"fieldname": "select_print_heading",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Print Heading",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "select_print_heading",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Print Heading",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"report_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "amended_from",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"ignore_restrictions": 1,
|
||||||
|
"label": "Amended From",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "amended_from",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Journal Voucher",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-file-text",
|
||||||
|
"idx": 1,
|
||||||
|
"is_submittable": 1,
|
||||||
|
"modified": "2014-01-20 17:48:51.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Journal Voucher",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"amend": 1,
|
||||||
|
"cancel": 1,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 1,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 1,
|
||||||
|
"cancel": 1,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 1,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 0,
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Auditor",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"read_only_onload": 1,
|
||||||
|
"search_fields": "voucher_type,posting_date, due_date, cheque_no"
|
||||||
|
}
|
@ -5,28 +5,26 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate
|
from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate
|
||||||
from frappe.model.doc import addchild
|
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
|
|
||||||
class DocType(AccountsController):
|
class JournalVoucher(AccountsController):
|
||||||
def __init__(self,d,dl):
|
def __init__(self, arg1, arg2=None):
|
||||||
self.doc, self.doclist = d,dl
|
super(JournalVoucher, self).__init__(arg1, arg2)
|
||||||
self.master_type = {}
|
self.master_type = {}
|
||||||
self.credit_days_for = {}
|
self.credit_days_for = {}
|
||||||
self.credit_days_global = -1
|
self.credit_days_global = -1
|
||||||
self.is_approving_authority = -1
|
self.is_approving_authority = -1
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.doc.is_opening:
|
if not self.is_opening:
|
||||||
self.doc.is_opening='No'
|
self.is_opening='No'
|
||||||
|
|
||||||
self.doc.clearance_date = None
|
self.clearance_date = None
|
||||||
|
|
||||||
super(DocType, self).validate_date_with_fiscal_year()
|
super(JournalVoucher, self).validate_date_with_fiscal_year()
|
||||||
|
|
||||||
self.validate_debit_credit()
|
self.validate_debit_credit()
|
||||||
self.validate_cheque_info()
|
self.validate_cheque_info()
|
||||||
@ -40,39 +38,39 @@ class DocType(AccountsController):
|
|||||||
|
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if self.doc.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']:
|
if self.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']:
|
||||||
self.check_credit_days()
|
self.check_credit_days()
|
||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
self.check_credit_limit()
|
self.check_credit_limit()
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
from erpnext.accounts.utils import remove_against_link_from_jv
|
from erpnext.accounts.utils import remove_against_link_from_jv
|
||||||
remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_jv")
|
remove_against_link_from_jv(self.doctype, self.name, "against_jv")
|
||||||
|
|
||||||
self.make_gl_entries(1)
|
self.make_gl_entries(1)
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
pass
|
pass
|
||||||
#if self.doc.amended_from:
|
#if self.amended_from:
|
||||||
# frappe.delete_doc("Journal Voucher", self.doc.amended_from)
|
# frappe.delete_doc("Journal Voucher", self.amended_from)
|
||||||
|
|
||||||
def validate_debit_credit(self):
|
def validate_debit_credit(self):
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in self.get('entries'):
|
||||||
if d.debit and d.credit:
|
if d.debit and d.credit:
|
||||||
msgprint("You cannot credit and debit same account at the same time.",
|
msgprint("You cannot credit and debit same account at the same time.",
|
||||||
raise_exception=1)
|
raise_exception=1)
|
||||||
|
|
||||||
def validate_cheque_info(self):
|
def validate_cheque_info(self):
|
||||||
if self.doc.voucher_type in ['Bank Voucher']:
|
if self.voucher_type in ['Bank Voucher']:
|
||||||
if not self.doc.cheque_no or not self.doc.cheque_date:
|
if not self.cheque_no or not self.cheque_date:
|
||||||
msgprint("Reference No & Reference Date is required for %s" %
|
msgprint("Reference No & Reference Date is required for %s" %
|
||||||
self.doc.voucher_type, raise_exception=1)
|
self.voucher_type, raise_exception=1)
|
||||||
|
|
||||||
if self.doc.cheque_date and not self.doc.cheque_no:
|
if self.cheque_date and not self.cheque_no:
|
||||||
msgprint("Reference No is mandatory if you entered Reference Date", raise_exception=1)
|
msgprint("Reference No is mandatory if you entered Reference Date", raise_exception=1)
|
||||||
|
|
||||||
def validate_entries_for_advance(self):
|
def validate_entries_for_advance(self):
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in self.get('entries'):
|
||||||
if not d.is_advance and not d.against_voucher and \
|
if not d.is_advance and not d.against_voucher and \
|
||||||
not d.against_invoice and not d.against_jv:
|
not d.against_invoice and not d.against_jv:
|
||||||
master_type = frappe.db.get_value("Account", d.account, "master_type")
|
master_type = frappe.db.get_value("Account", d.account, "master_type")
|
||||||
@ -82,9 +80,9 @@ class DocType(AccountsController):
|
|||||||
Account %s if this is an advance entry." % d.account)
|
Account %s if this is an advance entry." % d.account)
|
||||||
|
|
||||||
def validate_against_jv(self):
|
def validate_against_jv(self):
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in self.get('entries'):
|
||||||
if d.against_jv:
|
if d.against_jv:
|
||||||
if d.against_jv == self.doc.name:
|
if d.against_jv == self.name:
|
||||||
msgprint("You can not enter current voucher in 'Against JV' column",
|
msgprint("You can not enter current voucher in 'Against JV' column",
|
||||||
raise_exception=1)
|
raise_exception=1)
|
||||||
elif not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
elif not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||||
@ -96,34 +94,34 @@ class DocType(AccountsController):
|
|||||||
# Debit = Credit
|
# Debit = Credit
|
||||||
debit, credit = 0.0, 0.0
|
debit, credit = 0.0, 0.0
|
||||||
debit_list, credit_list = [], []
|
debit_list, credit_list = [], []
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in self.get('entries'):
|
||||||
debit += flt(d.debit, 2)
|
debit += flt(d.debit, 2)
|
||||||
credit += flt(d.credit, 2)
|
credit += flt(d.credit, 2)
|
||||||
if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account)
|
if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account)
|
||||||
if flt(d.credit)>0 and (d.account not in credit_list): credit_list.append(d.account)
|
if flt(d.credit)>0 and (d.account not in credit_list): credit_list.append(d.account)
|
||||||
|
|
||||||
self.doc.total_debit = debit
|
self.total_debit = debit
|
||||||
self.doc.total_credit = credit
|
self.total_credit = credit
|
||||||
|
|
||||||
if abs(self.doc.total_debit-self.doc.total_credit) > 0.001:
|
if abs(self.total_debit-self.total_credit) > 0.001:
|
||||||
msgprint("Debit must be equal to Credit. The difference is %s" %
|
msgprint("Debit must be equal to Credit. The difference is %s" %
|
||||||
(self.doc.total_debit-self.doc.total_credit), raise_exception=1)
|
(self.total_debit-self.total_credit), raise_exception=1)
|
||||||
|
|
||||||
# update against account
|
# update against account
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in self.get('entries'):
|
||||||
if flt(d.debit) > 0: d.against_account = ', '.join(credit_list)
|
if flt(d.debit) > 0: d.against_account = ', '.join(credit_list)
|
||||||
if flt(d.credit) > 0: d.against_account = ', '.join(debit_list)
|
if flt(d.credit) > 0: d.against_account = ', '.join(debit_list)
|
||||||
|
|
||||||
def create_remarks(self):
|
def create_remarks(self):
|
||||||
r = []
|
r = []
|
||||||
if self.doc.cheque_no :
|
if self.cheque_no:
|
||||||
if self.doc.cheque_date:
|
if self.cheque_date:
|
||||||
r.append('Via Reference #%s dated %s' %
|
r.append('Via Reference #%s dated %s' %
|
||||||
(self.doc.cheque_no, formatdate(self.doc.cheque_date)))
|
(self.cheque_no, formatdate(self.cheque_date)))
|
||||||
else :
|
else :
|
||||||
msgprint("Please enter Reference date", raise_exception=1)
|
msgprint("Please enter Reference date", raise_exception=1)
|
||||||
|
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in self.get('entries'):
|
||||||
if d.against_invoice and d.credit:
|
if d.against_invoice and d.credit:
|
||||||
currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency")
|
currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency")
|
||||||
r.append('%s %s against Invoice: %s' %
|
r.append('%s %s against Invoice: %s' %
|
||||||
@ -138,60 +136,60 @@ class DocType(AccountsController):
|
|||||||
(cstr(bill_no[0][2]), fmt_money(flt(d.debit)), bill_no[0][0],
|
(cstr(bill_no[0][2]), fmt_money(flt(d.debit)), bill_no[0][0],
|
||||||
bill_no[0][1] and formatdate(bill_no[0][1].strftime('%Y-%m-%d')) or ''))
|
bill_no[0][1] and formatdate(bill_no[0][1].strftime('%Y-%m-%d')) or ''))
|
||||||
|
|
||||||
if self.doc.user_remark:
|
if self.user_remark:
|
||||||
r.append("User Remark : %s"%self.doc.user_remark)
|
r.append("User Remark : %s"%self.user_remark)
|
||||||
|
|
||||||
if r:
|
if r:
|
||||||
self.doc.remark = ("\n").join(r)
|
self.remark = ("\n").join(r)
|
||||||
else:
|
else:
|
||||||
frappe.msgprint("User Remarks is mandatory", raise_exception=1)
|
frappe.msgprint("User Remarks is mandatory", raise_exception=1)
|
||||||
|
|
||||||
def set_aging_date(self):
|
def set_aging_date(self):
|
||||||
if self.doc.is_opening != 'Yes':
|
if self.is_opening != 'Yes':
|
||||||
self.doc.aging_date = self.doc.posting_date
|
self.aging_date = self.posting_date
|
||||||
else:
|
else:
|
||||||
# check account type whether supplier or customer
|
# check account type whether supplier or customer
|
||||||
exists = False
|
exists = False
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in self.get('entries'):
|
||||||
account_type = frappe.db.get_value("Account", d.account, "account_type")
|
account_type = frappe.db.get_value("Account", d.account, "account_type")
|
||||||
if account_type in ["Supplier", "Customer"]:
|
if account_type in ["Supplier", "Customer"]:
|
||||||
exists = True
|
exists = True
|
||||||
break
|
break
|
||||||
|
|
||||||
# If customer/supplier account, aging date is mandatory
|
# If customer/supplier account, aging date is mandatory
|
||||||
if exists and not self.doc.aging_date:
|
if exists and not self.aging_date:
|
||||||
msgprint("Aging Date is mandatory for opening entry", raise_exception=1)
|
msgprint("Aging Date is mandatory for opening entry", raise_exception=1)
|
||||||
else:
|
else:
|
||||||
self.doc.aging_date = self.doc.posting_date
|
self.aging_date = self.posting_date
|
||||||
|
|
||||||
def set_print_format_fields(self):
|
def set_print_format_fields(self):
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in self.get('entries'):
|
||||||
account_type, master_type = frappe.db.get_value("Account", d.account,
|
account_type, master_type = frappe.db.get_value("Account", d.account,
|
||||||
["account_type", "master_type"])
|
["account_type", "master_type"])
|
||||||
|
|
||||||
if master_type in ['Supplier', 'Customer']:
|
if master_type in ['Supplier', 'Customer']:
|
||||||
if not self.doc.pay_to_recd_from:
|
if not self.pay_to_recd_from:
|
||||||
self.doc.pay_to_recd_from = frappe.db.get_value(master_type,
|
self.pay_to_recd_from = frappe.db.get_value(master_type,
|
||||||
' - '.join(d.account.split(' - ')[:-1]),
|
' - '.join(d.account.split(' - ')[:-1]),
|
||||||
master_type == 'Customer' and 'customer_name' or 'supplier_name')
|
master_type == 'Customer' and 'customer_name' or 'supplier_name')
|
||||||
|
|
||||||
if account_type in ['Bank', 'Cash']:
|
if account_type in ['Bank', 'Cash']:
|
||||||
company_currency = get_company_currency(self.doc.company)
|
company_currency = get_company_currency(self.company)
|
||||||
amt = flt(d.debit) and d.debit or d.credit
|
amt = flt(d.debit) and d.debit or d.credit
|
||||||
self.doc.total_amount = company_currency + ' ' + cstr(amt)
|
self.total_amount = company_currency + ' ' + cstr(amt)
|
||||||
from frappe.utils import money_in_words
|
from frappe.utils import money_in_words
|
||||||
self.doc.total_amount_in_words = money_in_words(amt, company_currency)
|
self.total_amount_in_words = money_in_words(amt, company_currency)
|
||||||
|
|
||||||
def check_credit_days(self):
|
def check_credit_days(self):
|
||||||
date_diff = 0
|
date_diff = 0
|
||||||
if self.doc.cheque_date:
|
if self.cheque_date:
|
||||||
date_diff = (getdate(self.doc.cheque_date)-getdate(self.doc.posting_date)).days
|
date_diff = (getdate(self.cheque_date)-getdate(self.posting_date)).days
|
||||||
|
|
||||||
if date_diff <= 0: return
|
if date_diff <= 0: return
|
||||||
|
|
||||||
# Get List of Customer Account
|
# Get List of Customer Account
|
||||||
acc_list = filter(lambda d: frappe.db.get_value("Account", d.account,
|
acc_list = filter(lambda d: frappe.db.get_value("Account", d.account,
|
||||||
"master_type")=='Customer', getlist(self.doclist,'entries'))
|
"master_type")=='Customer', self.get('entries'))
|
||||||
|
|
||||||
for d in acc_list:
|
for d in acc_list:
|
||||||
credit_days = self.get_credit_days_for(d.account)
|
credit_days = self.get_credit_days_for(d.account)
|
||||||
@ -207,7 +205,7 @@ class DocType(AccountsController):
|
|||||||
if not self.credit_days_for[ac]:
|
if not self.credit_days_for[ac]:
|
||||||
if self.credit_days_global==-1:
|
if self.credit_days_global==-1:
|
||||||
self.credit_days_global = cint(frappe.db.get_value("Company",
|
self.credit_days_global = cint(frappe.db.get_value("Company",
|
||||||
self.doc.company, "credit_days"))
|
self.company, "credit_days"))
|
||||||
|
|
||||||
return self.credit_days_global
|
return self.credit_days_global
|
||||||
else:
|
else:
|
||||||
@ -228,7 +226,7 @@ class DocType(AccountsController):
|
|||||||
return self.is_approving_authority
|
return self.is_approving_authority
|
||||||
|
|
||||||
def check_account_against_entries(self):
|
def check_account_against_entries(self):
|
||||||
for d in self.doclist.get({"parentfield": "entries"}):
|
for d in self.get("entries"):
|
||||||
if d.against_invoice and frappe.db.get_value("Sales Invoice",
|
if d.against_invoice and frappe.db.get_value("Sales Invoice",
|
||||||
d.against_invoice, "debit_to") != d.account:
|
d.against_invoice, "debit_to") != d.account:
|
||||||
frappe.throw(_("Row #") + cstr(d.idx) + ": " +
|
frappe.throw(_("Row #") + cstr(d.idx) + ": " +
|
||||||
@ -246,7 +244,7 @@ class DocType(AccountsController):
|
|||||||
self.check_account_against_entries()
|
self.check_account_against_entries()
|
||||||
|
|
||||||
gl_map = []
|
gl_map = []
|
||||||
for d in self.doclist.get({"parentfield": "entries"}):
|
for d in self.get("entries"):
|
||||||
if d.debit or d.credit:
|
if d.debit or d.credit:
|
||||||
gl_map.append(
|
gl_map.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
@ -258,7 +256,7 @@ class DocType(AccountsController):
|
|||||||
or (d.against_invoice and "Sales Invoice")
|
or (d.against_invoice and "Sales Invoice")
|
||||||
or (d.against_jv and "Journal Voucher")),
|
or (d.against_jv and "Journal Voucher")),
|
||||||
"against_voucher": d.against_voucher or d.against_invoice or d.against_jv,
|
"against_voucher": d.against_voucher or d.against_invoice or d.against_jv,
|
||||||
"remarks": self.doc.remark,
|
"remarks": self.remark,
|
||||||
"cost_center": d.cost_center
|
"cost_center": d.cost_center
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -266,21 +264,21 @@ class DocType(AccountsController):
|
|||||||
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
|
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
|
||||||
|
|
||||||
def check_credit_limit(self):
|
def check_credit_limit(self):
|
||||||
for d in self.doclist.get({"parentfield": "entries"}):
|
for d in self.get("entries"):
|
||||||
master_type, master_name = frappe.db.get_value("Account", d.account,
|
master_type, master_name = frappe.db.get_value("Account", d.account,
|
||||||
["master_type", "master_name"])
|
["master_type", "master_name"])
|
||||||
if master_type == "Customer" and master_name:
|
if master_type == "Customer" and master_name:
|
||||||
super(DocType, self).check_credit_limit(d.account)
|
super(JournalVoucher, self).check_credit_limit(d.account)
|
||||||
|
|
||||||
def get_balance(self):
|
def get_balance(self):
|
||||||
if not getlist(self.doclist,'entries'):
|
if not self.get('entries'):
|
||||||
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
|
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
|
||||||
else:
|
else:
|
||||||
flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0
|
flag, self.total_debit, self.total_credit = 0, 0, 0
|
||||||
diff = flt(self.doc.difference, 2)
|
diff = flt(self.difference, 2)
|
||||||
|
|
||||||
# If any row without amount, set the diff on that row
|
# If any row without amount, set the diff on that row
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in self.get('entries'):
|
||||||
if not d.credit and not d.debit and diff != 0:
|
if not d.credit and not d.debit and diff != 0:
|
||||||
if diff>0:
|
if diff>0:
|
||||||
d.credit = diff
|
d.credit = diff
|
||||||
@ -290,51 +288,51 @@ class DocType(AccountsController):
|
|||||||
|
|
||||||
# Set the diff in a new row
|
# Set the diff in a new row
|
||||||
if flag == 0 and diff != 0:
|
if flag == 0 and diff != 0:
|
||||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
|
jd = self.append('entries', {})
|
||||||
if diff>0:
|
if diff>0:
|
||||||
jd.credit = abs(diff)
|
jd.credit = abs(diff)
|
||||||
elif diff<0:
|
elif diff<0:
|
||||||
jd.debit = abs(diff)
|
jd.debit = abs(diff)
|
||||||
|
|
||||||
# Set the total debit, total credit and difference
|
# Set the total debit, total credit and difference
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in self.get('entries'):
|
||||||
self.doc.total_debit += flt(d.debit, 2)
|
self.total_debit += flt(d.debit, 2)
|
||||||
self.doc.total_credit += flt(d.credit, 2)
|
self.total_credit += flt(d.credit, 2)
|
||||||
|
|
||||||
self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2)
|
self.difference = flt(self.total_debit, 2) - flt(self.total_credit, 2)
|
||||||
|
|
||||||
def get_outstanding_invoices(self):
|
def get_outstanding_invoices(self):
|
||||||
self.doclist = self.doc.clear_table(self.doclist, 'entries')
|
self.set('entries', [])
|
||||||
total = 0
|
total = 0
|
||||||
for d in self.get_values():
|
for d in self.get_values():
|
||||||
total += flt(d[2])
|
total += flt(d[2])
|
||||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
|
jd = self.append('entries', {})
|
||||||
jd.account = cstr(d[1])
|
jd.account = cstr(d[1])
|
||||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
if self.write_off_based_on == 'Accounts Receivable':
|
||||||
jd.credit = flt(d[2])
|
jd.credit = flt(d[2])
|
||||||
jd.against_invoice = cstr(d[0])
|
jd.against_invoice = cstr(d[0])
|
||||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
elif self.write_off_based_on == 'Accounts Payable':
|
||||||
jd.debit = flt(d[2])
|
jd.debit = flt(d[2])
|
||||||
jd.against_voucher = cstr(d[0])
|
jd.against_voucher = cstr(d[0])
|
||||||
jd.save(1)
|
jd.save(1)
|
||||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
|
jd = self.append('entries', {})
|
||||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
if self.write_off_based_on == 'Accounts Receivable':
|
||||||
jd.debit = total
|
jd.debit = total
|
||||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
elif self.write_off_based_on == 'Accounts Payable':
|
||||||
jd.credit = total
|
jd.credit = total
|
||||||
jd.save(1)
|
jd.save(1)
|
||||||
|
|
||||||
def get_values(self):
|
def get_values(self):
|
||||||
cond = (flt(self.doc.write_off_amount) > 0) and \
|
cond = (flt(self.write_off_amount) > 0) and \
|
||||||
' and outstanding_amount <= '+ self.doc.write_off_amount or ''
|
' and outstanding_amount <= '+ self.write_off_amount or ''
|
||||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
if self.write_off_based_on == 'Accounts Receivable':
|
||||||
return frappe.db.sql("""select name, debit_to, outstanding_amount
|
return frappe.db.sql("""select name, debit_to, outstanding_amount
|
||||||
from `tabSales Invoice` where docstatus = 1 and company = %s
|
from `tabSales Invoice` where docstatus = 1 and company = %s
|
||||||
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
and outstanding_amount > 0 %s""" % ('%s', cond), self.company)
|
||||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
elif self.write_off_based_on == 'Accounts Payable':
|
||||||
return frappe.db.sql("""select name, credit_to, outstanding_amount
|
return frappe.db.sql("""select name, credit_to, outstanding_amount
|
||||||
from `tabPurchase Invoice` where docstatus = 1 and company = %s
|
from `tabPurchase Invoice` where docstatus = 1 and company = %s
|
||||||
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
and outstanding_amount > 0 %s""" % ('%s', cond), self.company)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_default_bank_cash_account(company, voucher_type):
|
def get_default_bank_cash_account(company, voucher_type):
|
||||||
@ -350,61 +348,54 @@ def get_default_bank_cash_account(company, voucher_type):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_payment_entry_from_sales_invoice(sales_invoice):
|
def get_payment_entry_from_sales_invoice(sales_invoice):
|
||||||
from erpnext.accounts.utils import get_balance_on
|
from erpnext.accounts.utils import get_balance_on
|
||||||
si = frappe.bean("Sales Invoice", sales_invoice)
|
si = frappe.get_doc("Sales Invoice", sales_invoice)
|
||||||
jv = get_payment_entry(si.doc)
|
jv = get_payment_entry(si)
|
||||||
jv.doc.remark = 'Payment received against Sales Invoice %(name)s. %(remarks)s' % si.doc.fields
|
jv.remark = 'Payment received against Sales Invoice {0}. {1}'.format(si.name, si.remarks)
|
||||||
|
|
||||||
# credit customer
|
# credit customer
|
||||||
jv.doclist[1].account = si.doc.debit_to
|
jv.get("entries")[0].account = si.debit_to
|
||||||
jv.doclist[1].balance = get_balance_on(si.doc.debit_to)
|
jv.get("entries")[0].balance = get_balance_on(si.debit_to)
|
||||||
jv.doclist[1].credit = si.doc.outstanding_amount
|
jv.get("entries")[0].credit = si.outstanding_amount
|
||||||
jv.doclist[1].against_invoice = si.doc.name
|
jv.get("entries")[0].against_invoice = si.name
|
||||||
|
|
||||||
# debit bank
|
# debit bank
|
||||||
jv.doclist[2].debit = si.doc.outstanding_amount
|
jv.get("entries")[1].debit = si.outstanding_amount
|
||||||
|
|
||||||
return [d.fields for d in jv.doclist]
|
return jv.as_dict()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_payment_entry_from_purchase_invoice(purchase_invoice):
|
def get_payment_entry_from_purchase_invoice(purchase_invoice):
|
||||||
from erpnext.accounts.utils import get_balance_on
|
from erpnext.accounts.utils import get_balance_on
|
||||||
pi = frappe.bean("Purchase Invoice", purchase_invoice)
|
pi = frappe.get_doc("Purchase Invoice", purchase_invoice)
|
||||||
jv = get_payment_entry(pi.doc)
|
jv = get_payment_entry(pi)
|
||||||
jv.doc.remark = 'Payment against Purchase Invoice %(name)s. %(remarks)s' % pi.doc.fields
|
jv.remark = 'Payment against Purchase Invoice {0}. {1}'.format(pi.name, pi.remarks)
|
||||||
|
|
||||||
# credit supplier
|
# credit supplier
|
||||||
jv.doclist[1].account = pi.doc.credit_to
|
jv.get("entries")[0].account = pi.credit_to
|
||||||
jv.doclist[1].balance = get_balance_on(pi.doc.credit_to)
|
jv.get("entries")[0].balance = get_balance_on(pi.credit_to)
|
||||||
jv.doclist[1].debit = pi.doc.outstanding_amount
|
jv.get("entries")[0].debit = pi.outstanding_amount
|
||||||
jv.doclist[1].against_voucher = pi.doc.name
|
jv.get("entries")[0].against_voucher = pi.name
|
||||||
|
|
||||||
# credit bank
|
# credit bank
|
||||||
jv.doclist[2].credit = pi.doc.outstanding_amount
|
jv.get("entries")[1].credit = pi.outstanding_amount
|
||||||
|
|
||||||
return [d.fields for d in jv.doclist]
|
return jv.as_dict()
|
||||||
|
|
||||||
def get_payment_entry(doc):
|
def get_payment_entry(doc):
|
||||||
bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher")
|
bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher")
|
||||||
|
|
||||||
jv = frappe.new_bean('Journal Voucher')
|
jv = frappe.new_doc('Journal Voucher')
|
||||||
jv.doc.voucher_type = 'Bank Voucher'
|
jv.voucher_type = 'Bank Voucher'
|
||||||
|
|
||||||
jv.doc.company = doc.company
|
jv.company = doc.company
|
||||||
jv.doc.fiscal_year = doc.fiscal_year
|
jv.fiscal_year = doc.fiscal_year
|
||||||
|
|
||||||
jv.doclist.append({
|
d1 = jv.append("entries")
|
||||||
"doctype": "Journal Voucher Detail",
|
d2 = jv.append("entries")
|
||||||
"parentfield": "entries"
|
|
||||||
})
|
|
||||||
|
|
||||||
jv.doclist.append({
|
|
||||||
"doctype": "Journal Voucher Detail",
|
|
||||||
"parentfield": "entries"
|
|
||||||
})
|
|
||||||
|
|
||||||
if bank_account:
|
if bank_account:
|
||||||
jv.doclist[2].account = bank_account["account"]
|
d2.account = bank_account["account"]
|
||||||
jv.doclist[2].balance = bank_account["balance"]
|
d2.balance = bank_account["balance"]
|
||||||
|
|
||||||
return jv
|
return jv
|
||||||
|
|
||||||
|
@ -1,503 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-03-25 10:53:52",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-01-20 17:48:51",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_import": 1,
|
|
||||||
"autoname": "naming_series:",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"icon": "icon-file-text",
|
|
||||||
"is_submittable": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"read_only_onload": 1,
|
|
||||||
"search_fields": "voucher_type,posting_date, due_date, cheque_no"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Journal Voucher",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Journal Voucher",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Journal Voucher"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_type_and_date",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Voucher Type and Date",
|
|
||||||
"options": "icon-flag"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break0",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"read_only": 0,
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "naming_series",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Series",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "naming_series",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "JV",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_type",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Voucher Type",
|
|
||||||
"oldfieldname": "voucher_type",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher\nOpening Entry",
|
|
||||||
"print_hide": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break1",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"read_only": 0,
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "posting_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_filter": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Posting Date",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "posting_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "2_add_edit_gl_entries",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Journal Entries",
|
|
||||||
"oldfieldtype": "Section Break",
|
|
||||||
"options": "icon-table",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_on_submit": 1,
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "entries",
|
|
||||||
"fieldtype": "Table",
|
|
||||||
"label": "Entries",
|
|
||||||
"oldfieldname": "entries",
|
|
||||||
"oldfieldtype": "Table",
|
|
||||||
"options": "Journal Voucher Detail",
|
|
||||||
"print_hide": 0,
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "section_break99",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_debit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"in_filter": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Total Debit",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "total_debit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_credit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Total Credit",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "total_credit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break99",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "difference",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Difference",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "difference",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "get_balance",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"label": "Make Difference Entry",
|
|
||||||
"oldfieldtype": "Button",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "reference",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Reference",
|
|
||||||
"options": "icon-pushpin",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "eg. Cheque Number",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cheque_no",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_filter": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Reference Number",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "cheque_no",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"read_only": 0,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cheque_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Reference Date",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "cheque_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "clearance_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Clearance Date",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "clearance_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"print_hide": 0,
|
|
||||||
"read_only": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break98",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "user_remark",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "User Remark",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "user_remark",
|
|
||||||
"oldfieldtype": "Small Text",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "User Remark will be added to Auto Remark",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "remark",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"in_list_view": 0,
|
|
||||||
"label": "Remark",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "remark",
|
|
||||||
"oldfieldtype": "Small Text",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "bill_no",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_list_view": 0,
|
|
||||||
"label": "Bill No",
|
|
||||||
"oldfieldname": "bill_no",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "bill_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Bill Date",
|
|
||||||
"oldfieldname": "bill_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "due_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Due Date",
|
|
||||||
"oldfieldname": "due_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"print_hide": 0,
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "addtional_info",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "More Info",
|
|
||||||
"oldfieldtype": "Section Break",
|
|
||||||
"options": "icon-file-text",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break2",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"read_only": 0,
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "No",
|
|
||||||
"description": "Considered as Opening Balance",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "is_opening",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Is Opening",
|
|
||||||
"oldfieldname": "is_opening",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "No\nYes",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Actual Posting Date",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "aging_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Aging Date",
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "aging_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "Accounts Receivable",
|
|
||||||
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "write_off_based_on",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Write Off Based On",
|
|
||||||
"options": "Accounts Receivable\nAccounts Payable",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"report_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "write_off_amount",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Write Off Amount <=",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"report_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.voucher_type == 'Write Off Voucher'",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "get_outstanding_invoices",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"label": "Get Outstanding Invoices",
|
|
||||||
"options": "get_outstanding_invoices",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "letter_head",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Letter Head",
|
|
||||||
"options": "Letter Head"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break3",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"read_only": 0,
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "pay_to_recd_from",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "Pay To / Recd From",
|
|
||||||
"no_copy": 1,
|
|
||||||
"print_hide": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"report_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_amount",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 1,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"label": "Total Amount",
|
|
||||||
"no_copy": 1,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1,
|
|
||||||
"report_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_amount_in_words",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Total Amount in Words",
|
|
||||||
"no_copy": 1,
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1,
|
|
||||||
"report_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "fiscal_year",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Fiscal Year",
|
|
||||||
"oldfieldname": "fiscal_year",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "link:Fiscal Year",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Company",
|
|
||||||
"oldfieldname": "company",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Company",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_on_submit": 1,
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "select_print_heading",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Print Heading",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "select_print_heading",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Print Heading",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"report_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "amended_from",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"ignore_restrictions": 1,
|
|
||||||
"label": "Amended From",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "amended_from",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Journal Voucher",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 1,
|
|
||||||
"cancel": 1,
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts User",
|
|
||||||
"submit": 1,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 1,
|
|
||||||
"cancel": 1,
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"submit": 1,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Auditor",
|
|
||||||
"submit": 0,
|
|
||||||
"write": 0
|
|
||||||
}
|
|
||||||
]
|
|
@ -9,36 +9,40 @@ import frappe
|
|||||||
class TestJournalVoucher(unittest.TestCase):
|
class TestJournalVoucher(unittest.TestCase):
|
||||||
def test_journal_voucher_with_against_jv(self):
|
def test_journal_voucher_with_against_jv(self):
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
jv_invoice = frappe.bean(copy=test_records[2])
|
jv_invoice = frappe.copy_doc(test_records[2])
|
||||||
jv_invoice.insert()
|
jv_invoice.insert()
|
||||||
jv_invoice.submit()
|
jv_invoice.submit()
|
||||||
|
|
||||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||||
where against_jv=%s""", jv_invoice.doc.name))
|
where account = %s and docstatus = 1 and parent = %s""",
|
||||||
|
("_Test Customer - _TC", jv_invoice.name)))
|
||||||
|
|
||||||
jv_payment = frappe.bean(copy=test_records[0])
|
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||||
jv_payment.doclist[1].against_jv = jv_invoice.doc.name
|
where against_jv=%s""", jv_invoice.name))
|
||||||
|
|
||||||
|
jv_payment = frappe.copy_doc(test_records[0])
|
||||||
|
jv_payment.get("entries")[0].against_jv = jv_invoice.name
|
||||||
jv_payment.insert()
|
jv_payment.insert()
|
||||||
jv_payment.submit()
|
jv_payment.submit()
|
||||||
|
|
||||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||||
where against_jv=%s""", jv_invoice.doc.name))
|
where against_jv=%s""", jv_invoice.name))
|
||||||
|
|
||||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||||
where against_jv=%s and credit=400""", jv_invoice.doc.name))
|
where against_jv=%s and credit=400""", jv_invoice.name))
|
||||||
|
|
||||||
# cancel jv_invoice
|
# cancel jv_invoice
|
||||||
jv_invoice.cancel()
|
jv_invoice.cancel()
|
||||||
|
|
||||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||||
where against_jv=%s""", jv_invoice.doc.name))
|
where against_jv=%s""", jv_invoice.name))
|
||||||
|
|
||||||
def test_jv_against_stock_account(self):
|
def test_jv_against_stock_account(self):
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.copy_doc(test_records[0])
|
||||||
jv.doclist[1].account = "_Test Warehouse - _TC"
|
jv.get("entries")[0].account = "_Test Warehouse - _TC"
|
||||||
jv.insert()
|
jv.insert()
|
||||||
|
|
||||||
from erpnext.accounts.general_ledger import StockAccountInvalidTransaction
|
from erpnext.accounts.general_ledger import StockAccountInvalidTransaction
|
||||||
@ -50,26 +54,26 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.copy_doc(test_records[0])
|
||||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv.get("entries")[1].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[2].debit = 20000.0
|
jv.get("entries")[1].debit = 20000.0
|
||||||
jv.doclist[1].credit = 20000.0
|
jv.get("entries")[0].credit = 20000.0
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||||
{"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name}))
|
{"voucher_type": "Journal Voucher", "voucher_no": jv.name}))
|
||||||
|
|
||||||
def test_monthly_budget_crossed_stop(self):
|
def test_monthly_budget_crossed_stop(self):
|
||||||
from erpnext.accounts.utils import BudgetError
|
from erpnext.accounts.utils import BudgetError
|
||||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.copy_doc(test_records[0])
|
||||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv.get("entries")[1].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[2].debit = 20000.0
|
jv.get("entries")[1].debit = 20000.0
|
||||||
jv.doclist[1].credit = 20000.0
|
jv.get("entries")[0].credit = 20000.0
|
||||||
jv.insert()
|
jv.insert()
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
self.assertRaises(BudgetError, jv.submit)
|
||||||
@ -83,12 +87,12 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop")
|
frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop")
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.copy_doc(test_records[0])
|
||||||
jv.doc.posting_date = "2013-08-12"
|
jv.posting_date = "2013-08-12"
|
||||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv.get("entries")[1].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[2].debit = 150000.0
|
jv.get("entries")[1].debit = 150000.0
|
||||||
jv.doclist[1].credit = 150000.0
|
jv.get("entries")[0].credit = 150000.0
|
||||||
jv.insert()
|
jv.insert()
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
self.assertRaises(BudgetError, jv.submit)
|
||||||
@ -100,25 +104,25 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
|
|
||||||
jv = frappe.bean(copy=test_records[0])
|
jv = frappe.copy_doc(test_records[0])
|
||||||
jv.doclist[1].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.get("entries")[0].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[1].cost_center = "_Test Cost Center - _TC"
|
jv.get("entries")[0].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[1].credit = 30000.0
|
jv.get("entries")[0].credit = 30000.0
|
||||||
jv.doclist[2].debit = 30000.0
|
jv.get("entries")[1].debit = 30000.0
|
||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||||
{"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name}))
|
{"voucher_type": "Journal Voucher", "voucher_no": jv.name}))
|
||||||
|
|
||||||
jv1 = frappe.bean(copy=test_records[0])
|
jv1 = frappe.copy_doc(test_records[0])
|
||||||
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv1.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv1.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv1.get("entries")[1].cost_center = "_Test Cost Center - _TC"
|
||||||
jv1.doclist[2].debit = 40000.0
|
jv1.get("entries")[1].debit = 40000.0
|
||||||
jv1.doclist[1].credit = 40000.0
|
jv1.get("entries")[0].credit = 40000.0
|
||||||
jv1.submit()
|
jv1.submit()
|
||||||
|
|
||||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||||
{"voucher_type": "Journal Voucher", "voucher_no": jv1.doc.name}))
|
{"voucher_type": "Journal Voucher", "voucher_no": jv1.name}))
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.cancel)
|
self.assertRaises(BudgetError, jv.cancel)
|
||||||
|
|
||||||
@ -128,81 +132,4 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||||
|
|
||||||
|
|
||||||
test_records = [
|
test_records = frappe.get_test_records('Journal Voucher')
|
||||||
[{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"doctype": "Journal Voucher",
|
|
||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
|
||||||
"naming_series": "_T-Journal Voucher-",
|
|
||||||
"posting_date": "2013-02-14",
|
|
||||||
"user_remark": "test",
|
|
||||||
"voucher_type": "Bank Voucher",
|
|
||||||
"cheque_no": "33",
|
|
||||||
"cheque_date": "2013-02-14"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "_Test Customer - _TC",
|
|
||||||
"doctype": "Journal Voucher Detail",
|
|
||||||
"credit": 400.0,
|
|
||||||
"debit": 0.0,
|
|
||||||
"parentfield": "entries"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "_Test Account Bank Account - _TC",
|
|
||||||
"doctype": "Journal Voucher Detail",
|
|
||||||
"debit": 400.0,
|
|
||||||
"credit": 0.0,
|
|
||||||
"parentfield": "entries"
|
|
||||||
}],
|
|
||||||
[{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"doctype": "Journal Voucher",
|
|
||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
|
||||||
"naming_series": "_T-Journal Voucher-",
|
|
||||||
"posting_date": "2013-02-14",
|
|
||||||
"user_remark": "test",
|
|
||||||
"voucher_type": "Bank Voucher",
|
|
||||||
"cheque_no": "33",
|
|
||||||
"cheque_date": "2013-02-14"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "_Test Supplier - _TC",
|
|
||||||
"doctype": "Journal Voucher Detail",
|
|
||||||
"credit": 0.0,
|
|
||||||
"debit": 400.0,
|
|
||||||
"parentfield": "entries"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "_Test Account Bank Account - _TC",
|
|
||||||
"doctype": "Journal Voucher Detail",
|
|
||||||
"debit": 0.0,
|
|
||||||
"credit": 400.0,
|
|
||||||
"parentfield": "entries"
|
|
||||||
}],
|
|
||||||
[{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"doctype": "Journal Voucher",
|
|
||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
|
||||||
"naming_series": "_T-Journal Voucher-",
|
|
||||||
"posting_date": "2013-02-14",
|
|
||||||
"user_remark": "test",
|
|
||||||
"voucher_type": "Bank Voucher",
|
|
||||||
"cheque_no": "33",
|
|
||||||
"cheque_date": "2013-02-14"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "_Test Customer - _TC",
|
|
||||||
"doctype": "Journal Voucher Detail",
|
|
||||||
"credit": 0.0,
|
|
||||||
"debit": 400.0,
|
|
||||||
"parentfield": "entries"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "Sales - _TC",
|
|
||||||
"doctype": "Journal Voucher Detail",
|
|
||||||
"credit": 400.0,
|
|
||||||
"debit": 0.0,
|
|
||||||
"parentfield": "entries",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
}],
|
|
||||||
]
|
|
||||||
|
84
erpnext/accounts/doctype/journal_voucher/test_records.json
Normal file
84
erpnext/accounts/doctype/journal_voucher/test_records.json
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"cheque_date": "2013-02-14",
|
||||||
|
"cheque_no": "33",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Journal Voucher",
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"account": "_Test Customer - _TC",
|
||||||
|
"credit": 400.0,
|
||||||
|
"debit": 0.0,
|
||||||
|
"doctype": "Journal Voucher Detail",
|
||||||
|
"parentfield": "entries"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account": "_Test Account Bank Account - _TC",
|
||||||
|
"credit": 0.0,
|
||||||
|
"debit": 400.0,
|
||||||
|
"doctype": "Journal Voucher Detail",
|
||||||
|
"parentfield": "entries"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
|
"naming_series": "_T-Journal Voucher-",
|
||||||
|
"posting_date": "2013-02-14",
|
||||||
|
"user_remark": "test",
|
||||||
|
"voucher_type": "Bank Voucher"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cheque_date": "2013-02-14",
|
||||||
|
"cheque_no": "33",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Journal Voucher",
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"account": "_Test Supplier - _TC",
|
||||||
|
"credit": 0.0,
|
||||||
|
"debit": 400.0,
|
||||||
|
"doctype": "Journal Voucher Detail",
|
||||||
|
"parentfield": "entries"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account": "_Test Account Bank Account - _TC",
|
||||||
|
"credit": 400.0,
|
||||||
|
"debit": 0.0,
|
||||||
|
"doctype": "Journal Voucher Detail",
|
||||||
|
"parentfield": "entries"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
|
"naming_series": "_T-Journal Voucher-",
|
||||||
|
"posting_date": "2013-02-14",
|
||||||
|
"user_remark": "test",
|
||||||
|
"voucher_type": "Bank Voucher"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cheque_date": "2013-02-14",
|
||||||
|
"cheque_no": "33",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"doctype": "Journal Voucher",
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"account": "_Test Customer - _TC",
|
||||||
|
"credit": 0.0,
|
||||||
|
"debit": 400.0,
|
||||||
|
"doctype": "Journal Voucher Detail",
|
||||||
|
"parentfield": "entries"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account": "Sales - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"credit": 400.0,
|
||||||
|
"debit": 0.0,
|
||||||
|
"doctype": "Journal Voucher Detail",
|
||||||
|
"parentfield": "entries"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
|
"naming_series": "_T-Journal Voucher-",
|
||||||
|
"posting_date": "2013-02-14",
|
||||||
|
"user_remark": "test",
|
||||||
|
"voucher_type": "Bank Voucher"
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,166 @@
|
|||||||
|
{
|
||||||
|
"autoname": "JVD.######",
|
||||||
|
"creation": "2013-02-22 01:27:39.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Account",
|
||||||
|
"oldfieldname": "account",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "250px",
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 1,
|
||||||
|
"width": "250px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": ":Company",
|
||||||
|
"description": "If Income or Expense",
|
||||||
|
"fieldname": "cost_center",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Cost Center",
|
||||||
|
"oldfieldname": "cost_center",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Cost Center",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "180px",
|
||||||
|
"search_index": 0,
|
||||||
|
"width": "180px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "col_break1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "balance",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Account Balance",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "balance",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "sec_break1",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "debit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Debit",
|
||||||
|
"oldfieldname": "debit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "col_break2",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "credit",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Credit",
|
||||||
|
"oldfieldname": "credit",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reference",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Reference",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_invoice",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Against Sales Invoice",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "against_invoice",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Sales Invoice",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_voucher",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Against Purchase Invoice",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "against_voucher",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Purchase Invoice",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "col_break3",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_jv",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_filter": 1,
|
||||||
|
"label": "Against Journal Voucher",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "against_jv",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Journal Voucher",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 0,
|
||||||
|
"search_index": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "is_advance",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Is Advance",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "is_advance",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "No\nYes",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_account",
|
||||||
|
"fieldtype": "Text",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Against Account",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "against_account",
|
||||||
|
"oldfieldtype": "Text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"modified": "2014-02-03 12:44:31.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Journal Voucher Detail",
|
||||||
|
"owner": "Administrator"
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
from frappe.model.document import Document
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
class JournalVoucherDetail(Document):
|
||||||
|
pass
|
@ -1,179 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-02-22 01:27:39",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-02-03 12:44:31",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "JVD.######",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"istable": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Journal Voucher Detail",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Journal Voucher Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Account",
|
|
||||||
"oldfieldname": "account",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Account",
|
|
||||||
"print_width": "250px",
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1,
|
|
||||||
"width": "250px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": ":Company",
|
|
||||||
"description": "If Income or Expense",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cost_center",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Cost Center",
|
|
||||||
"oldfieldname": "cost_center",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Cost Center",
|
|
||||||
"print_width": "180px",
|
|
||||||
"search_index": 0,
|
|
||||||
"width": "180px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "col_break1",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "balance",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Account Balance",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "balance",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "sec_break1",
|
|
||||||
"fieldtype": "Section Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "debit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Debit",
|
|
||||||
"oldfieldname": "debit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "col_break2",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "credit",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Credit",
|
|
||||||
"oldfieldname": "credit",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "reference",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Reference"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against_invoice",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Against Sales Invoice",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "against_invoice",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Sales Invoice",
|
|
||||||
"print_hide": 0,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against_voucher",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Against Purchase Invoice",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "against_voucher",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Purchase Invoice",
|
|
||||||
"print_hide": 0,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "col_break3",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against_jv",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_filter": 1,
|
|
||||||
"label": "Against Journal Voucher",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "against_jv",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Journal Voucher",
|
|
||||||
"print_hide": 0,
|
|
||||||
"search_index": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "is_advance",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Is Advance",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "is_advance",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "No\nYes",
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against_account",
|
|
||||||
"fieldtype": "Text",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Against Account",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "against_account",
|
|
||||||
"oldfieldtype": "Text",
|
|
||||||
"print_hide": 1
|
|
||||||
}
|
|
||||||
]
|
|
@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"allow_import": 1,
|
||||||
|
"allow_rename": 1,
|
||||||
|
"autoname": "field:mode_of_payment",
|
||||||
|
"creation": "2012-12-04 17:49:20.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "Master",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "mode_of_payment",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Mode of Payment",
|
||||||
|
"oldfieldname": "mode_of_payment",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Company",
|
||||||
|
"options": "Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.",
|
||||||
|
"fieldname": "default_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Default Account",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-credit-card",
|
||||||
|
"idx": 1,
|
||||||
|
"modified": "2013-12-20 19:24:14.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Mode of Payment",
|
||||||
|
"owner": "harshada@webnotestech.com",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
from frappe.model.document import Document
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
class ModeOfPayment(Document):
|
||||||
|
pass
|
@ -1,75 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2012-12-04 17:49:20",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:24:14",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "harshada@webnotestech.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_import": 1,
|
|
||||||
"allow_rename": 1,
|
|
||||||
"autoname": "field:mode_of_payment",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "Master",
|
|
||||||
"icon": "icon-credit-card",
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Mode of Payment",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Mode of Payment",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Mode of Payment"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "mode_of_payment",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Mode of Payment",
|
|
||||||
"oldfieldname": "mode_of_payment",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Company",
|
|
||||||
"options": "Company"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "default_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Default Account",
|
|
||||||
"options": "Account"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm"
|
|
||||||
}
|
|
||||||
]
|
|
@ -0,0 +1,186 @@
|
|||||||
|
{
|
||||||
|
"creation": "2013-01-30 12:49:46.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "Other",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Account",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "account_type",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Account Type",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Company",
|
||||||
|
"options": "Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Voucher Type",
|
||||||
|
"options": "Sales Invoice\nPurchase Invoice\nJournal Voucher",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_no",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Voucher No",
|
||||||
|
"options": "[Select]",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "pull_payment_entries",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Pull Payment Entries",
|
||||||
|
"options": "get_payment_entries",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "50%",
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Total Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "pending_amt_to_reconcile",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Outstanding Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "payment_entries",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Payment Entries",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Update allocated amount in the above table and then click \"Allocate\" button",
|
||||||
|
"fieldname": "ir_payment_details",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Payment Entries",
|
||||||
|
"options": "Payment to Invoice Matching Tool Detail",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reconcile",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Allocate",
|
||||||
|
"options": "reconcile",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break0",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"options": "Simple",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break2",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"label": "Filter By Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "50%",
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "from_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "From Date",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "to_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "To Date",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "help_html",
|
||||||
|
"fieldtype": "HTML",
|
||||||
|
"label": "Help HTML",
|
||||||
|
"options": "Click \"Pull Payment Entries\" to refresh the table with filters.",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break3",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"label": "Filter By Amount",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "50%",
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "amt_greater_than",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Amount >=",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "amt_less_than",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Amount <=",
|
||||||
|
"permlevel": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hide_toolbar": 1,
|
||||||
|
"icon": "icon-magic",
|
||||||
|
"idx": 1,
|
||||||
|
"issingle": 1,
|
||||||
|
"modified": "2013-12-20 19:23:24.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Payment to Invoice Matching Tool",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 0,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 0,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -5,26 +5,23 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from frappe.model.doc import addchild
|
|
||||||
from frappe.model.bean import getlist
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
class DocType:
|
from frappe.model.document import Document
|
||||||
def __init__(self, doc, doclist):
|
|
||||||
self.doc = doc
|
|
||||||
self.doclist = doclist
|
|
||||||
|
|
||||||
|
class PaymenttoInvoiceMatchingTool(Document):
|
||||||
def get_voucher_details(self):
|
def get_voucher_details(self):
|
||||||
total_amount = frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
total_amount = frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
where voucher_type = %s and voucher_no = %s
|
where voucher_type = %s and voucher_no = %s
|
||||||
and account = %s""", (self.doc.voucher_type, self.doc.voucher_no, self.doc.account))
|
and account = %s""", (self.voucher_type, self.voucher_no, self.account))
|
||||||
|
|
||||||
total_amount = total_amount and flt(total_amount[0][0]) or 0
|
total_amount = total_amount and flt(total_amount[0][0]) or 0
|
||||||
reconciled_payment = frappe.db.sql("""
|
reconciled_payment = frappe.db.sql("""
|
||||||
select abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))) from `tabGL Entry` where
|
select abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))) from `tabGL Entry` where
|
||||||
against_voucher = %s and voucher_no != %s
|
against_voucher = %s and voucher_no != %s
|
||||||
and account = %s""", (self.doc.voucher_no, self.doc.voucher_no, self.doc.account))
|
and account = %s""", (self.voucher_no, self.voucher_no, self.account))
|
||||||
|
|
||||||
reconciled_payment = reconciled_payment and flt(reconciled_payment[0][0]) or 0
|
reconciled_payment = reconciled_payment and flt(reconciled_payment[0][0]) or 0
|
||||||
ret = {
|
ret = {
|
||||||
@ -40,22 +37,22 @@ class DocType:
|
|||||||
Payment entry will be decided based on account type (Dr/Cr)
|
Payment entry will be decided based on account type (Dr/Cr)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.doclist = self.doc.clear_table(self.doclist, 'ir_payment_details')
|
self.set('ir_payment_details', [])
|
||||||
gle = self.get_gl_entries()
|
gle = self.get_gl_entries()
|
||||||
self.create_payment_table(gle)
|
self.create_payment_table(gle)
|
||||||
|
|
||||||
def get_gl_entries(self):
|
def get_gl_entries(self):
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
|
|
||||||
cond = self.doc.from_date and " and t1.posting_date >= '" + self.doc.from_date + "'" or ""
|
cond = self.from_date and " and t1.posting_date >= '" + self.from_date + "'" or ""
|
||||||
cond += self.doc.to_date and " and t1.posting_date <= '" + self.doc.to_date + "'"or ""
|
cond += self.to_date and " and t1.posting_date <= '" + self.to_date + "'"or ""
|
||||||
|
|
||||||
if self.doc.amt_greater_than:
|
if self.amt_greater_than:
|
||||||
cond += ' and abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) >= ' + \
|
cond += ' and abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) >= ' + \
|
||||||
self.doc.amt_greater_than
|
self.amt_greater_than
|
||||||
if self.doc.amt_less_than:
|
if self.amt_less_than:
|
||||||
cond += ' and abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) >= ' + \
|
cond += ' and abs(ifnull(t2.debit, 0) - ifnull(t2.credit, 0)) >= ' + \
|
||||||
self.doc.amt_less_than
|
self.amt_less_than
|
||||||
|
|
||||||
gle = frappe.db.sql("""
|
gle = frappe.db.sql("""
|
||||||
select t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt,
|
select t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt,
|
||||||
@ -65,14 +62,13 @@ class DocType:
|
|||||||
where t1.name = t2.parent and t1.docstatus = 1 and t2.account = %s
|
where t1.name = t2.parent and t1.docstatus = 1 and t2.account = %s
|
||||||
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')=''
|
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')=''
|
||||||
and ifnull(t2.against_jv, '')='' and t1.name != %s %s group by t1.name, t2.name """ %
|
and ifnull(t2.against_jv, '')='' and t1.name != %s %s group by t1.name, t2.name """ %
|
||||||
('%s', '%s', cond), (self.doc.account, self.doc.voucher_no), as_dict=1)
|
('%s', '%s', cond), (self.account, self.voucher_no), as_dict=1)
|
||||||
|
|
||||||
return gle
|
return gle
|
||||||
|
|
||||||
def create_payment_table(self, gle):
|
def create_payment_table(self, gle):
|
||||||
for d in gle:
|
for d in gle:
|
||||||
ch = addchild(self.doc, 'ir_payment_details',
|
ch = self.append('ir_payment_details', {})
|
||||||
'Payment to Invoice Matching Tool Detail', self.doclist)
|
|
||||||
ch.voucher_no = d.get('voucher_no')
|
ch.voucher_no = d.get('voucher_no')
|
||||||
ch.posting_date = d.get('posting_date')
|
ch.posting_date = d.get('posting_date')
|
||||||
ch.amt_due = flt(d.get('amt_due'))
|
ch.amt_due = flt(d.get('amt_due'))
|
||||||
@ -82,7 +78,7 @@ class DocType:
|
|||||||
ch.voucher_detail_no = d.get('voucher_detail_no')
|
ch.voucher_detail_no = d.get('voucher_detail_no')
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
if not self.doc.account:
|
if not self.account:
|
||||||
msgprint("Please select Account first", raise_exception=1)
|
msgprint("Please select Account first", raise_exception=1)
|
||||||
|
|
||||||
def reconcile(self):
|
def reconcile(self):
|
||||||
@ -92,21 +88,21 @@ class DocType:
|
|||||||
2. split into multiple rows if partially adjusted, assign against voucher
|
2. split into multiple rows if partially adjusted, assign against voucher
|
||||||
3. submit payment voucher
|
3. submit payment voucher
|
||||||
"""
|
"""
|
||||||
if not self.doc.voucher_no or not frappe.db.sql("""select name from `tab%s`
|
if not self.voucher_no or not frappe.db.sql("""select name from `tab%s`
|
||||||
where name = %s""" % (self.doc.voucher_type, '%s'), self.doc.voucher_no):
|
where name = %s""" % (self.voucher_type, '%s'), self.voucher_no):
|
||||||
frappe.throw(_("Please select valid Voucher No to proceed"))
|
frappe.throw(_("Please select valid Voucher No to proceed"))
|
||||||
|
|
||||||
lst = []
|
lst = []
|
||||||
for d in getlist(self.doclist, 'ir_payment_details'):
|
for d in self.get('ir_payment_details'):
|
||||||
if flt(d.amt_to_be_reconciled) > 0:
|
if flt(d.amt_to_be_reconciled) > 0:
|
||||||
args = {
|
args = {
|
||||||
'voucher_no' : d.voucher_no,
|
'voucher_no' : d.voucher_no,
|
||||||
'voucher_detail_no' : d.voucher_detail_no,
|
'voucher_detail_no' : d.voucher_detail_no,
|
||||||
'against_voucher_type' : self.doc.voucher_type,
|
'against_voucher_type' : self.voucher_type,
|
||||||
'against_voucher' : self.doc.voucher_no,
|
'against_voucher' : self.voucher_no,
|
||||||
'account' : self.doc.account,
|
'account' : self.account,
|
||||||
'is_advance' : 'No',
|
'is_advance' : 'No',
|
||||||
# 'dr_or_cr' : self.doc.account_type=='debit' and 'credit' or 'debit',
|
# 'dr_or_cr' : self.account_type=='debit' and 'credit' or 'debit',
|
||||||
'unadjusted_amt' : flt(d.amt_due),
|
'unadjusted_amt' : flt(d.amt_due),
|
||||||
'allocated_amt' : flt(d.amt_to_be_reconciled)
|
'allocated_amt' : flt(d.amt_to_be_reconciled)
|
||||||
}
|
}
|
||||||
|
@ -1,198 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-01-30 12:49:46",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:23:24",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "Other",
|
|
||||||
"hide_toolbar": 1,
|
|
||||||
"icon": "icon-magic",
|
|
||||||
"issingle": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Payment to Invoice Matching Tool",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Payment to Invoice Matching Tool",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 0,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Payment to Invoice Matching Tool"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Account",
|
|
||||||
"options": "Account",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "account_type",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Account Type",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Company",
|
|
||||||
"options": "Company",
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_type",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Voucher Type",
|
|
||||||
"options": "Sales Invoice\nPurchase Invoice\nJournal Voucher",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_no",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Voucher No",
|
|
||||||
"options": "[Select]",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "pull_payment_entries",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"label": "Pull Payment Entries",
|
|
||||||
"options": "get_payment_entries"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break1",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"print_width": "50%",
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_amount",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Total Amount",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "pending_amt_to_reconcile",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"label": "Outstanding Amount",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "payment_entries",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Payment Entries"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Update allocated amount in the above table and then click \"Allocate\" button",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "ir_payment_details",
|
|
||||||
"fieldtype": "Table",
|
|
||||||
"label": "Payment Entries",
|
|
||||||
"options": "Payment to Invoice Matching Tool Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "reconcile",
|
|
||||||
"fieldtype": "Button",
|
|
||||||
"label": "Allocate",
|
|
||||||
"options": "reconcile"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "section_break0",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"options": "Simple"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break2",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"label": "Filter By Date",
|
|
||||||
"print_width": "50%",
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "from_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "From Date"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "to_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "To Date"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "help_html",
|
|
||||||
"fieldtype": "HTML",
|
|
||||||
"label": "Help HTML",
|
|
||||||
"options": "Click \"Pull Payment Entries\" to refresh the table with filters."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break3",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"label": "Filter By Amount",
|
|
||||||
"print_width": "50%",
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "amt_greater_than",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Amount >="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "amt_less_than",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"label": "Amount <="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts User"
|
|
||||||
}
|
|
||||||
]
|
|
@ -5,4 +5,4 @@ from __future__ import unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
test_records = []
|
test_records = frappe.get_test_records('Payment To Invoice Matching Tool')
|
@ -0,0 +1 @@
|
|||||||
|
[]
|
@ -0,0 +1,88 @@
|
|||||||
|
{
|
||||||
|
"creation": "2013-02-22 01:27:39.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_no",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Voucher No",
|
||||||
|
"options": "Journal Voucher",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "140px",
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 0,
|
||||||
|
"width": "140px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "amt_due",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Unmatched Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "amt_to_be_reconciled",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Allocated Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "posting_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Posting Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "total_amt",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Total Amount",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "against_account",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Against Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "remarks",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Remarks",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_width": "200px",
|
||||||
|
"read_only": 1,
|
||||||
|
"width": "200px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "voucher_detail_no",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Voucher Detail No",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1,
|
||||||
|
"reqd": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"modified": "2013-12-20 19:23:24.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Payment to Invoice Matching Tool Detail",
|
||||||
|
"owner": "Administrator"
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
from frappe.model.document import Document
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
class PaymentToInvoiceMatchingToolDetail(Document):
|
||||||
|
pass
|
@ -1,101 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-02-22 01:27:39",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-12-20 19:23:24",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"istable": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Payment to Invoice Matching Tool Detail",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Payment to Invoice Matching Tool Detail"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_no",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Voucher No",
|
|
||||||
"options": "Journal Voucher",
|
|
||||||
"print_width": "140px",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 0,
|
|
||||||
"width": "140px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "amt_due",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Unmatched Amount",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "amt_to_be_reconciled",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Allocated Amount",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "posting_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Posting Date",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "total_amt",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Total Amount",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "against_account",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Against Account",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "remarks",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"label": "Remarks",
|
|
||||||
"print_width": "200px",
|
|
||||||
"read_only": 1,
|
|
||||||
"width": "200px"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "voucher_detail_no",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Voucher Detail No",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 0
|
|
||||||
}
|
|
||||||
]
|
|
@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"autoname": "PCE/.###",
|
||||||
|
"creation": "2013-01-10 16:34:07.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "column_break0",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "transaction_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Transaction Date",
|
||||||
|
"oldfieldname": "transaction_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "posting_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Posting Date",
|
||||||
|
"oldfieldname": "posting_date",
|
||||||
|
"oldfieldtype": "Date",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "fiscal_year",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Closing Fiscal Year",
|
||||||
|
"oldfieldname": "fiscal_year",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "link:Fiscal Year",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "amended_from",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"ignore_restrictions": 1,
|
||||||
|
"label": "Amended From",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "amended_from",
|
||||||
|
"oldfieldtype": "Data",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Company",
|
||||||
|
"oldfieldname": "company",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "link:Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "The account head under Liability, in which Profit/Loss will be booked",
|
||||||
|
"fieldname": "closing_account_head",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Closing Account Head",
|
||||||
|
"oldfieldname": "closing_account_head",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "coa_help",
|
||||||
|
"fieldtype": "HTML",
|
||||||
|
"label": "CoA Help",
|
||||||
|
"oldfieldtype": "HTML",
|
||||||
|
"options": "<a href=\"#!Accounts Browser/Account\">To manage Account Head, click here</a>",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "remarks",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Remarks",
|
||||||
|
"oldfieldname": "remarks",
|
||||||
|
"oldfieldtype": "Small Text",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-file-text",
|
||||||
|
"idx": 1,
|
||||||
|
"is_submittable": 1,
|
||||||
|
"modified": "2014-01-20 17:48:59.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Period Closing Voucher",
|
||||||
|
"owner": "jai@webnotestech.com",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"amend": 1,
|
||||||
|
"cancel": 1,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"submit": 1,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"amend": 1,
|
||||||
|
"cancel": 1,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"search_fields": "posting_date, fiscal_year"
|
||||||
|
}
|
@ -7,11 +7,7 @@ from frappe.utils import cstr, flt
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
|
|
||||||
class DocType(AccountsController):
|
class PeriodClosingVoucher(AccountsController):
|
||||||
def __init__(self,d,dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
|
||||||
self.year_start_date = ''
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_account_head()
|
self.validate_account_head()
|
||||||
self.validate_posting_date()
|
self.validate_posting_date()
|
||||||
@ -21,24 +17,24 @@ class DocType(AccountsController):
|
|||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
frappe.db.sql("""delete from `tabGL Entry`
|
frappe.db.sql("""delete from `tabGL Entry`
|
||||||
where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.doc.name)
|
where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.name)
|
||||||
|
|
||||||
def validate_account_head(self):
|
def validate_account_head(self):
|
||||||
if frappe.db.get_value("Account", self.doc.closing_account_head, "report_type") \
|
if frappe.db.get_value("Account", self.closing_account_head, "report_type") \
|
||||||
!= "Balance Sheet":
|
!= "Balance Sheet":
|
||||||
frappe.throw(_("Account") + ": " + self.doc.closing_account_head +
|
frappe.throw(_("Account") + ": " + self.closing_account_head +
|
||||||
_("must be a Liability account"))
|
_("must be a Liability account"))
|
||||||
|
|
||||||
def validate_posting_date(self):
|
def validate_posting_date(self):
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
self.year_start_date = get_fiscal_year(self.doc.posting_date, self.doc.fiscal_year)[1]
|
self.year_start_date = get_fiscal_year(self.posting_date, self.fiscal_year)[1]
|
||||||
|
|
||||||
pce = frappe.db.sql("""select name from `tabPeriod Closing Voucher`
|
pce = frappe.db.sql("""select name from `tabPeriod Closing Voucher`
|
||||||
where posting_date > %s and fiscal_year = %s and docstatus = 1""",
|
where posting_date > %s and fiscal_year = %s and docstatus = 1""",
|
||||||
(self.doc.posting_date, self.doc.fiscal_year))
|
(self.posting_date, self.fiscal_year))
|
||||||
if pce and pce[0][0]:
|
if pce and pce[0][0]:
|
||||||
frappe.throw(_("Another Period Closing Entry") + ": " + cstr(pce[0][0]) +
|
frappe.throw(_("Another Period Closing Entry") + ": " + cstr(pce[0][0]) +
|
||||||
_("has been made after posting date") + ": " + self.doc.posting_date)
|
_("has been made after posting date") + ": " + self.posting_date)
|
||||||
|
|
||||||
def get_pl_balances(self):
|
def get_pl_balances(self):
|
||||||
"""Get balance for pl accounts"""
|
"""Get balance for pl accounts"""
|
||||||
@ -49,7 +45,7 @@ class DocType(AccountsController):
|
|||||||
and t2.docstatus < 2 and t2.company = %s
|
and t2.docstatus < 2 and t2.company = %s
|
||||||
and t1.posting_date between %s and %s
|
and t1.posting_date between %s and %s
|
||||||
group by t1.account
|
group by t1.account
|
||||||
""", (self.doc.company, self.year_start_date, self.doc.posting_date), as_dict=1)
|
""", (self.company, self.get("year_start_date"), self.posting_date), as_dict=1)
|
||||||
|
|
||||||
def make_gl_entries(self):
|
def make_gl_entries(self):
|
||||||
gl_entries = []
|
gl_entries = []
|
||||||
@ -67,7 +63,7 @@ class DocType(AccountsController):
|
|||||||
|
|
||||||
if net_pl_balance:
|
if net_pl_balance:
|
||||||
gl_entries.append(self.get_gl_dict({
|
gl_entries.append(self.get_gl_dict({
|
||||||
"account": self.doc.closing_account_head,
|
"account": self.closing_account_head,
|
||||||
"debit": abs(net_pl_balance) if net_pl_balance > 0 else 0,
|
"debit": abs(net_pl_balance) if net_pl_balance > 0 else 0,
|
||||||
"credit": abs(net_pl_balance) if net_pl_balance < 0 else 0
|
"credit": abs(net_pl_balance) if net_pl_balance < 0 else 0
|
||||||
}))
|
}))
|
||||||
|
@ -1,145 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-01-10 16:34:07",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-01-20 17:48:59",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "jai@webnotestech.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "PCE/.###",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"icon": "icon-file-text",
|
|
||||||
"is_submittable": 1,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__",
|
|
||||||
"search_fields": "posting_date, fiscal_year"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Period Closing Voucher",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"amend": 1,
|
|
||||||
"cancel": 1,
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Period Closing Voucher",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"submit": 1,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Period Closing Voucher"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break0",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"width": "50%"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "transaction_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Transaction Date",
|
|
||||||
"oldfieldname": "transaction_date",
|
|
||||||
"oldfieldtype": "Date"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "posting_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Posting Date",
|
|
||||||
"oldfieldname": "posting_date",
|
|
||||||
"oldfieldtype": "Date",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "fiscal_year",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Closing Fiscal Year",
|
|
||||||
"oldfieldname": "fiscal_year",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "link:Fiscal Year",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "amended_from",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"ignore_restrictions": 1,
|
|
||||||
"label": "Amended From",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "amended_from",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Company",
|
|
||||||
"oldfieldname": "company",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "link:Company",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break1",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"oldfieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "The account head under Liability, in which Profit/Loss will be booked",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "closing_account_head",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Closing Account Head",
|
|
||||||
"oldfieldname": "closing_account_head",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Account",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "coa_help",
|
|
||||||
"fieldtype": "HTML",
|
|
||||||
"label": "CoA Help",
|
|
||||||
"oldfieldtype": "HTML",
|
|
||||||
"options": "<a href=\"#!Accounts Browser/Account\">To manage Account Head, click here</a>"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "remarks",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"label": "Remarks",
|
|
||||||
"oldfieldname": "remarks",
|
|
||||||
"oldfieldtype": "Small Text",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "System Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts Manager"
|
|
||||||
}
|
|
||||||
]
|
|
@ -5,31 +5,31 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
import frappe
|
import frappe
|
||||||
|
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
||||||
|
|
||||||
class TestPeriodClosingVoucher(unittest.TestCase):
|
class TestPeriodClosingVoucher(unittest.TestCase):
|
||||||
def test_closing_entry(self):
|
def test_closing_entry(self):
|
||||||
# clear GL Entries
|
# clear GL Entries
|
||||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||||
|
jv = frappe.copy_doc(jv_records[2])
|
||||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
|
||||||
jv = frappe.bean(copy=jv_records[2])
|
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
jv1 = frappe.bean(copy=jv_records[0])
|
jv1 = frappe.copy_doc(jv_records[0])
|
||||||
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv1.get("entries")[1].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv1.doclist[2].debit = 600.0
|
jv1.get("entries")[1].cost_center = "_Test Cost Center - _TC"
|
||||||
jv1.doclist[1].credit = 600.0
|
jv1.get("entries")[1].debit = 600.0
|
||||||
|
jv1.get("entries")[0].credit = 600.0
|
||||||
jv1.insert()
|
jv1.insert()
|
||||||
jv1.submit()
|
jv1.submit()
|
||||||
|
|
||||||
pcv = frappe.bean(copy=test_record)
|
pcv = frappe.copy_doc(test_records[0])
|
||||||
pcv.insert()
|
pcv.insert()
|
||||||
pcv.submit()
|
pcv.submit()
|
||||||
|
|
||||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||||
from `tabGL Entry` where voucher_type='Period Closing Voucher' and voucher_no=%s
|
from `tabGL Entry` where voucher_type='Period Closing Voucher' and voucher_no=%s
|
||||||
order by account asc, debit asc""", pcv.doc.name, as_dict=1)
|
order by account asc, debit asc""", pcv.name, as_dict=1)
|
||||||
|
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
|
|
||||||
@ -45,12 +45,4 @@ class TestPeriodClosingVoucher(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
test_dependencies = ["Customer", "Cost Center"]
|
test_dependencies = ["Customer", "Cost Center"]
|
||||||
|
test_records = frappe.get_test_records("Period Closing Voucher")
|
||||||
test_record = [{
|
|
||||||
"doctype": "Period Closing Voucher",
|
|
||||||
"closing_account_head": "_Test Account Reserves and Surplus - _TC",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
|
||||||
"posting_date": "2013-03-31",
|
|
||||||
"remarks": "test"
|
|
||||||
}]
|
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
[{
|
||||||
|
"doctype": "Period Closing Voucher",
|
||||||
|
"closing_account_head": "_Test Account Reserves and Surplus - _TC",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
|
"posting_date": "2013-03-31",
|
||||||
|
"remarks": "test"
|
||||||
|
}]
|
@ -2,7 +2,7 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||||
return $c_obj(make_doclist(cdt,cdn),'get_series','',function(r,rt){
|
return $c_obj(cur_frm.doc, 'get_series','',function(r,rt){
|
||||||
if(r.message) set_field_options('naming_series', r.message);
|
if(r.message) set_field_options('naming_series', r.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
234
erpnext/accounts/doctype/pos_setting/pos_setting.json
Executable file
234
erpnext/accounts/doctype/pos_setting/pos_setting.json
Executable file
@ -0,0 +1,234 @@
|
|||||||
|
{
|
||||||
|
"autoname": "POS/.####",
|
||||||
|
"creation": "2013-05-24 12:15:51.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "user",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "User",
|
||||||
|
"oldfieldname": "user",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "User",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
|
||||||
|
"fieldname": "territory",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Territory",
|
||||||
|
"oldfieldname": "territory",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Territory",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "naming_series",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Series",
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldname": "naming_series",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "currency",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Currency",
|
||||||
|
"oldfieldname": "currency",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "Currency",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "selling_price_list",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Price List",
|
||||||
|
"oldfieldname": "price_list_name",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "Price List",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Company",
|
||||||
|
"oldfieldname": "company",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Company",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break0",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"oldfieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"description": "Create Stock Ledger Entries when you submit a Sales Invoice",
|
||||||
|
"fieldname": "update_stock",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Update Stock",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "customer",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Customer",
|
||||||
|
"oldfieldname": "customer_account",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Customer",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "cash_bank_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Cash/Bank Account",
|
||||||
|
"oldfieldname": "cash_bank_account",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "income_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Income Account",
|
||||||
|
"oldfieldname": "income_account",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
||||||
|
"fieldname": "expense_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Expense Account",
|
||||||
|
"options": "Account",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Warehouse",
|
||||||
|
"oldfieldname": "warehouse",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Warehouse",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "cost_center",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Cost Center",
|
||||||
|
"oldfieldname": "cost_center",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Cost Center",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "taxes_and_charges",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Taxes and Charges",
|
||||||
|
"oldfieldname": "charge",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Sales Taxes and Charges Master",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "letter_head",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Letter Head",
|
||||||
|
"oldfieldname": "letter_head",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "link:Letter Head",
|
||||||
|
"permlevel": 0,
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "tc_name",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Terms and Conditions",
|
||||||
|
"oldfieldname": "tc_name",
|
||||||
|
"oldfieldtype": "Link",
|
||||||
|
"options": "Terms and Conditions",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "select_print_heading",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_filter": 0,
|
||||||
|
"label": "Print Heading",
|
||||||
|
"oldfieldname": "select_print_heading",
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"options": "link:Print Heading",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-cog",
|
||||||
|
"idx": 1,
|
||||||
|
"modified": "2014-01-29 13:08:25.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "POS Setting",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"cancel": 0,
|
||||||
|
"create": 1,
|
||||||
|
"delete": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"submit": 0,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cancel": 0,
|
||||||
|
"delete": 0,
|
||||||
|
"email": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"submit": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -6,16 +6,11 @@ import frappe
|
|||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
|
|
||||||
class DocType:
|
from frappe.model.document import Document
|
||||||
def __init__(self,doc,doclist):
|
|
||||||
self.doc, self.doclist = doc,doclist
|
|
||||||
|
|
||||||
|
class POSSetting(Document):
|
||||||
def get_series(self):
|
def get_series(self):
|
||||||
import frappe.model.doctype
|
frappe.get_meta("Sales Invoice").get_field("naming_series").options or ""
|
||||||
docfield = frappe.model.doctype.get('Sales Invoice')
|
|
||||||
series = [d.options for d in docfield
|
|
||||||
if d.doctype == 'DocField' and d.fieldname == 'naming_series']
|
|
||||||
return series and series[0] or ''
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.check_for_duplicate()
|
self.check_for_duplicate()
|
||||||
@ -25,30 +20,30 @@ class DocType:
|
|||||||
def check_for_duplicate(self):
|
def check_for_duplicate(self):
|
||||||
res = frappe.db.sql("""select name, user from `tabPOS Setting`
|
res = frappe.db.sql("""select name, user from `tabPOS Setting`
|
||||||
where ifnull(user, '') = %s and name != %s and company = %s""",
|
where ifnull(user, '') = %s and name != %s and company = %s""",
|
||||||
(self.doc.user, self.doc.name, self.doc.company))
|
(self.user, self.name, self.company))
|
||||||
if res:
|
if res:
|
||||||
if res[0][1]:
|
if res[0][1]:
|
||||||
msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'" %
|
msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'" %
|
||||||
(res[0][0], res[0][1], self.doc.company), raise_exception=1)
|
(res[0][0], res[0][1], self.company), raise_exception=1)
|
||||||
else:
|
else:
|
||||||
msgprint("Global POS Setting already created - %s for this company: '%s'" %
|
msgprint("Global POS Setting already created - %s for this company: '%s'" %
|
||||||
(res[0][0], self.doc.company), raise_exception=1)
|
(res[0][0], self.company), raise_exception=1)
|
||||||
|
|
||||||
def validate_expense_account(self):
|
def validate_expense_account(self):
|
||||||
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
|
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
|
||||||
and not self.doc.expense_account:
|
and not self.expense_account:
|
||||||
msgprint(_("Expense Account is mandatory"), raise_exception=1)
|
msgprint(_("Expense Account is mandatory"), raise_exception=1)
|
||||||
|
|
||||||
def validate_all_link_fields(self):
|
def validate_all_link_fields(self):
|
||||||
accounts = {"Account": [self.doc.cash_bank_account, self.doc.income_account,
|
accounts = {"Account": [self.cash_bank_account, self.income_account,
|
||||||
self.doc.expense_account], "Cost Center": [self.doc.cost_center],
|
self.expense_account], "Cost Center": [self.cost_center],
|
||||||
"Warehouse": [self.doc.warehouse]}
|
"Warehouse": [self.warehouse]}
|
||||||
|
|
||||||
for link_dt, dn_list in accounts.items():
|
for link_dt, dn_list in accounts.items():
|
||||||
for link_dn in dn_list:
|
for link_dn in dn_list:
|
||||||
if link_dn and not frappe.db.exists({"doctype": link_dt,
|
if link_dn and not frappe.db.exists({"doctype": link_dt,
|
||||||
"company": self.doc.company, "name": link_dn}):
|
"company": self.company, "name": link_dn}):
|
||||||
frappe.throw(link_dn +_(" does not belong to ") + self.doc.company)
|
frappe.throw(link_dn +_(" does not belong to ") + self.company)
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.set_defaults()
|
self.set_defaults()
|
||||||
@ -60,7 +55,7 @@ class DocType:
|
|||||||
frappe.defaults.clear_default("is_pos")
|
frappe.defaults.clear_default("is_pos")
|
||||||
|
|
||||||
if not include_current_pos:
|
if not include_current_pos:
|
||||||
condition = " where name != '%s'" % self.doc.name.replace("'", "\'")
|
condition = " where name != '%s'" % self.name.replace("'", "\'")
|
||||||
else:
|
else:
|
||||||
condition = ""
|
condition = ""
|
||||||
|
|
||||||
|
@ -1,246 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-05-24 12:15:51",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-01-29 13:08:25",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "POS/.####",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"icon": "icon-cog",
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "POS Setting",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cancel": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"email": 1,
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "POS Setting",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"submit": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "POS Setting"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "user",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "User",
|
|
||||||
"oldfieldname": "user",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "User",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "territory",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Territory",
|
|
||||||
"oldfieldname": "territory",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Territory",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "naming_series",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Series",
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldname": "naming_series",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "currency",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Currency",
|
|
||||||
"oldfieldname": "currency",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "Currency",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "selling_price_list",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Price List",
|
|
||||||
"oldfieldname": "price_list_name",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "Price List",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Company",
|
|
||||||
"oldfieldname": "company",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Company",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "column_break0",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "1",
|
|
||||||
"description": "Create Stock Ledger Entries when you submit a Sales Invoice",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "update_stock",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Update Stock",
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "customer",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Customer",
|
|
||||||
"oldfieldname": "customer_account",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Customer",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cash_bank_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Cash/Bank Account",
|
|
||||||
"oldfieldname": "cash_bank_account",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Account",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "income_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Income Account",
|
|
||||||
"oldfieldname": "income_account",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Account",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "expense_account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "Expense Account",
|
|
||||||
"options": "Account",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "warehouse",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Warehouse",
|
|
||||||
"oldfieldname": "warehouse",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Warehouse",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "cost_center",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Cost Center",
|
|
||||||
"oldfieldname": "cost_center",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Cost Center",
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "taxes_and_charges",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Taxes and Charges",
|
|
||||||
"oldfieldname": "charge",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Sales Taxes and Charges Master",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "letter_head",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Letter Head",
|
|
||||||
"oldfieldname": "letter_head",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "link:Letter Head",
|
|
||||||
"print_hide": 1,
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "tc_name",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Terms and Conditions",
|
|
||||||
"oldfieldname": "tc_name",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Terms and Conditions",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "select_print_heading",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_filter": 0,
|
|
||||||
"label": "Print Heading",
|
|
||||||
"oldfieldname": "select_print_heading",
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"options": "link:Print Heading",
|
|
||||||
"read_only": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts Manager",
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts User"
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,19 +1,6 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
test_records = [
|
|
||||||
[{
|
import frappe
|
||||||
"doctype": "POS Setting",
|
test_records = frappe.get_test_records('Pos Setting')
|
||||||
"name": "_Test POS Setting",
|
|
||||||
"currency": "INR",
|
|
||||||
"selling_price_list": "_Test Price List",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
|
||||||
"territory": "_Test Territory",
|
|
||||||
"cash_bank_account": "_Test Account Bank Account - _TC",
|
|
||||||
"income_account": "Sales - _TC",
|
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
|
||||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
|
||||||
"naming_series": "_T-Sales Invoice-"
|
|
||||||
}]
|
|
||||||
]
|
|
16
erpnext/accounts/doctype/pos_setting/test_records.json
Normal file
16
erpnext/accounts/doctype/pos_setting/test_records.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"cash_bank_account": "_Test Account Bank Account - _TC",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"currency": "INR",
|
||||||
|
"doctype": "POS Setting",
|
||||||
|
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||||
|
"income_account": "Sales - _TC",
|
||||||
|
"name": "_Test POS Setting",
|
||||||
|
"naming_series": "_T-Sales Invoice-",
|
||||||
|
"selling_price_list": "_Test Price List",
|
||||||
|
"territory": "_Test Territory",
|
||||||
|
"warehouse": "_Test Warehouse - _TC"
|
||||||
|
}
|
||||||
|
]
|
258
erpnext/accounts/doctype/pricing_rule/pricing_rule.json
Normal file
258
erpnext/accounts/doctype/pricing_rule/pricing_rule.json
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
{
|
||||||
|
"autoname": "PRULE.#####",
|
||||||
|
"creation": "2014-02-21 15:02:51.000000",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "Master",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "basic_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Basic Section",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Today",
|
||||||
|
"fieldname": "valid_from",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Valid From",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "valid_upto",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "Valid Upto",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "col_break1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "priority",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Priority",
|
||||||
|
"options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "disable",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Disable",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "price_discount_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Price / Discount",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Discount Percentage",
|
||||||
|
"fieldname": "price_or_discount",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Price or Discount",
|
||||||
|
"options": "\nPrice\nDiscount Percentage",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "col_break2",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.price_or_discount==\"Price\"",
|
||||||
|
"fieldname": "price",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Price",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"",
|
||||||
|
"fieldname": "discount_percentage",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Discount Percentage",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"",
|
||||||
|
"fieldname": "for_price_list",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "For Price List",
|
||||||
|
"options": "Price List",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "applicability_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Applicability",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Item Code",
|
||||||
|
"fieldname": "apply_on",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Apply On",
|
||||||
|
"options": "\nItem Code\nItem Group\nBrand",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.apply_on==\"Item Code\"",
|
||||||
|
"fieldname": "item_code",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Item Code",
|
||||||
|
"options": "Item",
|
||||||
|
"permlevel": 0,
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.apply_on==\"Item Group\"",
|
||||||
|
"fieldname": "item_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Item Group",
|
||||||
|
"options": "Item Group",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.apply_on==\"Brand\"",
|
||||||
|
"fieldname": "brand",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Brand",
|
||||||
|
"options": "Brand",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "col_break3",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "applicable_for",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Applicable For",
|
||||||
|
"options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Type",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.applicable_for==\"Customer\"",
|
||||||
|
"fieldname": "customer",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Customer",
|
||||||
|
"options": "Customer",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.applicable_for==\"Customer Group\"",
|
||||||
|
"fieldname": "customer_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Customer Group",
|
||||||
|
"options": "Customer Group",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.applicable_for==\"Territory\"",
|
||||||
|
"fieldname": "territory",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Territory",
|
||||||
|
"options": "Territory",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.applicable_for==\"Sales Partner\"",
|
||||||
|
"fieldname": "sales_partner",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Sales Partner",
|
||||||
|
"options": "Sales Partner",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.applicable_for==\"Campaign\"",
|
||||||
|
"fieldname": "campaign",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Campaign",
|
||||||
|
"options": "Campaign",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.applicable_for==\"Supplier\"",
|
||||||
|
"fieldname": "supplier",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Supplier",
|
||||||
|
"options": "Supplier",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:doc.applicable_for==\"Supplier Type\"",
|
||||||
|
"fieldname": "supplier_type",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Supplier Type",
|
||||||
|
"options": "Supplier Type",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "min_qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Min Qty",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "max_qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Max Qty",
|
||||||
|
"permlevel": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"icon": "icon-gift",
|
||||||
|
"idx": 1,
|
||||||
|
"istable": 0,
|
||||||
|
"modified": "2014-03-05 18:23:34.000000",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Pricing Rule",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"read": 1,
|
||||||
|
"role": "Accounts Manager",
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"read": 1,
|
||||||
|
"role": "Sales Manager",
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"read": 1,
|
||||||
|
"role": "Purchase Manager",
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"read": 1,
|
||||||
|
"role": "Website Manager",
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"read": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -8,9 +8,7 @@ import frappe
|
|||||||
from frappe import throw, _
|
from frappe import throw, _
|
||||||
from frappe.model.controller import DocListController
|
from frappe.model.controller import DocListController
|
||||||
|
|
||||||
class DocType(DocListController):
|
class PricingRule(DocListController):
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
@ -18,14 +16,14 @@ class DocType(DocListController):
|
|||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
for field in ["apply_on", "applicable_for", "price_or_discount"]:
|
for field in ["apply_on", "applicable_for", "price_or_discount"]:
|
||||||
val = self.doc.fields.get("applicable_for")
|
val = self.get("applicable_for")
|
||||||
if val and not self.doc.fields.get(frappe.scrub(val)):
|
if val and not self.get(frappe.scrub(val)):
|
||||||
throw("{fname} {msg}".format(fname = _(val), msg = _(" is mandatory")),
|
throw("{fname} {msg}".format(fname = _(val), msg = _(" is mandatory")),
|
||||||
frappe.MandatoryError)
|
frappe.MandatoryError)
|
||||||
|
|
||||||
def cleanup_fields_value(self):
|
def cleanup_fields_value(self):
|
||||||
for logic_field in ["apply_on", "applicable_for", "price_or_discount"]:
|
for logic_field in ["apply_on", "applicable_for", "price_or_discount"]:
|
||||||
fieldname = frappe.scrub(self.doc.fields.get(logic_field) or "")
|
fieldname = frappe.scrub(self.get(logic_field) or "")
|
||||||
|
|
||||||
# reset all values except for the logic field
|
# reset all values except for the logic field
|
||||||
options = (self.meta.get_options(logic_field) or "").split("\n")
|
options = (self.meta.get_options(logic_field) or "").split("\n")
|
||||||
@ -34,5 +32,5 @@ class DocType(DocListController):
|
|||||||
|
|
||||||
f = frappe.scrub(f)
|
f = frappe.scrub(f)
|
||||||
if f!=fieldname:
|
if f!=fieldname:
|
||||||
self.doc.fields[f] = None
|
self.set(f, None)
|
||||||
|
|
@ -1,261 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2014-02-21 15:02:51",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2014-03-05 18:23:34",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"autoname": "PRULE.#####",
|
|
||||||
"doctype": "DocType",
|
|
||||||
"document_type": "Master",
|
|
||||||
"icon": "icon-gift",
|
|
||||||
"istable": 0,
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "__common__"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Pricing Rule",
|
|
||||||
"parentfield": "fields",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"name": "__common__",
|
|
||||||
"parent": "Pricing Rule",
|
|
||||||
"parentfield": "permissions",
|
|
||||||
"parenttype": "DocType",
|
|
||||||
"permlevel": 0,
|
|
||||||
"read": 1,
|
|
||||||
"write": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocType",
|
|
||||||
"name": "Pricing Rule"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "basic_section",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Basic Section"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "Today",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "valid_from",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Valid From"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "valid_upto",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"label": "Valid Upto"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "col_break1",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "priority",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Priority",
|
|
||||||
"options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "disable",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Disable"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "price_discount_section",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Price / Discount"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "Discount Percentage",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "price_or_discount",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Price or Discount",
|
|
||||||
"options": "\nPrice\nDiscount Percentage",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "col_break2",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.price_or_discount==\"Price\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "price",
|
|
||||||
"fieldtype": "Float",
|
|
||||||
"label": "Price"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "discount_percentage",
|
|
||||||
"fieldtype": "Float",
|
|
||||||
"label": "Discount Percentage"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "for_price_list",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "For Price List",
|
|
||||||
"options": "Price List"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "applicability_section",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"label": "Applicability"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "Item Code",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "apply_on",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Apply On",
|
|
||||||
"options": "\nItem Code\nItem Group\nBrand",
|
|
||||||
"reqd": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.apply_on==\"Item Code\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "item_code",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Item Code",
|
|
||||||
"options": "Item",
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.apply_on==\"Item Group\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "item_group",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Item Group",
|
|
||||||
"options": "Item Group"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.apply_on==\"Brand\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "brand",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Brand",
|
|
||||||
"options": "Brand"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "col_break3",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "applicable_for",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Applicable For",
|
|
||||||
"options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Type"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.applicable_for==\"Customer\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "customer",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Customer",
|
|
||||||
"options": "Customer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.applicable_for==\"Customer Group\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "customer_group",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Customer Group",
|
|
||||||
"options": "Customer Group"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.applicable_for==\"Territory\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "territory",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Territory",
|
|
||||||
"options": "Territory"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.applicable_for==\"Sales Partner\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "sales_partner",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Sales Partner",
|
|
||||||
"options": "Sales Partner"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.applicable_for==\"Campaign\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "campaign",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Campaign",
|
|
||||||
"options": "Campaign"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.applicable_for==\"Supplier\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "supplier",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Supplier",
|
|
||||||
"options": "Supplier"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval:doc.applicable_for==\"Supplier Type\"",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "supplier_type",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Supplier Type",
|
|
||||||
"options": "Supplier Type"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "min_qty",
|
|
||||||
"fieldtype": "Float",
|
|
||||||
"label": "Min Qty"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "max_qty",
|
|
||||||
"fieldtype": "Float",
|
|
||||||
"label": "Max Qty"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Accounts Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Sales Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Purchase Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "Website Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocPerm",
|
|
||||||
"role": "System Manager"
|
|
||||||
}
|
|
||||||
]
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user