mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
first cut for lazy loading framework
This commit is contained in:
0
erpnext/.no_timestamps
Normal file
0
erpnext/.no_timestamps
Normal file
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'Administrator', 'name': 'Payable Voucher', 'parent': None, 'dt_label': 'Purchase Invoice', 'creation': '2010-06-10 10:44:55', 'modified': '2010-06-10 10:44:55', 'module': 'Accounts', 'doctype': 'DocType Label', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'dt': 'Payable Voucher', 'parentfield': None}]
|
||||
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'Administrator', 'name': 'Receivable Voucher', 'parent': None, 'dt_label': 'Sales Invoice', 'creation': '2010-06-10 10:44:40', 'modified': '2010-06-10 10:44:40', 'module': 'Accounts', 'doctype': 'DocType Label', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'dt': 'Receivable Voucher', 'parentfield': None}]
|
||||
@@ -0,0 +1,139 @@
|
||||
# DocType Mapper, Delivery Note-Receivable Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:34',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-08-09 11:14:09',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': 'Delivery Note-Receivable Voucher',
|
||||
'parentfield': 'table_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Delivery Note-Receivable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'from_doctype': 'Delivery Note',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'to_doctype': 'Receivable Voucher'
|
||||
},
|
||||
|
||||
# DocType Mapper, Delivery Note-Receivable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'name': 'Delivery Note-Receivable Voucher'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.basic_rate)',
|
||||
'to_field': 'qty'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'to_field': 'delivery_note'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'to_field': 'dn_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'prevdoc_docname',
|
||||
'to_field': 'sales_order'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'prevdoc_detail_docname',
|
||||
'to_field': 'so_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: flt(obj.amount) - flt(obj.billed_amt)',
|
||||
'to_field': 'amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt)) * flt(obj.export_rate)/flt(obj.basic_rate)',
|
||||
'to_field': 'export_amount'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_table': 'Delivery Note',
|
||||
'match_id': 0,
|
||||
'to_table': 'Receivable Voucher',
|
||||
'validation_logic': 'docstatus=1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'delivery_note_details',
|
||||
'from_table': 'Delivery Note Detail',
|
||||
'match_id': 1,
|
||||
'to_field': 'entries',
|
||||
'to_table': 'RV Detail',
|
||||
'validation_logic': 'amount > ifnull(billed_amt, 0) and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'other_charges',
|
||||
'from_table': 'RV Tax Detail',
|
||||
'match_id': 2,
|
||||
'to_field': 'other_charges',
|
||||
'to_table': 'RV Tax Detail',
|
||||
'validation_logic': 'name is not null'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'sales_team',
|
||||
'from_table': 'Sales Team',
|
||||
'match_id': 3,
|
||||
'to_field': 'sales_team',
|
||||
'to_table': 'Sales Team',
|
||||
'validation_logic': 'name is not null'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,64 @@
|
||||
# DocType Mapper, Project-Receivable Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:48:10',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-01 14:24:38',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_table': 'Project',
|
||||
'match_id': 0,
|
||||
'name': '__common__',
|
||||
'parent': 'Project-Receivable Voucher',
|
||||
'parentfield': 'table_mapper_details',
|
||||
'parenttype': 'DocType Mapper',
|
||||
'to_table': 'Receivable Voucher',
|
||||
'validation_logic': 'name is not null'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'customer',
|
||||
'map': 'Yes',
|
||||
'match_id': 0,
|
||||
'name': '__common__',
|
||||
'parent': 'Project-Receivable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
'parenttype': 'DocType Mapper',
|
||||
'to_field': 'customer'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'from_doctype': 'Project',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'to_doctype': 'Receivable Voucher'
|
||||
},
|
||||
|
||||
# DocType Mapper, Project-Receivable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'name': 'Project-Receivable Voucher'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,121 @@
|
||||
# DocType Mapper, Purchase Order-Payable Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-13 11:26:20',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': 'Purchase Order-Payable Voucher',
|
||||
'parentfield': 'table_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Purchase Order-Payable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'from_doctype': 'Purchase Order',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'to_doctype': 'Payable Voucher'
|
||||
},
|
||||
|
||||
# DocType Mapper, Purchase Order-Payable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'name': 'Purchase Order-Payable Voucher'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: flt(obj.qty) - flt(obj.billed_qty)',
|
||||
'to_field': 'qty'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'purchase_rate',
|
||||
'to_field': 'rate'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
|
||||
'to_field': 'amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
|
||||
'to_field': 'import_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'to_field': 'purchase_order'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'to_field': 'po_detail'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_table': 'Purchase Order',
|
||||
'match_id': 0,
|
||||
'to_table': 'Payable Voucher',
|
||||
'validation_logic': 'docstatus =1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'po_details',
|
||||
'from_table': 'PO Detail',
|
||||
'match_id': 1,
|
||||
'to_field': 'entries',
|
||||
'to_table': 'PV Detail',
|
||||
'validation_logic': 'ifnull(billed_qty,0) < qty'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'purchase_tax_details',
|
||||
'from_table': 'Purchase Tax Detail',
|
||||
'match_id': 2,
|
||||
'to_field': 'purchase_tax_details',
|
||||
'to_table': 'Purchase Tax Detail',
|
||||
'validation_logic': 'docstatus =1'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,135 @@
|
||||
# DocType Mapper, Purchase Receipt-Payable Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-13 12:18:34',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': 'Purchase Receipt-Payable Voucher',
|
||||
'parentfield': 'table_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'match_id': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Purchase Receipt-Payable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'from_doctype': 'Purchase Receipt',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'to_doctype': 'Payable Voucher'
|
||||
},
|
||||
|
||||
# DocType Mapper, Purchase Receipt-Payable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'name': 'Purchase Receipt-Payable Voucher'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: flt(obj.qty) - flt(obj.billed_qty)',
|
||||
'to_field': 'qty'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'purchase_rate',
|
||||
'to_field': 'rate'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
|
||||
'to_field': 'amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
|
||||
'to_field': 'import_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'to_field': 'purchase_receipt'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'prevdoc_docname',
|
||||
'to_field': 'purchase_order'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'to_field': 'pr_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'prevdoc_detail_docname',
|
||||
'to_field': 'po_detail'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'purchase_receipt_details',
|
||||
'from_table': 'Purchase Receipt Detail',
|
||||
'match_id': 1,
|
||||
'to_field': 'entries',
|
||||
'to_table': 'PV Detail',
|
||||
'validation_logic': 'ifnull(billed_qty,0) < qty'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_table': 'Purchase Receipt',
|
||||
'match_id': 0,
|
||||
'to_table': 'Payable Voucher',
|
||||
'validation_logic': 'docstatus=1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'purchase_tax_details',
|
||||
'from_table': 'Purchase Tax Detail',
|
||||
'match_id': 2,
|
||||
'to_field': 'purchase_tax_details',
|
||||
'to_table': 'Purchase Tax Detail',
|
||||
'validation_logic': 'docstatus=1'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,155 @@
|
||||
# DocType Mapper, Sales Order-Receivable Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:36',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-08-08 16:56:40',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': 'Sales Order-Receivable Voucher',
|
||||
'parentfield': 'table_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'map': 'Yes',
|
||||
'name': '__common__',
|
||||
'parent': 'Sales Order-Receivable Voucher',
|
||||
'parentfield': 'field_mapper_details',
|
||||
'parenttype': 'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'from_doctype': 'Sales Order',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'to_doctype': 'Receivable Voucher'
|
||||
},
|
||||
|
||||
# DocType Mapper, Sales Order-Receivable Voucher
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'name': 'Sales Order-Receivable Voucher'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'customer',
|
||||
'match_id': 0,
|
||||
'to_field': 'customer'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate)',
|
||||
'match_id': 1,
|
||||
'to_field': 'qty'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'parent',
|
||||
'match_id': 1,
|
||||
'to_field': 'sales_order'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'name',
|
||||
'match_id': 1,
|
||||
'to_field': 'so_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval:flt(obj.amount) - flt(obj.billed_amt)',
|
||||
'match_id': 1,
|
||||
'to_field': 'amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'eval: (flt(obj.amount) - flt(obj.billed_amt))* flt(obj.export_rate)/flt(obj.basic_rate)',
|
||||
'match_id': 1,
|
||||
'to_field': 'export_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'checking_operator': '=',
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'project_name',
|
||||
'match_id': 0,
|
||||
'to_field': 'project_name'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': 'Field Mapper Detail',
|
||||
'from_field': 'reserved_warehouse',
|
||||
'match_id': 1,
|
||||
'to_field': 'warehouse'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_table': 'Sales Order',
|
||||
'match_id': 0,
|
||||
'to_table': 'Receivable Voucher',
|
||||
'validation_logic': 'docstatus=1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'sales_order_detail',
|
||||
'from_table': 'Sales Order Detail',
|
||||
'match_id': 1,
|
||||
'to_field': 'entries',
|
||||
'to_table': 'RV Detail',
|
||||
'validation_logic': 'amount > ifnull(billed_amt, 0) and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'other_charges',
|
||||
'from_table': 'RV Tax Detail',
|
||||
'match_id': 2,
|
||||
'to_field': 'other_charges',
|
||||
'to_table': 'RV Tax Detail',
|
||||
'validation_logic': 'name is not null'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': 'Table Mapper Detail',
|
||||
'from_field': 'sales_team',
|
||||
'from_table': 'Sales Team',
|
||||
'match_id': 3,
|
||||
'to_field': 'sales_team',
|
||||
'to_table': 'Sales Team',
|
||||
'validation_logic': 'name is not null'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
[{'doc_type': 'Journal Voucher', 'modified_by': 'nabin@webnotestech.com', 'name': 'Journal Voucher', 'parent': None, 'creation': '2009-03-12 12:09:24', 'modified': '2010-04-30 17:56:41', 'module': 'Accounts', 'doctype': 'GL Mapper', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center', 'voucher_no': 'parent:name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': "value:d.against_voucher or d.against_invoice or ''", 'table_field': 'entries', 'transaction_date': 'parent:voucher_date', 'debit': 'debit', 'docstatus': 0, 'parent': 'Journal Voucher', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': 'is_advance', 'remarks': 'parent:remark', 'account': 'account', 'name': 'GLMDetail00001', 'idx': 1, 'against_voucher_type': "value:(d.against_voucher and 'Payable Voucher') or (d.against_invoice and 'Receivable Voucher') or ''", 'modified': '2010-04-30 17:56:41', 'against': 'against_account', 'credit': 'credit', 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2009-06-11 11:09:11', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': '', 'voucher_no': 'name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': '', 'table_field': '', 'transaction_date': 'voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'Journal Voucher', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': '', 'remarks': 'remark', 'account': 'tax_code', 'name': 'GLMDetail00009', 'idx': 2, 'against_voucher_type': None, 'modified': '2010-04-30 17:56:41', 'against': 'supplier_account', 'credit': 'ded_amount', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}]
|
||||
@@ -0,0 +1,233 @@
|
||||
[
|
||||
{
|
||||
'creation': '2011-05-10 11:21:22',
|
||||
'doc_type': 'POS with write off',
|
||||
'docstatus': 0,
|
||||
'doctype': 'GL Mapper',
|
||||
'idx': None,
|
||||
'modified': '2011-05-10 11:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'POS with write off',
|
||||
'owner': 'Administrator',
|
||||
'parent': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None
|
||||
},
|
||||
{
|
||||
'account': 'income_account',
|
||||
'against': 'parent:debit_to',
|
||||
'against_voucher': None,
|
||||
'against_voucher_type': None,
|
||||
'aging_date': 'parent:aging_date',
|
||||
'company': 'parent:company',
|
||||
'cost_center': 'cost_center',
|
||||
'creation': '2011-05-10 11:21:22',
|
||||
'credit': 'amount',
|
||||
'debit': 'value:0',
|
||||
'docstatus': 0,
|
||||
'doctype': 'GL Mapper Detail',
|
||||
'fiscal_year': 'parent:fiscal_year',
|
||||
'idx': 1,
|
||||
'is_advance': None,
|
||||
'is_opening': 'parent:is_opening',
|
||||
'modified': '2011-05-10 11:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000002752',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'POS with write off',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'GL Mapper',
|
||||
'posting_date': 'parent:posting_date',
|
||||
'remarks': 'parent:remarks',
|
||||
'table_field': 'entries',
|
||||
'transaction_date': 'parent:voucher_date',
|
||||
'voucher_no': 'parent:name',
|
||||
'voucher_type': 'parent:doctype'
|
||||
},
|
||||
{
|
||||
'account': 'account_head',
|
||||
'against': 'parent:debit_to',
|
||||
'against_voucher': None,
|
||||
'against_voucher_type': None,
|
||||
'aging_date': 'parent:aging_date',
|
||||
'company': 'parent:company',
|
||||
'cost_center': 'cost_center_other_charges',
|
||||
'creation': '2011-05-10 11:21:22',
|
||||
'credit': 'tax_amount',
|
||||
'debit': 'value:0',
|
||||
'docstatus': 0,
|
||||
'doctype': 'GL Mapper Detail',
|
||||
'fiscal_year': 'parent:fiscal_year',
|
||||
'idx': 2,
|
||||
'is_advance': None,
|
||||
'is_opening': 'parent:is_opening',
|
||||
'modified': '2011-05-10 11:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000002753',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'POS with write off',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'GL Mapper',
|
||||
'posting_date': 'parent:posting_date',
|
||||
'remarks': 'parent:remarks',
|
||||
'table_field': 'other_charges',
|
||||
'transaction_date': 'parent:voucher_date',
|
||||
'voucher_no': 'parent:name',
|
||||
'voucher_type': 'parent:doctype'
|
||||
},
|
||||
{
|
||||
'account': 'debit_to',
|
||||
'against': 'against_income_account',
|
||||
'against_voucher': 'name',
|
||||
'against_voucher_type': 'doctype',
|
||||
'aging_date': 'aging_date',
|
||||
'company': 'company',
|
||||
'cost_center': None,
|
||||
'creation': '2011-05-10 11:21:22',
|
||||
'credit': 'value:0',
|
||||
'debit': 'grand_total',
|
||||
'docstatus': 0,
|
||||
'doctype': 'GL Mapper Detail',
|
||||
'fiscal_year': 'fiscal_year',
|
||||
'idx': 3,
|
||||
'is_advance': None,
|
||||
'is_opening': 'is_opening',
|
||||
'modified': '2011-05-10 11:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000002754',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'POS with write off',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'GL Mapper',
|
||||
'posting_date': 'posting_date',
|
||||
'remarks': 'remarks',
|
||||
'table_field': None,
|
||||
'transaction_date': 'voucher_date',
|
||||
'voucher_no': 'name',
|
||||
'voucher_type': 'doctype'
|
||||
},
|
||||
{
|
||||
'account': 'debit_to',
|
||||
'against': 'cash_bank_account',
|
||||
'against_voucher': 'name',
|
||||
'against_voucher_type': 'doctype',
|
||||
'aging_date': 'aging_date',
|
||||
'company': 'company',
|
||||
'cost_center': None,
|
||||
'creation': '2011-05-10 11:21:22',
|
||||
'credit': 'paid_amount',
|
||||
'debit': 'value:0',
|
||||
'docstatus': 0,
|
||||
'doctype': 'GL Mapper Detail',
|
||||
'fiscal_year': 'fiscal_year',
|
||||
'idx': 4,
|
||||
'is_advance': None,
|
||||
'is_opening': 'is_opening',
|
||||
'modified': '2011-05-10 11:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000002755',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'POS with write off',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'GL Mapper',
|
||||
'posting_date': 'posting_date',
|
||||
'remarks': 'remarks',
|
||||
'table_field': None,
|
||||
'transaction_date': 'voucher_date',
|
||||
'voucher_no': 'name',
|
||||
'voucher_type': 'doctype'
|
||||
},
|
||||
{
|
||||
'account': 'debit_to',
|
||||
'against': 'write_off_account',
|
||||
'against_voucher': 'name',
|
||||
'against_voucher_type': 'doctype',
|
||||
'aging_date': 'aging_date',
|
||||
'company': 'company',
|
||||
'cost_center': None,
|
||||
'creation': '2011-05-10 11:21:22',
|
||||
'credit': 'write_off_amount',
|
||||
'debit': 'value:0',
|
||||
'docstatus': 0,
|
||||
'doctype': 'GL Mapper Detail',
|
||||
'fiscal_year': 'fiscal_year',
|
||||
'idx': 5,
|
||||
'is_advance': None,
|
||||
'is_opening': 'is_opening',
|
||||
'modified': '2011-05-10 11:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000002758',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'POS with write off',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'GL Mapper',
|
||||
'posting_date': 'posting_date',
|
||||
'remarks': 'remarks',
|
||||
'table_field': None,
|
||||
'transaction_date': 'voucher_date',
|
||||
'voucher_no': 'name',
|
||||
'voucher_type': 'doctype'
|
||||
},
|
||||
{
|
||||
'account': 'cash_bank_account',
|
||||
'against': 'debit_to',
|
||||
'against_voucher': None,
|
||||
'against_voucher_type': None,
|
||||
'aging_date': 'aging_date',
|
||||
'company': 'company',
|
||||
'cost_center': None,
|
||||
'creation': '2011-05-10 11:21:22',
|
||||
'credit': 'value:0',
|
||||
'debit': 'paid_amount',
|
||||
'docstatus': 0,
|
||||
'doctype': 'GL Mapper Detail',
|
||||
'fiscal_year': 'fiscal_year',
|
||||
'idx': 6,
|
||||
'is_advance': None,
|
||||
'is_opening': 'is_opening',
|
||||
'modified': '2011-05-10 11:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000002756',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'POS with write off',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'GL Mapper',
|
||||
'posting_date': 'posting_date',
|
||||
'remarks': 'remarks',
|
||||
'table_field': None,
|
||||
'transaction_date': 'voucher_date',
|
||||
'voucher_no': 'name',
|
||||
'voucher_type': 'doctype'
|
||||
},
|
||||
{
|
||||
'account': 'write_off_account',
|
||||
'against': 'debit_to',
|
||||
'against_voucher': None,
|
||||
'against_voucher_type': None,
|
||||
'aging_date': 'aging_date',
|
||||
'company': 'company',
|
||||
'cost_center': 'write_off_cost_center',
|
||||
'creation': '2011-05-10 11:21:22',
|
||||
'credit': 'value:0',
|
||||
'debit': 'write_off_amount',
|
||||
'docstatus': 0,
|
||||
'doctype': 'GL Mapper Detail',
|
||||
'fiscal_year': 'fiscal_year',
|
||||
'idx': 7,
|
||||
'is_advance': None,
|
||||
'is_opening': 'is_opening',
|
||||
'modified': '2011-05-10 11:21:22',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000002757',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'POS with write off',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'GL Mapper',
|
||||
'posting_date': 'posting_date',
|
||||
'remarks': 'remarks',
|
||||
'table_field': None,
|
||||
'transaction_date': 'voucher_date',
|
||||
'voucher_no': 'name',
|
||||
'voucher_type': 'doctype'
|
||||
}
|
||||
]
|
||||
1
erpnext/accounts/GL Mapper/POS/POS.txt
Normal file
1
erpnext/accounts/GL Mapper/POS/POS.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'doc_type': 'POS', 'modified_by': 'Administrator', 'name': 'POS', 'parent': None, 'creation': '2010-12-14 16:40:09', 'modified': '2010-12-14 20:15:04', 'doctype': 'GL Mapper', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}, {'creation': '2010-12-14 16:40:09', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center', 'voucher_no': 'parent:name', 'modified_by': 'Administrator', 'against_voucher': None, 'table_field': 'entries', 'transaction_date': 'parent:voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'POS', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': None, 'remarks': 'parent:remarks', 'account': 'income_account', 'name': 'GLMDetail00010', 'idx': 1, 'against_voucher_type': None, 'modified': '2010-12-14 20:15:04', 'against': 'parent:debit_to', 'credit': 'amount', 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2010-12-14 16:40:09', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center_other_charges', 'voucher_no': 'parent:name', 'modified_by': 'Administrator', 'against_voucher': None, 'table_field': 'other_charges', 'transaction_date': 'parent:voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'POS', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': None, 'remarks': 'parent:remarks', 'account': 'account_head', 'name': 'GLMDetail00011', 'idx': 2, 'against_voucher_type': None, 'modified': '2010-12-14 20:15:04', 'against': 'parent:debit_to', 'credit': 'tax_amount', 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2010-12-14 16:40:09', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': None, 'voucher_no': 'name', 'modified_by': 'Administrator', 'against_voucher': 'name', 'table_field': None, 'transaction_date': 'voucher_date', 'debit': 'grand_total', 'docstatus': 0, 'parent': 'POS', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': None, 'remarks': 'remarks', 'account': 'debit_to', 'name': 'GLMDetail00012', 'idx': 3, 'against_voucher_type': 'doctype', 'modified': '2010-12-14 20:15:04', 'against': 'against_income_account', 'credit': 'value:0', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}, {'creation': '2010-12-14 16:40:09', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': '', 'voucher_no': 'name', 'modified_by': 'Administrator', 'against_voucher': 'name', 'table_field': None, 'transaction_date': 'voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'POS', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': None, 'remarks': 'remarks', 'account': 'debit_to', 'name': 'GLMDetail00013', 'idx': 4, 'against_voucher_type': 'doctype', 'modified': '2010-12-14 20:15:04', 'against': 'cash_bank_account', 'credit': 'paid_amount', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}, {'creation': '2010-12-14 16:40:09', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': '', 'voucher_no': 'name', 'modified_by': 'Administrator', 'against_voucher': '', 'table_field': None, 'transaction_date': 'voucher_date', 'debit': 'paid_amount', 'docstatus': 0, 'parent': 'POS', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': None, 'remarks': 'remarks', 'account': 'cash_bank_account', 'name': 'GLMDetail00014', 'idx': 5, 'against_voucher_type': '', 'modified': '2010-12-14 20:15:04', 'against': 'debit_to', 'credit': 'value:0', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}]
|
||||
@@ -0,0 +1 @@
|
||||
[{'doc_type': 'Payable Voucher', 'modified_by': 'nabin@webnotestech.com', 'name': 'Payable Voucher', 'parent': None, 'creation': '2009-03-12 12:09:24', 'modified': '2010-05-26 16:48:58', 'module': 'Accounts', 'doctype': 'GL Mapper', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center', 'voucher_no': 'parent:name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': None, 'table_field': 'entries', 'transaction_date': 'parent:voucher_date', 'debit': 'amount', 'docstatus': 0, 'parent': 'Payable Voucher', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': None, 'remarks': 'parent:remarks', 'account': 'expense_head', 'name': 'GLMDetail00002', 'idx': 1, 'against_voucher_type': None, 'modified': '2010-05-26 16:48:58', 'against': 'parent:credit_to', 'credit': 'value:0', 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center', 'voucher_no': 'parent:name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': None, 'table_field': 'purchase_tax_details', 'transaction_date': 'parent:voucher_date', 'debit': "value:d.fields.get('category') != 'For Valuation' and d.fields.get('add_deduct_tax') == 'Add' and d.fields.get('tax_amount') or 0", 'docstatus': 0, 'parent': 'Payable Voucher', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': None, 'remarks': 'parent:remarks', 'account': 'account_head', 'name': 'GLMDetail00003', 'idx': 2, 'against_voucher_type': None, 'modified': '2010-05-26 16:48:58', 'against': 'parent:credit_to', 'credit': "value:d.fields.get('category') != 'For Valuation' and d.fields.get('add_deduct_tax') == 'Deduct' and d.fields.get('tax_amount') or 0", 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': '', 'voucher_no': 'name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': None, 'table_field': '', 'transaction_date': 'voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'Payable Voucher', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': None, 'remarks': 'remarks', 'account': 'tax_code', 'name': 'GLMDetail00004', 'idx': 3, 'against_voucher_type': None, 'modified': '2010-05-26 16:48:58', 'against': 'credit_to', 'credit': 'ded_amount', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': '', 'voucher_no': 'name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': 'name', 'table_field': '', 'transaction_date': 'voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'Payable Voucher', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': None, 'remarks': 'remarks', 'account': 'credit_to', 'name': 'GLMDetail00005', 'idx': 4, 'against_voucher_type': "value:'Payable Voucher'", 'modified': '2010-05-26 16:48:58', 'against': 'against_expense_account', 'credit': 'total_amount_to_pay', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}]
|
||||
@@ -0,0 +1 @@
|
||||
[{'doc_type': 'Receivable Voucher', 'modified_by': 'Administrator', 'name': 'Receivable Voucher', 'parent': None, 'creation': '2009-03-12 12:09:24', 'modified': '2010-05-17 08:59:14', 'module': 'Accounts', 'doctype': 'GL Mapper', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center', 'voucher_no': 'parent:name', 'modified_by': 'Administrator', 'against_voucher': None, 'table_field': 'entries', 'transaction_date': 'parent:voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'Receivable Voucher', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': None, 'remarks': 'parent:remarks', 'account': 'income_account', 'name': 'GLMDetail00006', 'idx': 1, 'against_voucher_type': None, 'modified': '2010-05-17 08:59:14', 'against': 'parent:debit_to', 'credit': 'amount', 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center_other_charges', 'voucher_no': 'parent:name', 'modified_by': 'Administrator', 'against_voucher': None, 'table_field': 'other_charges', 'transaction_date': 'parent:voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'Receivable Voucher', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': None, 'remarks': 'parent:remarks', 'account': 'account_head', 'name': 'GLMDetail00007', 'idx': 2, 'against_voucher_type': None, 'modified': '2010-05-17 08:59:14', 'against': 'parent:debit_to', 'credit': 'tax_amount', 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': '', 'voucher_no': 'name', 'modified_by': 'Administrator', 'against_voucher': 'name', 'table_field': '', 'transaction_date': 'voucher_date', 'debit': 'grand_total', 'docstatus': 0, 'parent': 'Receivable Voucher', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': None, 'remarks': 'remarks', 'account': 'debit_to', 'name': 'GLMDetail00008', 'idx': 3, 'against_voucher_type': "value:'Receivable Voucher'", 'modified': '2010-05-17 08:59:14', 'against': 'against_income_account', 'credit': 'value:0', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}]
|
||||
441
erpnext/accounts/Module Def/Accounts/Accounts.txt
Normal file
441
erpnext/accounts/Module Def/Accounts/Accounts.txt
Normal file
@@ -0,0 +1,441 @@
|
||||
# Module Def, Accounts
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-25 10:50:34',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-07-28 12:01:10',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'name': '__common__',
|
||||
'parent': 'Accounts',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
|
||||
# These values are common for all Module Def Item
|
||||
{
|
||||
'doctype': 'Module Def Item',
|
||||
'name': '__common__',
|
||||
'parent': 'Accounts',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
|
||||
# These values are common for all Module Def
|
||||
{
|
||||
'disabled': 'No',
|
||||
'doctype': 'Module Def',
|
||||
'doctype_list': 'GL Mapper, Journal Voucher\nGL Mapper, Payable Voucher\nGL Mapper, Receivable Voucher\nDocType Label, Receivable Voucher\nDocType Label, Payable Voucher',
|
||||
'file_list': 'finance.gif,FileData/00210',
|
||||
'is_hidden': 'No',
|
||||
'last_updated_date': '2010-12-08 10:13:30',
|
||||
'module_desc': 'Data about your payables, receivables and books of accounts',
|
||||
'module_icon': 'Accounts.gif',
|
||||
'module_label': 'Accounts',
|
||||
'module_name': 'Accounts',
|
||||
'module_seq': 3,
|
||||
'name': '__common__'
|
||||
},
|
||||
|
||||
# Module Def, Accounts
|
||||
{
|
||||
'doctype': 'Module Def',
|
||||
'name': 'Accounts'
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'click_function': "show_chart_browser('Accounts Browser','Account')",
|
||||
'description': 'Manage your accounts',
|
||||
'display_name': 'Chart of Accounts',
|
||||
'doc_name': 'Accounts Browser',
|
||||
'doc_type': 'Pages',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 1
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'click_function': "show_chart_browser('Accounts Browser','Cost Center')",
|
||||
'description': 'Manage your cost centers',
|
||||
'display_name': 'Chart of Cost Centers',
|
||||
'doc_name': 'Accounts Browser',
|
||||
'doc_type': 'Pages',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 2
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Regular journal entry',
|
||||
'display_name': 'Journal Voucher',
|
||||
'doc_name': 'Journal Voucher',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'voucher_type\nvoucher_date\nfiscal_year\ntotal_debit\ntotal_credit',
|
||||
'idx': 3
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Outgoing Invoice to your customers',
|
||||
'display_name': 'Sales Invoice',
|
||||
'doc_name': 'Receivable Voucher',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'voucher_date\ndue_date\ndebit_to\ngrand_total\noutstanding_amount',
|
||||
'idx': 4
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Incoming invoice from your service providers',
|
||||
'display_name': 'Purchase Invoice',
|
||||
'doc_name': 'Payable Voucher',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'voucher_date\ncredit_to\nbill_no\ngrand_total\noutstanding_amount',
|
||||
'idx': 5
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Lease Agreement for Vehicles',
|
||||
'display_name': 'Lease Agreement',
|
||||
'doc_name': 'Lease Agreement',
|
||||
'doc_type': 'Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 6
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Profit & Loss and Balance Sheet builder',
|
||||
'display_name': 'Financial Statements',
|
||||
'doc_name': 'Financial Statements',
|
||||
'doc_type': 'Pages',
|
||||
'doctype': 'Module Def Item',
|
||||
'icon': 'table.gif',
|
||||
'idx': 7
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Update your actual clearance dates and find out if bank ledger tallies with your bank statement.',
|
||||
'display_name': 'Bank Reconciliation',
|
||||
'doc_name': 'Bank Reconciliation',
|
||||
'doc_type': 'Single DocType',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 8
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'TDS Payment',
|
||||
'doc_name': 'TDS Payment',
|
||||
'doc_type': 'Setup Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 9
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'TDS Return Acknowledgement',
|
||||
'doc_name': 'TDS Return Acknowledgement',
|
||||
'doc_type': 'Setup Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 10
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Form 16A',
|
||||
'doc_name': 'Form 16A',
|
||||
'doc_type': 'Setup Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 11
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Account closing entry (Profit Booking) on any date',
|
||||
'display_name': 'Period Closing Voucher',
|
||||
'doc_name': 'Period Closing Voucher',
|
||||
'doc_type': 'Setup Forms',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 12
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'You can export balance of selected ledgers within a specific period',
|
||||
'display_name': 'Ledger Balance Export',
|
||||
'doc_name': 'Ledger Balance Export',
|
||||
'doc_type': 'Single DocType',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 13
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'General Ledger',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 14
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Accounts Receivable',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 15
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Accounts Payable',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 16
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Bank Reconciliation Statement',
|
||||
'doc_name': 'Journal Voucher Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 17
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Trial Balance',
|
||||
'doc_name': 'Account',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 18
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Sales Register',
|
||||
'doc_name': 'Receivable Voucher',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 19
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Purchase Register',
|
||||
'doc_name': 'Payable Voucher',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 20
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Bank Clearance report',
|
||||
'doc_name': 'Journal Voucher Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 21
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Monthly Ledger Summary Report',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 22
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Collection Report',
|
||||
'doc_name': 'Journal Voucher Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 23
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Total amout collection for a period - Customerwise',
|
||||
'doc_name': 'Account',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 24
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Payment Report',
|
||||
'doc_name': 'Journal Voucher Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 25
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Itemwise Sales Register',
|
||||
'doc_name': 'RV Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 26
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Itemwise Purchase Register',
|
||||
'doc_name': 'PV Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 27
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Cost Center wise Expense',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 28
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'TDS Return',
|
||||
'doc_name': 'TDS Payment Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 29
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Budget Variance Report',
|
||||
'doc_name': 'Budget Detail',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 30
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Payment Receipt Report',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 31
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'description': 'Track total commission given to your Business Associate',
|
||||
'display_name': 'Business Associate Commission Report',
|
||||
'doc_name': 'Receivable Voucher',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 32
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Lease Agreement List',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 33
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Lease Monthly Future Installment Inflows',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 34
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Lease Overdue Age Wise',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 35
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Lease Overdue List',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 36
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Lease Receipts Client Wise',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 37
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Lease Receipt Summary Month Wise',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 38
|
||||
},
|
||||
|
||||
# Module Def Item
|
||||
{
|
||||
'display_name': 'Lease Yearly Future Installment Inflows',
|
||||
'doc_name': 'GL Entry',
|
||||
'doc_type': 'Reports',
|
||||
'doctype': 'Module Def Item',
|
||||
'idx': 39
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'idx': 1,
|
||||
'role': 'Accounts Manager'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'idx': 2,
|
||||
'role': 'Accounts User'
|
||||
},
|
||||
|
||||
# Module Def Role
|
||||
{
|
||||
'doctype': 'Module Def Role',
|
||||
'idx': 3,
|
||||
'role': 'Administrator'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,27 @@
|
||||
# Print Format, Cheque Printing Format
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-03-25 15:26:02',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-03-28 12:33:24',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Print Format
|
||||
{
|
||||
'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>',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Print Format, Cheque Printing Format
|
||||
{
|
||||
'doctype': 'Print Format',
|
||||
'name': 'Cheque Printing Format'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,27 @@
|
||||
# Print Format, Form 16A Print Format
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-27 17:30:34',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-15 13:36:06',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Print Format
|
||||
{
|
||||
'doctype': 'Print Format',
|
||||
'html': '<html>\n \n<body>\n<table border = "1" style=\'border-collapse: collapse;\'>\n \n <tr>\n <td colspan = "3"><h1 align = "center"><b>FORM No. 16 A</b></h1>\n <p align="right">Certificate No:<script>doc.name</script></p>\n <p align = "center">[See rule 31 (1)(b)]</p>\n <h2 align = "center"><b>Certifiction of deduction of tax at source under section 203 of the Income-tax Act, 1961</b></h2>\n <p>[For interest on securities; dividends; interests other than \'interests on securities\';winnings from lottery or crossword puzzle;\n winnings from horse race; payments to contractors and sub-contractors;insurance comission;payments to\n \n non-resident sportsmen/ sports associations;payments in respect of deposits under National Savings Scheme:\n payments on account of repurchase of units by Mutual Fund or Unit Trust of India; commission, remuneration or prize\n \n on sale of lottery tickets; comission or brokerage;rent;fees for professional or technical services;royalty and any sum \n under section 28(va);income in respect of units; payment of compensation on acquisition of certain immovable property;\n\n other sums under section 195; income in respect of units of non-residents referred to in section 196A; income from units\n referred to in section 196B;income from foreign currency bonds or shares of an Indian Company referred to in section</p>\n 196C; income of Foreign Institutional Investors from securities referred to in section 196D]\n </td> \n </tr>\n\n <tr>\n <td width="30%">Name and address of person deducing tax</td>\n <td width="40%">Acknowledgement No.s of all quarterly statements of TDS under sub-section(3) of section 200 as provided by TIN Facilitation Centre or NSDL web-site</td>\n <td width="30%">Name and address of the person to whom payment is made or in whose account it is credited</td>\n </tr>\n \n <tr>\n <td>\n <table>\n <tr><script>doc.company</script></tr><br><br>\n <tr><script>replace_newlines(doc.company_address)</script></tr>\n </table>\n </td>\n <td>\n <script>print_table(\'Form 16A\', doc.name, \'form_16A_ack_details\',\'Form 16A Ack Detail\', [\'quarter\',\'ack_no\'], [\'Quarter\' , \'Acknowledgement No.\'] , [\'40%\',\'60%\']).innerHTML</script>\n </td>\n <td>\n <table>\n <tr><script>doc.party_name</script></tr><br><br>\n <tr><script>replace_newlines(doc.party_address)</script></tr>\n </table>\n </td>\n </tr>\n \n <tr>\n <td>\n <table>\n <tr><b>Registration Details OF THE DEDUCTOR</b></tr><br>\n <tr><script>replace_newlines(doc.registration_details)</script></tr>\n </table>\n </td>\n \n <td>\n <table>\n <tr><b><center>NATURE OF PAYMENT</center></b></tr><br><br>\n <tr><b><center><script>doc.tds_category</script></center></b></tr>\n \n </table>\n </td>\n \n <td>\n <table>\n <tr><b>PAN NO. OF THE PAYEE</b></tr><br>\n <tr><script>doc.pan_number</script></tr>\n \n </table>\n </td>\n </tr>\n \n <tr>\n <td align = "center" colspan ="3"><b>DETAILS OF PAYMENT, TAX DEDUCTION AND DEPOSIT OF TAX INTO CENTRAL GOVERNMENT ACCOUNT</b>\n <p align = "center">(The deductor is to provide transaction wise details of tax deducted and deposited)</p>\n </tr>\n \n <tr>\n <td colspan="3">\n <script>print_table(\'Form 16A\', doc.name, \'form_16A_tax_details\',\'Form 16A Tax Detail\', [\'SR\',\'amount_paid\', \'date_of_payment\',\'tds_main\',\'surcharge\',\'cess_on_tds\',\'total_tax_deposited\',\'cheque_no\',\'bsr_code\',\'tax_deposited_date\',\'challan_no\'], [\'S No.\' , \'Amount paid / credited\',\'Date of payment / credit\',\'TDS (Rs.)\',\'Surcharge (Rs.)\',\'Cess on TDS(Rs.)\',\'Total Tax Deposited (Rs.)\',\'Cheque/DD no.(if any)\',\'BSR code on bank branch\', \'Date on which tax deposited(dd/mm/yy)\',\'Transfer Voucher/Challan Identification no.\'] , [\'3%\', \'10%\',\'10%\', \'10%\',\'10%\',\'6%\',\'10%\' ,\'10%\',\'7%\' ,\'10%\',\'7%\',\'7%\'] ).innerHTML</script>\n </td>\n </tr>\n \n <tr>\n <td colspan="3">\n Certified that a sum of Rs. <script>doc.total_amount</script> has been deducted at source and paid to the credit of the Central Government as per details given above <br><br><br><br>\n <p align="right"> Signature of person responsible for deduction of tax \n </td>\n </tr>\n \n <tr>\n <td colspan="3">\n <table width="100%" border="0">\n <tr>\n <td width="50%">Place: <script>doc.place</script></td>\n <td width="50%" align="right">Full Name: <script>doc.full_name</script></td>\n </tr>\n <tr>\n <td width="50%">Date: <script>date.str_to_user(doc.dt)</script></td>\n <td width="50%" align="right">Designation: <script>doc.designation</script></td>\n </tr>\n </table>\n </td>\n </tr>\n \n</table>\n</body>\n</html>',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Print Format, Form 16A Print Format
|
||||
{
|
||||
'doctype': 'Print Format',
|
||||
'name': 'Form 16A Print Format'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,27 @@
|
||||
# Print Format, Payment Receipt Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-03-25 17:30:45',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-04-27 11:44:30',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Print Format
|
||||
{
|
||||
'doctype': 'Print Format',
|
||||
'html': '<div style="position: relative;">\n<h3 align="center"><script>doc.company</script>\n</div>\n\n<font size="4">\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_rec_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<div>This receipt is issued subject to realization of the <script>if(doc.cheque_no){\'Cheque\'}else{\'Cash\'}</script></div>\n</font>\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'
|
||||
},
|
||||
|
||||
# Print Format, Payment Receipt Voucher
|
||||
{
|
||||
'doctype': 'Print Format',
|
||||
'name': 'Payment Receipt Voucher'
|
||||
}
|
||||
]
|
||||
26
erpnext/accounts/Role/Accounts Manager/Accounts Manager.txt
Normal file
26
erpnext/accounts/Role/Accounts Manager/Accounts Manager.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
# Role, Accounts Manager
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2009-03-19 14:57:46',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Role
|
||||
{
|
||||
'doctype': 'Role',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'role_name': 'Accounts Manager'
|
||||
},
|
||||
|
||||
# Role, Accounts Manager
|
||||
{
|
||||
'doctype': 'Role',
|
||||
'name': 'Accounts Manager'
|
||||
}
|
||||
]
|
||||
26
erpnext/accounts/Role/Accounts User/Accounts User.txt
Normal file
26
erpnext/accounts/Role/Accounts User/Accounts User.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
# Role, Accounts User
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-04-08 12:05:21',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Role
|
||||
{
|
||||
'doctype': 'Role',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'role_name': 'Accounts User'
|
||||
},
|
||||
|
||||
# Role, Accounts User
|
||||
{
|
||||
'doctype': 'Role',
|
||||
'name': 'Accounts User'
|
||||
}
|
||||
]
|
||||
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
0
erpnext/accounts/__init__.py
Normal file
0
erpnext/accounts/__init__.py
Normal file
0
erpnext/accounts/doctype/__init__.py
Normal file
0
erpnext/accounts/doctype/__init__.py
Normal file
0
erpnext/accounts/doctype/account/__init__.py
Normal file
0
erpnext/accounts/doctype/account/__init__.py
Normal file
79
erpnext/accounts/doctype/account/account.js
Normal file
79
erpnext/accounts/doctype/account/account.js
Normal file
@@ -0,0 +1,79 @@
|
||||
// Fetch parent details
|
||||
// -----------------------------------------
|
||||
cur_frm.add_fetch('parent_account', 'debit_or_credit', 'debit_or_credit');
|
||||
cur_frm.add_fetch('parent_account', 'is_pl_account', 'is_pl_account');
|
||||
|
||||
// Hide tax rate based on account type
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.account_type = function(doc, cdt, cdn) {
|
||||
if(doc.account_type == 'Tax') unhide_field(['tax_rate']);
|
||||
else hide_field(['tax_rate']);
|
||||
}
|
||||
|
||||
// Onload
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.account_type(doc, cdt, cdn);
|
||||
// hide India specific fields
|
||||
var cp = locals['Control Panel']['Control Panel'];
|
||||
if(cp.country == 'India')
|
||||
unhide_field(['pan_number', 'tds_applicable', 'tds_details', 'TDS']);
|
||||
else
|
||||
hide_field(['pan_number', 'tds_applicable', 'tds_details', 'TDS']);
|
||||
}
|
||||
|
||||
// Refresh
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
root_acc = [' Application of Funds (Assets)','Expenses','Income','Source of Funds (Liabilities)'];
|
||||
if(inList(root_acc, doc.account_name))
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
}
|
||||
|
||||
// Hide/unhide group or ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
||||
hide_field(['Convert to Group', 'Convert to Ledger']);
|
||||
if (cstr(doc.group_or_ledger) == 'Group') unhide_field('Convert to Ledger');
|
||||
else if (cstr(doc.group_or_ledger) == 'Ledger') unhide_field('Convert to Group');
|
||||
}
|
||||
|
||||
// Convert group to ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript['Convert to Ledger'] = function(doc, cdt, cdn) {
|
||||
$c_obj(make_doclist(cdt,cdn),'convert_group_to_ledger','',function(r,rt) {
|
||||
if(r.message == 1) {
|
||||
doc.group_or_ledger = 'Ledger';
|
||||
refresh_field('group_or_ledger');
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Convert ledger to group
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript['Convert to Group'] = function(doc, cdt, cdn) {
|
||||
$c_obj(make_doclist(cdt,cdn),'convert_ledger_to_group','',function(r,rt) {
|
||||
if(r.message == 1) {
|
||||
doc.group_or_ledger = 'Group';
|
||||
refresh_field('group_or_ledger');
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Master name get query
|
||||
// -----------------------------------------
|
||||
cur_frm.fields_dict['master_name'].get_query=function(doc){
|
||||
if (doc.master_type){
|
||||
return 'SELECT `tab'+doc.master_type+'`.name FROM `tab'+doc.master_type+'` WHERE `tab'+doc.master_type+'`.name LIKE "%s" and `tab'+doc.master_type+'`.docstatus != 2 ORDER BY `tab'+doc.master_type+'`.name LIMIT 50';
|
||||
}
|
||||
else alert("Please select master type");
|
||||
}
|
||||
|
||||
// parent account get query
|
||||
// -----------------------------------------
|
||||
cur_frm.fields_dict['parent_account'].get_query = function(doc){
|
||||
return 'SELECT DISTINCT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.group_or_ledger="Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.company="'+ doc.company+'" AND `tabAccount`.company is not NULL AND `tabAccount`.name LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
}
|
||||
275
erpnext/accounts/doctype/account/account.py
Normal file
275
erpnext/accounts/doctype/account/account.py
Normal file
@@ -0,0 +1,275 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
self.nsm_parent_field = 'parent_account'
|
||||
|
||||
def autoname(self):
|
||||
company_abbr = sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
|
||||
self.doc.name = self.doc.account_name.strip() + ' - ' + company_abbr
|
||||
|
||||
# Get customer/supplier address
|
||||
# ==================================================================
|
||||
def get_address(self):
|
||||
add=sql("Select address from `tab%s` where name='%s'"%(self.doc.master_type,self.doc.master_name))
|
||||
ret={'address':add[0][0]}
|
||||
return ret
|
||||
|
||||
|
||||
# check whether master name entered for supplier/customer
|
||||
# ==================================================================
|
||||
def validate_master_name(self):
|
||||
if (self.doc.master_type == 'Customer' or self.doc.master_type == 'Supplier') and not self.doc.master_name:
|
||||
msgprint("Message: Please enter Master Name once the account is created.")
|
||||
|
||||
|
||||
# Rate is mandatory for tax account
|
||||
# ==================================================================
|
||||
def validate_rate_for_tax(self):
|
||||
if self.doc.account_type == 'Tax' and not self.doc.tax_rate:
|
||||
msgprint("Please Enter Rate", raise_exception=1)
|
||||
|
||||
# Fetch Parent Details and validation for account not to be created under ledger
|
||||
# ==================================================================
|
||||
def validate_parent(self):
|
||||
if self.doc.parent_account:
|
||||
par = sql("select name, group_or_ledger, is_pl_account, debit_or_credit from tabAccount where name =%s",self.doc.parent_account)
|
||||
if not par:
|
||||
msgprint("Parent account does not exists", raise_exception=1)
|
||||
elif par and par[0][0] == self.doc.name:
|
||||
msgprint("You can not assign itself as parent account", raise_exception=1)
|
||||
elif par and par[0][1] != 'Group':
|
||||
msgprint("Parent account can not be a ledger", raise_exception=1)
|
||||
elif par and self.doc.debit_or_credit and par[0][3] != self.doc.debit_or_credit:
|
||||
msgprint("You can not move a %s account under %s account" % (self.doc.debit_or_credit, par[0][3]), raise_exception=1)
|
||||
elif par and not self.doc.is_pl_account:
|
||||
self.doc.is_pl_account = par[0][2]
|
||||
self.doc.debit_or_credit = par[0][3]
|
||||
|
||||
# Account name must be unique
|
||||
# ==================================================================
|
||||
def validate_duplicate_account(self):
|
||||
if (self.doc.__islocal or (not self.doc.name)) and sql("select name from tabAccount where account_name=%s and company=%s", (self.doc.account_name, self.doc.company)):
|
||||
msgprint("Account Name already exists, please rename", raise_exception=1)
|
||||
|
||||
# validate root details
|
||||
# ==================================================================
|
||||
def validate_root_details(self):
|
||||
#does not exists parent
|
||||
if self.doc.account_name in ['Income','Source of Funds', 'Expenses','Application of Funds'] and self.doc.parent_account:
|
||||
msgprint("You can not assign parent for root account", raise_exception=1)
|
||||
|
||||
# Debit / Credit
|
||||
if self.doc.account_name in ['Income','Source of Funds']:
|
||||
self.doc.debit_or_credit = 'Credit'
|
||||
elif self.doc.account_name in ['Expenses','Application of Funds']:
|
||||
self.doc.debit_or_credit = 'Debit'
|
||||
|
||||
# Is PL Account
|
||||
if self.doc.account_name in ['Income','Expenses']:
|
||||
self.doc.is_pl_account = 'Yes'
|
||||
elif self.doc.account_name in ['Source of Funds','Application of Funds']:
|
||||
self.doc.is_pl_account = 'No'
|
||||
|
||||
# Convert group to ledger
|
||||
# ==================================================================
|
||||
def convert_group_to_ledger(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Account: %s has existing child. You can not convert this account to ledger" % (self.doc.name), raise_exception=1)
|
||||
elif self.check_gle_exists():
|
||||
msgprint("Account with existing transaction can not be converted to ledger.", raise_exception=1)
|
||||
else:
|
||||
self.doc.group_or_ledger = 'Ledger'
|
||||
self.doc.save()
|
||||
return 1
|
||||
|
||||
# Convert ledger to group
|
||||
# ==================================================================
|
||||
def convert_ledger_to_group(self):
|
||||
if self.check_gle_exists():
|
||||
msgprint("Account with existing transaction can not be converted to group.", raise_exception=1)
|
||||
else:
|
||||
self.doc.group_or_ledger = 'Group'
|
||||
self.doc.save()
|
||||
return 1
|
||||
|
||||
# Check if any previous balance exists
|
||||
# ==================================================================
|
||||
def check_gle_exists(self):
|
||||
exists = sql("select name from `tabGL Entry` where account = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (self.doc.name))
|
||||
return exists and exists[0][0] or ''
|
||||
|
||||
# check if child exists
|
||||
# ==================================================================
|
||||
def check_if_child_exists(self):
|
||||
return sql("select name from `tabAccount` where parent_account = %s and docstatus != 2", self.doc.name, debug=0)
|
||||
|
||||
# Update balance
|
||||
# ==================================================================
|
||||
def update_balance(self, fy, period_det, flag = 1):
|
||||
# update in all parents
|
||||
for p in period_det:
|
||||
sql("update `tabAccount Balance` t1, `tabAccount` t2 set t1.balance = t1.balance + (%s), t1.opening = t1.opening + (%s), t1.debit = t1.debit + (%s), t1.credit = t1.credit + (%s) where t1.period = %s and t1.account = t2.name and t2.lft<=%s and t2.rgt>=%s", (flt(flag)*flt(p[1]), flt(flag)*flt(p[2]), flt(flag)*flt(p[3]), flt(flag)*flt(p[4]), p[0], self.doc.lft, self.doc.rgt))
|
||||
|
||||
|
||||
# change parent balance
|
||||
# ==================================================================
|
||||
def change_parent_bal(self):
|
||||
period_det = []
|
||||
fy = sql("select name from `tabFiscal Year` where if(ifnull(is_fiscal_year_closed, 'No'),ifnull(is_fiscal_year_closed, 'No'), 'No') = 'No'")
|
||||
for f in fy:
|
||||
# get my opening, balance
|
||||
per = sql("select period, balance, opening, debit, credit from `tabAccount Balance` where account = %s and fiscal_year = %s", (self.doc.name, f[0]))
|
||||
for p in per:
|
||||
period_det.append([p[0], p[1], p[2], p[3], p[4]])
|
||||
|
||||
# deduct balance from old_parent
|
||||
op = get_obj('Account',self.doc.old_parent)
|
||||
op.update_balance(fy, period_det, -1)
|
||||
|
||||
# add to new parent_account
|
||||
flag = 1
|
||||
if op.doc.debit_or_credit != self.doc.debit_or_credit:
|
||||
flag = -1
|
||||
|
||||
get_obj('Account', self.doc.parent_account).update_balance(fy, period_det, flag)
|
||||
msgprint('Balances updated')
|
||||
|
||||
# VALIDATE
|
||||
# ==================================================================
|
||||
def validate(self):
|
||||
self.validate_master_name()
|
||||
self.validate_rate_for_tax()
|
||||
self.validate_parent()
|
||||
self.validate_duplicate_account()
|
||||
self.validate_root_details()
|
||||
|
||||
# Defaults
|
||||
if not self.doc.parent_account:
|
||||
self.doc.parent_account = ''
|
||||
|
||||
# parent changed
|
||||
if self.doc.old_parent and self.doc.parent_account and (self.doc.parent_account != self.doc.old_parent):
|
||||
self.change_parent_bal()
|
||||
|
||||
# Add current fiscal year balance
|
||||
# ==================================================================
|
||||
def set_year_balance(self):
|
||||
p = sql("select name, start_date, end_date, fiscal_year from `tabPeriod` where docstatus != 2 and period_type in ('Month', 'Year')")
|
||||
for d in p:
|
||||
if not sql("select name from `tabAccount Balance` where account=%s and period=%s", (self.doc.name, d[0])):
|
||||
ac = Document('Account Balance')
|
||||
ac.account = self.doc.name
|
||||
ac.period = d[0]
|
||||
ac.start_date = d[1].strftime('%Y-%m-%d')
|
||||
ac.end_date = d[2].strftime('%Y-%m-%d')
|
||||
ac.fiscal_year = d[3]
|
||||
ac.opening = 0
|
||||
ac.debit = 0
|
||||
ac.credit = 0
|
||||
ac.balance = 0
|
||||
ac.save(1)
|
||||
|
||||
# Update Node Set Model
|
||||
# ==================================================================
|
||||
def update_nsm_model(self):
|
||||
import webnotes
|
||||
import webnotes.utils.nestedset
|
||||
webnotes.utils.nestedset.update_nsm(self)
|
||||
|
||||
# ON UPDATE
|
||||
# ==================================================================
|
||||
def on_update(self):
|
||||
# update nsm
|
||||
self.update_nsm_model()
|
||||
# Add curret year balance
|
||||
self.set_year_balance()
|
||||
|
||||
|
||||
# Check user role for approval process
|
||||
# ==================================================================
|
||||
def get_authorized_user(self):
|
||||
# Check logged-in user is authorized
|
||||
if get_value('Manage Account', None, 'credit_controller') in webnotes.user.get_roles():
|
||||
return 1
|
||||
|
||||
# Check Credit limit for customer
|
||||
# ==================================================================
|
||||
def check_credit_limit(self, account, company, tot_outstanding):
|
||||
# Get credit limit
|
||||
credit_limit_from = 'Customer'
|
||||
|
||||
cr_limit = sql("select t1.credit_limit from tabCustomer t1, `tabAccount` t2 where t2.name='%s' and t1.name = t2.master_name" % account)
|
||||
credit_limit = cr_limit and flt(cr_limit[0][0]) or 0
|
||||
if not credit_limit:
|
||||
credit_limit = get_value('Company', company, 'credit_limit')
|
||||
credit_limit_from = 'global settings in the Company'
|
||||
|
||||
# If outstanding greater than credit limit and not authorized person raise exception
|
||||
if credit_limit > 0 and flt(tot_outstanding) > credit_limit and not self.get_authorized_user():
|
||||
msgprint("Total Outstanding amount (%s) for <b>%s</b> can not be greater than credit limit (%s). To change your credit limit settings, please update the <b>%s</b>" \
|
||||
% (fmt_money(tot_outstanding), account, fmt_money(credit_limit), credit_limit_from), raise_exception=1)
|
||||
|
||||
# Account with balance cannot be inactive
|
||||
# ==================================================================
|
||||
def check_balance_before_trash(self):
|
||||
if self.check_gle_exists():
|
||||
msgprint("Account with existing transaction can not be trashed", raise_exception=1)
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Child account exists for this account. You can not trash this account.", raise_exception=1)
|
||||
|
||||
|
||||
# get current year balance
|
||||
# ==================================================================
|
||||
def get_curr_bal(self):
|
||||
bal = sql("select balance from `tabAccount Balance` where period = '%s' and parent = '%s'" % (get_defaults()['fiscal_year'], self.doc.name),debug=0)
|
||||
return bal and flt(bal[0][0]) or 0
|
||||
|
||||
# On Trash
|
||||
# ==================================================================
|
||||
def on_trash(self):
|
||||
# Check balance before trash
|
||||
self.check_balance_before_trash()
|
||||
# rebuild tree
|
||||
set(self.doc,'old_parent', '')
|
||||
self.update_nsm_model()
|
||||
|
||||
#delete Account Balance
|
||||
sql("delete from `tabAccount Balance` where account = %s", self.doc.name)
|
||||
|
||||
# On restore
|
||||
# ==================================================================
|
||||
def on_restore(self):
|
||||
# rebuild tree
|
||||
self.update_nsm_model()
|
||||
|
||||
# on rename
|
||||
# ---------
|
||||
def on_rename(self,newdn,olddn):
|
||||
company_abbr = sql("select tc.abbr from `tabAccount` ta, `tabCompany` tc where ta.company = tc.name and ta.name=%s", olddn)[0][0]
|
||||
|
||||
newdnchk = newdn.split(" - ")
|
||||
|
||||
if newdnchk[-1].lower() != company_abbr.lower():
|
||||
msgprint("Please add company abbreviation <b>%s</b>" %(company_abbr), raise_exception=1)
|
||||
else:
|
||||
account_name = " - ".join(newdnchk[:-1])
|
||||
sql("update `tabAccount` set account_name = '%s' where name = '%s'" %(account_name,olddn))
|
||||
521
erpnext/accounts/doctype/account/account.txt
Normal file
521
erpnext/accounts/doctype/account/account.txt
Normal file
@@ -0,0 +1,521 @@
|
||||
# DocType, Account
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-23 17:11:38',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1309508836',
|
||||
'allow_copy': 1,
|
||||
'allow_trash': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'in_create': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': 'debit_or_credit, group_or_ledger',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 133
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Account',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Account',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Account
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Account'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'Sales User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'Purchase User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 7,
|
||||
'permlevel': 2,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 8,
|
||||
'permlevel': 2,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Properties',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'Account Name',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'account_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'parent_account',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 4,
|
||||
'label': 'Parent Account',
|
||||
'oldfieldname': 'parent_account',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Account',
|
||||
'permlevel': 0,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'level',
|
||||
'fieldtype': 'Int',
|
||||
'hidden': 1,
|
||||
'idx': 5,
|
||||
'label': 'Level',
|
||||
'oldfieldname': 'level',
|
||||
'oldfieldtype': 'Int',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'default': 'Ledger',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'group_or_ledger',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Group or Ledger',
|
||||
'oldfieldname': 'group_or_ledger',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nLedger\nGroup',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 7,
|
||||
'label': 'Convert to Group',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 8,
|
||||
'label': 'Convert to Ledger',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'debit_or_credit',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'Debit or Credit',
|
||||
'oldfieldname': 'debit_or_credit',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_pl_account',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 10,
|
||||
'in_filter': 1,
|
||||
'label': 'Is PL Account',
|
||||
'oldfieldname': 'is_pl_account',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'Yes\nNo',
|
||||
'permlevel': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 11,
|
||||
'in_filter': 1,
|
||||
'label': 'Account Type',
|
||||
'oldfieldname': 'account_type',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nFixed Asset Account\nBank or Cash\nExpense Account\nTax\nIncome Account\nChargeable',
|
||||
'permlevel': 0,
|
||||
'search_index': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'If Account Type is "Tax" then the default rate is required.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tax_rate',
|
||||
'fieldtype': 'Currency',
|
||||
'hidden': 0,
|
||||
'idx': 12,
|
||||
'label': 'Rate',
|
||||
'oldfieldname': 'tax_rate',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 13,
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'freeze_account',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 14,
|
||||
'label': 'Freeze Account',
|
||||
'oldfieldname': 'freeze_account',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'No\nYes',
|
||||
'permlevel': 2
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 15,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit_days',
|
||||
'fieldtype': 'Int',
|
||||
'hidden': 0,
|
||||
'idx': 16,
|
||||
'label': 'Credit Days',
|
||||
'oldfieldname': 'credit_days',
|
||||
'oldfieldtype': 'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit_limit',
|
||||
'fieldtype': 'Currency',
|
||||
'hidden': 0,
|
||||
'idx': 17,
|
||||
'label': 'Credit Limit',
|
||||
'oldfieldname': 'credit_limit',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'master_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 18,
|
||||
'label': 'Master Type',
|
||||
'oldfieldname': 'master_type',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nNA\nSupplier\nCustomer\nEmployee',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'master_name',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 19,
|
||||
'label': 'Master Name',
|
||||
'oldfieldname': 'master_name',
|
||||
'oldfieldtype': 'Link',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 20,
|
||||
'label': 'TDS',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'pan_number',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 21,
|
||||
'label': 'PAN Number',
|
||||
'oldfieldname': 'pan_number',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'default': 'No',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tds_applicable',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 22,
|
||||
'label': 'TDS Applicable',
|
||||
'oldfieldname': 'tds_applicable',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nYes\nNo',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tds_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 23,
|
||||
'label': 'TDS Details',
|
||||
'oldfieldname': 'tds_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'TDS Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': "Don't delete this field at any cost",
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'old_parent',
|
||||
'fieldtype': 'Link',
|
||||
'options': 'Account',
|
||||
'hidden': 1,
|
||||
'idx': 24,
|
||||
'label': 'Old Parent',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'old_parent',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': "Don't delete this field at any cost",
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'lft',
|
||||
'fieldtype': 'Int',
|
||||
'hidden': 1,
|
||||
'idx': 25,
|
||||
'in_filter': 1,
|
||||
'label': 'Lft',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'lft',
|
||||
'oldfieldtype': 'Int',
|
||||
'permlevel': 3,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': "Don't delete this field at any cost",
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'rgt',
|
||||
'fieldtype': 'Int',
|
||||
'hidden': 1,
|
||||
'idx': 26,
|
||||
'in_filter': 1,
|
||||
'label': 'Rgt',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'rgt',
|
||||
'oldfieldtype': 'Int',
|
||||
'permlevel': 3,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 27,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
207
erpnext/accounts/doctype/account_balance/account_balance.txt
Normal file
207
erpnext/accounts/doctype/account_balance/account_balance.txt
Normal file
@@ -0,0 +1,207 @@
|
||||
# DocType, Account Balance
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-03-24 14:43:15',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1305714002',
|
||||
'autoname': '_ACB.######',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 0,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': 'account, period, fiscal_year, balance',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 28
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Account Balance',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Account Balance',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocType, Account Balance
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Account Balance'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'role': 'Accounts User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'role': 'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'in_filter': 1,
|
||||
'label': 'Account',
|
||||
'options': 'Account',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'period',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Period',
|
||||
'oldfieldname': 'period',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Period',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'opening',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Opening',
|
||||
'oldfieldname': 'opening',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'debit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 6,
|
||||
'label': 'Debit',
|
||||
'oldfieldname': 'debit',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'debit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 6,
|
||||
'label': 'Debit',
|
||||
'oldfieldname': 'debit',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 7,
|
||||
'label': 'Credit',
|
||||
'oldfieldname': 'credit',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 7,
|
||||
'label': 'Credit',
|
||||
'oldfieldname': 'credit',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'balance',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 8,
|
||||
'label': 'Balance',
|
||||
'oldfieldname': 'balance',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': 1,
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Fiscal Year',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'start_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': 1,
|
||||
'idx': 10,
|
||||
'in_filter': 1,
|
||||
'label': 'Start Date',
|
||||
'oldfieldname': 'start_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'end_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': 1,
|
||||
'idx': 11,
|
||||
'in_filter': 1,
|
||||
'label': 'End Date',
|
||||
'oldfieldname': 'end_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'search_index': 1
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,110 @@
|
||||
# DocType, Advance Adjustment Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 24
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'no_copy': 1,
|
||||
'parent': 'Advance Adjustment Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, Advance Adjustment Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Advance Adjustment Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'journal_voucher',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'label': 'Journal Voucher',
|
||||
'oldfieldname': 'journal_voucher',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Journal Voucher',
|
||||
'permlevel': 1,
|
||||
'width': '250px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'jv_detail_no',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'idx': 2,
|
||||
'label': 'Journal Voucher Detail No',
|
||||
'oldfieldname': 'jv_detail_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'width': '120px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'advance_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'Advance amount',
|
||||
'oldfieldname': 'advance_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'width': '120px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'allocated_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Allocated amount',
|
||||
'oldfieldname': 'allocated_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client',
|
||||
'width': '120px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'remarks',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 5,
|
||||
'label': 'Remarks',
|
||||
'oldfieldname': 'remarks',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1,
|
||||
'width': '150px'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,141 @@
|
||||
# DocType, Advance Allocation Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 20
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Advance Allocation Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, Advance Allocation Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Advance Allocation Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'journal_voucher',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'label': 'Journal Voucher',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'journal_voucher',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Journal Voucher',
|
||||
'permlevel': 1,
|
||||
'width': '180px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'jv_detail_no',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': 1,
|
||||
'idx': 2,
|
||||
'label': 'Journal Voucher Detail No',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'jv_detail_no',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'width': '80px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'advance_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'Advance Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'advance_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'width': '100px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'allocated_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Allocated Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'allocated_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client',
|
||||
'width': '100px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tds_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'TDS Amount',
|
||||
'oldfieldname': 'tds_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'width': '80px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tds_allocated',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 6,
|
||||
'label': 'TDS Allocated',
|
||||
'oldfieldname': 'tds_allocated',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'width': '80px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'remarks',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 7,
|
||||
'label': 'Remarks',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'remarks',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1,
|
||||
'width': '150px'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,4 @@
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
||||
// add page head
|
||||
var ph = new PageHeader(cur_frm.fields_dict['Head HTML'].wrapper, 'Bank Reconciliation', '');
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def get_details(self):
|
||||
if not (self.doc.bank_account and self.doc.from_date and self.doc.to_date):
|
||||
msgprint("Bank Account, From Date and To Date are Mandatory")
|
||||
return
|
||||
|
||||
dl = 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.cheque_no is not null or t1.cheque_no != '') 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))
|
||||
|
||||
self.doc.clear_table(self.doclist, 'entries')
|
||||
self.doc.total_amount = 0.0
|
||||
|
||||
for d in dl:
|
||||
nl = addchild(self.doc, 'entries', 'Bank Reconciliation Detail', 1, self.doclist)
|
||||
nl.posting_date = str(d[5])
|
||||
nl.voucher_id = str(d[0])
|
||||
nl.cheque_number = str(d[1])
|
||||
nl.cheque_date = str(d[2])
|
||||
nl.debit = flt(d[3])
|
||||
nl.credit = flt(d[4])
|
||||
nl.against_account = d[6]
|
||||
self.doc.total_amount += flt(flt(d[4]) - flt(d[3]))
|
||||
|
||||
def update_details(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.clearance_date:
|
||||
sql("update `tabJournal Voucher` set clearance_date = %s, modified = %s where name=%s", (d.clearance_date, nowdate(), d.voucher_id))
|
||||
msgprint("Updated")
|
||||
@@ -0,0 +1,165 @@
|
||||
# DocType, Bank Reconciliation
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:52',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-29 18:11:06',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1294312169',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 1,
|
||||
'hide_toolbar': 1,
|
||||
'issingle': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 12
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Bank Reconciliation',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Bank Reconciliation',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Bank Reconciliation
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Bank Reconciliation'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'HTML',
|
||||
'idx': 1,
|
||||
'label': 'Head HTML',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'Select account head of the bank where cheque was deposited.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'bank_account',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 2,
|
||||
'label': 'Bank Account',
|
||||
'options': 'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 3,
|
||||
'label': 'From Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 4,
|
||||
'label': 'To Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 5,
|
||||
'label': 'Get Non Reconciled Entries',
|
||||
'options': 'get_details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'entries',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 6,
|
||||
'label': 'Entries',
|
||||
'options': 'Bank Reconciliation Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 7,
|
||||
'label': 'Update Clearance Date',
|
||||
'options': 'update_details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 8,
|
||||
'label': 'Total Amount',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,113 @@
|
||||
# DocType, Bank Reconciliation Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:52',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-23 13:57:17',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 4
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Bank Reconciliation Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, Bank Reconciliation Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Bank Reconciliation Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_id',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'label': 'Voucher ID',
|
||||
'oldfieldname': 'voucher_id',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Journal Voucher',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_account',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Against Account',
|
||||
'oldfieldname': 'against_account',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry will get or has actually executed.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 3,
|
||||
'label': 'Posting Date',
|
||||
'oldfieldname': 'posting_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cheque_number',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Cheque Number',
|
||||
'oldfieldname': 'cheque_number',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cheque_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 5,
|
||||
'label': 'Cheque Date',
|
||||
'oldfieldname': 'cheque_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'clearance_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 8,
|
||||
'label': 'Clearance Date',
|
||||
'oldfieldname': 'clearance_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/budget_control/__init__.py
Normal file
0
erpnext/accounts/doctype/budget_control/__init__.py
Normal file
59
erpnext/accounts/doctype/budget_control/budget_control.js
Normal file
59
erpnext/accounts/doctype/budget_control/budget_control.js
Normal file
@@ -0,0 +1,59 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# Get monthly budget
|
||||
#-------------------
|
||||
def get_monthly_budget(self, distribution_id, cfy, st_date, post_dt, budget_allocated):
|
||||
|
||||
# get month_list
|
||||
st_date, post_dt = getdate(st_date), getdate(post_dt)
|
||||
|
||||
if distribution_id:
|
||||
if st_date.month <= post_dt.month:
|
||||
tot_per_allocated = sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, st_date.month, post_dt.month))[0][0]
|
||||
|
||||
if st_date.month > post_dt.month:
|
||||
|
||||
tot_per_allocated = flt(sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, st_date.month, 12 ))[0][0])
|
||||
tot_per_allocated = flt(tot_per_allocated) + flt(sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, 1, post_dt.month))[0][0])
|
||||
|
||||
return (flt(budget_allocated) * flt(tot_per_allocated)) / 100
|
||||
period_diff = sql("select PERIOD_DIFF('%s','%s')" % (post_dt.strftime('%Y%m'), st_date.strftime('%Y%m')))
|
||||
|
||||
return (flt(budget_allocated) * (flt(period_diff[0][0]) + 1)) / 12
|
||||
|
||||
def validate_budget(self, acct, cost_center, actual, budget, action):
|
||||
# action if actual exceeds budget
|
||||
if flt(actual) > flt(budget):
|
||||
msgprint("Your monthly expense "+ cstr((action == 'stop') and "will exceed" or "has exceeded") +" budget for <b>Account - "+cstr(acct)+" </b> under <b>Cost Center - "+ cstr(cost_center) + "</b>"+cstr((action == 'Stop') and ", you can not have this transaction." or "."))
|
||||
if action == 'Stop': raise Exception
|
||||
|
||||
def check_budget(self,le_list,cancel):
|
||||
# get value from record
|
||||
acct, cost_center, debit, credit, post_dt, cfy, company = le_list
|
||||
|
||||
# get allocated budget
|
||||
bgt = sql("select t1.budget_allocated, t1.actual, t2.distribution_id from `tabBudget Detail` t1, `tabCost Center` t2 where t1.account='%s' and t1.parent=t2.name and t2.name = '%s' and t1.fiscal_year='%s'" % (acct,cost_center,cfy), as_dict =1)
|
||||
curr_amt = ((cancel and -1 or 1) * flt(debit)) + ((cancel and 1 or -1) * flt(credit))
|
||||
|
||||
if bgt and bgt[0]['budget_allocated']:
|
||||
# check budget flag in Company
|
||||
bgt_flag = sql("select yearly_bgt_flag, monthly_bgt_flag from `tabCompany` where name = '%s'" % company, as_dict =1)
|
||||
|
||||
if bgt_flag and bgt_flag[0]['monthly_bgt_flag'] in ['Stop', 'Warn']:
|
||||
# get start date and last date
|
||||
st_date = get_value('Fiscal Year', cfy, 'year_start_date').strftime('%Y-%m-%d')
|
||||
lt_date = sql("select LAST_DAY('%s')" % post_dt)
|
||||
|
||||
# get Actual
|
||||
actual = get_obj('GL Control').get_period_difference(acct + '~~~' + cstr(st_date) + '~~~' + cstr(lt_date[0][0]), cost_center)
|
||||
|
||||
# Get Monthly budget
|
||||
budget = self.get_monthly_budget(bgt and bgt[0]['distribution_id'] or '' , cfy, st_date, post_dt, bgt[0]['budget_allocated'])
|
||||
|
||||
# validate monthly budget
|
||||
self.validate_budget(acct, cost_center, flt(actual) + flt(curr_amt), budget, 'monthly_bgt_flag')
|
||||
|
||||
# update actual against budget allocated in cost center
|
||||
sql("update `tabBudget Detail` set actual = ifnull(actual,0) + %s where account = '%s' and fiscal_year = '%s' and parent = '%s'" % (curr_amt,cstr(acct),cstr(cfy),cstr(cost_center)))
|
||||
78
erpnext/accounts/doctype/budget_control/budget_control.py
Normal file
78
erpnext/accounts/doctype/budget_control/budget_control.py
Normal file
@@ -0,0 +1,78 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# Get monthly budget
|
||||
#-------------------
|
||||
def get_monthly_budget(self, distribution_id, cfy, st_date, post_dt, budget_allocated):
|
||||
|
||||
# get month_list
|
||||
st_date, post_dt = getdate(st_date), getdate(post_dt)
|
||||
|
||||
if distribution_id:
|
||||
if st_date.month <= post_dt.month:
|
||||
tot_per_allocated = sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, st_date.month, post_dt.month))[0][0]
|
||||
|
||||
if st_date.month > post_dt.month:
|
||||
|
||||
tot_per_allocated = flt(sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, st_date.month, 12 ))[0][0])
|
||||
tot_per_allocated = flt(tot_per_allocated) + flt(sql("select ifnull(sum(percentage_allocation),0) from `tabBudget Distribution Detail` where parent='%s' and idx between '%s' and '%s'" % (distribution_id, 1, post_dt.month))[0][0])
|
||||
|
||||
return (flt(budget_allocated) * flt(tot_per_allocated)) / 100
|
||||
period_diff = sql("select PERIOD_DIFF('%s','%s')" % (post_dt.strftime('%Y%m'), st_date.strftime('%Y%m')))
|
||||
|
||||
return (flt(budget_allocated) * (flt(period_diff[0][0]) + 1)) / 12
|
||||
|
||||
def validate_budget(self, acct, cost_center, actual, budget, action):
|
||||
# action if actual exceeds budget
|
||||
if flt(actual) > flt(budget):
|
||||
msgprint("Your monthly expense "+ cstr((action == 'stop') and "will exceed" or "has exceeded") +" budget for <b>Account - "+cstr(acct)+" </b> under <b>Cost Center - "+ cstr(cost_center) + "</b>"+cstr((action == 'Stop') and ", you can not have this transaction." or "."))
|
||||
if action == 'Stop': raise Exception
|
||||
|
||||
def check_budget(self,le_list,cancel):
|
||||
# get value from record
|
||||
acct, cost_center, debit, credit, post_dt, cfy, company = le_list
|
||||
|
||||
# get allocated budget
|
||||
bgt = sql("select t1.budget_allocated, t1.actual, t2.distribution_id from `tabBudget Detail` t1, `tabCost Center` t2 where t1.account='%s' and t1.parent=t2.name and t2.name = '%s' and t1.fiscal_year='%s'" % (acct,cost_center,cfy), as_dict =1)
|
||||
curr_amt = ((cancel and -1 or 1) * flt(debit)) + ((cancel and 1 or -1) * flt(credit))
|
||||
|
||||
if bgt and bgt[0]['budget_allocated']:
|
||||
# check budget flag in Company
|
||||
bgt_flag = sql("select yearly_bgt_flag, monthly_bgt_flag from `tabCompany` where name = '%s'" % company, as_dict =1)
|
||||
|
||||
if bgt_flag and bgt_flag[0]['monthly_bgt_flag'] in ['Stop', 'Warn']:
|
||||
# get start date and last date
|
||||
st_date = get_value('Fiscal Year', cfy, 'year_start_date').strftime('%Y-%m-%d')
|
||||
lt_date = sql("select LAST_DAY('%s')" % post_dt)
|
||||
|
||||
# get Actual
|
||||
actual = get_obj('GL Control').get_period_difference(acct + '~~~' + cstr(st_date) + '~~~' + cstr(lt_date[0][0]), cost_center)
|
||||
|
||||
# Get Monthly budget
|
||||
budget = self.get_monthly_budget(bgt and bgt[0]['distribution_id'] or '' , cfy, st_date, post_dt, bgt[0]['budget_allocated'])
|
||||
|
||||
# validate monthly budget
|
||||
self.validate_budget(acct, cost_center, flt(actual) + flt(curr_amt), budget, 'monthly_bgt_flag')
|
||||
|
||||
# update actual against budget allocated in cost center
|
||||
sql("update `tabBudget Detail` set actual = ifnull(actual,0) + %s where account = '%s' and fiscal_year = '%s' and parent = '%s'" % (curr_amt,cstr(acct),cstr(cfy),cstr(cost_center)))
|
||||
31
erpnext/accounts/doctype/budget_control/budget_control.txt
Normal file
31
erpnext/accounts/doctype/budget_control/budget_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, Budget Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'nabin@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 23
|
||||
},
|
||||
|
||||
# DocType, Budget Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Budget Control'
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/budget_detail/__init__.py
Normal file
0
erpnext/accounts/doctype/budget_detail/__init__.py
Normal file
98
erpnext/accounts/doctype/budget_detail/budget_detail.txt
Normal file
98
erpnext/accounts/doctype/budget_detail/budget_detail.txt
Normal file
@@ -0,0 +1,98 @@
|
||||
# DocType, Budget Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'CBD/.######',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Budget Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, Budget Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Budget Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'in_filter': 1,
|
||||
'label': 'Account',
|
||||
'oldfieldname': 'account',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'budget_allocated',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 2,
|
||||
'label': 'Budget Allocated',
|
||||
'oldfieldname': 'budget_allocated',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'actual',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'Actual',
|
||||
'oldfieldname': 'actual',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
if(doc.__islocal){
|
||||
var callback1 = function(r,rt){
|
||||
refresh_field('budget_distribution_details');
|
||||
}
|
||||
|
||||
$c('runserverobj',args={'method' : 'get_months', 'docs' : compress_doclist([doc])},callback1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc,self.doclist = doc,doclist
|
||||
|
||||
def get_months(self):
|
||||
month_list = ['January','February','March','April','May','June','July','August','September','October','November','December']
|
||||
idx =1
|
||||
for m in month_list:
|
||||
mnth = addchild(self.doc,'budget_distribution_details','Budget Distribution Detail',1,self.doclist)
|
||||
mnth.month = m or ''
|
||||
mnth.idx = idx
|
||||
idx += 1
|
||||
|
||||
def validate(self):
|
||||
total = 0
|
||||
for d in getlist(self.doclist,'budget_distribution_details'):
|
||||
total = flt(total) + flt(d.percentage_allocation)
|
||||
if total > 100:
|
||||
msgprint("Percentage Allocation should not exceed 100%.")
|
||||
raise Exception
|
||||
elif total < 100:
|
||||
msgprint("Percentage Allocation should not recede 100%.")
|
||||
raise Exception
|
||||
@@ -0,0 +1,166 @@
|
||||
# DocType, Budget Distribution
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-29 18:20:37',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:distribution_id',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'name_case': 'Title Case',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 24
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Budget Distribution',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Budget Distribution',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Budget Distribution
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Budget Distribution'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 2,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 2,
|
||||
'role': 'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'distribution_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Distribution ID',
|
||||
'oldfieldname': 'distribution_id',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'budget_distribution_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 3,
|
||||
'label': 'Budget Distribution Details',
|
||||
'oldfieldname': 'budget_distribution_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Budget Distribution Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 4,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,78 @@
|
||||
# DocType, Budget Distribution Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'BDD/.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Budget Distribution Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, Budget Distribution Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Budget Distribution Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'month',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Month',
|
||||
'oldfieldname': 'month',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 2,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'percentage_allocation',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 2,
|
||||
'label': 'Percentage Allocation',
|
||||
'oldfieldname': 'percentage_allocation',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'aggregate_percentage',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'Aggregate Percentage',
|
||||
'oldfieldname': 'aggregate_percentage',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 2
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/cost_center/__init__.py
Normal file
0
erpnext/accounts/doctype/cost_center/__init__.py
Normal file
39
erpnext/accounts/doctype/cost_center/cost_center.js
Normal file
39
erpnext/accounts/doctype/cost_center/cost_center.js
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
//Account filtering for cost center
|
||||
cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = function(doc) {
|
||||
var mydoc = locals[this.doctype][this.docname];
|
||||
return 'SELECT DISTINCT `tabAccount`.`name`,`tabAccount`.debit_or_credit,`tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.`company` = "' + doc.company_name + '" AND `tabAccount`.docstatus != 2 AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.debit_or_credit = "Debit" AND `tabAccount`.`group_or_ledger` != "Group" AND `tabAccount`.`group_or_ledger` is not NULL AND `tabAccount`.`name` LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['parent_cost_center'].get_query = function(doc){
|
||||
return 'SELECT DISTINCT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Group" AND `tabCost Center`.docstatus != 2 AND `tabCost Center`.company_name="'+ doc.company_name+'" AND `tabCost Center`.company_name is not NULL AND `tabCost Center`.name LIKE "%s" ORDER BY `tabCost Center`.name LIMIT 50';
|
||||
}
|
||||
|
||||
//parent cost center
|
||||
cur_frm.cscript.parent_cost_center = function(doc,cdt,cdn){
|
||||
if(!doc.company_name){
|
||||
alert('Please enter company name first');
|
||||
}
|
||||
}
|
||||
|
||||
//company abbr
|
||||
cur_frm.cscript.company_name = function(doc,cdt,cdn){
|
||||
get_server_fields('get_abbr','','',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
//onload if cost center is group
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
if(!doc.__islocal && doc.docstatus == 0){
|
||||
get_field(doc.doctype,'group_or_ledger',doc.name).permlevel = 1;
|
||||
refresh_field('group_or_ledger');
|
||||
get_field(doc.doctype,'company_name',doc.name).permlevel = 1;
|
||||
refresh_field('company_name');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
68
erpnext/accounts/doctype/cost_center/cost_center.py
Normal file
68
erpnext/accounts/doctype/cost_center/cost_center.py
Normal file
@@ -0,0 +1,68 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
self.nsm_parent_field = 'parent_cost_center'
|
||||
|
||||
def autoname(self):
|
||||
#company_abbr = sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
|
||||
self.doc.name = self.doc.cost_center_name + ' - ' + self.doc.company_abbr
|
||||
|
||||
def get_abbr(self):
|
||||
abbr = sql("select abbr from tabCompany where company_name='%s'"%(self.doc.company_name))[0][0] or ''
|
||||
ret = {
|
||||
'company_abbr' : abbr
|
||||
}
|
||||
return ret
|
||||
|
||||
def validate(self):
|
||||
# Cost Center name must be unique
|
||||
# ---------------------------
|
||||
if (self.doc.__islocal or (not self.doc.name)) and sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
|
||||
msgprint("Cost Center Name already exists, please rename")
|
||||
raise Exception
|
||||
|
||||
check_acc_list = []
|
||||
for d in getlist(self.doclist, 'budget_details'):
|
||||
if [d.account, d.fiscal_year] in check_acc_list:
|
||||
msgprint("Account " + cstr(d.account) + "has been entered more than once for fiscal year " + cstr(d.fiscal_year))
|
||||
raise Exception
|
||||
if [d.account, d.fiscal_year] not in check_acc_list: check_acc_list.append([d.account, d.fiscal_year])
|
||||
|
||||
def on_update(self):
|
||||
# update Node Set Model
|
||||
import webnotes
|
||||
import webnotes.utils.nestedset
|
||||
# update Node Set Model
|
||||
webnotes.utils.nestedset.update_nsm(self)
|
||||
|
||||
def check_if_child_exists(self):
|
||||
return sql("select name from `tabCost Center` where parent_cost_center = %s and docstatus != 2", self.doc.name, debug=0)
|
||||
|
||||
# On Trash
|
||||
# --------
|
||||
def on_trash(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Child exists for this cost center. You can not trash this account.", raise_exception=1)
|
||||
|
||||
# rebuild tree
|
||||
set(self.doc,'old_parent', '')
|
||||
self.update_nsm_model()
|
||||
300
erpnext/accounts/doctype/cost_center/cost_center.txt
Normal file
300
erpnext/accounts/doctype/cost_center/cost_center.txt
Normal file
@@ -0,0 +1,300 @@
|
||||
# DocType, Cost Center
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-29 18:18:55',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308741898',
|
||||
'allow_copy': 1,
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:cost_center_name',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'in_create': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': 'name,parent_cost_center',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 104
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Cost Center',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Cost Center',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Cost Center
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Cost Center'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 1,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 1,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cost_center_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'in_filter': 0,
|
||||
'label': 'Cost Center Name',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'cost_center_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'Select company name first.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'parent_cost_center',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'label': 'Parent Cost Center',
|
||||
'oldfieldname': 'parent_cost_center',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Cost Center',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company_name',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 4,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company_name',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company_abbr',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Company Abbr',
|
||||
'oldfieldname': 'company_abbr',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'group_or_ledger',
|
||||
'fieldtype': 'Select',
|
||||
'hidden': 1,
|
||||
'idx': 6,
|
||||
'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,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'distribution_id',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'label': 'Distribution Id',
|
||||
'oldfieldname': 'distribution_id',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Budget Distribution',
|
||||
'permlevel': 0,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'budget_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 8,
|
||||
'label': 'Budget Details',
|
||||
'oldfieldname': 'budget_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Budget Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'lft',
|
||||
'fieldtype': 'Int',
|
||||
'hidden': 1,
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'lft',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'lft',
|
||||
'oldfieldtype': 'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'rgt',
|
||||
'fieldtype': 'Int',
|
||||
'hidden': 1,
|
||||
'idx': 10,
|
||||
'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
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'old_parent',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'idx': 11,
|
||||
'label': 'old_parent',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'old_parent',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/fiscal_year/__init__.py
Normal file
0
erpnext/accounts/doctype/fiscal_year/__init__.py
Normal file
197
erpnext/accounts/doctype/fiscal_year/fiscal_year.py
Normal file
197
erpnext/accounts/doctype/fiscal_year/fiscal_year.py
Normal file
@@ -0,0 +1,197 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
def repost(self, account = ''):
|
||||
if not self.doc.company:
|
||||
msgprint("Please select company", raise_exception=1)
|
||||
|
||||
if not in_transaction:
|
||||
sql("start transaction")
|
||||
|
||||
self.clear_account_balances(account)
|
||||
self.create_account_balances(account)
|
||||
self.update_opening(account)
|
||||
self.post_entries(account)
|
||||
sql("commit")
|
||||
|
||||
msg_cond = account and " and account: " + account or ""
|
||||
msgprint("Account balance reposted for fiscal year: " + self.doc.name + msg_cond)
|
||||
|
||||
def clear_account_balances(self, account = ''):
|
||||
# balances clear - `tabAccount Balance` for fiscal year
|
||||
cond = account and (" and account = '" + account + "'") or ''
|
||||
sql("update `tabAccount Balance` set opening=0, balance=0, debit=0, credit=0 where fiscal_year=%s %s", (self.doc.name, cond))
|
||||
|
||||
def create_account_balances(self, account = ''):
|
||||
# get periods
|
||||
period_list = self.get_period_list()
|
||||
cnt = 0
|
||||
|
||||
# get accounts
|
||||
al = account and [[account]] or sql("select name from tabAccount")
|
||||
|
||||
for a in al:
|
||||
# check
|
||||
if sql("select count(*) from `tabAccount Balance` where fiscal_year=%s and account=%s", (self.doc.name, a[0]))[0][0] < 13:
|
||||
for p in period_list:
|
||||
# check if missing
|
||||
if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.name)):
|
||||
d = Document('Account Balance')
|
||||
d.account = a[0]
|
||||
d.period = p[0]
|
||||
d.start_date = p[1].strftime('%Y-%m-%d')
|
||||
d.end_date = p[2].strftime('%Y-%m-%d')
|
||||
d.fiscal_year = p[3]
|
||||
d.debit = 0
|
||||
d.credit = 0
|
||||
d.opening = 0
|
||||
d.balance = 0
|
||||
d.save(1)
|
||||
cnt += 1
|
||||
if cnt % 100 == 0:
|
||||
sql("commit")
|
||||
sql("start transaction")
|
||||
return cnt
|
||||
|
||||
# Get periods(month and year)
|
||||
#=================================
|
||||
def get_period_list(self):
|
||||
periods = []
|
||||
pl = sql("SELECT name, start_date, end_date, fiscal_year FROM tabPeriod WHERE fiscal_year = '%s' and period_type in ('Month', 'Year') order by start_date ASC, end_date DESC" % self.doc.name)
|
||||
for p in pl:
|
||||
periods.append([p[0], p[1], p[2], p[3]])
|
||||
return periods
|
||||
|
||||
# ====================================================================================
|
||||
def update_opening(self, account = ''):
|
||||
"""
|
||||
set opening from last year closing
|
||||
|
||||
"""
|
||||
cond = account and (" and t2.name = '" + account + "'") or ''
|
||||
|
||||
abl = sql("select t1.account, t1.balance from `tabAccount Balance` t1, tabAccount t2 where t1.period= '%s' and t2.company= '%s' and ifnull(t2.is_pl_account, 'No') = 'No' and t1.account = t2.name %s for update" % (self.doc.past_year, self.doc.company, cond))
|
||||
|
||||
cnt = 0
|
||||
for ab in abl:
|
||||
if cnt % 100 == 0:
|
||||
sql("commit")
|
||||
sql("start transaction")
|
||||
|
||||
sql("update `tabAccount Balance` set opening=%s where period=%s and account=%s", (ab[1], self.doc.name, ab[0]))
|
||||
sql("update `tabAccount Balance` set balance=%s where fiscal_year=%s and account=%s", (ab[1], self.doc.name, ab[0]))
|
||||
cnt += 1
|
||||
|
||||
return cnt
|
||||
|
||||
def get_account_details(self, account):
|
||||
return sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", account)[0]
|
||||
|
||||
# ====================================================================================
|
||||
def post_entries(self, account = ''):
|
||||
sql("LOCK TABLE `tabGL Entry` WRITE")
|
||||
cond = account and (" and account = '" + account + "'") or ''
|
||||
# post each gl entry (batch or complete)
|
||||
gle = sql("select name, account, debit, credit, is_opening, posting_date from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled,'No')='No' and company=%s %s", (self.doc.name, self.doc.company, cond))
|
||||
account_details = {}
|
||||
|
||||
cnt = 0
|
||||
for entry in gle:
|
||||
# commit in batches of 100
|
||||
if cnt % 100 == 0:
|
||||
sql("commit")
|
||||
sql("start transaction")
|
||||
cnt += 1
|
||||
#print cnt
|
||||
|
||||
if not account_details.has_key(entry[1]):
|
||||
account_details[entry[1]] = self.get_account_details(entry[1])
|
||||
|
||||
det = account_details[entry[1]]
|
||||
diff = flt(entry[2])-flt(entry[3])
|
||||
if det[0]=='Credit': diff = -diff
|
||||
|
||||
# build dict
|
||||
p = {
|
||||
'debit': flt(entry[2])
|
||||
,'credit':flt(entry[3])
|
||||
,'opening': entry[4]=='Yes' and diff or 0
|
||||
|
||||
# end date conditino only if it is not opening
|
||||
,'end_date_condition':(entry[4]!='Yes' and ("and ab.end_date >= '"+entry[5].strftime('%Y-%m-%d')+"'") or '')
|
||||
,'diff': diff
|
||||
,'lft': det[1]
|
||||
,'rgt': det[2]
|
||||
,'posting_date': entry[5]
|
||||
,'fiscal_year': self.doc.name
|
||||
}
|
||||
|
||||
sql("""update `tabAccount Balance` ab, `tabAccount` a
|
||||
set
|
||||
ab.debit = ifnull(ab.debit,0) + %(debit)s
|
||||
,ab.credit = ifnull(ab.credit,0) + %(credit)s
|
||||
,ab.opening = ifnull(ab.opening,0) + %(opening)s
|
||||
,ab.balance = ifnull(ab.balance,0) + %(diff)s
|
||||
where
|
||||
a.lft <= %(lft)s
|
||||
and a.rgt >= %(rgt)s
|
||||
and ab.account = a.name
|
||||
%(end_date_condition)s
|
||||
and ab.fiscal_year = '%(fiscal_year)s' """ % p)
|
||||
|
||||
sql("UNLOCK TABLES")
|
||||
|
||||
|
||||
# Clear PV/RV outstanding
|
||||
# ====================================================================================
|
||||
def clear_outstanding(self):
|
||||
# clear o/s of current year
|
||||
sql("update `tabPayable Voucher` set outstanding_amount = 0 where fiscal_year=%s and company=%s", (self.doc.name, self.doc.company))
|
||||
sql("update `tabReceivable Voucher` set outstanding_amount = 0 where fiscal_year=%s and company=%s", (self.doc.name, self.doc.company))
|
||||
|
||||
# Update Voucher Outstanding
|
||||
def update_voucher_outstanding(self):
|
||||
# Clear outstanding
|
||||
self.clear_outstanding()
|
||||
against_voucher = sql("select against_voucher, against_voucher_type from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled, 'No')='No' and company=%s and ifnull(against_voucher, '') != '' and ifnull(against_voucher_type, '') != '' group by against_voucher, against_voucher_type", (self.doc.name, self.doc.company))
|
||||
for d in against_voucher:
|
||||
# get voucher balance
|
||||
bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled, 'No') = 'No'", (d[0], d[1]))
|
||||
bal = bal and flt(bal[0][0]) or 0.0
|
||||
if d[1] == 'Payable Voucher':
|
||||
bal = -bal
|
||||
# set voucher balance
|
||||
sql("update `tab%s` set outstanding_amount=%s where name='%s'"% (d[1], bal, d[0]))
|
||||
|
||||
# ====================================================================================
|
||||
# Generate periods
|
||||
def create_periods(self):
|
||||
get_obj('Period Control').generate_periods(self.doc.name)
|
||||
|
||||
# on update
|
||||
def on_update(self):
|
||||
if not self.doc.is_fiscal_year_closed:
|
||||
self.is_fiscal_year_closed = 'No'
|
||||
self.doc.save()
|
||||
self.create_periods()
|
||||
self.create_account_balances()
|
||||
209
erpnext/accounts/doctype/fiscal_year/fiscal_year.txt
Normal file
209
erpnext/accounts/doctype/fiscal_year/fiscal_year.txt
Normal file
@@ -0,0 +1,209 @@
|
||||
# DocType, Fiscal Year
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:02',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-03 17:52:39',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1307707462',
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:year',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tabbed',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 54
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Fiscal Year',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Fiscal Year',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Fiscal Year
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Fiscal Year'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Year Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 2,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'year',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Year Name',
|
||||
'oldfieldname': 'year',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'abbreviation',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Abbreviation',
|
||||
'oldfieldname': 'abbreviation',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'year_start_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 5,
|
||||
'label': 'Year Start Date',
|
||||
'oldfieldname': 'year_start_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_fiscal_year_closed',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'label': 'Year Closed',
|
||||
'oldfieldname': 'is_fiscal_year_closed',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nNo\nYes',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': "Click on the button below to reset balances from your previous year's closing and repost your balances. You can use this if your previous year balance sheet has been changed and you wish to update your current accounts.",
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 7,
|
||||
'label': 'Repost Accounts',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'past_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 8,
|
||||
'label': 'Past Year',
|
||||
'oldfieldname': 'past_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'permlevel': 0,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 10,
|
||||
'label': 'Repost Account Balances',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'repost',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 11,
|
||||
'label': 'Repost Voucher Outstanding',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'update_voucher_outstanding',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/form_16a/__init__.py
Normal file
0
erpnext/accounts/doctype/form_16a/__init__.py
Normal file
32
erpnext/accounts/doctype/form_16a/form_16a.js
Normal file
32
erpnext/accounts/doctype/form_16a/form_16a.js
Normal file
@@ -0,0 +1,32 @@
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
if(doc.company)get_server_fields('get_registration_details','','',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
cur_frm.cscript.company = function(doc,cdt,cdn){
|
||||
if(doc.company)get_server_fields('get_registration_details','','',doc,cdt,cdn);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['party_name'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.master_type = "Supplier" AND `tabAccount`.docstatus != 2 AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.cscript.party_name = function(doc,cdt,cdn){
|
||||
if(doc.party_name)get_server_fields('get_party_det','','',doc,cdt,cdn);
|
||||
}
|
||||
|
||||
// Date validation
|
||||
cur_frm.cscript.to_date = function(doc,cdt,cdn){
|
||||
if((doc.from_date) && (doc.to_date) && (doc.from_date>doc.to_date)){
|
||||
alert("From date can not be greater than To date");
|
||||
doc.to_date='';
|
||||
refresh_field('to_date');
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.from_date = function(doc,cdt,cdn){
|
||||
if((doc.from_date) && (doc.to_date) && (doc.from_date>doc.to_date)){
|
||||
alert("From date can not be greater than To date");
|
||||
doc.from_date='';
|
||||
refresh_field('from_date');
|
||||
}
|
||||
}
|
||||
109
erpnext/accounts/doctype/form_16a/form_16a.py
Normal file
109
erpnext/accounts/doctype/form_16a/form_16a.py
Normal file
@@ -0,0 +1,109 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType(TransactionBase):
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname('Form 16A' + '/.#####')
|
||||
|
||||
# Get pan no and tan no from company
|
||||
#-------------------------------------
|
||||
def get_registration_details(self):
|
||||
comp_det=sql("Select address,registration_details from `tabCompany` where name = '%s'"%(self.doc.company))
|
||||
if not comp_det:
|
||||
msgprint("Registration Details is not mentioned in comapny")
|
||||
ret = {
|
||||
'company_address':'',
|
||||
'registration_details': ''
|
||||
}
|
||||
else:
|
||||
ret = {
|
||||
'company_address': cstr(comp_det[0][0]),
|
||||
'registration_details': cstr(comp_det[0][1])
|
||||
}
|
||||
return ret
|
||||
|
||||
# Get party details
|
||||
#------------------
|
||||
def get_party_det(self):
|
||||
party_det=sql("select master_type, master_name from `tabAccount` where name='%s'" % self.doc.party_name)
|
||||
if party_det and party_det[0][0]=='Supplier':
|
||||
try:
|
||||
rec = sql("select name, address_line1, address_line2, city, country, pincode, state from `tabAddress` where supplier = '%s' and docstatus != 2 order by is_primary_address desc limit 1" %(party_det[0][1]), as_dict = 1)
|
||||
address_display = cstr((rec[0]['address_line1'] and rec[0]['address_line1'] or '')) + cstr((rec[0]['address_line2'] and '\n' + rec[0]['address_line2'] or '')) + cstr((rec[0]['city'] and '\n'+rec[0]['city'] or '')) + cstr((rec[0]['pincode'] and '\n' + rec[0]['pincode'] or '')) + cstr((rec[0]['state'] and '\n'+rec[0]['state'] or '')) + cstr((rec[0]['country'] and '\n'+rec[0]['country'] or ''))
|
||||
except:
|
||||
address_display = ''
|
||||
|
||||
ret = {
|
||||
'party_address': cstr(address_display)
|
||||
}
|
||||
|
||||
return ret
|
||||
|
||||
# Get TDS Return acknowledgement
|
||||
#-------------------------------
|
||||
def get_return_ack_details(self):
|
||||
self.doc.clear_table(self.doclist, 'form_16A_ack_details')
|
||||
if not (self.doc.from_date and self.doc.to_date):
|
||||
msgprint("Please enter From Date, To Date")
|
||||
else:
|
||||
ack = sql("select quarter, acknowledgement_no from `tabTDS Return Acknowledgement` where date_of_receipt>='%s' and date_of_receipt<='%s' and tds_category = '%s' order by date_of_receipt ASC" % (self.doc.from_date, self.doc.to_date, self.doc.tds_category))
|
||||
for d in ack:
|
||||
ch = addchild(self.doc, 'form_16A_ack_details', 'Form 16A Ack Detail', 1, self.doclist)
|
||||
ch.quarter = d[0]
|
||||
ch.ack_no = d[1]
|
||||
|
||||
# Get tds payment details
|
||||
#-------------------------------
|
||||
def get_tds(self):
|
||||
self.doc.clear_table(self.doclist,'form_16A_tax_details')
|
||||
import datetime
|
||||
if self.doc.from_date and self.doc.to_date and self.doc.tds_category:
|
||||
tot=0.0
|
||||
party_tds_list=sql("select t2.amount_paid,t2.date_of_payment,t2.tds_amount,t2.cess_on_tds, t2.total_tax_amount, t1.cheque_no, t1.bsr_code, t1.date_of_receipt, t1.challan_id from `tabTDS Payment` t1, `tabTDS Payment Detail` t2 where t1.tds_category='%s' and t2.party_name='%s' and t1.from_date >= '%s' and t1.to_date <= '%s' and t2.total_tax_amount>0 and t2.parent=t1.name and t1.docstatus=1" % (self.doc.tds_category,self.doc.party_name,self.doc.from_date,self.doc.to_date))
|
||||
for s in party_tds_list:
|
||||
child = addchild(self.doc, 'form_16A_tax_details', 'Form 16A Tax Detail', 1, self.doclist)
|
||||
child.amount_paid = s and flt(s[0]) or ''
|
||||
child.date_of_payment =s and s[1].strftime('%Y-%m-%d') or ''
|
||||
child.tds_main = s and flt(s[2]) or ''
|
||||
child.surcharge = 0
|
||||
child.cess_on_tds = s and flt(s[3]) or ''
|
||||
child.total_tax_deposited = s and flt(s[4]) or ''
|
||||
child.cheque_no = s and s[5] or ''
|
||||
child.bsr_code = s and s[6] or ''
|
||||
child.tax_deposited_date = s and s[7].strftime('%Y-%m-%d') or ''
|
||||
child.challan_no = s and s[8] or ''
|
||||
tot=flt(tot)+flt(s[4])
|
||||
self.doc.total_amount = flt(tot)
|
||||
else:
|
||||
msgprint("Plaese enter from date, to date and TDS category")
|
||||
|
||||
|
||||
# validate
|
||||
#----------------
|
||||
def validate(self):
|
||||
tot=0.0
|
||||
for d in getlist(self.doclist,'form_16A_tax_details'):
|
||||
tot=flt(tot)+flt(d.total_tax_deposited)
|
||||
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
self.doc.total_amount = flt(tot)
|
||||
self.doc.in_words = get_obj('Sales Common').get_total_in_words(dcc, self.doc.total_amount)
|
||||
477
erpnext/accounts/doctype/form_16a/form_16a.txt
Normal file
477
erpnext/accounts/doctype/form_16a/form_16a.txt
Normal file
@@ -0,0 +1,477 @@
|
||||
# DocType, Form 16A
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-27 15:56:52',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-15 13:07:17',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Form 16A',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308123438',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 0,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 75
|
||||
},
|
||||
|
||||
# These values are common for all DocFormat
|
||||
{
|
||||
'doctype': 'DocFormat',
|
||||
'format': 'Form 16A Print Format',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Form 16A',
|
||||
'parentfield': 'formats',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Form 16A',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Form 16A
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Form 16A'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocFormat
|
||||
{
|
||||
'doctype': 'DocFormat'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Basic Info',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 2,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 3,
|
||||
'label': 'From Date',
|
||||
'oldfieldname': 'from_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 4,
|
||||
'label': 'To Date',
|
||||
'oldfieldname': 'to_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tds_category',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 5,
|
||||
'in_filter': 1,
|
||||
'label': 'TDS Category',
|
||||
'oldfieldname': 'tds_category',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'TDS Category',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'party_name',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': 0,
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Party Name',
|
||||
'oldfieldname': 'party_name',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'party_address',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 7,
|
||||
'label': 'Address',
|
||||
'oldfieldname': 'party_address',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'pan_number',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 0,
|
||||
'idx': 8,
|
||||
'label': 'PAN No',
|
||||
'oldfieldname': 'pan_number',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 9,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 10,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 11,
|
||||
'in_filter': 1,
|
||||
'label': 'Company ',
|
||||
'oldfieldname': 'company',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company_address',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 12,
|
||||
'label': 'Company Address',
|
||||
'oldfieldname': 'company_address',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'registration_details',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 13,
|
||||
'label': 'Registration Details',
|
||||
'oldfieldname': 'registration_details',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 14,
|
||||
'label': 'Return Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 15,
|
||||
'label': 'Get Return Details',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'get_return_ack_details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'form_16A_ack_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 16,
|
||||
'label': 'Form 16A Ack Details',
|
||||
'oldfieldname': 'form_16A_ack_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Form 16A Ack Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 17,
|
||||
'label': 'Payment Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 18,
|
||||
'label': 'Get TDS',
|
||||
'oldfieldtype': 'Button',
|
||||
'options': 'get_tds',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'form_16A_tax_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 19,
|
||||
'label': 'Tax Details',
|
||||
'oldfieldname': 'form_16A_tax_details',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Form 16A Tax Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 20,
|
||||
'label': 'Total Amount',
|
||||
'oldfieldname': 'total_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'in_words',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 21,
|
||||
'label': 'In Words',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 22,
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 23,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'place',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 24,
|
||||
'label': 'Place',
|
||||
'oldfieldname': 'place',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'dt',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 25,
|
||||
'label': 'Date',
|
||||
'oldfieldname': 'dt',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 26,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'full_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 27,
|
||||
'label': 'Full Name',
|
||||
'oldfieldname': 'full_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 28,
|
||||
'label': 'Designation',
|
||||
'oldfieldname': 'designation',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,63 @@
|
||||
# DocType, Form 16A Ack Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:02',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Form 16A Ack Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Form 16A Ack Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Form 16A Ack Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'quarter',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 1,
|
||||
'label': 'Quarter',
|
||||
'oldfieldname': 'quarter',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nApr-Jun\nJul-Sept\nOct-Dec\nJan-Mar'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'ack_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Acknowledgement No.',
|
||||
'oldfieldname': 'ack_no',
|
||||
'oldfieldtype': 'Data'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,150 @@
|
||||
# DocType, Form 16A Tax Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:02',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-27 16:53:54',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Form 16A Tax Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Form 16A Tax Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Form 16A Tax Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amount_paid',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 1,
|
||||
'label': 'Amount paid / credited',
|
||||
'oldfieldname': 'amount_paid',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'date_of_payment',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Date of payment / credit',
|
||||
'oldfieldname': 'date_of_payment',
|
||||
'oldfieldtype': 'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tds_main',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 3,
|
||||
'label': 'TDS(Main)',
|
||||
'oldfieldname': 'tds_main',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'surcharge',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Surcharge',
|
||||
'oldfieldname': 'surcharge',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cess_on_tds',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Cess on TDS',
|
||||
'oldfieldname': 'cess_on_tds',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_tax_deposited',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 8,
|
||||
'label': 'Total Tax Deposited',
|
||||
'oldfieldname': 'total_tax_deposited',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cheque_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 9,
|
||||
'label': 'Cheque / DD No.',
|
||||
'oldfieldname': 'cheque_no',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'bsr_code',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 10,
|
||||
'label': 'BSR Code',
|
||||
'oldfieldname': 'bsr_code',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tax_deposited_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 11,
|
||||
'label': 'Tax Deposited Date',
|
||||
'oldfieldname': 'tax_deposited_date',
|
||||
'oldfieldtype': 'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'challan_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 12,
|
||||
'label': 'Challan No.',
|
||||
'oldfieldname': 'challan_no',
|
||||
'oldfieldtype': 'Data'
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/gl_control/__init__.py
Normal file
0
erpnext/accounts/doctype/gl_control/__init__.py
Normal file
367
erpnext/accounts/doctype/gl_control/gl_control.js
Normal file
367
erpnext/accounts/doctype/gl_control/gl_control.js
Normal file
@@ -0,0 +1,367 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
self.entries = []
|
||||
|
||||
# Get Company List
|
||||
# ----------------
|
||||
def get_companies(self,arg=''):
|
||||
d = get_defaults()
|
||||
ret = sql("select name, abbr from tabCompany where docstatus != 2")
|
||||
pl = {}
|
||||
for r in ret:
|
||||
inc = get_value('Account','Income - '+r[1], 'balance')
|
||||
exp = get_value('Account','Expenses - '+r[1], 'balance')
|
||||
pl[r[0]] = flt(flt(inc) - flt(exp))
|
||||
return {'cl':[r[0] for r in ret], 'pl':pl}
|
||||
|
||||
# Get current balance
|
||||
# --------------------
|
||||
def get_bal(self,arg):
|
||||
ac, fy = arg.split('~~~')
|
||||
det = sql("select t1.balance, t2.debit_or_credit from `tabAccount Balance` t1, `tabAccount` t2 where t1.period = %s and t2.name=%s and t1.parent = t2.name", (fy, ac))
|
||||
bal = det and flt(det[0][0]) or 0
|
||||
dr_or_cr = det and flt(det[0][1]) or ''
|
||||
return fmt_money(bal) + ' ' + dr_or_cr
|
||||
|
||||
def get_period_balance(self,arg):
|
||||
acc, f, t = arg.split('~~~')
|
||||
c, fy = '', get_defaults()['fiscal_year']
|
||||
|
||||
det = sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", acc)
|
||||
if f: c += (' and t1.posting_date >= "%s"' % f)
|
||||
if t: c += (' and t1.posting_date <= "%s"' % t)
|
||||
bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1 where t1.account='%s' and ifnull(is_opening, 'No') = 'No' %s" % (acc, c))
|
||||
bal = bal and flt(bal[0][0]) or 0
|
||||
|
||||
if det[0][0] != 'Debit':
|
||||
bal = (-1) * bal
|
||||
|
||||
# add opening for balance sheet accounts
|
||||
if det[0][3] == 'No':
|
||||
opening = flt(sql("select opening from `tabAccount Balance` where parent=%s and period=%s", (acc, fy))[0][0])
|
||||
bal = bal + opening
|
||||
|
||||
return flt(bal)
|
||||
|
||||
|
||||
def get_period_difference(self,arg, cost_center =''):
|
||||
# used in General Ledger Page Report
|
||||
# used for Budget where cost center passed as extra argument
|
||||
acc, f, t = arg.split('~~~')
|
||||
c, fy = '', get_defaults()['fiscal_year']
|
||||
|
||||
det = sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", acc)
|
||||
if f: c += (' and t1.posting_date >= "%s"' % f)
|
||||
if t: c += (' and t1.posting_date <= "%s"' % t)
|
||||
if cost_center: c += (' and t1.cost_center = "%s"' % cost_center)
|
||||
bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1 where t1.account='%s' %s" % (acc, c))
|
||||
bal = bal and flt(bal[0][0]) or 0
|
||||
|
||||
if det[0][0] != 'Debit':
|
||||
bal = (-1) * bal
|
||||
|
||||
return flt(bal)
|
||||
|
||||
# Get Children (for tree)
|
||||
# -----------------------
|
||||
def get_cl(self, arg):
|
||||
fy = get_defaults()['fiscal_year']
|
||||
parent, parent_acc_name, company, type = arg.split(',')
|
||||
|
||||
# get children account details
|
||||
if type=='Account':
|
||||
if parent=='Root':
|
||||
cl = sql("select t1.name, t1.group_or_ledger, t1.debit_or_credit, t2.balance, t1.account_name from tabAccount t1, `tabAccount Balance` t2 where t1.parent_account is NULL or t1.parent_account='' and t1.docstatus != 2 and t1.company=%s and t1.name = t2.parent and t2.period = %s order by t1.name asc", (company, fy),as_dict=1)
|
||||
else:
|
||||
cl = sql("select t1.name, t1.group_or_ledger, t1.debit_or_credit, t2.balance, t1.account_name from tabAccount t1, `tabAccount Balance` t2 where t1.parent_account=%s and t1.docstatus != 2 and t1.company=%s and t1.name = t2.parent and t2.period = %s order by t1.name asc",(parent, company, fy) ,as_dict=1)
|
||||
|
||||
# remove Decimals
|
||||
for c in cl: c['balance'] = flt(c['balance'])
|
||||
|
||||
# get children cost center details
|
||||
elif type=='Cost Center':
|
||||
if parent=='Root':
|
||||
cl = sql("select name,group_or_ledger, cost_center_name from `tabCost Center` where parent_cost_center is NULL or parent_cost_center='' and docstatus != 2 and company_name=%s order by name asc",(company),as_dict=1)
|
||||
else:
|
||||
cl = sql("select name,group_or_ledger,cost_center_name from `tabCost Center` where parent_cost_center=%s and docstatus != 2 and company_name=%s order by name asc",(parent,company),as_dict=1)
|
||||
|
||||
return {'parent':parent, 'parent_acc_name':parent_acc_name, 'cl':cl}
|
||||
|
||||
# Add a new account
|
||||
# -----------------
|
||||
def add_ac(self,arg):
|
||||
arg = eval(arg)
|
||||
ac = Document('Account')
|
||||
for d in arg.keys():
|
||||
ac.fields[d] = arg[d]
|
||||
ac.old_parent = ''
|
||||
ac_obj = get_obj(doc=ac)
|
||||
ac_obj.validate()
|
||||
ac_obj.doc.save(1)
|
||||
ac_obj.on_update()
|
||||
|
||||
return ac_obj.doc.name
|
||||
|
||||
# Add a new cost center
|
||||
#----------------------
|
||||
def add_cc(self,arg):
|
||||
arg = eval(arg)
|
||||
cc = Document('Cost Center')
|
||||
# map fields
|
||||
for d in arg.keys():
|
||||
cc.fields[d] = arg[d]
|
||||
# map company abbr
|
||||
other_info = sql("select company_abbr from `tabCost Center` where name='%s'"%arg['parent_cost_center'])
|
||||
cc.company_abbr = other_info and other_info[0][0] or arg['company_abbr']
|
||||
|
||||
cc_obj = get_obj(doc=cc)
|
||||
cc_obj.validate()
|
||||
cc_obj.doc.save(1)
|
||||
cc_obj.on_update()
|
||||
|
||||
return cc_obj.doc.name
|
||||
|
||||
|
||||
|
||||
# Get field values from the voucher
|
||||
#------------------------------------------
|
||||
def get_val(self, src, d, parent=None):
|
||||
if not src:
|
||||
return None
|
||||
if src.startswith('parent:'):
|
||||
return parent.fields[src.split(':')[1]]
|
||||
elif src.startswith('value:'):
|
||||
return eval(src.split(':')[1])
|
||||
elif src:
|
||||
return d.fields.get(src)
|
||||
|
||||
def check_if_in_list(self, le):
|
||||
for e in self.entries:
|
||||
if e.account == le.account and (cstr(e.against_voucher)==cstr(le.against_voucher)) and (cstr(e.against_voucher_type)==cstr(le.against_voucher_type)) and (cstr(e.cost_center)==cstr(le.cost_center)):
|
||||
return [e]
|
||||
return 0
|
||||
|
||||
# Make a dictionary(le) for every gl entry and append to a list(self.entries)
|
||||
#----------------------------------------------------------------------------
|
||||
def make_single_entry(self,parent,d,le_map,cancel):
|
||||
if self.get_val(le_map['account'], d, parent) and (self.get_val(le_map['debit'], d, parent) or self.get_val(le_map['credit'], d, parent)):
|
||||
flist = ['account','cost_center','against','debit','credit','remarks','voucher_type','voucher_no','transaction_date','posting_date','fiscal_year','against_voucher','against_voucher_type','company','is_opening', 'aging_date']
|
||||
|
||||
# Check budget before gl entry
|
||||
#check budget only if account is expense account
|
||||
is_expense_acct = sql("select name from tabAccount where is_pl_account='Yes' and debit_or_credit='Debit' and name=%s",self.get_val(le_map['account'], d, parent))
|
||||
if is_expense_acct and self.get_val(le_map['cost_center'], d, parent):
|
||||
get_obj('Budget Control').check_budget([self.get_val(le_map[k], d, parent) for k in flist if k in ['account','cost_center','debit','credit','posting_date','fiscal_year','company']],cancel)
|
||||
|
||||
# Create new GL entry object and map values
|
||||
le = Document('GL Entry')
|
||||
for k in flist:
|
||||
le.fields[k] = self.get_val(le_map[k], d, parent)
|
||||
|
||||
# if there is already an entry in this account then just add it to that entry
|
||||
same_head = self.check_if_in_list(le)
|
||||
if same_head:
|
||||
same_head = same_head[0]
|
||||
same_head.debit = flt(same_head.debit) + flt(le.debit)
|
||||
same_head.credit = flt(same_head.credit) + flt(le.credit)
|
||||
else:
|
||||
self.entries.append(le)
|
||||
|
||||
# Save GL Entries
|
||||
# ----------------
|
||||
def save_entries(self, cancel, adv_adj):
|
||||
for le in self.entries:
|
||||
# cancel
|
||||
if cancel:
|
||||
tmp=le.debit
|
||||
le.debit, le.credit = le.credit, tmp
|
||||
|
||||
le_obj = get_obj(doc=le)
|
||||
# validate except on_cancel
|
||||
if not cancel:
|
||||
le_obj.validate()
|
||||
|
||||
# save
|
||||
le.save(1)
|
||||
le_obj.on_update(adv_adj)
|
||||
|
||||
# update total debit / credit
|
||||
self.td += flt(le.debit)
|
||||
self.tc += flt(le.credit)
|
||||
|
||||
# Make Multiple Entries
|
||||
# ---------------------
|
||||
def make_gl_entries(self, doc, doclist, cancel=0, adv_adj = 0):
|
||||
# get entries
|
||||
le_map_list = sql("select * from `tabGL Mapper Detail` where parent = %s", doc.doctype, as_dict=1)
|
||||
|
||||
self.td, self.tc = 0.0, 0.0
|
||||
|
||||
for le_map in le_map_list:
|
||||
if le_map['table_field']:
|
||||
for d in getlist(doclist,le_map['table_field']):
|
||||
# purchase_tax_details is the table of other charges in purchase cycle
|
||||
if le_map['table_field'] != 'purchase_tax_details' or (le_map['table_field'] == 'purchase_tax_details' and d.fields.get('category') != 'For Valuation'):
|
||||
self.make_single_entry(doc,d,le_map,cancel)
|
||||
else:
|
||||
self.make_single_entry(None,doc,le_map,cancel)
|
||||
|
||||
# save entries
|
||||
self.save_entries(cancel,adv_adj)
|
||||
|
||||
# check total debit / credit
|
||||
# Due to old wrong entries (total debit != total credit) some voucher could be cancelled
|
||||
if abs(self.td - self.tc) > 0.001 and not cancel:
|
||||
msgprint("Debit and Credit not equal for this voucher: Diff (Debit) is %s" % (self.td-self.tc))
|
||||
raise Exception
|
||||
|
||||
# set as cancelled
|
||||
if cancel:
|
||||
vt, vn = self.get_val(le_map['voucher_type'], doc, doc), self.get_val(le_map['voucher_no'], doc, doc)
|
||||
sql("update `tabGL Entry` set is_cancelled='Yes' where voucher_type=%s and voucher_no=%s", (vt, vn))
|
||||
|
||||
# Get account balance on any date
|
||||
# -------------------------------
|
||||
|
||||
def get_as_on_balance(self, account_name, fiscal_year, as_on, credit_or_debit, is_pl, lft, rgt, ysd):
|
||||
# get total transaction value for the current year
|
||||
bal = bal = sql("select SUM(t1.debit), SUM(t1.credit) from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= %s AND t1.posting_date <= %s and t1.is_opening = 'No' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s and t1.is_cancelled = 'No'", (ysd,as_on,lft, rgt))
|
||||
bal = bal and (flt(bal[0][0]) - flt(bal[0][1])) or 0
|
||||
|
||||
if credit_or_debit == 'Credit' and bal:
|
||||
bal = -bal
|
||||
|
||||
# Add opening balance with the transaction value
|
||||
if is_pl=='No':
|
||||
op = sql("select opening from `tabAccount Balance` where parent=%s and period=%s", (account_name, fiscal_year))
|
||||
op = op and op[0][0] or 0
|
||||
bal += flt(op)
|
||||
return flt(bal)
|
||||
|
||||
# ADVANCE ALLOCATION
|
||||
#-------------------
|
||||
def get_advances(self, obj, account_head, table_name,table_field_name, dr_or_cr):
|
||||
jv_detail = sql("select t1.name, t1.remark, t2.%s, t2.name, t1.ded_amount from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher is null or t2.against_voucher = '') and (t2.against_invoice is null or t2.against_invoice = '') and t2.account = '%s' and t2.is_advance = 'Yes' and t1.docstatus = 1 order by t1.voucher_date " % (dr_or_cr,account_head))
|
||||
# clear advance table
|
||||
obj.doc.clear_table(obj.doclist,table_field_name)
|
||||
# Create advance table
|
||||
for d in jv_detail:
|
||||
add = addchild(obj.doc, table_field_name, table_name, 1, obj.doclist)
|
||||
add.journal_voucher = d[0]
|
||||
add.jv_detail_no = d[3]
|
||||
add.remarks = d[1]
|
||||
add.advance_amount = flt(d[2])
|
||||
add.allocate_amount = 0
|
||||
if table_name == 'Advance Allocation Detail':
|
||||
add.tds_amount = flt(d[4])
|
||||
|
||||
# Clear rows which is not adjusted
|
||||
#-------------------------------------
|
||||
def clear_advances(self, obj,table_name,table_field_name):
|
||||
for d in getlist(obj.doclist,table_field_name):
|
||||
if not flt(d.allocated_amount):
|
||||
sql("update `tab%s` set parent = '' where name = '%s' and parent = '%s'" % (table_name, d.name, d.parent))
|
||||
d.parent = ''
|
||||
|
||||
# Update aginst document in journal voucher
|
||||
#------------------------------------------
|
||||
def update_against_document_in_jv(self, obj, table_field_name, against_document_no, against_document_doctype, account_head, dr_or_cr,doctype):
|
||||
for d in getlist(obj.doclist, table_field_name):
|
||||
self.validate_jv_entry(d, account_head, dr_or_cr)
|
||||
if flt(d.advance_amount) == flt(d.allocated_amount):
|
||||
# cancel JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children=1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj =1)
|
||||
|
||||
# update ref in JV Detail
|
||||
sql("update `tabJournal Voucher Detail` set %s = '%s' where name = '%s'" % (doctype=='Payable Voucher' and 'against_voucher' or 'against_invoice', cstr(against_document_no), d.jv_detail_no))
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children =1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj =1)
|
||||
|
||||
elif flt(d.advance_amount) > flt(d.allocated_amount):
|
||||
# cancel JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children=1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj = 1)
|
||||
|
||||
# add extra entries
|
||||
self.add_extra_entry(jv_obj, d.journal_voucher, d.jv_detail_no, flt(d.allocated_amount), account_head, doctype, dr_or_cr, against_document_no)
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children =1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj = 1)
|
||||
else:
|
||||
msgprint("Allocation amount cannot be greater than advance amount")
|
||||
raise Exception
|
||||
|
||||
# Add extra row in jv detail for unadjusted amount
|
||||
#--------------------------------------------------
|
||||
def add_extra_entry(self,jv_obj,jv,jv_detail_no, allocate, account_head, doctype, dr_or_cr, against_document_no):
|
||||
# get old entry details
|
||||
|
||||
jvd = sql("select %s, cost_center, balance, against_account from `tabJournal Voucher Detail` where name = '%s'" % (dr_or_cr,jv_detail_no))
|
||||
advance = jvd and flt(jvd[0][0]) or 0
|
||||
balance = flt(advance) - flt(allocate)
|
||||
|
||||
# update old entry
|
||||
sql("update `tabJournal Voucher Detail` set %s = '%s', %s = '%s' where name = '%s'" % (dr_or_cr, flt(allocate), doctype == "Payable Voucher" and 'against_voucher' or 'against_invoice',cstr(against_document_no), jv_detail_no))
|
||||
|
||||
# new entry with balance amount
|
||||
add = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', 1, jv_obj.doclist)
|
||||
add.account = account_head
|
||||
add.cost_center = cstr(jvd[0][1])
|
||||
add.balance = cstr(jvd[0][2])
|
||||
add.fields[dr_or_cr] = balance
|
||||
add.against_account = cstr(jvd[0][3])
|
||||
add.is_advance = 'Yes'
|
||||
add.save(1)
|
||||
|
||||
# check if advance entries are still valid
|
||||
# ----------------------------------------
|
||||
def validate_jv_entry(self, d, account_head, dr_or_cr):
|
||||
# 1. check if there is already a voucher reference
|
||||
# 2. check if amount is same
|
||||
# 3. check if is_advance is 'Yes'
|
||||
# 4. check if jv is submitted
|
||||
ret = sql("select t2.%s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher = '' || t2.against_voucher is null) and (t2.against_invoice = '' || t2.against_invoice is null) and t2.account = '%s' and t1.name = '%s' and t2.name = '%s' and t2.is_advance = 'Yes' and t1.docstatus=1 and t2.%s = %s" % ( dr_or_cr, account_head, d.journal_voucher, d.jv_detail_no, dr_or_cr, d.advance_amount))
|
||||
if (not ret):
|
||||
msgprint("Please click on 'Get Advances Paid' button as the advance entries have been changed.")
|
||||
raise Exception
|
||||
return
|
||||
|
||||
##############################################################################
|
||||
# Repair Outstanding Amount
|
||||
##############################################################################
|
||||
def repair_voucher_outstanding(self, voucher_obj):
|
||||
msg = []
|
||||
|
||||
# Get Balance from GL Entries
|
||||
bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s", (voucher_obj.doc.name , voucher_obj.doc.doctype))
|
||||
bal = bal and flt(bal[0][0]) or 0.0
|
||||
if cstr(voucher_obj.doc.doctype) == 'Payable Voucher':
|
||||
bal = -bal
|
||||
|
||||
# Check outstanding Amount
|
||||
if flt(voucher_obj.doc.outstanding_amount) != flt(bal):
|
||||
msgprint('<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>' % (voucher_obj.doc.doctype, voucher_obj.doc.name, voucher_obj.doc.outstanding_amount, bal))
|
||||
msg.append('<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>' % (voucher_obj.doc.doctype, voucher_obj.doc.name, voucher_obj.doc.outstanding_amount, bal))
|
||||
|
||||
# set voucher balance
|
||||
#sql("update `tab%s` set outstanding_amount=%s where name='%s'" % (voucher_obj.doc.doctype, bal, voucher_obj.doc.name))
|
||||
set(voucher_obj.doc, 'outstanding_amount', flt(bal))
|
||||
|
||||
# Send Mail
|
||||
if msg:
|
||||
email_msg = """ Dear Administrator,
|
||||
|
||||
In Account := %s User := %s has Repaired Outstanding Amount For %s : %s and following was found:-
|
||||
|
||||
%s
|
||||
|
||||
""" % (get_value('Control Panel', None,'account_id'), session['user'], voucher_obj.doc.doctype, voucher_obj.doc.name, '\n'.join(msg))
|
||||
|
||||
sendmail(['jai@webnotestech.com'], subject='Repair Outstanding Amount', parts = [('text/plain', email_msg)])
|
||||
# Acknowledge User
|
||||
msgprint(cstr(voucher_obj.doc.doctype) + " : " + cstr(voucher_obj.doc.name) + " has been checked" + cstr(msg and " and repaired successfully." or ". No changes Found."))
|
||||
428
erpnext/accounts/doctype/gl_control/gl_control.py
Normal file
428
erpnext/accounts/doctype/gl_control/gl_control.py
Normal file
@@ -0,0 +1,428 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
self.entries = []
|
||||
|
||||
# Get Company List
|
||||
# ----------------
|
||||
def get_companies(self,arg=''):
|
||||
#d = get_defaults()
|
||||
ret = sql("select name, abbr from tabCompany where docstatus != 2")
|
||||
#pl = {}
|
||||
#for r in ret:
|
||||
# inc = get_value('Account','Income - '+r[1], 'balance')
|
||||
# exp = get_value('Account','Expenses - '+r[1], 'balance')
|
||||
# pl[r[0]] = flt(flt(inc) - flt(exp))
|
||||
return {'cl':[r[0] for r in ret]}#, 'pl':pl}
|
||||
|
||||
def get_company_currency(self,arg=''):
|
||||
dcc = TransactionBase().get_company_currency(arg)
|
||||
return dcc
|
||||
|
||||
# Get current balance
|
||||
# --------------------
|
||||
def get_bal(self,arg):
|
||||
ac, fy = arg.split('~~~')
|
||||
det = sql("select t1.balance, t2.debit_or_credit from `tabAccount Balance` t1, `tabAccount` t2 where t1.period = %s and t2.name=%s and t1.account = t2.name", (fy, ac))
|
||||
bal = det and flt(det[0][0]) or 0
|
||||
dr_or_cr = det and flt(det[0][1]) or ''
|
||||
return fmt_money(bal) + ' ' + dr_or_cr
|
||||
|
||||
def get_period_balance(self,arg):
|
||||
acc, f, t = arg.split('~~~')
|
||||
c, fy = '', get_defaults()['fiscal_year']
|
||||
|
||||
det = sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", acc)
|
||||
if f: c += (' and t1.posting_date >= "%s"' % f)
|
||||
if t: c += (' and t1.posting_date <= "%s"' % t)
|
||||
bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1 where t1.account='%s' and ifnull(is_opening, 'No') = 'No' %s" % (acc, c))
|
||||
bal = bal and flt(bal[0][0]) or 0
|
||||
|
||||
if det[0][0] != 'Debit':
|
||||
bal = (-1) * bal
|
||||
|
||||
# add opening for balance sheet accounts
|
||||
if det[0][3] == 'No':
|
||||
opening = flt(sql("select opening from `tabAccount Balance` where account=%s and period=%s", (acc, fy))[0][0])
|
||||
bal = bal + opening
|
||||
|
||||
return flt(bal)
|
||||
|
||||
|
||||
def get_period_difference(self,arg, cost_center =''):
|
||||
# used in General Ledger Page Report
|
||||
# used for Budget where cost center passed as extra argument
|
||||
acc, f, t = arg.split('~~~')
|
||||
c, fy = '', get_defaults()['fiscal_year']
|
||||
|
||||
det = sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", acc)
|
||||
if f: c += (' and t1.posting_date >= "%s"' % f)
|
||||
if t: c += (' and t1.posting_date <= "%s"' % t)
|
||||
if cost_center: c += (' and t1.cost_center = "%s"' % cost_center)
|
||||
bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1 where t1.account='%s' %s" % (acc, c))
|
||||
bal = bal and flt(bal[0][0]) or 0
|
||||
|
||||
if det[0][0] != 'Debit':
|
||||
bal = (-1) * bal
|
||||
|
||||
return flt(bal)
|
||||
|
||||
# Get Children (for tree)
|
||||
# -----------------------
|
||||
def get_cl(self, arg):
|
||||
|
||||
fy = get_defaults()['fiscal_year']
|
||||
parent, parent_acc_name, company, type = arg.split(',')
|
||||
|
||||
# get children account details
|
||||
if type=='Account':
|
||||
|
||||
if parent=='Root Node':
|
||||
|
||||
cl = sql("select t1.name, t1.group_or_ledger, t1.debit_or_credit, t2.balance, t1.account_name from tabAccount t1, `tabAccount Balance` t2 where ifnull(t1.parent_account, '') = '' and t1.docstatus != 2 and t1.company=%s and t1.name = t2.account and t2.period = %s order by t1.name asc", (company, fy),as_dict=1)
|
||||
else:
|
||||
cl = sql("select t1.name, t1.group_or_ledger, t1.debit_or_credit, t2.balance, t1.account_name from tabAccount t1, `tabAccount Balance` t2 where ifnull(t1.parent_account, '')=%s and t1.docstatus != 2 and t1.company=%s and t1.name = t2.account and t2.period = %s order by t1.name asc",(parent, company, fy) ,as_dict=1)
|
||||
|
||||
# remove Decimals
|
||||
for c in cl: c['balance'] = flt(c['balance'])
|
||||
|
||||
# get children cost center details
|
||||
elif type=='Cost Center':
|
||||
if parent=='Root Node':
|
||||
cl = sql("select name,group_or_ledger, cost_center_name from `tabCost Center` where ifnull(parent_cost_center, '')='' and docstatus != 2 and company_name=%s order by name asc",(company),as_dict=1)
|
||||
else:
|
||||
cl = sql("select name,group_or_ledger,cost_center_name from `tabCost Center` where ifnull(parent_cost_center, '')=%s and docstatus != 2 and company_name=%s order by name asc",(parent,company),as_dict=1)
|
||||
return {'parent':parent, 'parent_acc_name':parent_acc_name, 'cl':cl}
|
||||
|
||||
# Add a new account
|
||||
# -----------------
|
||||
def add_ac(self,arg):
|
||||
arg = eval(arg)
|
||||
ac = Document('Account')
|
||||
for d in arg.keys():
|
||||
ac.fields[d] = arg[d]
|
||||
ac.old_parent = ''
|
||||
ac_obj = get_obj(doc=ac)
|
||||
ac_obj.validate()
|
||||
ac_obj.doc.save(1)
|
||||
ac_obj.on_update()
|
||||
|
||||
return ac_obj.doc.name
|
||||
|
||||
# Add a new cost center
|
||||
#----------------------
|
||||
def add_cc(self,arg):
|
||||
arg = eval(arg)
|
||||
cc = Document('Cost Center')
|
||||
# map fields
|
||||
for d in arg.keys():
|
||||
cc.fields[d] = arg[d]
|
||||
# map company abbr
|
||||
other_info = sql("select company_abbr from `tabCost Center` where name='%s'"%arg['parent_cost_center'])
|
||||
cc.company_abbr = other_info and other_info[0][0] or arg['company_abbr']
|
||||
|
||||
cc_obj = get_obj(doc=cc)
|
||||
cc_obj.validate()
|
||||
cc_obj.doc.save(1)
|
||||
cc_obj.on_update()
|
||||
|
||||
return cc_obj.doc.name
|
||||
|
||||
|
||||
# Get field values from the voucher
|
||||
#------------------------------------------
|
||||
def get_val(self, src, d, parent=None):
|
||||
if not src:
|
||||
return None
|
||||
if src.startswith('parent:'):
|
||||
return parent.fields[src.split(':')[1]]
|
||||
elif src.startswith('value:'):
|
||||
return eval(src.split(':')[1])
|
||||
elif src:
|
||||
return d.fields.get(src)
|
||||
|
||||
def check_if_in_list(self, le):
|
||||
for e in self.entries:
|
||||
if e.account == le.account and (cstr(e.against_voucher)==cstr(le.against_voucher)) and (cstr(e.against_voucher_type)==cstr(le.against_voucher_type)) and (cstr(e.cost_center)==cstr(le.cost_center)):
|
||||
return [e]
|
||||
return 0
|
||||
|
||||
# Make a dictionary(le) for every gl entry and append to a list(self.entries)
|
||||
#----------------------------------------------------------------------------
|
||||
def make_single_entry(self,parent,d,le_map,cancel, merge_entries):
|
||||
if self.get_val(le_map['account'], d, parent) and (self.get_val(le_map['debit'], d, parent) or self.get_val(le_map['credit'], d, parent)):
|
||||
flist = ['account','cost_center','against','debit','credit','remarks','voucher_type','voucher_no','transaction_date','posting_date','fiscal_year','against_voucher','against_voucher_type','company','is_opening', 'aging_date']
|
||||
|
||||
# Check budget before gl entry
|
||||
#check budget only if account is expense account
|
||||
is_expense_acct = sql("select name from tabAccount where is_pl_account='Yes' and debit_or_credit='Debit' and name=%s",self.get_val(le_map['account'], d, parent))
|
||||
if is_expense_acct and self.get_val(le_map['cost_center'], d, parent):
|
||||
get_obj('Budget Control').check_budget([self.get_val(le_map[k], d, parent) for k in flist if k in ['account','cost_center','debit','credit','posting_date','fiscal_year','company']],cancel)
|
||||
|
||||
# Create new GL entry object and map values
|
||||
le = Document('GL Entry')
|
||||
for k in flist:
|
||||
le.fields[k] = self.get_val(le_map[k], d, parent)
|
||||
|
||||
# if there is already an entry in this account then just add it to that entry
|
||||
same_head = self.check_if_in_list(le)
|
||||
if same_head and merge_entries:
|
||||
same_head = same_head[0]
|
||||
same_head.debit = flt(same_head.debit) + flt(le.debit)
|
||||
same_head.credit = flt(same_head.credit) + flt(le.credit)
|
||||
else:
|
||||
self.entries.append(le)
|
||||
|
||||
# Save GL Entries
|
||||
# ----------------
|
||||
def save_entries(self, cancel, adv_adj, update_outstanding):
|
||||
for le in self.entries:
|
||||
# cancel
|
||||
if cancel or flt(le.debit) < 0 or flt(le.credit) < 0:
|
||||
tmp=le.debit
|
||||
le.debit, le.credit = abs(flt(le.credit)), abs(flt(tmp))
|
||||
|
||||
|
||||
le_obj = get_obj(doc=le)
|
||||
# validate except on_cancel
|
||||
if not cancel:
|
||||
le_obj.validate()
|
||||
|
||||
# save
|
||||
le.save(1)
|
||||
le_obj.on_update(adv_adj, cancel, update_outstanding)
|
||||
|
||||
# update total debit / credit
|
||||
self.td += flt(le.debit)
|
||||
self.tc += flt(le.credit)
|
||||
|
||||
# Make Multiple Entries
|
||||
# ---------------------
|
||||
def make_gl_entries(self, doc, doclist, cancel=0, adv_adj = 0, use_mapper='', merge_entries = 1, update_outstanding='Yes'):
|
||||
# get entries
|
||||
le_map_list = sql("select * from `tabGL Mapper Detail` where parent = %s", use_mapper or doc.doctype, as_dict=1)
|
||||
self.td, self.tc = 0.0, 0.0
|
||||
for le_map in le_map_list:
|
||||
if le_map['table_field']:
|
||||
for d in getlist(doclist,le_map['table_field']):
|
||||
# purchase_tax_details is the table of other charges in purchase cycle
|
||||
if le_map['table_field'] != 'purchase_tax_details' or (le_map['table_field'] == 'purchase_tax_details' and d.fields.get('category') != 'For Valuation'):
|
||||
self.make_single_entry(doc,d,le_map,cancel, merge_entries)
|
||||
else:
|
||||
self.make_single_entry(None,doc,le_map,cancel, merge_entries)
|
||||
|
||||
# save entries
|
||||
self.save_entries(cancel, adv_adj, update_outstanding)
|
||||
|
||||
# check total debit / credit
|
||||
# Due to old wrong entries (total debit != total credit) some voucher could be cancelled
|
||||
if abs(self.td - self.tc) > 0.001 and not cancel:
|
||||
msgprint("Debit and Credit not equal for this voucher: Diff (Debit) is %s" % (self.td-self.tc))
|
||||
raise Exception
|
||||
|
||||
# set as cancelled
|
||||
if cancel:
|
||||
vt, vn = self.get_val(le_map['voucher_type'], doc, doc), self.get_val(le_map['voucher_no'], doc, doc)
|
||||
sql("update `tabGL Entry` set is_cancelled='Yes' where voucher_type=%s and voucher_no=%s", (vt, vn))
|
||||
|
||||
# Get account balance on any date
|
||||
# -------------------------------
|
||||
def get_as_on_balance(self, account_name, fiscal_year, as_on, credit_or_debit, lft, rgt):
|
||||
# initialization
|
||||
det = sql("select start_date, opening from `tabAccount Balance` where period = %s and account = %s", (fiscal_year, account_name))
|
||||
from_date, opening, debit_bal, credit_bal, closing_bal = det and det[0][0] or getdate(nowdate()), det and flt(det[0][1]) or 0, 0, 0, det and flt(det[0][1]) or 0
|
||||
|
||||
# prev month closing
|
||||
prev_month_det = sql("select end_date, debit, credit, balance from `tabAccount Balance` where account = %s and end_date <= %s and fiscal_year = %s order by end_date desc limit 1", (account_name, as_on, fiscal_year))
|
||||
if prev_month_det:
|
||||
from_date = getdate(add_days(prev_month_det[0][0].strftime('%Y-%m-%d'), 1))
|
||||
opening = 0
|
||||
debit_bal = flt(prev_month_det[0][1])
|
||||
credit_bal = flt(prev_month_det[0][2])
|
||||
closing_bal = flt(prev_month_det[0][3])
|
||||
|
||||
# curr month transaction
|
||||
if getdate(as_on) >= from_date:
|
||||
curr_month_bal = sql("select SUM(t1.debit), SUM(t1.credit) from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= %s AND t1.posting_date <= %s and ifnull(t1.is_opening, 'No') = 'No' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s and ifnull(t1.is_cancelled, 'No') = 'No'", (from_date, as_on, lft, rgt))
|
||||
curr_debit_amt, curr_credit_amt = flt(curr_month_bal[0][0]), flt(curr_month_bal[0][1])
|
||||
debit_bal = curr_month_bal and debit_bal + curr_debit_amt or debit_bal
|
||||
credit_bal = curr_month_bal and credit_bal + curr_credit_amt or credit_bal
|
||||
|
||||
if credit_or_debit == 'Credit':
|
||||
curr_debit_amt, curr_credit_amt = -1*flt(curr_month_bal[0][0]), -1*flt(curr_month_bal[0][1])
|
||||
closing_bal = closing_bal + curr_debit_amt - curr_credit_amt
|
||||
|
||||
return flt(debit_bal), flt(credit_bal), flt(closing_bal)
|
||||
|
||||
|
||||
# ADVANCE ALLOCATION
|
||||
#-------------------
|
||||
def get_advances(self, obj, account_head, table_name,table_field_name, dr_or_cr):
|
||||
jv_detail = sql("select t1.name, t1.remark, t2.%s, t2.name, t1.ded_amount from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher is null or t2.against_voucher = '') and (t2.against_invoice is null or t2.against_invoice = '') and (t2.against_jv is null or t2.against_jv = '') and t2.account = '%s' and t2.is_advance = 'Yes' and t1.docstatus = 1 order by t1.voucher_date " % (dr_or_cr,account_head))
|
||||
# clear advance table
|
||||
obj.doc.clear_table(obj.doclist,table_field_name)
|
||||
# Create advance table
|
||||
for d in jv_detail:
|
||||
add = addchild(obj.doc, table_field_name, table_name, 1, obj.doclist)
|
||||
add.journal_voucher = d[0]
|
||||
add.jv_detail_no = d[3]
|
||||
add.remarks = d[1]
|
||||
add.advance_amount = flt(d[2])
|
||||
add.allocate_amount = 0
|
||||
if table_name == 'Advance Allocation Detail':
|
||||
add.tds_amount = flt(d[4])
|
||||
|
||||
# Clear rows which is not adjusted
|
||||
#-------------------------------------
|
||||
def clear_advances(self, obj,table_name,table_field_name):
|
||||
for d in getlist(obj.doclist,table_field_name):
|
||||
if not flt(d.allocated_amount):
|
||||
sql("update `tab%s` set parent = '' where name = '%s' and parent = '%s'" % (table_name, d.name, d.parent))
|
||||
d.parent = ''
|
||||
|
||||
# Update aginst document in journal voucher
|
||||
#------------------------------------------
|
||||
def update_against_document_in_jv(self, obj, table_field_name, against_document_no, against_document_doctype, account_head, dr_or_cr,doctype):
|
||||
for d in getlist(obj.doclist, table_field_name):
|
||||
self.validate_jv_entry(d, account_head, dr_or_cr)
|
||||
if flt(d.advance_amount) == flt(d.allocated_amount):
|
||||
# cancel JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children=1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj =1)
|
||||
|
||||
# update ref in JV Detail
|
||||
sql("update `tabJournal Voucher Detail` set %s = '%s' where name = '%s'" % (doctype=='Payable Voucher' and 'against_voucher' or 'against_invoice', cstr(against_document_no), d.jv_detail_no))
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children =1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj =1)
|
||||
|
||||
elif flt(d.advance_amount) > flt(d.allocated_amount):
|
||||
# cancel JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children=1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj = 1)
|
||||
|
||||
# add extra entries
|
||||
self.add_extra_entry(jv_obj, d.journal_voucher, d.jv_detail_no, flt(d.allocated_amount), account_head, doctype, dr_or_cr, against_document_no)
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = get_obj('Journal Voucher', d.journal_voucher, with_children =1)
|
||||
get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj = 1)
|
||||
else:
|
||||
msgprint("Allocation amount cannot be greater than advance amount")
|
||||
raise Exception
|
||||
|
||||
# Add extra row in jv detail for unadjusted amount
|
||||
#--------------------------------------------------
|
||||
def add_extra_entry(self,jv_obj,jv,jv_detail_no, allocate, account_head, doctype, dr_or_cr, against_document_no):
|
||||
# get old entry details
|
||||
|
||||
jvd = sql("select %s, cost_center, balance, against_account from `tabJournal Voucher Detail` where name = '%s'" % (dr_or_cr,jv_detail_no))
|
||||
advance = jvd and flt(jvd[0][0]) or 0
|
||||
balance = flt(advance) - flt(allocate)
|
||||
|
||||
# update old entry
|
||||
sql("update `tabJournal Voucher Detail` set %s = '%s', %s = '%s' where name = '%s'" % (dr_or_cr, flt(allocate), doctype == "Payable Voucher" and 'against_voucher' or 'against_invoice',cstr(against_document_no), jv_detail_no))
|
||||
|
||||
# new entry with balance amount
|
||||
add = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', 1, jv_obj.doclist)
|
||||
add.account = account_head
|
||||
add.cost_center = cstr(jvd[0][1])
|
||||
add.balance = cstr(jvd[0][2])
|
||||
add.fields[dr_or_cr] = balance
|
||||
add.against_account = cstr(jvd[0][3])
|
||||
add.is_advance = 'Yes'
|
||||
add.save(1)
|
||||
|
||||
# check if advance entries are still valid
|
||||
# ----------------------------------------
|
||||
def validate_jv_entry(self, d, account_head, dr_or_cr):
|
||||
# 1. check if there is already a voucher reference
|
||||
# 2. check if amount is same
|
||||
# 3. check if is_advance is 'Yes'
|
||||
# 4. check if jv is submitted
|
||||
ret = sql("select t2.%s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and (t2.against_voucher = '' or t2.against_voucher is null) and (t2.against_invoice = '' or t2.against_invoice is null) and t2.account = '%s' and t1.name = '%s' and t2.name = '%s' and t2.is_advance = 'Yes' and t1.docstatus=1 and t2.%s = %s" % ( dr_or_cr, account_head, d.journal_voucher, d.jv_detail_no, dr_or_cr, d.advance_amount))
|
||||
if (not ret):
|
||||
msgprint("Please click on 'Get Advances Paid' button as the advance entries have been changed.")
|
||||
raise Exception
|
||||
return
|
||||
|
||||
##############################################################################
|
||||
# Repair Outstanding Amount
|
||||
##############################################################################
|
||||
def repair_voucher_outstanding(self, voucher_obj):
|
||||
msg = []
|
||||
|
||||
# Get Balance from GL Entries
|
||||
bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s", (voucher_obj.doc.name , voucher_obj.doc.doctype))
|
||||
bal = bal and flt(bal[0][0]) or 0.0
|
||||
if cstr(voucher_obj.doc.doctype) == 'Payable Voucher':
|
||||
bal = -bal
|
||||
|
||||
# Check outstanding Amount
|
||||
if flt(voucher_obj.doc.outstanding_amount) != flt(bal):
|
||||
msgprint('<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>' % (voucher_obj.doc.doctype, voucher_obj.doc.name, voucher_obj.doc.outstanding_amount, bal))
|
||||
msg.append('<div style="color: RED"> Difference found in Outstanding Amount of %s : %s (Before : %s; After : %s) </div>' % (voucher_obj.doc.doctype, voucher_obj.doc.name, voucher_obj.doc.outstanding_amount, bal))
|
||||
|
||||
# set voucher balance
|
||||
#sql("update `tab%s` set outstanding_amount=%s where name='%s'" % (voucher_obj.doc.doctype, bal, voucher_obj.doc.name))
|
||||
webnotes.conn.set(voucher_obj.doc, 'outstanding_amount', flt(bal))
|
||||
|
||||
# Send Mail
|
||||
if msg:
|
||||
email_msg = """ Dear Administrator,
|
||||
|
||||
In Account := %s User := %s has Repaired Outstanding Amount For %s : %s and following was found:-
|
||||
|
||||
%s
|
||||
|
||||
""" % (get_value('Control Panel', None,'account_id'), session['user'], voucher_obj.doc.doctype, voucher_obj.doc.name, '\n'.join(msg))
|
||||
|
||||
sendmail(['support@iwebnotes.com'], subject='Repair Outstanding Amount', parts = [('text/plain', email_msg)])
|
||||
# Acknowledge User
|
||||
msgprint(cstr(voucher_obj.doc.doctype) + " : " + cstr(voucher_obj.doc.name) + " has been checked" + cstr(msg and " and repaired successfully." or ". No changes Found."))
|
||||
|
||||
def repost_illegal_cancelled(self, after_date='2011-01-01'):
|
||||
"""
|
||||
Find vouchers that are not cancelled correctly and repost them
|
||||
"""
|
||||
vl = sql("""
|
||||
select voucher_type, voucher_no, account, sum(debit) as sum_debit, sum(credit) as sum_credit
|
||||
from `tabGL Entry`
|
||||
where is_cancelled='Yes' and creation > %s
|
||||
group by voucher_type, voucher_no, account
|
||||
""", after_date, as_dict=1)
|
||||
|
||||
ac_list = []
|
||||
for v in vl:
|
||||
if v['sum_debit'] != 0 or v['sum_credit'] != 0:
|
||||
ac_list.append(v['account'])
|
||||
|
||||
fy_list = sql("""select name from `tabFiscal Year`
|
||||
where (%s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day))
|
||||
or year_start_date > %s
|
||||
order by year_start_date ASC""", (after_date, after_date))
|
||||
|
||||
for fy in fy_list:
|
||||
fy_obj = get_obj('Fiscal Year', fy[0])
|
||||
for a in set(ac_list):
|
||||
fy_obj.repost(a)
|
||||
|
||||
31
erpnext/accounts/doctype/gl_control/gl_control.txt
Normal file
31
erpnext/accounts/doctype/gl_control/gl_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, GL Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-29 12:57:24',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 288
|
||||
},
|
||||
|
||||
# DocType, GL Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'GL Control'
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/gl_entry/__init__.py
Normal file
0
erpnext/accounts/doctype/gl_entry/__init__.py
Normal file
202
erpnext/accounts/doctype/gl_entry/gl_entry.js
Normal file
202
erpnext/accounts/doctype/gl_entry/gl_entry.js
Normal file
@@ -0,0 +1,202 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# Validate mandatory
|
||||
#-------------------
|
||||
def check_mandatory(self):
|
||||
# Following fields are mandatory in GL Entry
|
||||
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
|
||||
for k in mandatory:
|
||||
if not self.doc.fields.get(k):
|
||||
msgprint("%s is mandatory for GL Entry" % k)
|
||||
raise Exception
|
||||
|
||||
# Zero value transaction is not allowed
|
||||
if not (flt(self.doc.debit) or flt(self.doc.credit)):
|
||||
msgprint("GL Entry: Debit or Credit amount is mandatory for %s" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# Debit and credit can not done at the same time
|
||||
if flt(self.doc.credit) != 0 and flt(self.doc.debit) != 0:
|
||||
msgprint("Sorry you cannot credit and debit under same account head.")
|
||||
raise Exception, "Validation Error."
|
||||
|
||||
# Cost center is required only if transaction made against pl account
|
||||
#--------------------------------------------------------------------
|
||||
def pl_must_have_cost_center(self):
|
||||
if sql("select name from tabAccount where name=%s and is_pl_account='Yes'", self.doc.account):
|
||||
if not self.doc.cost_center and not self.doc.voucher_type != 'Period Closing Entry':
|
||||
msgprint("Error: Cost Center must be specified for PL Account: %s" % self.doc.account_name)
|
||||
raise Exception
|
||||
else: # not pl
|
||||
if self.doc.cost_center:
|
||||
self.doc.cost_center = ''
|
||||
|
||||
# Account must be ledger, active and not freezed
|
||||
#-----------------------------------------------
|
||||
def validate_account_details(self, adv_adj):
|
||||
ret = sql("select group_or_ledger, docstatus, freeze_account, company from tabAccount where name=%s", self.doc.account)
|
||||
|
||||
# 1. Checks whether Account type is group or ledger
|
||||
if ret and ret[0][0]=='Group':
|
||||
msgprint("Error: All accounts must be Ledgers. Account %s is a group" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 2. Checks whether Account is active
|
||||
if ret and ret[0][1]==2:
|
||||
msgprint("Error: All accounts must be Active. Account %s moved to Trash" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 3. Account has been freezed for other users except account manager
|
||||
if ret and ret[0][2]== 'Yes' and not adv_adj and not 'Accounts Manager' in session['data']['roles']:
|
||||
msgprint("Error: Account %s has been freezed. Only Accounts Manager can do transaction against this account." % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 4. Check whether account is within the company
|
||||
if ret and ret[0][3] != self.doc.company:
|
||||
msgprint("Account: %s does not belong to the company: %s" % (self.doc.account, self.doc.company))
|
||||
raise Exception
|
||||
|
||||
# Posting date must be in selected fiscal year and fiscal year is active
|
||||
#-------------------------------------------------------------------------
|
||||
def validate_posting_date(self):
|
||||
fy = sql("select docstatus, year_start_date from `tabFiscal Year` where name=%s ", self.doc.fiscal_year)
|
||||
ysd = fy[0][1]
|
||||
yed = get_last_day(get_first_day(ysd,0,11))
|
||||
pd = getdate(self.doc.posting_date)
|
||||
if fy[0][0] == 2:
|
||||
msgprint("Fiscal Year is not active. You can restore it from Trash")
|
||||
raise Exception
|
||||
if pd < ysd or pd > yed:
|
||||
msgprint("Posting date must be in the Selected Financial Year")
|
||||
raise Exception
|
||||
|
||||
|
||||
# Nobody can do GL Entries where posting date is before freezing date except 'Accounts Manager'
|
||||
#----------------------------------------------------------------------------------------------
|
||||
def check_freezing_date(self, adv_adj):
|
||||
if not adv_adj:
|
||||
pd,fd = getdate(self.doc.posting_date),0
|
||||
acc_frozen_upto = get_obj(dt = 'Manage Account').doc.acc_frozen_upto or ''
|
||||
if acc_frozen_upto:
|
||||
fd = getdate(acc_frozen_upto)
|
||||
|
||||
bde_auth_role = get_value( 'Manage Account', None,'bde_auth_role')
|
||||
if fd and pd <= fd and (bde_auth_role and not bde_auth_role in session['data']['roles']):
|
||||
msgprint("Message:You are not authorized to do back dated entries for account: %s before %s." % (self.doc.account, str(fd)))
|
||||
raise Exception
|
||||
|
||||
# create new bal if not exists
|
||||
#-----------------------------
|
||||
def create_new_balances(self, ac_obj, p, amt):
|
||||
ac = addchild(ac_obj.doc, 'account_balances', 'Account Balance', 1)
|
||||
ac.period = p[0]
|
||||
ac.start_date = p[1].strftime('%Y-%m-%d')
|
||||
ac.end_date = p[2].strftime('%Y-%m-%d')
|
||||
ac.fiscal_year = p[3]
|
||||
ac.opening = 0
|
||||
ac.balance = amt
|
||||
ac.save()
|
||||
|
||||
# Post Balance
|
||||
# ------------
|
||||
def post_balance(self, acc):
|
||||
# get details
|
||||
lft = sql("select lft, rgt, debit_or_credit from `tabAccount` where name='%s'" % acc)
|
||||
|
||||
# amount to debit
|
||||
amt = flt(self.doc.debit) - flt(self.doc.credit)
|
||||
if lft[0][2] == 'Credit': amt = -amt
|
||||
|
||||
# get periods
|
||||
periods = self.get_period_list(self.doc.posting_date, self.doc.fiscal_year)
|
||||
|
||||
acc_obj = get_obj('Account', self.doc.account)
|
||||
for p in periods:
|
||||
if not sql("select name from `tabAccount Balance` where parent=%s and period=%s", (self.doc.account, p[0])):
|
||||
self.create_new_balances(acc_obj, p, amt)
|
||||
else:
|
||||
# update current
|
||||
pl = sql("update `tabAccount Balance` t1, `tabAccount` t2 set t1.balance = t1.balance + %s where t2.lft<=%s and t2.rgt>=%s and t1.parent = t2.name and t1.period = '%s'" % (amt, cint(lft[0][0]), cint(lft[0][1]), p[0]))
|
||||
|
||||
# update opening
|
||||
if self.doc.is_opening=='Yes':
|
||||
pl = sql("update `tabAccount Balance` t1, `tabAccount` t2 set t1.opening = ifnull(t1.opening,0) + %s where t2.lft<=%s and t2.rgt>=%s and t1.parent = t2.name and t1.period = '%s'" % (amt, cint(lft[0][0]), cint(lft[0][1]), self.doc.fiscal_year))
|
||||
|
||||
# Get periods(month and year)
|
||||
#-----------------------------
|
||||
def get_period_list(self, dt, fy):
|
||||
pl = sql("SELECT name, start_date, end_date, fiscal_year FROM tabPeriod WHERE end_date >='%s' and fiscal_year = '%s' and period_type in ('Month', 'Year')" % (dt,fy))
|
||||
return pl
|
||||
|
||||
# Voucher Balance
|
||||
# ---------------
|
||||
def update_outstanding_amt(self):
|
||||
# get final outstanding amt
|
||||
bal = flt(sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled,'No') = 'No'", (self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
|
||||
tds = 0
|
||||
|
||||
if self.doc.against_voucher_type=='Payable Voucher':
|
||||
# amount to debit
|
||||
bal = -bal
|
||||
|
||||
# Check if tds applicable
|
||||
tds = sql("select total_tds_on_voucher from `tabPayable Voucher` where name = '%s'" % self.doc.against_voucher)
|
||||
tds = tds and flt(tds[0][0]) or 0
|
||||
|
||||
# Validation : Outstanding can not be negative
|
||||
if bal < 0 and not tds and self.doc.is_cancelled == 'No':
|
||||
msgprint("Outstanding for Voucher %s will become %s. Outstanding cannot be less than zero. Please match exact outstanding." % (self.doc.against_voucher, fmt_money(bal)))
|
||||
raise Exception
|
||||
|
||||
# Update outstanding amt on against voucher
|
||||
sql("update `tab%s` set outstanding_amount=%s where name='%s'"% (self.doc.against_voucher_type,bal,self.doc.against_voucher))
|
||||
|
||||
|
||||
# Total outstanding can not be greater than credit limit for any time for any customer
|
||||
#---------------------------------------------------------------------------------------------
|
||||
def check_credit_limit(self):
|
||||
#check for user role Freezed
|
||||
master_type=sql("select master_type from `tabAccount` where name='%s' " %self.doc.account)
|
||||
tot_outstanding = 0 #needed when there is no GL Entry in the system for that acc head
|
||||
if (self.doc.voucher_type=='Journal Voucher' or self.doc.voucher_type=='Receivable Voucher') and (master_type and master_type[0][0]=='Customer'):
|
||||
dbcr=sql("select sum(debit),sum(credit) from `tabGL Entry` where account = '%s' and is_cancelled='No'" % self.doc.account)
|
||||
if dbcr:
|
||||
tot_outstanding = flt(dbcr[0][0])-flt(dbcr[0][1])+flt(self.doc.debit)-flt(self.doc.credit)
|
||||
get_obj('Account',self.doc.account).check_credit_limit(self.doc.account, self.doc.company, tot_outstanding)
|
||||
|
||||
#for opening entry account can not be pl account
|
||||
#-----------------------------------------------
|
||||
def check_pl_account(self):
|
||||
if self.doc.is_opening=='Yes':
|
||||
is_pl_account=sql("select is_pl_account from `tabAccount` where name='%s'"%(self.doc.account))
|
||||
if is_pl_account and is_pl_account[0][0]=='Yes':
|
||||
msgprint("For opening balance entry account can not be a PL account")
|
||||
raise Exception
|
||||
|
||||
# Validate
|
||||
# --------
|
||||
def validate(self): # not called on cancel
|
||||
self.check_mandatory()
|
||||
self.pl_must_have_cost_center()
|
||||
self.validate_posting_date()
|
||||
self.doc.is_cancelled = 'No' # will be reset by GL Control if cancelled
|
||||
self.check_credit_limit()
|
||||
self.check_pl_account()
|
||||
|
||||
# On Update
|
||||
#----------
|
||||
def on_update(self,adv_adj):
|
||||
# Account must be ledger, active and not freezed
|
||||
self.validate_account_details(adv_adj)
|
||||
|
||||
# Posting date must be after freezing date
|
||||
self.check_freezing_date(adv_adj)
|
||||
|
||||
# Update current account balance
|
||||
self.post_balance(self.doc.account)
|
||||
|
||||
# Update outstanding amt on against voucher
|
||||
if self.doc.against_voucher:
|
||||
self.update_outstanding_amt()
|
||||
251
erpnext/accounts/doctype/gl_entry/gl_entry.py
Normal file
251
erpnext/accounts/doctype/gl_entry/gl_entry.py
Normal file
@@ -0,0 +1,251 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# Validate mandatory
|
||||
#-------------------
|
||||
def check_mandatory(self):
|
||||
# Following fields are mandatory in GL Entry
|
||||
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
|
||||
for k in mandatory:
|
||||
if not self.doc.fields.get(k):
|
||||
msgprint("%s is mandatory for GL Entry" % k)
|
||||
raise Exception
|
||||
|
||||
# Zero value transaction is not allowed
|
||||
if not (flt(self.doc.debit) or flt(self.doc.credit)):
|
||||
msgprint("GL Entry: Debit or Credit amount is mandatory for %s" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# Debit and credit can not done at the same time
|
||||
if flt(self.doc.credit) != 0 and flt(self.doc.debit) != 0:
|
||||
msgprint("Sorry you cannot credit and debit under same account head.")
|
||||
raise Exception, "Validation Error."
|
||||
|
||||
# Cost center is required only if transaction made against pl account
|
||||
#--------------------------------------------------------------------
|
||||
def pl_must_have_cost_center(self):
|
||||
if sql("select name from tabAccount where name=%s and is_pl_account='Yes'", self.doc.account):
|
||||
if not self.doc.cost_center and self.doc.voucher_type != 'Period Closing Voucher':
|
||||
msgprint("Error: Cost Center must be specified for PL Account: %s" % self.doc.account)
|
||||
raise Exception
|
||||
else: # not pl
|
||||
if self.doc.cost_center:
|
||||
self.doc.cost_center = ''
|
||||
|
||||
# Account must be ledger, active and not freezed
|
||||
#-----------------------------------------------
|
||||
def validate_account_details(self, adv_adj):
|
||||
ret = sql("select group_or_ledger, docstatus, freeze_account, company from tabAccount where name=%s", self.doc.account)
|
||||
|
||||
# 1. Checks whether Account type is group or ledger
|
||||
if ret and ret[0][0]=='Group':
|
||||
msgprint("Error: All accounts must be Ledgers. Account %s is a group" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 2. Checks whether Account is active
|
||||
if ret and ret[0][1]==2:
|
||||
msgprint("Error: All accounts must be Active. Account %s moved to Trash" % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 3. Account has been freezed for other users except account manager
|
||||
if ret and ret[0][2]== 'Yes' and not adv_adj and not 'Accounts Manager' in webnotes.user.get_roles():
|
||||
msgprint("Error: Account %s has been freezed. Only Accounts Manager can do transaction against this account." % self.doc.account)
|
||||
raise Exception
|
||||
|
||||
# 4. Check whether account is within the company
|
||||
if ret and ret[0][3] != self.doc.company:
|
||||
msgprint("Account: %s does not belong to the company: %s" % (self.doc.account, self.doc.company))
|
||||
raise Exception
|
||||
|
||||
# Posting date must be in selected fiscal year and fiscal year is active
|
||||
#-------------------------------------------------------------------------
|
||||
def validate_posting_date(self):
|
||||
fy = sql("select docstatus, year_start_date from `tabFiscal Year` where name=%s ", self.doc.fiscal_year)
|
||||
ysd = fy[0][1]
|
||||
yed = get_last_day(get_first_day(ysd,0,11))
|
||||
pd = getdate(self.doc.posting_date)
|
||||
if fy[0][0] == 2:
|
||||
msgprint("Fiscal Year is not active. You can restore it from Trash")
|
||||
raise Exception
|
||||
if pd < ysd or pd > yed:
|
||||
msgprint("Posting date must be in the Selected Financial Year")
|
||||
raise Exception
|
||||
|
||||
|
||||
# Nobody can do GL Entries where posting date is before freezing date except authorized person
|
||||
#----------------------------------------------------------------------------------------------
|
||||
def check_freezing_date(self, adv_adj):
|
||||
if not adv_adj:
|
||||
acc_frozen_upto = get_value('Manage Account', None, 'acc_frozen_upto')
|
||||
if acc_frozen_upto:
|
||||
bde_auth_role = get_value( 'Manage Account', None,'bde_auth_role')
|
||||
if getdate(self.doc.posting_date) <= getdate(acc_frozen_upto) and not bde_auth_role in webnotes.user.get_roles():
|
||||
msgprint("You are not authorized to do/modify back dated accounting entries before %s." % getdate(acc_frozen_upto).strftime('%d-%m-%Y'), raise_exception=1)
|
||||
|
||||
# create new bal if not exists
|
||||
#-----------------------------
|
||||
def create_new_balances(self, det):
|
||||
# check
|
||||
if sql("select count(t1.name) from `tabAccount Balance` t1, tabAccount t2 where t1.fiscal_year=%s and t2.lft <= %s and t2.rgt >= %s and t2.name = t1.account", (self.doc.fiscal_year, det[0][0], det[0][1]))[0][0] < 13*(cint(det[0][1]) - cint(det[0][0]) +1)/2:
|
||||
period_list = self.get_period_list()
|
||||
accounts = sql("select name from tabAccount where lft <= %s and rgt >= %s" % (det[0][0], det[0][1]))
|
||||
|
||||
for p in period_list:
|
||||
for a in accounts:
|
||||
# check if missing
|
||||
if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.fiscal_year)):
|
||||
d = Document('Account Balance')
|
||||
d.account = a[0]
|
||||
d.period = p[0]
|
||||
d.start_date = p[1].strftime('%Y-%m-%d')
|
||||
d.end_date = p[2].strftime('%Y-%m-%d')
|
||||
d.fiscal_year = self.doc.fiscal_year
|
||||
d.debit = 0
|
||||
d.credit = 0
|
||||
d.opening = 0
|
||||
d.balance = 0
|
||||
d.save(1)
|
||||
|
||||
# Post Balance
|
||||
# ------------
|
||||
def post_balance(self, acc, cancel):
|
||||
# get details
|
||||
det = sql("select lft, rgt, debit_or_credit from `tabAccount` where name='%s'" % acc)
|
||||
|
||||
# amount to debit
|
||||
amt = flt(self.doc.debit) - flt(self.doc.credit)
|
||||
if det[0][2] == 'Credit': amt = -amt
|
||||
if cancel:
|
||||
debit = -1 * flt(self.doc.credit)
|
||||
credit = -1 * flt(self.doc.debit)
|
||||
else:
|
||||
debit = flt(self.doc.debit)
|
||||
credit = flt(self.doc.credit)
|
||||
|
||||
self.create_new_balances(det)
|
||||
|
||||
# build dict
|
||||
p = {
|
||||
'debit': flt(debit)
|
||||
,'credit':flt(credit)
|
||||
,'opening': self.doc.is_opening=='Yes' and amt or 0
|
||||
# end date condition only if it is not opening
|
||||
,'end_date_condition':(self.doc.is_opening!='Yes' and ("and ab.end_date >= '"+self.doc.posting_date+"'") or '')
|
||||
,'diff': amt
|
||||
,'lft': cint(det[0][0])
|
||||
,'rgt': cint(det[0][1])
|
||||
,'posting_date': self.doc.posting_date
|
||||
,'fiscal_year': self.doc.fiscal_year
|
||||
}
|
||||
|
||||
sql("""update `tabAccount Balance` ab, `tabAccount` a
|
||||
set
|
||||
ab.debit = ifnull(ab.debit,0) + %(debit)s
|
||||
,ab.credit = ifnull(ab.credit,0) + %(credit)s
|
||||
,ab.opening = ifnull(ab.opening,0) + %(opening)s
|
||||
,ab.balance = ifnull(ab.balance,0) + %(diff)s
|
||||
where
|
||||
a.lft <= %(lft)s
|
||||
and a.rgt >= %(rgt)s
|
||||
and ab.account = a.name
|
||||
%(end_date_condition)s
|
||||
and ab.fiscal_year = '%(fiscal_year)s' """ % p)
|
||||
|
||||
|
||||
# Get periods(month and year)
|
||||
#-----------------------------
|
||||
def get_period_list(self):
|
||||
pl = sql("SELECT name, start_date, end_date, fiscal_year FROM tabPeriod WHERE fiscal_year = '%s' and period_type in ('Month', 'Year')" % (self.doc.fiscal_year))
|
||||
return pl
|
||||
|
||||
# Voucher Balance
|
||||
# ---------------
|
||||
def update_outstanding_amt(self):
|
||||
# get final outstanding amt
|
||||
|
||||
bal = flt(sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled,'No') = 'No'", (self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
|
||||
tds = 0
|
||||
|
||||
if self.doc.against_voucher_type=='Payable Voucher':
|
||||
# amount to debit
|
||||
bal = -bal
|
||||
|
||||
# Check if tds applicable
|
||||
tds = sql("select total_tds_on_voucher from `tabPayable Voucher` where name = '%s'" % self.doc.against_voucher)
|
||||
tds = tds and flt(tds[0][0]) or 0
|
||||
|
||||
# Validation : Outstanding can not be negative
|
||||
if bal < 0 and not tds and self.doc.is_cancelled == 'No':
|
||||
msgprint("Outstanding for Voucher %s will become %s. Outstanding cannot be less than zero. Please match exact outstanding." % (self.doc.against_voucher, fmt_money(bal)))
|
||||
raise Exception
|
||||
|
||||
# Update outstanding amt on against voucher
|
||||
sql("update `tab%s` set outstanding_amount=%s where name='%s'"% (self.doc.against_voucher_type,bal,self.doc.against_voucher))
|
||||
|
||||
|
||||
# Total outstanding can not be greater than credit limit for any time for any customer
|
||||
#---------------------------------------------------------------------------------------------
|
||||
def check_credit_limit(self):
|
||||
#check for user role Freezed
|
||||
master_type=sql("select master_type, master_name from `tabAccount` where name='%s' " %self.doc.account)
|
||||
tot_outstanding = 0 #needed when there is no GL Entry in the system for that acc head
|
||||
if (self.doc.voucher_type=='Journal Voucher' or self.doc.voucher_type=='Receivable Voucher') and (master_type and master_type[0][0]=='Customer' and master_type[0][1]):
|
||||
dbcr = sql("select sum(debit),sum(credit) from `tabGL Entry` where account = '%s' and is_cancelled='No'" % self.doc.account)
|
||||
if dbcr:
|
||||
tot_outstanding = flt(dbcr[0][0])-flt(dbcr[0][1])+flt(self.doc.debit)-flt(self.doc.credit)
|
||||
get_obj('Account',self.doc.account).check_credit_limit(self.doc.account, self.doc.company, tot_outstanding)
|
||||
|
||||
#for opening entry account can not be pl account
|
||||
#-----------------------------------------------
|
||||
def check_pl_account(self):
|
||||
if self.doc.is_opening=='Yes':
|
||||
is_pl_account=sql("select is_pl_account from `tabAccount` where name='%s'"%(self.doc.account))
|
||||
if is_pl_account and is_pl_account[0][0]=='Yes':
|
||||
msgprint("For opening balance entry account can not be a PL account")
|
||||
raise Exception
|
||||
|
||||
# Validate
|
||||
# --------
|
||||
def validate(self): # not called on cancel
|
||||
self.check_mandatory()
|
||||
self.pl_must_have_cost_center()
|
||||
self.validate_posting_date()
|
||||
self.doc.is_cancelled = 'No' # will be reset by GL Control if cancelled
|
||||
self.check_credit_limit()
|
||||
self.check_pl_account()
|
||||
|
||||
# On Update
|
||||
#----------
|
||||
def on_update(self,adv_adj, cancel, update_outstanding = 'Yes'):
|
||||
# Account must be ledger, active and not freezed
|
||||
self.validate_account_details(adv_adj)
|
||||
|
||||
# Posting date must be after freezing date
|
||||
self.check_freezing_date(adv_adj)
|
||||
|
||||
# Update current account balance
|
||||
self.post_balance(self.doc.account, cancel)
|
||||
|
||||
# Update outstanding amt on against voucher
|
||||
if self.doc.against_voucher and self.doc.against_voucher_type not in ('Journal Voucher','POS') and update_outstanding == 'Yes':
|
||||
self.update_outstanding_amt()
|
||||
323
erpnext/accounts/doctype/gl_entry/gl_entry.txt
Normal file
323
erpnext/accounts/doctype/gl_entry/gl_entry.txt
Normal file
@@ -0,0 +1,323 @@
|
||||
# DocType, GL Entry
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-29 12:59:45',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1309508838',
|
||||
'autoname': 'GL.#######',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': 'voucher_no,account,posting_date,against_voucher',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 101
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'GL Entry',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'GL Entry',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, GL Entry
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'GL Entry'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry will get or has actually executed.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 1,
|
||||
'in_filter': 1,
|
||||
'label': 'Posting Date',
|
||||
'oldfieldname': 'posting_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry is made in system.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'transaction_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Transaction Date',
|
||||
'oldfieldname': 'transaction_date',
|
||||
'oldfieldtype': 'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'aging_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'Aging Date',
|
||||
'oldfieldname': 'aging_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 4,
|
||||
'in_filter': 1,
|
||||
'label': 'Account',
|
||||
'oldfieldname': 'account',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Account',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cost_center',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 5,
|
||||
'in_filter': 1,
|
||||
'label': 'Cost Center',
|
||||
'oldfieldname': 'cost_center',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Cost Center',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'debit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 6,
|
||||
'label': 'Debit Amt',
|
||||
'oldfieldname': 'debit',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 7,
|
||||
'label': 'Credit Amt',
|
||||
'oldfieldname': 'credit',
|
||||
'oldfieldtype': 'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'Against',
|
||||
'oldfieldname': 'against',
|
||||
'oldfieldtype': 'Text'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_voucher',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'Against Voucher',
|
||||
'oldfieldname': 'against_voucher',
|
||||
'oldfieldtype': 'Data',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_voucher_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 10,
|
||||
'in_filter': 0,
|
||||
'label': 'Against Voucher Type',
|
||||
'oldfieldname': 'against_voucher_type',
|
||||
'oldfieldtype': 'Data',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 11,
|
||||
'in_filter': 1,
|
||||
'label': 'Voucher Type',
|
||||
'oldfieldname': 'voucher_type',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'Journal Voucher\nReceivable Voucher\nPayable Voucher',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 12,
|
||||
'in_filter': 1,
|
||||
'label': 'Voucher No',
|
||||
'oldfieldname': 'voucher_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'remarks',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 13,
|
||||
'in_filter': 1,
|
||||
'label': 'Remarks',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'remarks',
|
||||
'oldfieldtype': 'Text',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_cancelled',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 14,
|
||||
'in_filter': 1,
|
||||
'label': 'Is Cancelled',
|
||||
'oldfieldname': 'is_cancelled',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'No\nYes',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_opening',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 15,
|
||||
'in_filter': 1,
|
||||
'label': 'Is Opening',
|
||||
'oldfieldname': 'is_opening',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'No\nYes',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_advance',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 16,
|
||||
'in_filter': 0,
|
||||
'label': 'Is Advance',
|
||||
'oldfieldname': 'is_advance',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'No\nYes',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 17,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 18,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'search_index': 0
|
||||
}
|
||||
]
|
||||
154
erpnext/accounts/doctype/journal_voucher/journal_voucher.js
Normal file
154
erpnext/accounts/doctype/journal_voucher/journal_voucher.js
Normal file
@@ -0,0 +1,154 @@
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
var cp = locals['Control Panel']['Control Panel'];
|
||||
|
||||
if (!doc.voucher_date) doc.voucher_date = dateutil.obj_to_str(new Date());
|
||||
|
||||
if(cp.country == 'India') {
|
||||
unhide_field(['tds_applicable','tds_category','Get TDS','tax_code','rate','ded_amount','supplier_account']);
|
||||
}
|
||||
else {
|
||||
hide_field(['tds_applicable','tds_category','Get TDS','tax_code','rate','ded_amount','supplier_account']);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
|
||||
hide_field('aging_date');
|
||||
if (doc.is_opening == 'Yes') unhide_field('aging_date');
|
||||
|
||||
if(doc.docstatus==1) { unhide_field('View Ledger Entry'); }
|
||||
else hide_field('View Ledger Entry');
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = cur_frm.cscript.is_opening;
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field('account').get_query = function(doc) {
|
||||
return "SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company='"+doc.company+"' AND tabAccount.group_or_ledger = 'Ledger' AND tabAccount.docstatus != 2 AND `tabAccount`.%(key)s LIKE '%s' ORDER BY `tabAccount`.name DESC LIMIT 50";
|
||||
}
|
||||
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.docstatus != 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
// Restrict Voucher based on Account
|
||||
// ---------------------------------
|
||||
cur_frm.fields_dict['entries'].grid.get_field('against_voucher').get_query = function(doc) {
|
||||
var d = locals[this.doctype][this.docname];
|
||||
return "SELECT `tabPayable Voucher`.name, `tabPayable Voucher`.credit_to, `tabPayable Voucher`.outstanding_amount,`tabPayable Voucher`.bill_no, `tabPayable Voucher`.bill_date FROM `tabPayable Voucher` WHERE `tabPayable Voucher`.credit_to='"+d.account+"' AND `tabPayable Voucher`.outstanding_amount > 0 AND `tabPayable Voucher`.docstatus = 1 AND `tabPayable Voucher`.%(key)s LIKE '%s' ORDER BY `tabPayable Voucher`.name DESC LIMIT 200";
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field('against_invoice').get_query = function(doc) {
|
||||
var d = locals[this.doctype][this.docname];
|
||||
return "SELECT `tabReceivable Voucher`.name, `tabReceivable Voucher`.debit_to, `tabReceivable Voucher`.outstanding_amount FROM `tabReceivable Voucher` WHERE `tabReceivable Voucher`.debit_to='"+d.account+"' AND `tabReceivable Voucher`.outstanding_amount > 0 AND `tabReceivable Voucher`.docstatus = 1 AND `tabReceivable Voucher`.%(key)s LIKE '%s' ORDER BY `tabReceivable Voucher`.name DESC LIMIT 200";
|
||||
}
|
||||
|
||||
// TDS Account Head
|
||||
cur_frm.fields_dict['tax_code'].get_query = function(doc) {
|
||||
return "SELECT `tabTDS Category Account`.account_head FROM `tabTDS Category Account` WHERE `tabTDS Category Account`.parent = '"+doc.tds_category+"' AND `tabTDS Category Account`.company='"+doc.company+"' AND `tabTDS Category Account`.account_head LIKE '%s' ORDER BY `tabTDS Category Account`.account_head DESC LIMIT 50";
|
||||
}
|
||||
|
||||
//Set debit and credit to zero on adding new row
|
||||
//----------------------------------------------
|
||||
cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.idx == 1){
|
||||
d.debit = 0;
|
||||
d.credit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Get Outstanding of Payable & Receivable Voucher
|
||||
// -----------------------------------------------
|
||||
|
||||
cur_frm.cscript.against_voucher = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.against_voucher && !flt(d.debit)) {
|
||||
args = {'doctype': 'Payable Voucher', 'docname': d.against_voucher }
|
||||
get_server_fields('get_outstanding',docstring(args),'entries',doc,cdt,cdn,1,function(r,rt) { cur_frm.cscript.update_totals(doc); });
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.against_invoice = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.against_invoice && !flt(d.credit)) {
|
||||
args = {'doctype': 'Receivable Voucher', 'docname': d.against_invoice }
|
||||
get_server_fields('get_outstanding',docstring(args),'entries',doc,cdt,cdn,1,function(r,rt) { cur_frm.cscript.update_totals(doc); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update Totals
|
||||
// ---------------
|
||||
cur_frm.cscript.update_totals = function(doc) {
|
||||
var td=0.0; var tc =0.0;
|
||||
var el = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
||||
for(var i in el) {
|
||||
td += flt(el[i].debit);
|
||||
tc += flt(el[i].credit);
|
||||
}
|
||||
var doc = locals[doc.doctype][doc.name];
|
||||
tc += flt(doc.ded_amount)
|
||||
doc.total_debit = td;
|
||||
doc.total_credit = tc;
|
||||
doc.difference = flt(td - tc);
|
||||
refresh_many(['total_debit','total_credit','difference']);
|
||||
}
|
||||
|
||||
cur_frm.cscript.debit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc); }
|
||||
cur_frm.cscript.credit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc); }
|
||||
cur_frm.cscript.ded_amount = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc); }
|
||||
cur_frm.cscript.rate = function(doc,dt,dn) {
|
||||
doc.ded_amount = doc.total_debit*doc.rate/100;
|
||||
refresh_field('ded_amount');
|
||||
cur_frm.cscript.update_totals(doc);
|
||||
}
|
||||
cur_frm.cscript['Get Balance'] = function(doc,dt,dn) {
|
||||
cur_frm.cscript.update_totals(doc);
|
||||
$c_obj(make_doclist(dt,dn), 'get_balance', '', function(r, rt){
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
// Get balance
|
||||
// -----------
|
||||
|
||||
cur_frm.cscript.account = function(doc,dt,dn) {
|
||||
var d = locals[dt][dn];
|
||||
$c_obj('GL Control','get_bal',d.account+'~~~'+doc.fiscal_year, function(r,rt) { d.balance = r.message; refresh_field('balance',d.name,'entries'); });
|
||||
}
|
||||
|
||||
cur_frm.cscript.validate = function(doc,cdt,cdn) {
|
||||
cur_frm.cscript.update_totals(doc);
|
||||
}
|
||||
|
||||
// TDS
|
||||
// --------
|
||||
cur_frm.cscript['Get TDS'] = function(doc, dt, dn) {
|
||||
$c_obj(make_doclist(dt,dn), 'get_tds', '', function(r, rt){
|
||||
cur_frm.refresh();
|
||||
cur_frm.cscript.update_totals(doc);
|
||||
});
|
||||
}
|
||||
|
||||
// ***************** Get Print Heading based on Receivable Voucher *****************
|
||||
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
|
||||
cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
|
||||
if(doc.select_print_heading){
|
||||
// print heading
|
||||
cur_frm.pformat.print_heading = doc.select_print_heading;
|
||||
}
|
||||
else
|
||||
cur_frm.pformat.print_heading = "Journal Voucher";
|
||||
}
|
||||
|
||||
/****************** Get Accounting Entry *****************/
|
||||
cur_frm.cscript['View Ledger Entry'] = function(doc,cdt,cdn){
|
||||
var callback = function(report){
|
||||
report.set_filter('GL Entry', 'Voucher No',doc.name);
|
||||
report.dt.run();
|
||||
}
|
||||
loadreport('GL Entry','General Ledger', callback);
|
||||
}
|
||||
448
erpnext/accounts/doctype/journal_voucher/journal_voucher.py
Normal file
448
erpnext/accounts/doctype/journal_voucher/journal_voucher.py
Normal file
@@ -0,0 +1,448 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getTraceback, get_defaults, getdate, has_common, month_name, now, nowdate, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
self.master_type = {}
|
||||
self.credit_days_for = {}
|
||||
self.credit_days_global = -1
|
||||
self.is_approving_authority = -1
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# Autoname
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# Fetch outstanding amount from RV/PV
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def get_outstanding(self, args):
|
||||
args = eval(args)
|
||||
o_s = sql("select outstanding_amount from `tab%s` where name = '%s'" % (args['doctype'],args['docname']))
|
||||
if args['doctype'] == 'Payable Voucher':
|
||||
return {'debit': o_s and flt(o_s[0][0]) or 0}
|
||||
if args['doctype'] == 'Receivable Voucher':
|
||||
return {'credit': o_s and flt(o_s[0][0]) or 0}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# Create remarks
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def create_remarks(self):
|
||||
r = []
|
||||
if self.doc.cheque_no :
|
||||
if self.doc.cheque_date:
|
||||
r.append('Via cheque #%s dated %s' % (self.doc.cheque_no, formatdate(self.doc.cheque_date)))
|
||||
else :
|
||||
msgprint("Please enter cheque date")
|
||||
raise Exception
|
||||
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.against_invoice and d.credit:
|
||||
currency = sql("select currency from `tabReceivable Voucher` where name = '%s'" % d.against_invoice)
|
||||
currency = currency and currency[0][0] or ''
|
||||
r.append('%s %s against Invoice: %s' % (cstr(currency), fmt_money(flt(d.credit)), d.against_invoice))
|
||||
if d.against_voucher and d.debit:
|
||||
bill_no = sql("select bill_no, bill_date, currency from `tabPayable Voucher` where name=%s", d.against_voucher)
|
||||
if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() not in ['na', 'not applicable', 'none']:
|
||||
bill_no = bill_no and bill_no[0]
|
||||
r.append('%s %s against Bill %s dated %s' % (bill_no[2] and cstr(bill_no[2]) or '', fmt_money(flt(d.debit)), bill_no[0], bill_no[1] and formatdate(bill_no[1].strftime('%Y-%m-%d')) or ''))
|
||||
if self.doc.ded_amount:
|
||||
r.append("TDS Amount: %s" % self.doc.ded_amount)
|
||||
|
||||
if self.doc.user_remark:
|
||||
r.append("User Remark : %s"%self.doc.user_remark)
|
||||
|
||||
if r:
|
||||
self.doc.remark = ("\n").join(r)
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------
|
||||
# Check user role for approval process
|
||||
# --------------------------------------------------------------------------------------------------------
|
||||
def get_authorized_user(self):
|
||||
if self.is_approving_authority==-1:
|
||||
self.is_approving_authority = 0
|
||||
|
||||
# Fetch credit controller role
|
||||
approving_authority = sql("select value from `tabSingles` where field='credit_controller' and doctype='Manage Account'")
|
||||
approving_authority = approving_authority and approving_authority[0][0] or ''
|
||||
|
||||
# Check logged-in user is authorized
|
||||
if approving_authority in webnotes.user.get_roles():
|
||||
self.is_approving_authority = 1
|
||||
|
||||
return self.is_approving_authority
|
||||
|
||||
# get master type
|
||||
# ---------------
|
||||
def get_master_type(self, ac):
|
||||
if not self.master_type.get(ac):
|
||||
self.master_type[ac] = sql("select master_type from `tabAccount` where name=%s", ac)[0][0] or 'None'
|
||||
return self.master_type[ac]
|
||||
|
||||
# get credit days for
|
||||
# -------------------
|
||||
def get_credit_days_for(self, ac):
|
||||
|
||||
if not self.credit_days_for.has_key(ac):
|
||||
self.credit_days_for[ac] = sql("select credit_days from `tabAccount` where name='%s'" % ac)[0][0] or 0
|
||||
|
||||
if not self.credit_days_for[ac]:
|
||||
if self.credit_days_global==-1:
|
||||
self.credit_days_global = sql("select credit_days from `tabCompany` where name='%s'" % self.doc.company)[0][0] or 0
|
||||
return self.credit_days_global
|
||||
else:
|
||||
return self.credit_days_for[ac]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------
|
||||
# Check Credit Days - Cheque Date can not after (Posting date + Credit Days)
|
||||
# --------------------------------------------------------------------------------------------------------
|
||||
def check_credit_days(self):
|
||||
date_diff = 0
|
||||
if self.doc.cheque_date:
|
||||
date_diff = (getdate(self.doc.cheque_date)-getdate(self.doc.posting_date)).days
|
||||
|
||||
if date_diff <= 0: return
|
||||
|
||||
# Get List of Customer Account
|
||||
acc_list = filter(lambda d: self.get_master_type(d.account)=='Customer', getlist(self.doclist,'entries'))
|
||||
|
||||
for d in acc_list:
|
||||
credit_days = self.get_credit_days_for(d.account)
|
||||
|
||||
# Check credit days
|
||||
if credit_days > 0 and not self.get_authorized_user() and cint(date_diff) > credit_days:
|
||||
msgprint("Credit Not Allowed: Cannot allow a check that is dated more than %s days after the posting date" % credit_days)
|
||||
raise Exception
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# validation of debit/credit account with Debit To Account(RV) or Credit To Account (PV)
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def check_account_against_entries(self):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if d.against_invoice:
|
||||
acc=sql("select debit_to from `tabReceivable Voucher` where name='%s'"%d.against_invoice)
|
||||
if acc and acc[0][0] != d.account:
|
||||
msgprint("Debit account is not matching with receivable voucher")
|
||||
raise Exception
|
||||
|
||||
if d.against_voucher:
|
||||
acc=sql("select credit_to from `tabPayable Voucher` where name='%s'"%d.against_voucher)
|
||||
if acc and acc[0][0] != d.account:
|
||||
msgprint("Credit account is not matching with payable voucher")
|
||||
raise Exception
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# Validate Cheque Info: Mandatory for Bank/Contra voucher
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def validate_cheque_info(self):
|
||||
if self.doc.voucher_type in ['Bank Voucher']:
|
||||
if not self.doc.cheque_no or not self.doc.cheque_date:
|
||||
msgprint("Cheque No & Cheque Date is required for " + cstr(self.doc.voucher_type))
|
||||
raise Exception
|
||||
|
||||
if self.doc.cheque_date and not self.doc.cheque_no:
|
||||
msgprint("Cheque No is mandatory if you entered Cheque Date")
|
||||
raise Exception
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# Gives reminder for making is_advance = 'Yes' in Advance Entry
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def validate_entries_for_advance(self):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if not d.is_advance and not d.against_voucher and not d.against_invoice and d.against_jv:
|
||||
master_type = self.get_master_type(d.account)
|
||||
if (master_type == 'Customer' and flt(d.credit) > 0) or (master_type == 'Supplier' and flt(d.debit) > 0):
|
||||
msgprint("Message: Please check Is Advance as 'Yes' against Account %s if this is an advance entry." % d.account)
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# TDS: Validate tds related fields
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def get_tds_category_account(self):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if flt(d.debit) > 0 and not d.against_voucher and d.is_advance == 'Yes':
|
||||
acc = sql("select tds_applicable from `tabAccount` where name = '%s'" % d.account)
|
||||
acc_tds_applicable = acc and acc[0][0] or 'No'
|
||||
if acc_tds_applicable == 'Yes':
|
||||
# TDS applicable field become mandatory for advance payment towards supplier or related party
|
||||
if not self.doc.tds_applicable:
|
||||
msgprint("Please select TDS Applicable or Not")
|
||||
raise Exception
|
||||
|
||||
# If TDS applicable, category and supplier account bocome mandatory
|
||||
elif self.doc.tds_applicable == 'Yes':
|
||||
self.validate_category_account(d.account)
|
||||
if self.doc.ded_amount and not self.doc.tax_code:
|
||||
msgprint("Please enter Tax Code in TDS section")
|
||||
raise Exception
|
||||
|
||||
#If TDS not applicable, all related fields should blank
|
||||
else:
|
||||
self.set_fields_null()
|
||||
|
||||
# If tds amount but tds applicability not mentioned in account master
|
||||
elif self.doc.ded_amount:
|
||||
msgprint("Please select TDS Applicable = 'Yes' in account head: '%s' if you want to deduct TDS." % self.doc.supplier_account)
|
||||
raise Exception
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# If TDS applicable , TDS category and supplier account should be mandatory
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def validate_category_account(self, credit_account):
|
||||
if not self.doc.tds_category:
|
||||
msgprint("Please select TDS Category")
|
||||
raise Exception
|
||||
|
||||
if not self.doc.supplier_account:
|
||||
self.doc.supplier_account = credit_account
|
||||
elif self.doc.supplier_account and self.doc.supplier_account != credit_account:
|
||||
msgprint("Supplier Account is not matching with the account mentioned in the table. Please select proper Supplier Account and click on 'Get TDS' button.")
|
||||
raise Exception
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# If TDS is not applicable , all related fields should blank
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def set_fields_null(self):
|
||||
self.doc.ded_amount = 0
|
||||
self.doc.rate = 0
|
||||
self.doc.tax_code = ''
|
||||
self.doc.tds_category = ''
|
||||
self.doc.supplier_account = ''
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# Get TDS amount
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def get_tds(self):
|
||||
if cstr(self.doc.is_opening) != 'Yes':
|
||||
if self.doc.total_debit > 0:
|
||||
self.get_tds_category_account()
|
||||
if self.doc.supplier_account and self.doc.tds_category:
|
||||
get_obj('TDS Control').get_tds_amount(self)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# Insert new row to balance total debit and total credit
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def get_balance(self):
|
||||
if not getlist(self.doclist,'entries'):
|
||||
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
|
||||
else:
|
||||
flag, self.doc.total_debit, self.doc.total_credit = 0,0,0
|
||||
diff = flt(self.doc.difference)
|
||||
|
||||
# If any row without amount, set the diff on that row
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if (d.credit==0 or d.credit is None) and (d.debit==0 or d.debit is None) and (flt(diff) != 0):
|
||||
if diff>0:
|
||||
d.credit = flt(diff)
|
||||
elif diff<0:
|
||||
d.debit = flt(diff)
|
||||
flag = 1
|
||||
|
||||
# Set the diff in a new row
|
||||
if flag == 0 and (flt(diff) != 0):
|
||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist)
|
||||
if diff>0:
|
||||
jd.credit = flt(diff)
|
||||
elif diff<0:
|
||||
jd.debit = flt(diff)
|
||||
|
||||
# Set the total debit, total credit and difference
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
self.doc.total_debit += flt(d.debit)
|
||||
self.doc.total_credit += flt(d.credit)
|
||||
|
||||
if self.doc.tds_applicable == 'Yes':
|
||||
self.doc.total_credit = flt(self.doc.total_credit) + flt(self.doc.ded_amount)
|
||||
|
||||
self.doc.difference = flt(self.doc.total_debit) - flt(self.doc.total_credit)
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# Set against account
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def get_against_account(self):
|
||||
# Debit = Credit
|
||||
debit, credit = 0.0, 0.0
|
||||
debit_list, credit_list = [], []
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
debit += flt(d.debit)
|
||||
credit += flt(d.credit)
|
||||
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)
|
||||
|
||||
self.doc.total_debit = debit
|
||||
if self.doc.tds_applicable == 'Yes':
|
||||
self.doc.total_credit = credit + flt(self.doc.ded_amount)
|
||||
else:
|
||||
self.doc.total_credit = credit
|
||||
|
||||
if abs(self.doc.total_debit-self.doc.total_credit) > 0.001:
|
||||
msgprint("Debit must be equal to Credit. The difference is %s" % (self.doc.total_debit-self.doc.total_credit))
|
||||
raise Exception
|
||||
|
||||
# update against account
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if flt(d.debit) > 0: d.against_account = ', '.join(credit_list)
|
||||
if flt(d.credit) > 0: d.against_account = ', '.join(debit_list)
|
||||
|
||||
|
||||
# set aging date
|
||||
#---------------
|
||||
def set_aging_date(self):
|
||||
if self.doc.is_opening != 'Yes':
|
||||
self.doc.aging_date = self.doc.posting_date
|
||||
else:
|
||||
# check account type whether supplier or customer
|
||||
exists = ''
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
exists = sql("select name from tabAccount where account_type in ('Supplier', 'Customer') and name = '%s'" % d.account)
|
||||
if exists:
|
||||
break
|
||||
|
||||
# If cus/supp aging dt is mandatory
|
||||
if exists and not self.doc.aging_date:
|
||||
msgprint("Aging Date is mandatory for opening entry")
|
||||
raise Exception
|
||||
# otherwise aging dt = posting dt
|
||||
else:
|
||||
self.doc.aging_date = self.doc.posting_date
|
||||
|
||||
# ------------------------
|
||||
# set print format fields
|
||||
# ------------------------
|
||||
def set_print_format_fields(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
#msgprint(self.doc.company)
|
||||
chk_type = sql("select master_type, account_type from `tabAccount` where name='%s'" % d.account)
|
||||
master_type, acc_type = chk_type and cstr(chk_type[0][0]) or '', chk_type and cstr(chk_type[0][1]) or ''
|
||||
if master_type in ['Supplier', 'Customer']:
|
||||
if not self.doc.pay_to_recd_from:
|
||||
self.doc.pay_to_recd_from = get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name')
|
||||
|
||||
if acc_type == 'Bank or Cash':
|
||||
dcc = TransactionBase().get_company_currency(self.doc.company)
|
||||
amt = cint(d.debit) and d.debit or d.credit
|
||||
self.doc.total_amount = dcc +' '+ cstr(amt)
|
||||
self.doc.total_amount_in_words = get_obj('Sales Common').get_total_in_words(dcc, cstr(amt))
|
||||
|
||||
|
||||
# --------------------------------
|
||||
# get outstanding invoices values
|
||||
# --------------------------------
|
||||
def get_values(self):
|
||||
cond = (flt(self.doc.write_off_amount) > 0) and ' and outstanding_amount <= '+self.doc.write_off_amount or ''
|
||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
||||
return sql("select name, debit_to, outstanding_amount from `tabReceivable Voucher` where docstatus = 1 and company = '%s' and outstanding_amount > 0 %s" % (self.doc.company, cond))
|
||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
||||
return sql("select name, credit_to, outstanding_amount from `tabPayable Voucher` where docstatus = 1 and company = '%s' and outstanding_amount > 0 %s" % (self.doc.company, cond))
|
||||
|
||||
|
||||
# -------------------------
|
||||
# get outstanding invoices
|
||||
# -------------------------
|
||||
def get_outstanding_invoices(self):
|
||||
self.doc.clear_table(self.doclist, 'entries')
|
||||
total = 0
|
||||
for d in self.get_values():
|
||||
total += flt(d[2])
|
||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist)
|
||||
jd.account = cstr(d[1])
|
||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
||||
jd.credit = flt(d[2])
|
||||
jd.against_invoice = cstr(d[0])
|
||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
||||
jd.debit = flt(d[2])
|
||||
jd.against_voucher = cstr(d[0])
|
||||
jd.save(1)
|
||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', 1, self.doclist)
|
||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
||||
jd.debit = total
|
||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
||||
jd.credit = total
|
||||
jd.save(1)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# VALIDATE
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def validate(self):
|
||||
if not self.doc.is_opening:
|
||||
self.doc.is_opening='No'
|
||||
self.get_against_account()
|
||||
self.validate_cheque_info()
|
||||
self.create_remarks()
|
||||
# tds
|
||||
get_obj('TDS Control').validate_first_entry(self)
|
||||
self.get_tds_category_account()
|
||||
|
||||
self.validate_entries_for_advance()
|
||||
self.set_aging_date()
|
||||
|
||||
self.validate_against_jv()
|
||||
self.set_print_format_fields()
|
||||
|
||||
#FY and Date validation
|
||||
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# On Update - Update Feed
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def on_update(self):
|
||||
pass
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# On submit
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def on_submit(self):
|
||||
if self.doc.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']:
|
||||
self.check_credit_days()
|
||||
self.check_account_against_entries()
|
||||
get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist)
|
||||
|
||||
|
||||
# validate against jv no
|
||||
def validate_against_jv(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.against_jv:
|
||||
if d.against_jv == self.doc.name:
|
||||
msgprint("You can not enter current voucher in 'Against JV' column")
|
||||
raise Exception
|
||||
elif not sql("select name from `tabJournal Voucher Detail` where account = '%s' and docstatus = 1 and parent = '%s'" % (d.account, d.against_jv)):
|
||||
msgprint("Against JV: "+ d.against_jv + " is not valid. Please check")
|
||||
raise Exception
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
# On cancel reverse gl entry
|
||||
#--------------------------------------------------------------------------------------------------------
|
||||
def on_cancel(self):
|
||||
self.check_tds_payment_voucher()
|
||||
get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist, cancel=1)
|
||||
|
||||
# Check whether tds payment voucher has been created against this voucher
|
||||
#---------------------------------------------------------------------------
|
||||
def check_tds_payment_voucher(self):
|
||||
tdsp = sql("select parent from `tabTDS Payment Detail` where voucher_no = '%s' and docstatus = 1 and parent not like 'old%'")
|
||||
if tdsp:
|
||||
msgprint("TDS Payment voucher '%s' has been made against this voucher. Please cancel the payment voucher to proceed." % (tdsp and tdsp[0][0] or ''))
|
||||
raise Exception
|
||||
802
erpnext/accounts/doctype/journal_voucher/journal_voucher.txt
Normal file
802
erpnext/accounts/doctype/journal_voucher/journal_voucher.txt
Normal file
@@ -0,0 +1,802 @@
|
||||
# DocType, Journal Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:06',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-07-28 15:28:12',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1311251040',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': 'voucher_type,posting_date, due_date, cheque_no',
|
||||
'section_style': 'Tabbed',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': ' ',
|
||||
'tag_fields': 'voucher_type',
|
||||
'version': 309
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Journal Voucher',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Journal Voucher',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Journal Voucher
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Journal Voucher'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Basic Info',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 2,
|
||||
'label': '1. Select Series and Dates',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 3,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_type',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'in_filter': 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\nLoan Receipt',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': "eval:doc.voucher_type == 'Write Off Voucher'",
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'write_off_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Write Off Amount <=',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'Accounts Receivable',
|
||||
'depends_on': "eval:doc.voucher_type == 'Write Off Voucher'",
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'write_off_based_on',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 6,
|
||||
'label': 'Write Off Based On',
|
||||
'options': 'Accounts Receivable\nAccounts Payable',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'To manage multiple series please go to Setup > Manage Series',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'naming_series',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 7,
|
||||
'label': 'Series',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'naming_series',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'JV',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'Today',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'Voucher Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'voucher_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry will get or has actually executed.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 9,
|
||||
'in_filter': 1,
|
||||
'label': 'Posting Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'posting_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'due_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 10,
|
||||
'label': 'Due Date',
|
||||
'oldfieldname': 'due_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry is corrected in the system.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amendment_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 11,
|
||||
'label': 'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amendment_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amended_from',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 12,
|
||||
'label': 'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amended_from',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Journal Voucher',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': "eval:doc.voucher_type == 'Write Off Voucher'",
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 13,
|
||||
'label': 'Get Outstanding Invoices',
|
||||
'options': 'get_outstanding_invoices',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': 'Server'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 14,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cheque_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 15,
|
||||
'in_filter': 1,
|
||||
'label': 'Cheque No',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'cheque_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cheque_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 16,
|
||||
'label': 'Cheque Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'cheque_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'clearance_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 17,
|
||||
'in_filter': 1,
|
||||
'label': 'Clearance Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'clearance_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'user_remark',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 18,
|
||||
'in_filter': 1,
|
||||
'label': 'User Remark',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'user_remark',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'User Remark will be added to Auto Remark',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'remark',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 19,
|
||||
'label': 'Remark',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'remark',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 20,
|
||||
'label': '2. Add / Edit GL Entries',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'entries',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 21,
|
||||
'label': 'Entries',
|
||||
'oldfieldname': 'entries',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Journal Voucher Detail',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 22,
|
||||
'label': 'Get Balance',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_debit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 23,
|
||||
'in_filter': 1,
|
||||
'label': 'Total Debit',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'total_debit',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_credit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 24,
|
||||
'in_filter': 1,
|
||||
'label': 'Total Credit',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'total_credit',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'difference',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 25,
|
||||
'label': 'Difference',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'difference',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 26,
|
||||
'label': 'Addtional Info',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 27,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'bill_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 28,
|
||||
'label': 'Bill No',
|
||||
'oldfieldname': 'bill_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'bill_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 29,
|
||||
'label': 'Bill Date',
|
||||
'oldfieldname': 'bill_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'No',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_opening',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 30,
|
||||
'in_filter': 1,
|
||||
'label': 'Is Opening',
|
||||
'oldfieldname': 'is_opening',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'No\nYes',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'aging_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 31,
|
||||
'label': 'Aging Date',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': 'aging_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cancel_reason',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 32,
|
||||
'label': 'Cancel Reason',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'cancel_reason',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'pay_to_recd_from',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 0,
|
||||
'idx': 33,
|
||||
'label': 'Pay To / Recd From',
|
||||
'no_copy': 1,
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_amount',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 0,
|
||||
'idx': 34,
|
||||
'label': 'Total Amount',
|
||||
'no_copy': 1,
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_amount_in_words',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 0,
|
||||
'idx': 35,
|
||||
'label': 'Total Amount in Words',
|
||||
'no_copy': 1,
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 36,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 37,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 38,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Company',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'select_print_heading',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 39,
|
||||
'label': 'Select Print Heading',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'select_print_heading',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Print Heading',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 40,
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 41,
|
||||
'label': 'View Ledger Entry',
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 42,
|
||||
'label': 'TDS',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'default': 'No',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tds_applicable',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 43,
|
||||
'in_filter': 1,
|
||||
'label': 'TDS Applicable',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'tds_applicable',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': '\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tds_category',
|
||||
'fieldtype': 'Select',
|
||||
'hidden': 0,
|
||||
'idx': 44,
|
||||
'in_filter': 1,
|
||||
'label': 'TDS Category',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'tds_category',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'link:TDS Category',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier_account',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': 0,
|
||||
'idx': 45,
|
||||
'label': 'Supplier Account',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'supplier_account',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Account',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 46,
|
||||
'label': 'Get TDS',
|
||||
'no_copy': 0,
|
||||
'oldfieldtype': 'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Tax Code will be populated based on account head mentioned in TDS Category master',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'tax_code',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 47,
|
||||
'label': 'TDS Account Head',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'tax_code',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Account',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'rate',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 48,
|
||||
'label': 'Rate',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'rate',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'ded_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 49,
|
||||
'label': 'Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'ded_amount',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': 'Client'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,191 @@
|
||||
# DocType, Journal Voucher Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:06',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-10-01 16:24:51',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'JVD.######',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 2
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Journal Voucher Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, Journal Voucher Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Journal Voucher Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'in_filter': 1,
|
||||
'label': 'Account',
|
||||
'oldfieldname': 'account',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client',
|
||||
'width': '180px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cost_center',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 2,
|
||||
'in_filter': 1,
|
||||
'label': 'Cost Center',
|
||||
'oldfieldname': 'cost_center',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Cost Center',
|
||||
'permlevel': 0,
|
||||
'search_index': 0,
|
||||
'width': '180px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'balance',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Balance',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'balance',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'debit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 4,
|
||||
'label': 'Debit',
|
||||
'oldfieldname': 'debit',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 5,
|
||||
'label': 'Credit',
|
||||
'oldfieldname': 'credit',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_voucher',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Against Payable',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'against_voucher',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Payable Voucher',
|
||||
'permlevel': 0,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_invoice',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'in_filter': 1,
|
||||
'label': 'Against Receivable',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'against_invoice',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Receivable Voucher',
|
||||
'permlevel': 0,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_jv',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'Against JV',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'against_jv',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Journal Voucher',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_advance',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 9,
|
||||
'label': 'Is Advance',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'is_advance',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'No\nYes',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_account',
|
||||
'fieldtype': 'Text',
|
||||
'hidden': 1,
|
||||
'idx': 10,
|
||||
'label': 'Against Account',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'against_account',
|
||||
'oldfieldtype': 'Text',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
78
erpnext/accounts/doctype/lease_agreement/lease_agreement.js
Normal file
78
erpnext/accounts/doctype/lease_agreement/lease_agreement.js
Normal file
@@ -0,0 +1,78 @@
|
||||
$.extend(cur_frm.cscript, {
|
||||
Generate: function(doc, dt, dn) {
|
||||
if(doc.installment_amount==''){
|
||||
msgprint('Set Installment Amount before generating schedule');
|
||||
return;
|
||||
}
|
||||
if(doc.no_of_installments==''){
|
||||
msgprint('Set Number of Installments before generating schedule');
|
||||
return;
|
||||
}
|
||||
if(doc.start_date==''){
|
||||
msgprint('Set Start Date before generating schedule');
|
||||
return;
|
||||
}
|
||||
cur_frm.cscript.clear_installments(doc);
|
||||
tot=0;i=0;
|
||||
while(tot<flt(doc.invoice_amount)-flt(doc.down_payment)){
|
||||
d = LocalDB.add_child(doc, 'Lease Installment', 'installments');
|
||||
d.amount = flt(doc.installment_amount) < flt(doc.invoice_amount)-flt(doc.down_payment)-tot ? flt(doc.installment_amount) : flt(doc.invoice_amount)-flt(doc.down_payment)-tot
|
||||
d.due_date = dateutil.add_months(doc.start_date, i+1);
|
||||
tot += flt(doc.installment_amount)
|
||||
i++;
|
||||
}
|
||||
cur_frm.refresh();
|
||||
},
|
||||
refresh: function(doc) {
|
||||
cur_frm.cscript.hide_show_buttons(doc);
|
||||
},
|
||||
hide_show_buttons: function(doc) {
|
||||
if(doc.docstatus==0) {
|
||||
hide_field('Installment Reciept'); show_field('Generate');
|
||||
} else if (doc.docstatus==1) {
|
||||
show_field('Installment Reciept');hide_field('Generate');
|
||||
}
|
||||
},
|
||||
clear_installments: function(doc) {
|
||||
$.each(getchildren('Lease Installment', doc.name, 'installments', 'Lease Agreement'),
|
||||
function(i, d) {
|
||||
LocalDB.delete_doc('Lease Installment', d.name);
|
||||
}
|
||||
)
|
||||
},
|
||||
no_of_installments: function(doc)
|
||||
{
|
||||
if(flt(doc.no_of_installments)!=0) {
|
||||
doc.installment_amount = (flt(doc.invoice_amount)- flt(doc.down_payment))/flt(doc.no_of_installments);
|
||||
refresh_field('installment_amount');
|
||||
}
|
||||
},
|
||||
'Installment Reciept': function(doc, dt, dn) {
|
||||
var d = new wn.widgets.Dialog({
|
||||
width: 500,
|
||||
title: 'Add a new payment installment',
|
||||
fields: [
|
||||
{fieldtype:'Data', label:'Cheque Number', fieldname:'cheque_number', reqd:1},
|
||||
{fieldtype:'Date', label:'Cheque Date', fieldname:'cheque_date', reqd:1},
|
||||
{fieldtype:'Link', label:'Bank Account', fieldname:'bank_account', reqd:1, options:'Account'},
|
||||
{fieldtype:'Button', label:'Update',fieldname:'update'}
|
||||
]
|
||||
})
|
||||
d.show();
|
||||
d.fields_dict.update.input.onclick = function() {
|
||||
var data = d.get_values();
|
||||
|
||||
if(data) {
|
||||
$c_obj(make_doclist(dt,dn),'lease_installment_post',data,function(){cur_frm.refresh(); d.hide();});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
cur_frm.add_fetch('invoice','grand_total','invoice_amount');
|
||||
|
||||
cur_frm.fields_dict.invoice.get_query=function(doc){
|
||||
|
||||
return "SELECT tv.name FROM `tabReceivable Voucher` tv WHERE debit_to='"+doc.account+"' and tv.%(key)s like '%s' ORDER BY tv.name LIMIT 50"
|
||||
}
|
||||
37
erpnext/accounts/doctype/lease_agreement/lease_agreement.py
Normal file
37
erpnext/accounts/doctype/lease_agreement/lease_agreement.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import webnotes
|
||||
from webnotes.model.doc import make_autoname, Document, addchild
|
||||
from webnotes import msgprint
|
||||
from webnotes.utils import get_defaults
|
||||
import json
|
||||
from accounts.utils import post_jv
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc, self.doclist = doc, doclist
|
||||
|
||||
def autoname(self):
|
||||
"""
|
||||
Create Lease Id using naming_series pattern
|
||||
"""
|
||||
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
|
||||
|
||||
def lease_installment_post(self, args):
|
||||
"""
|
||||
Posts the Installment receipt into Journal Voucher
|
||||
"""
|
||||
next_inst = sql("select amount,name from `tabLease Installment` where parent=%s and ifnull(cheque_number,'')='' order by due_date limit 1",self.doc.name)
|
||||
|
||||
data = json.loads(args)
|
||||
data['voucher_type']='Lease Receipt'
|
||||
data['naming_series']='JV'
|
||||
data['amount']=next_inst[0][0]
|
||||
data['debit_account']=data.get('bank_account')
|
||||
data['credit_account']=self.doc.account
|
||||
data['fiscal_year']=get_defaults()['fiscal_year']
|
||||
data['company']=get_defaults()['company']
|
||||
jv_name=post_jv(data)
|
||||
|
||||
sql("update `tabLease Installment` set cheque_number=%s, cheque_date=%s, jv_number=%s where name=%s",(data.get('cheque_number'),data.get('cheque_date'),jv_name,next_inst[0][1]))
|
||||
|
||||
self.doclist = [Document(d.doctype, d.name) for d in self.doclist]
|
||||
310
erpnext/accounts/doctype/lease_agreement/lease_agreement.txt
Normal file
310
erpnext/accounts/doctype/lease_agreement/lease_agreement.txt
Normal file
@@ -0,0 +1,310 @@
|
||||
# DocType, Lease Agreement
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-07-22 17:47:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-07-27 15:33:55',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1311555967',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 21
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Lease Agreement',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Lease Agreement',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Lease Agreement
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Lease Agreement'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'Accounts Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'naming_series',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 1,
|
||||
'label': 'Naming Series',
|
||||
'options': '\nLA',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 2,
|
||||
'label': 'Lessee Info.',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'label': 'Lessee Account',
|
||||
'options': 'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'lessee_father',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Lessee Father',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'lessee_nic',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Lessee NIC',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'lessee_contact',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 6,
|
||||
'label': 'Lessee Contact',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'lessee_address',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 7,
|
||||
'label': 'Lessee Address',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 8,
|
||||
'label': 'Vehicle Info.',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'model_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 9,
|
||||
'label': 'Model No',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'engine_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 10,
|
||||
'label': 'Engine No',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'chassis_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 11,
|
||||
'label': 'Chassis No',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 12,
|
||||
'label': 'Invoice and Payment Info.',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'invoice',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 13,
|
||||
'label': 'Invoice',
|
||||
'options': 'Receivable Voucher',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'invoice_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 14,
|
||||
'label': 'Invoice Amount',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'down_payment',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 15,
|
||||
'label': 'Down Payment',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'start_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 16,
|
||||
'label': 'Start Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'no_of_installments',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 17,
|
||||
'label': 'No of Installments',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'installment_amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 18,
|
||||
'label': 'Installment Amount',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 19,
|
||||
'label': 'Generate',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'installments',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 20,
|
||||
'label': 'Installments',
|
||||
'options': 'Lease Installment',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 21,
|
||||
'label': 'Installment Reciept',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,91 @@
|
||||
# DocType, Lease Installment
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-07-22 17:49:33',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-07-22 17:49:33',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Lease Installment',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# DocType, Lease Installment
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Lease Installment'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amount',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 1,
|
||||
'label': 'Amount',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'due_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Due Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cheque_number',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Cheque Number',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cheque_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 4,
|
||||
'label': 'Cheque Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'jv_number',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': 0,
|
||||
'idx': 5,
|
||||
'label': 'JV Number',
|
||||
'options': 'Journal Voucher',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/ledger_balance_export/__init__.py
Executable file
0
erpnext/accounts/doctype/ledger_balance_export/__init__.py
Executable file
3
erpnext/accounts/doctype/ledger_balance_export/ledger_balance_export.js
Executable file
3
erpnext/accounts/doctype/ledger_balance_export/ledger_balance_export.js
Executable file
@@ -0,0 +1,3 @@
|
||||
cur_frm.cscript['Export Report'] = function(doc, cdt, cdn) {
|
||||
$c_obj_csv(make_doclist(cdt, cdn), 'get_report_data', '');
|
||||
}
|
||||
63
erpnext/accounts/doctype/ledger_balance_export/ledger_balance_export.py
Executable file
63
erpnext/accounts/doctype/ledger_balance_export/ledger_balance_export.py
Executable file
@@ -0,0 +1,63 @@
|
||||
import webnotes
|
||||
from webnotes.utils import add_days, cint, cstr, flt, getdate
|
||||
from webnotes.model.doclist import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
# Get fiscal year based on date
|
||||
def get_year(self, dt):
|
||||
yr = sql("select name from `tabFiscal Year` where %s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day)",dt)
|
||||
return yr and yr[0][0] or ''
|
||||
|
||||
# Get gl entries for the period and account
|
||||
def get_gl_entries(self, lft, rgt):
|
||||
gle = sql("select t1.posting_date, t1.voucher_type, t1.voucher_no, t1.debit, t1.credit, t1.remarks from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= %s AND t1.posting_date <= %s and ifnull(t1.is_opening, 'No') = 'No' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s and ifnull(t1.is_cancelled, 'No') = 'No'", (self.doc.from_date, self.doc.to_date, lft, rgt), as_dict=1)
|
||||
entries, dr, cr = [], 0, 0
|
||||
for d in gle:
|
||||
dr, cr = dr + flt(d['debit']), cr + flt(d['credit'])
|
||||
entries.append(['', d['posting_date'], d['voucher_type'], d['voucher_no'], d['debit'], d['credit'], d['remarks']])
|
||||
return entries, dr, cr
|
||||
|
||||
# Get Report Data
|
||||
def get_report_data(self):
|
||||
from_date_year = self.get_year(add_days(self.doc.from_date, -1))
|
||||
to_date_year = self.get_year(self.doc.to_date)
|
||||
|
||||
# result initiatlization
|
||||
header = 'Ledger Balances Between ' + getdate(self.doc.from_date).strftime('%d-%m-%Y') + ' and ' + getdate(self.doc.to_date).strftime('%d-%m-%Y')
|
||||
res = [[header], ['Account', 'Posting Date', 'Voucher Type', 'Voucher No', 'Debit', 'Credit', 'Remarks']]
|
||||
glc = get_obj('GL Control')
|
||||
|
||||
for d in getlist(self.doclist, 'ledger_details'):
|
||||
# Fetch acc details
|
||||
acc_det = sql("select debit_or_credit, is_pl_account, lft, rgt from tabAccount where name = '%s'" % d.account, as_dict=1)[0]
|
||||
|
||||
# Opening
|
||||
opening = glc.get_as_on_balance(d.account, from_date_year, add_days(self.doc.from_date, -1), acc_det['debit_or_credit'], acc_det['lft'], acc_det['rgt'])[2]
|
||||
if acc_det['debit_or_credit'] == 'Credit':
|
||||
opening = -1*opening
|
||||
|
||||
# GL Entries
|
||||
gle, debit, credit = self.get_gl_entries(acc_det['lft'], acc_det['rgt'])
|
||||
|
||||
# Closing
|
||||
closing = opening + debit - credit
|
||||
|
||||
# Append to result
|
||||
res.append([d.account])
|
||||
res += gle
|
||||
res.append(['', '', '', 'Total Debit/Credit', debit, credit])
|
||||
res.append(['', '', '', 'Opening Balance', opening])
|
||||
res.append(['', '', '', 'Closing Balance', closing])
|
||||
|
||||
return res
|
||||
129
erpnext/accounts/doctype/ledger_balance_export/ledger_balance_export.txt
Executable file
129
erpnext/accounts/doctype/ledger_balance_export/ledger_balance_export.txt
Executable file
@@ -0,0 +1,129 @@
|
||||
# DocType, Ledger Balance Export
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-05-24 14:41:08',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-24 15:22:43',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1306229235',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Other',
|
||||
'hide_heading': 0,
|
||||
'issingle': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 9
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Ledger Balance Export',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Ledger Balance Export',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Ledger Balance Export
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Ledger Balance Export'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'Accounts User'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 1,
|
||||
'label': 'Select Date Range'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'From Date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 3,
|
||||
'label': 'To Date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 4,
|
||||
'label': 'Select ledgers'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'ledger_details',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 5,
|
||||
'label': 'Ledger Details',
|
||||
'options': 'Ledger Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 6,
|
||||
'label': 'Export Report',
|
||||
'trigger': 'Client'
|
||||
}
|
||||
]
|
||||
0
erpnext/accounts/doctype/ledger_detail/__init__.py
Executable file
0
erpnext/accounts/doctype/ledger_detail/__init__.py
Executable file
52
erpnext/accounts/doctype/ledger_detail/ledger_detail.txt
Executable file
52
erpnext/accounts/doctype/ledger_detail/ledger_detail.txt
Executable file
@@ -0,0 +1,52 @@
|
||||
# DocType, Ledger Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-05-24 14:50:42',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-24 15:24:03',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 1,
|
||||
'label': 'Account',
|
||||
'name': '__common__',
|
||||
'options': 'Account',
|
||||
'parent': 'Ledger Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocType, Ledger Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Ledger Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField'
|
||||
}
|
||||
]
|
||||
10
erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js
Normal file
10
erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
73
erpnext/accounts/doctype/mode_of_payment/mode_of_payment.txt
Normal file
73
erpnext/accounts/doctype/mode_of_payment/mode_of_payment.txt
Normal file
@@ -0,0 +1,73 @@
|
||||
# DocType, Mode of Payment
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:10',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'field:mode_of_payment',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'mode_of_payment',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Mode of Payment',
|
||||
'name': '__common__',
|
||||
'oldfieldname': 'mode_of_payment',
|
||||
'oldfieldtype': 'Data',
|
||||
'parent': 'Mode of Payment',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Mode of Payment',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'Accounts Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Mode of Payment
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Mode of Payment'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField'
|
||||
}
|
||||
]
|
||||
450
erpnext/accounts/doctype/payable_voucher/payable_voucher.js
Normal file
450
erpnext/accounts/doctype/payable_voucher/payable_voucher.js
Normal file
@@ -0,0 +1,450 @@
|
||||
cur_frm.cscript.tname = "PV Detail";
|
||||
cur_frm.cscript.fname = "entries";
|
||||
cur_frm.cscript.other_fname = "purchase_tax_details";
|
||||
$import(Purchase Other Charges)
|
||||
$import(Purchase Common)
|
||||
|
||||
// On Load
|
||||
// --------
|
||||
cur_frm.cscript.onload = function(doc,dt,dn) {
|
||||
var cp = locals['Control Panel']['Control Panel'];
|
||||
|
||||
if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()});
|
||||
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
|
||||
|
||||
if(cp.country == 'India') {
|
||||
unhide_field(['TDS','tds_applicable','tds_category','Get TDS','tax_code','rate','ded_amount','total_tds_on_voucher','tds_amount_on_advance']);
|
||||
}
|
||||
else {
|
||||
hide_field(['TDS','tds_applicable','tds_category','Get TDS','tax_code','rate','ded_amount','total_tds_on_voucher','tds_amount_on_advance']);
|
||||
}
|
||||
|
||||
if(doc.__islocal){
|
||||
if(doc.supplier) {cur_frm.cscript.supplier(doc,dt,dn)}
|
||||
hide_field(['supplier_address','contact_person','supplier_name','address_display','contact_display','contact_mobile','contact_email']);
|
||||
}
|
||||
|
||||
|
||||
if(doc.supplier) unhide_field(['supplier_address','contact_person','supplier_name','address_display','contact_display','contact_mobile','contact_email']);
|
||||
}
|
||||
|
||||
// Refresh
|
||||
// --------
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
|
||||
cur_frm.clear_custom_buttons();
|
||||
|
||||
// Show / Hide button
|
||||
if(doc.docstatus==1 && doc.outstanding_amount > 0)
|
||||
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript['Make Bank Voucher']);
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
unhide_field(['Repair Outstanding Amt']);
|
||||
cur_frm.add_custom_button('View Ledger', cur_frm.cscript['View Ledger Entry']);
|
||||
} else hide_field(['Repair Outstanding Amt']);
|
||||
|
||||
cur_frm.cscript.is_opening(doc, dt, dn);
|
||||
}
|
||||
|
||||
|
||||
//Supplier
|
||||
cur_frm.cscript.supplier = function(doc,dt,dn) {
|
||||
|
||||
var callback = function(r,rt) {
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
get_server_fields('get_credit_to','','',doc, dt, dn, 0, callback2);
|
||||
}
|
||||
|
||||
var callback2 = function(r,rt){
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
var el = getchildren('PV Detail',doc.name,'entries');
|
||||
for(var i in el){
|
||||
if(el[i].item_code && (!el[i].expense_head || !el[i].cost_center)){
|
||||
args = "{'item_code':'" + el[i].item_code + "','expense_head':'" + el[i].expense_head + "','cost_center':'" + el[i].cost_center + "'}";
|
||||
get_server_fields('get_default_values', args, 'entries', doc, el[i].doctype, el[i].name, 1);
|
||||
}
|
||||
}
|
||||
cur_frm.cscript.calc_total(doc);
|
||||
}
|
||||
|
||||
if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1,callback);
|
||||
if(doc.supplier) unhide_field(['supplier_address','contact_person','supplier_name','address_display','contact_display','contact_mobile','contact_email']);
|
||||
}
|
||||
|
||||
cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
|
||||
if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name,address_line1,city FROM tabAddress WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict.supplier_address.on_new = function(dn) {
|
||||
locals['Address'][dn].supplier = locals[cur_frm.doctype][cur_frm.docname].supplier;
|
||||
locals['Address'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.contact_person.on_new = function(dn) {
|
||||
locals['Contact'][dn].supplier = locals[cur_frm.doctype][cur_frm.docname].supplier;
|
||||
locals['Contact'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.credit_to = function(doc,dt,dn) {
|
||||
|
||||
var callback = function(r,rt) {
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1);
|
||||
if(doc.supplier) unhide_field(['supplier_address','contact_person','supplier_name','address_display','contact_display','contact_mobile','contact_email']);
|
||||
cur_frm.refresh();
|
||||
}
|
||||
|
||||
get_server_fields('get_cust','','',doc,dt,dn,1,callback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Get Print Heading
|
||||
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
//Set expense_head and cost center on adding new row
|
||||
//----------------------------------------------
|
||||
cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){
|
||||
|
||||
cl = getchildren('PV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
|
||||
acc = '';
|
||||
cc = '';
|
||||
|
||||
for(var i = 0; i<cl.length; i++) {
|
||||
if (cl[i].idx == 1){
|
||||
acc = cl[i].expense_head;
|
||||
cc = cl[i].cost_center;
|
||||
}
|
||||
else{
|
||||
if (! cl[i].expense_head) { cl[i].expense_head = acc; refresh_field('expense_head', cl[i].name, 'entries');}
|
||||
if (! cl[i].cost_center) {cl[i].cost_center = cc; refresh_field('cost_center', cl[i].name, 'entries');}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.is_opening = function(doc, dt, dn) {
|
||||
hide_field('aging_date');
|
||||
if (doc.is_opening == 'Yes') unhide_field('aging_date');
|
||||
}
|
||||
|
||||
/* ******************************** TRIGGERS **************************************** */
|
||||
/*
|
||||
// Supplier
|
||||
// ---------
|
||||
cur_frm.cscript.supplier = function(doc,cdt,cdn){
|
||||
get_server_fields('get_credit_to','','',doc,cdt,cdn);
|
||||
}
|
||||
*/
|
||||
|
||||
// Conversion Rate
|
||||
// ----------------
|
||||
cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) {
|
||||
cur_frm.cscript.calc_total(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
// Recalculate Button
|
||||
// -------------------
|
||||
cur_frm.cscript['Recalculate'] = function(doc, dt, dn) {
|
||||
cur_frm.cscript.calc_total(doc, cdt, cdn);
|
||||
calc_total_advance(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
// Get Items Button
|
||||
// -----------------
|
||||
cur_frm.cscript['Get Items'] = function(doc, dt, dn) {
|
||||
var callback = function(r,rt) {
|
||||
unhide_field(['supplier_address','contact_person','supplier_name','address_display','contact_display','contact_mobile','contact_email']);
|
||||
refresh_many(['credit_to','supplier','supplier_address','contact_person','supplier_name','address_display','contact_display','contact_mobile','contact_email','entries','purchase_receipt_main','purchase_order_main']);
|
||||
}
|
||||
get_server_fields('pull_details','','',doc, dt, dn,1,callback);
|
||||
}
|
||||
|
||||
|
||||
// ========== PV Details Table ============
|
||||
|
||||
// Item Code
|
||||
// ----------
|
||||
cur_frm.cscript.item_code = function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.item_code){
|
||||
get_server_fields('get_item_details',d.item_code,'entries',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
|
||||
// Quantity
|
||||
// ---------
|
||||
cur_frm.cscript.qty = function(doc,dt,dn) { cur_frm.cscript.calc_exp_row(doc,dt,dn); }
|
||||
|
||||
// Import Rate
|
||||
// ------------
|
||||
cur_frm.cscript.import_rate = function(doc,dt,dn) {
|
||||
var d = locals[dt][dn];
|
||||
set_multiple('PV Detail', d.name, {'rate': flt(d.import_rate) * flt(doc.conversion_rate) }, 'entries');
|
||||
cur_frm.cscript.calc_exp_row(doc,dt,dn)
|
||||
}
|
||||
|
||||
|
||||
// ============== TDS ===============
|
||||
|
||||
// Rate in Deduct Taxes (TDS)
|
||||
// --------------------------
|
||||
cur_frm.cscript.rate = function(doc,dt,dn) {
|
||||
//This is done as Purchase tax detail and PV detail both contain the same fieldname 'rate'
|
||||
if(dt != 'Purchase Tax Detail') cur_frm.cscript.calc_exp_row(doc,dt,dn);
|
||||
}
|
||||
|
||||
// Amount
|
||||
// -------
|
||||
cur_frm.cscript.ded_amount = function(doc,dt,dn) { cur_frm.cscript.calc_total(doc); }
|
||||
|
||||
// Get TDS Button
|
||||
// ---------------
|
||||
cur_frm.cscript['Get TDS'] = function(doc, dt, dn) {
|
||||
var callback = function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
refresh_field('ded_amount');
|
||||
cur_frm.cscript.calc_total(locals[dt][dn]);
|
||||
}
|
||||
$c_obj(make_doclist(dt,dn), 'get_tds', '', callback);
|
||||
}
|
||||
|
||||
// ===================== Advance Allocation ==================
|
||||
cur_frm.cscript.allocated_amount = function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.allocated_amount && d.tds_amount){
|
||||
d.tds_allocated=flt(d.tds_amount*(d.allocated_amount/d.advance_amount))
|
||||
refresh_field('tds_allocated', d.name, 'advance_allocation_details');
|
||||
}
|
||||
tot_tds=0
|
||||
el = getchildren('Advance Allocation Detail',doc.name,'advance_allocation_details')
|
||||
for(var i in el){
|
||||
tot_tds += el[i].tds_allocated
|
||||
}
|
||||
doc.tds_amount_on_advance = tot_tds
|
||||
refresh_field('tds_amount_on_advance');
|
||||
|
||||
calc_total_advance(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
|
||||
// Make Journal Voucher
|
||||
// --------------------
|
||||
cur_frm.cscript['Make Bank Voucher'] = function(doc, dt, dn) {
|
||||
cur_frm.cscript.make_jv(cur_frm.doc);
|
||||
}
|
||||
|
||||
|
||||
/* ***************************** GET QUERY Functions *************************** */
|
||||
|
||||
// Item Code
|
||||
// ----------
|
||||
cur_frm.fields_dict['entries'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE tabItem.is_purchase_item="Yes" AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.%(key)s LIKE "%s" LIMIT 50'
|
||||
}
|
||||
|
||||
// Credit To
|
||||
// ----------
|
||||
cur_frm.fields_dict['credit_to'].get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.is_pl_account="No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
|
||||
// Purchase Order
|
||||
// ---------------
|
||||
cur_frm.fields_dict['purchase_order_main'].get_query = function(doc) {
|
||||
if (doc.supplier){
|
||||
return 'SELECT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`docstatus` = 1 AND `tabPurchase Order`.supplier = "'+ doc.supplier +'" AND `tabPurchase Order`.`status` != "Stopped" AND ifnull(`tabPurchase Order`.`per_billed`,0) < 100 AND `tabPurchase Order`.`company` = "' + doc.company + '" AND `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50'
|
||||
} else {
|
||||
return 'SELECT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`docstatus` = 1 AND `tabPurchase Order`.`status` != "Stopped" AND ifnull(`tabPurchase Order`.`per_billed`, 0) < 100 AND `tabPurchase Order`.`company` = "' + doc.company + '" AND `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50'
|
||||
}
|
||||
}
|
||||
|
||||
// Purchase Receipt
|
||||
// -----------------
|
||||
cur_frm.fields_dict['purchase_receipt_main'].get_query = function(doc) {
|
||||
if (doc.supplier){
|
||||
return 'SELECT `tabPurchase Receipt`.`name` FROM `tabPurchase Receipt` WHERE `tabPurchase Receipt`.`docstatus` = 1 AND `tabPurchase Receipt`.supplier = "'+ doc.supplier +'" AND `tabPurchase Receipt`.`status` != "Stopped" AND ifnull(`tabPurchase Receipt`.`per_billed`, 0) < 100 AND `tabPurchase Receipt`.`company` = "' + doc.company + '" AND `tabPurchase Receipt`.%(key)s LIKE "%s" ORDER BY `tabPurchase Receipt`.`name` DESC LIMIT 50'
|
||||
} else {
|
||||
return 'SELECT `tabPurchase Receipt`.`name` FROM `tabPurchase Receipt` WHERE `tabPurchase Receipt`.`docstatus` = 1 AND `tabPurchase Receipt`.`status` != "Stopped" AND ifnull(`tabPurchase Receipt`.`per_billed`, 0) < 100 AND `tabPurchase Receipt`.`company` = "' + doc.company + '" AND `tabPurchase Receipt`.%(key)s LIKE "%s" ORDER BY `tabPurchase Receipt`.`name` DESC LIMIT 50'
|
||||
}
|
||||
}
|
||||
|
||||
// ================== PV Details Table ===================
|
||||
// Expense Head
|
||||
// -------------
|
||||
cur_frm.fields_dict['entries'].grid.get_field("expense_head").get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
|
||||
}
|
||||
cur_frm.cscript.expense_head = function(doc, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.idx == 1 && d.expense_head){
|
||||
var cl = getchildren('PV Detail', doc.name, 'entries', doc.doctype);
|
||||
for(var i = 0; i < cl.length; i++){
|
||||
if(!cl[i].expense_head) cl[i].expense_head = d.expense_head;
|
||||
}
|
||||
}
|
||||
refresh_field('entries');
|
||||
}
|
||||
|
||||
|
||||
// Cost Center
|
||||
//-------------
|
||||
cur_frm.fields_dict['entries'].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.docstatus != 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.idx == 1 && d.cost_center){
|
||||
var cl = getchildren('PV Detail', doc.name, 'entries', doc.doctype);
|
||||
for(var i = 0; i < cl.length; i++){
|
||||
if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;
|
||||
}
|
||||
}
|
||||
refresh_field('entries');
|
||||
}
|
||||
|
||||
|
||||
// TDS Account Head
|
||||
cur_frm.fields_dict['tax_code'].get_query = function(doc) {
|
||||
return "SELECT `tabTDS Category Account`.account_head FROM `tabTDS Category Account` WHERE `tabTDS Category Account`.parent = '"+doc.tds_category+"' AND `tabTDS Category Account`.company='"+doc.company+"' AND `tabTDS Category Account`.account_head LIKE '%s' ORDER BY `tabTDS Category Account`.account_head DESC LIMIT 50";
|
||||
}
|
||||
|
||||
cur_frm.cscript.tax_code = function(doc, dt, dn) {
|
||||
get_server_fields('get_tds_rate','','',doc, dt, dn, 0);
|
||||
}
|
||||
|
||||
/* ***************************** UTILITY FUNCTIONS ************************ */
|
||||
|
||||
// Calculate
|
||||
// ---------
|
||||
cur_frm.cscript.calc_total = function(doc) {
|
||||
|
||||
// expense
|
||||
var t_exp = 0.0;
|
||||
var el = getchildren('PV Detail',doc.name,'entries');
|
||||
for(var i in el) {
|
||||
if (flt(el[i].import_rate) > 0){
|
||||
set_multiple('PV Detail', el[i].name, {'rate': flt(doc.conversion_rate) * flt(el[i].import_rate) }, 'entries');
|
||||
set_multiple('PV Detail', el[i].name, {'import_amount': flt(el[i].qty) * flt(el[i].import_rate) }, 'entries');
|
||||
}
|
||||
set_multiple('PV Detail', el[i].name, {'amount': flt(el[i].qty) * flt(el[i].rate) }, 'entries')
|
||||
t_exp += flt(el[i].amount);
|
||||
}
|
||||
doc.net_total = flt(t_exp);
|
||||
refresh_field('net_total');
|
||||
cur_frm.cscript.val_cal_charges(doc, cdt, cdn, cur_frm.cscript.tname, cur_frm.cscript.fname, cur_frm.cscript.other_fname);
|
||||
}
|
||||
|
||||
|
||||
// Calculate Advance
|
||||
// ------------------
|
||||
var calc_total_advance = function(doc,cdt,cdn) {
|
||||
var doc = locals[doc.doctype][doc.name];
|
||||
var el = getchildren('Advance Allocation Detail',doc.name,'advance_allocation_details')
|
||||
var tot_tds=0;
|
||||
var total_advance = 0;
|
||||
for(var i in el) {
|
||||
if (! el[i].allocated_amount == 0) {
|
||||
total_advance += flt(el[i].allocated_amount);
|
||||
tot_tds += flt(el[i].tds_allocated)
|
||||
}
|
||||
}
|
||||
doc.total_amount_to_pay = flt(doc.grand_total) - flt(doc.ded_amount);
|
||||
doc.tds_amount_on_advance = flt(tot_tds);
|
||||
doc.total_advance = flt(total_advance);
|
||||
doc.outstanding_amount = flt(doc.total_amount_to_pay) - flt(total_advance);
|
||||
refresh_many(['total_advance','outstanding_amount','tds_amount_on_advance', 'total_amount_to_pay']);
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.calc_exp_row = function(doc,dt,dn) {
|
||||
var d = locals[dt][dn];
|
||||
d.amount = flt(d.qty * d.rate);
|
||||
refresh_field('amount',dn,'entries');
|
||||
|
||||
if (!doc.conversion_rate){ doc.conversion_rate = 1; refresh_field('conversion_rate'); }
|
||||
|
||||
set_multiple('PV Detail', dn, {'import_rate': flt(d.rate) / flt(doc.conversion_rate) }, 'entries');
|
||||
set_multiple('PV Detail', dn, {'import_amount': flt(d.qty) * flt(d.rate) / flt(doc.conversion_rate) }, 'entries');
|
||||
|
||||
cur_frm.cscript.calc_total(doc)
|
||||
}
|
||||
|
||||
|
||||
// Make JV
|
||||
// --------
|
||||
cur_frm.cscript.make_jv = function(doc, dt, dn, det) {
|
||||
var jv = LocalDB.create('Journal Voucher');
|
||||
jv = locals['Journal Voucher'][jv];
|
||||
jv.voucher_type = 'Bank Voucher';
|
||||
//jv.voucher_series = det.def_bv_series;
|
||||
//jv.voucher_date = doc.voucher_date;
|
||||
//jv.posting_date = doc.posting_date;
|
||||
jv.remark = repl('Payment against voucher %(vn)s for %(rem)s', {vn:doc.name, rem:doc.remarks});
|
||||
jv.total_debit = doc.outstanding_amount;
|
||||
jv.total_credit = doc.outstanding_amount;
|
||||
jv.fiscal_year = doc.fiscal_year;
|
||||
jv.company = doc.company;
|
||||
|
||||
// debit to creditor
|
||||
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
d1.account = doc.credit_to;
|
||||
d1.debit = doc.outstanding_amount;
|
||||
//d1.balance = det.acc_balance;
|
||||
d1.against_voucher = doc.name;
|
||||
|
||||
// credit to bank
|
||||
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||
//d1.account = det.def_bank_account;
|
||||
//d1.balance = det.bank_balance;
|
||||
d1.credit = doc.outstanding_amount;
|
||||
|
||||
loaddoc('Journal Voucher', jv.name);
|
||||
}
|
||||
|
||||
// ***************** Get project name *****************
|
||||
cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
|
||||
if(doc.select_print_heading){
|
||||
// print heading
|
||||
cur_frm.pformat.print_heading = doc.select_print_heading;
|
||||
}
|
||||
else
|
||||
cur_frm.pformat.print_heading = "Purchase Invoice";
|
||||
}
|
||||
|
||||
/* *********************** Client Side Validation **************************** */
|
||||
// Validate
|
||||
// ---------
|
||||
cur_frm.cscript.validate = function(doc, cdt, cdn) {
|
||||
is_item_table(doc,cdt,cdn);
|
||||
cur_frm.cscript.calc_total(doc, cdt, cdn);
|
||||
calc_total_advance(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
/****************** Get Accounting Entry *****************/
|
||||
cur_frm.cscript['View Ledger Entry'] = function(){
|
||||
var callback = function(report){
|
||||
report.set_filter('GL Entry', 'Voucher No',cur_frm.doc.name);
|
||||
report.dt.run();
|
||||
}
|
||||
loadreport('GL Entry','General Ledger', callback);
|
||||
}
|
||||
507
erpnext/accounts/doctype/payable_voucher/payable_voucher.py
Normal file
507
erpnext/accounts/doctype/payable_voucher/payable_voucher.py
Normal file
@@ -0,0 +1,507 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
class DocType(TransactionBase):
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
self.tname = 'PV Detail'
|
||||
self.fname = 'entries'
|
||||
|
||||
# Autoname
|
||||
# ---------
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.####')
|
||||
|
||||
|
||||
# ************************** Trigger Functions ****************************
|
||||
|
||||
# Credit To
|
||||
# ----------
|
||||
def get_credit_to(self):
|
||||
acc_head = sql("select name, credit_days from `tabAccount` where (name = %s or (master_name = %s and master_type = 'supplier')) and docstatus != 2", (cstr(self.doc.supplier) + " - " + self.get_company_abbr(),self.doc.supplier))
|
||||
#supp_detail = sql("select supplier_name,address from `tabSupplier` where name = %s", self.doc.supplier, as_dict =1)
|
||||
#ret = {
|
||||
# 'supplier_name' : supp_detail and supp_detail[0]['supplier_name'] or '',
|
||||
# 'supplier_address': supp_detail and supp_detail[0]['address'] or ''
|
||||
#}
|
||||
ret = {}
|
||||
if acc_head and acc_head[0][0]:
|
||||
ret['credit_to'] = acc_head[0][0]
|
||||
if not self.doc.due_date:
|
||||
ret['due_date'] = add_days(cstr(self.doc.posting_date), acc_head and cint(acc_head[0][1]) or 0)
|
||||
elif not acc_head:
|
||||
msgprint("%s does not have an Account Head in %s. You must first create it from the Supplier Master" % (self.doc.supplier, self.doc.company))
|
||||
return ret
|
||||
|
||||
def get_cust(self):
|
||||
ret = {}
|
||||
if self.doc.credit_to:
|
||||
ret['supplier'] = get_value('Account',self.doc.credit_to,'master_name')
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
# Get Default Cost Center and Expense Head from Item Master
|
||||
# ----------------------------------------------------------
|
||||
def get_default_values(self,args):
|
||||
args = eval(args)
|
||||
ret = {}
|
||||
if sql("select name from `tabItem` where name = '%s'" % args['item_code']):
|
||||
if not args['expense_head'] or args['expense_head'] == 'undefined':
|
||||
expense_head = sql("select name from `tabAccount` where account_name in (select purchase_account from `tabItem` where name = '%s')" % args['item_code'])
|
||||
ret['expense_head'] = expense_head and expense_head[0][0] or ''
|
||||
if not args['cost_center'] or args['cost_center'] == 'undefined':
|
||||
cost_center = sql("select cost_center from `tabItem` where name = '%s'" % args['item_code'])
|
||||
ret['cost_center'] = cost_center and cost_center[0][0] or ''
|
||||
return ret
|
||||
|
||||
|
||||
# Get Items based on PO or PR
|
||||
# ----------------------------
|
||||
def pull_details(self):
|
||||
if self.doc.purchase_receipt_main:
|
||||
self.validate_duplicate_docname('purchase_receipt')
|
||||
self.doclist = get_obj('DocType Mapper', 'Purchase Receipt-Payable Voucher').dt_map('Purchase Receipt', 'Payable Voucher', self.doc.purchase_receipt_main, self.doc, self.doclist, "[['Purchase Receipt', 'Payable Voucher'],['Purchase Receipt Detail', 'PV Detail']]")
|
||||
|
||||
elif self.doc.purchase_order_main:
|
||||
self.validate_duplicate_docname('purchase_order')
|
||||
self.doclist = get_obj('DocType Mapper', 'Purchase Order-Payable Voucher').dt_map('Purchase Order', 'Payable Voucher', self.doc.purchase_order_main, self.doc, self.doclist, "[['Purchase Order', 'Payable Voucher'],['PO Detail', 'PV Detail']]")
|
||||
|
||||
ret = self.get_credit_to()
|
||||
#self.doc.supplier_name = ret['supplier_name']
|
||||
#self.doc.supplier_address = ret['supplier_address']
|
||||
|
||||
#self.doc.cst_no =ret['cst_no']
|
||||
#self.doc.bst_no = ret['bst_no']
|
||||
#self.doc.vat_tin_no = ret['vat_tin_no']
|
||||
|
||||
if ret.has_key('credit_to'):
|
||||
self.doc.credit_to = ret['credit_to']
|
||||
|
||||
|
||||
# Get Item Details
|
||||
# -----------------
|
||||
def get_item_details(self,arg):
|
||||
item_det = sql("select item_name, brand, description, item_group,purchase_account,cost_center from tabItem where name=%s",arg,as_dict=1)
|
||||
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg)
|
||||
t = {}
|
||||
for x in tax: t[x[0]] = flt(x[1])
|
||||
ret = {
|
||||
'item_name' : item_det and item_det[0]['item_name'] or '',
|
||||
'brand' : item_det and item_det[0]['brand'] or '',
|
||||
'description' : item_det and item_det[0]['description'] or '',
|
||||
'item_group' : item_det and item_det[0]['item_group'] or '',
|
||||
'rate' : 0.00,
|
||||
'qty' : 0.00,
|
||||
'amount' : 0.00,
|
||||
'expense_head' : item_det and item_det[0]['purchase_account'] or '',
|
||||
'cost_center' : item_det and item_det[0]['cost_center'] or '',
|
||||
'item_tax_rate' : str(t)
|
||||
}
|
||||
return ret
|
||||
|
||||
# Advance Allocation
|
||||
# -------------------
|
||||
def get_advances(self):
|
||||
get_obj('GL Control').get_advances( self, self.doc.credit_to, 'Advance Allocation Detail','advance_allocation_details','debit')
|
||||
|
||||
|
||||
# ============= OTHER CHARGES ====================
|
||||
|
||||
# Get Tax rate if account type is TAX
|
||||
# ------------------------------------
|
||||
def get_rate(self,arg):
|
||||
return get_obj('Purchase Common').get_rate(arg,self)
|
||||
|
||||
# Pull details from other charges master (Get Other Charges)
|
||||
# -----------------------------------------------------------
|
||||
def get_purchase_tax_details(self):
|
||||
return get_obj('Purchase Common').get_purchase_tax_details(self)
|
||||
|
||||
|
||||
def get_rate1(self,acc):
|
||||
rate = sql("select tax_rate from `tabAccount` where name='%s'"%(acc))
|
||||
ret={'add_tax_rate' :rate and flt(rate[0][0]) or 0 }
|
||||
return ret
|
||||
|
||||
|
||||
# *************************** Server Utility Functions *****************************
|
||||
# Get Company abbr
|
||||
# -----------------
|
||||
def get_company_abbr(self):
|
||||
return sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
|
||||
|
||||
# Check whether PO or PR is already fetched
|
||||
# ------------------------------------------
|
||||
def validate_duplicate_docname(self,doctype):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if doctype == 'purchase_receipt' and cstr(self.doc.purchase_receipt_main) == cstr(d.purchase_receipt):
|
||||
msgprint(cstr(self.doc.purchase_receipt_main) + " purchase receipt details have already been pulled.")
|
||||
raise Exception , " Validation Error. "
|
||||
|
||||
if doctype == 'purchase_order' and cstr(self.doc.purchase_order_main) == cstr(d.purchase_order) and not d.purchase_receipt:
|
||||
msgprint(cstr(self.doc.purchase_order_main) + " purchase order details have already been pulled.")
|
||||
raise Exception , " Validation Error. "
|
||||
|
||||
|
||||
# **************************** VALIDATE ********************************
|
||||
|
||||
# Check for Item.is_Purchase_item = 'Yes' and Item is active
|
||||
# ------------------------------------------------------------------
|
||||
def check_active_purchase_items(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.item_code: # extra condn coz item_code is not mandatory in PV
|
||||
valid_item = sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
|
||||
if valid_item[0][0] == 2:
|
||||
msgprint("Item : '%s' is Inactive, you can restore it from Trash" %(d.item_code))
|
||||
raise Exception
|
||||
if not valid_item[0][1] == 'Yes':
|
||||
msgprint("Item : '%s' is not Purchase Item"%(d.item_code))
|
||||
raise Exception
|
||||
|
||||
# Check Conversion Rate
|
||||
# ----------------------
|
||||
def check_conversion_rate(self):
|
||||
default_currency = TransactionBase().get_company_currency(self.doc.company)
|
||||
if not default_currency:
|
||||
msgprint('Message: Please enter default currency in Company Master')
|
||||
raise Exception
|
||||
if (self.doc.currency == default_currency and flt(self.doc.conversion_rate) != 1.00) or not self.doc.conversion_rate or (self.doc.currency != default_currency and flt(self.doc.conversion_rate) == 1.00):
|
||||
msgprint("Message: Please Enter Appropriate Conversion Rate.")
|
||||
raise Exception
|
||||
|
||||
# 1. Check whether bill is already booked against this bill no. or not
|
||||
# 2. Add Remarks
|
||||
# ---------------------------------------------------------------------
|
||||
def validate_bill_no(self):
|
||||
if self.doc.bill_no and self.doc.bill_no.lower().strip() not in ['na', 'not applicable', 'none']:
|
||||
b_no = sql("select bill_no, name, ifnull(is_opening,'') from `tabPayable Voucher` where bill_no = '%s' and credit_to = '%s' and docstatus = 1 and name != '%s' " % (self.doc.bill_no, self.doc.credit_to, self.doc.name))
|
||||
if b_no and cstr(b_no[0][2]) == cstr(self.doc.is_opening):
|
||||
msgprint("Please check you have already booked expense against Bill No. %s in Purchase Invoice %s" % (cstr(b_no[0][0]), cstr(b_no[0][1])))
|
||||
raise Exception , "Validation Error"
|
||||
if not self.doc.remarks:
|
||||
self.doc.remarks = (self.doc.remarks or '') + "\n" + ("Against Bill %s dated %s" % (self.doc.bill_no, formatdate(self.doc.bill_date)))
|
||||
if self.doc.ded_amount:
|
||||
self.doc.remarks = (self.doc.remarks or '') + "\n" + ("Grand Total: %s, Tax Deduction Amount: %s" %(self.doc.grand_total, self.doc.ded_amount))
|
||||
else:
|
||||
if not self.doc.remarks:
|
||||
self.doc.remarks = "No Remarks"
|
||||
|
||||
# Validate Bill No Date
|
||||
# ---------------------
|
||||
def validate_bill_no_date(self):
|
||||
if self.doc.bill_no and not self.doc.bill_date and self.doc.bill_no.lower().strip() not in ['na', 'not applicable', 'none']:
|
||||
msgprint("Please enter Bill Date")
|
||||
raise Exception
|
||||
|
||||
|
||||
|
||||
# Clear Advances
|
||||
# ---------------
|
||||
def clear_advances(self):
|
||||
get_obj('GL Control').clear_advances( self, 'Advance Allocation Detail','advance_allocation_details')
|
||||
|
||||
|
||||
# 1. Credit To Account Exists
|
||||
# 2. Is a Credit Account
|
||||
# 3. Is not a PL Account
|
||||
# ----------------------------
|
||||
def validate_credit_acc(self):
|
||||
acc = sql("select debit_or_credit, is_pl_account from tabAccount where name = '%s'" % self.doc.credit_to)
|
||||
if not acc:
|
||||
msgprint("Account: "+ self.doc.credit_to + "does not exist")
|
||||
raise Exception
|
||||
elif acc[0][0] and acc[0][0] != 'Credit':
|
||||
msgprint("Account: "+ self.doc.credit_to + "is not a credit account")
|
||||
raise Exception
|
||||
elif acc[0][1] and acc[0][1] != 'No':
|
||||
msgprint("Account: "+ self.doc.credit_to + "is a pl account")
|
||||
raise Exception
|
||||
|
||||
# Validate Acc Head of Supplier and Credit To Account entered
|
||||
# ------------------------------------------------------------
|
||||
def check_for_acc_head_of_supplier(self):
|
||||
acc_head = sql("select name from `tabAccount` where name = %s", (cstr(self.doc.supplier) + " - " + self.get_company_abbr()))
|
||||
if self.doc.supplier:
|
||||
if acc_head and acc_head[0][0]:
|
||||
if not cstr(acc_head[0][0]) == cstr(self.doc.credit_to):
|
||||
msgprint("Credit To: %s do not match with Supplier: %s for Company: %s i.e. %s" %(self.doc.credit_to,self.doc.supplier,self.doc.company,cstr(acc_head[0][0])))
|
||||
raise Exception, "Validation Error "
|
||||
if not acc_head:
|
||||
msgprint("Supplier %s does not have an Account Head in %s. You must first create it from the Supplier Master" % (self.doc.supplier, self.doc.company))
|
||||
raise Exception, "Validation Error "
|
||||
|
||||
# Check for Stopped PO
|
||||
# ---------------------
|
||||
def check_for_stopped_status(self):
|
||||
check_list = []
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
|
||||
check_list.append(d.purhcase_order)
|
||||
stopped = sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order)
|
||||
if stopped:
|
||||
msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order))
|
||||
raise Exception
|
||||
|
||||
# Validate Supplier
|
||||
# -----------------
|
||||
def validate_supplier(self, d):
|
||||
supplier = ''
|
||||
if d.purchase_order and not d.purchase_order in self.po_list:
|
||||
supplier = sql("select supplier from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0]
|
||||
doctype = 'purchase order'
|
||||
doctype_no = cstr(d.purchase_order)
|
||||
if supplier and not cstr(self.doc.supplier) == cstr(supplier):
|
||||
msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,doctype,doctype_no))
|
||||
raise Exception , " Validation Error "
|
||||
|
||||
if d.purchase_receipt and not d.purchase_receipt in self.pr_list:
|
||||
supplier = sql("select supplier from `tabPurchase Receipt` where name = '%s'" % d.purchase_receipt)[0][0]
|
||||
doctype = 'purchase receipt'
|
||||
doctype_no = cstr(d.purchase_receipt)
|
||||
if supplier and not cstr(self.doc.supplier) == cstr(supplier):
|
||||
msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,doctype,doctype_no))
|
||||
raise Exception , " Validation Error "
|
||||
|
||||
# Validate values with reference document
|
||||
#----------------------------------------
|
||||
def validate_reference_value(self):
|
||||
get_obj('DocType Mapper', 'Purchase Order-Payable Voucher', with_children = 1).validate_reference_value(self, self.doc.name)
|
||||
|
||||
|
||||
# Validate PO and PR
|
||||
# -------------------
|
||||
def validate_po_pr(self, d):
|
||||
# check po / pr for qty and rates and currency and conversion rate
|
||||
|
||||
# always import_rate must be equal to import_rate of purchase order
|
||||
if d.purchase_order and not d.purchase_order in self.po_list:
|
||||
# currency
|
||||
currency = cstr(sql("select currency from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0])
|
||||
if not cstr(currency) == cstr(self.doc.currency):
|
||||
msgprint("Purchase Order: " + cstr(d.purchase_order) + " currency : " + cstr(currency) + " does not match with currency of current document.")
|
||||
raise Exception
|
||||
# import_rate
|
||||
rate = flt(sql('select import_rate from `tabPO Detail` where item_code=%s and parent=%s and name = %s', (d.item_code, d.purchase_order, d.po_detail))[0][0])
|
||||
if abs(rate - flt(d.import_rate)) > 1:
|
||||
msgprint("Import Rate for %s in the Purchase Order is %s. Rate must be same as Purchase Order Rate" % (d.item_code,rate))
|
||||
raise Exception
|
||||
|
||||
if d.purchase_receipt and not d.purchase_receipt in self.pr_list:
|
||||
# currency , conversion_rate
|
||||
data = sql("select currency, conversion_rate from `tabPurchase Receipt` where name = '%s'" % d.purchase_receipt, as_dict = 1)
|
||||
if not cstr(data[0]['currency']) == cstr(self.doc.currency):
|
||||
msgprint("Purchase Receipt: " + cstr(d.purchase_receipt) + " currency : " + cstr(data[0]['currency']) + " does not match with currency of current document.")
|
||||
raise Exception
|
||||
if not flt(data[0]['conversion_rate']) == flt(self.doc.conversion_rate):
|
||||
msgprint("Purchase Receipt: " + cstr(d.purchase_receipt) + " conversion_rate : " + cstr(data[0]['conversion_rate']) + " does not match with conversion_rate of current document.")
|
||||
raise Exception
|
||||
|
||||
# Build tds table if applicable
|
||||
#------------------------------
|
||||
def get_tds(self):
|
||||
if cstr(self.doc.is_opening) != 'Yes':
|
||||
if not self.doc.credit_to:
|
||||
msgprint("Please Enter Credit To account first")
|
||||
raise Exception
|
||||
else:
|
||||
tds_applicable = sql("select tds_applicable from tabAccount where name = '%s'" % self.doc.credit_to)
|
||||
if tds_applicable and cstr(tds_applicable[0][0]) == 'Yes':
|
||||
if not self.doc.tds_applicable:
|
||||
msgprint("Please enter whether TDS Applicable or not")
|
||||
raise Exception
|
||||
if self.doc.tds_applicable == 'Yes':
|
||||
if not self.doc.tds_category:
|
||||
msgprint("Please select TDS Category")
|
||||
raise Exception
|
||||
else:
|
||||
get_obj('TDS Control').get_tds_amount(self)
|
||||
self.doc.total_tds_on_voucher = self.doc.ded_amount
|
||||
self.doc.total_amount_to_pay=flt(self.doc.grand_total)-flt(self.doc.ded_amount)-flt(self.doc.other_tax_deducted)
|
||||
elif self.doc.tds_applicable == 'No':
|
||||
self.doc.tds_category = ''
|
||||
self.doc.tax_code = ''
|
||||
self.doc.rate = 0
|
||||
self.doc.ded_amount = 0
|
||||
self.doc.total_tds_on_voucher = 0
|
||||
|
||||
# get tds rate
|
||||
# -------------
|
||||
def get_tds_rate(self):
|
||||
return {'rate' : flt(get_value('Account', self.doc.tax_code, 'tax_rate'))}
|
||||
|
||||
# set aging date
|
||||
#-------------------
|
||||
def set_aging_date(self):
|
||||
if self.doc.is_opening != 'Yes':
|
||||
self.doc.aging_date = self.doc.posting_date
|
||||
elif not self.doc.aging_date:
|
||||
msgprint("Aging Date is mandatory for opening entry")
|
||||
raise Exception
|
||||
|
||||
|
||||
# Set against account for debit to account
|
||||
#------------------------------------------
|
||||
def set_against_expense_account(self):
|
||||
against_acc = []
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.expense_account not in against_acc:
|
||||
against_acc.append(d.expense_account)
|
||||
self.doc.against_expense_account = ','.join(against_acc)
|
||||
|
||||
#check in manage account if purchase order required or not.
|
||||
# ====================================================================================
|
||||
def po_required(self):
|
||||
res = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = 'po_required'")
|
||||
if res and res[0][0] == 'Yes':
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if not d.purchase_order:
|
||||
msgprint("Purchse Order No. required against item %s"%d.item_code)
|
||||
raise Exception
|
||||
|
||||
#check in manage account if purchase receipt required or not.
|
||||
# ====================================================================================
|
||||
def pr_required(self):
|
||||
res = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = 'pr_required'")
|
||||
if res and res[0][0] == 'Yes':
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if not d.purchase_receipt:
|
||||
msgprint("Purchase Receipt No. required against item %s"%d.item_code)
|
||||
raise Exception
|
||||
|
||||
# VALIDATE
|
||||
# ====================================================================================
|
||||
def validate(self):
|
||||
self.po_required()
|
||||
self.pr_required()
|
||||
self.check_active_purchase_items()
|
||||
self.check_conversion_rate()
|
||||
self.validate_bill_no_date()
|
||||
self.validate_bill_no()
|
||||
self.validate_reference_value()
|
||||
self.clear_advances()
|
||||
self.validate_credit_acc()
|
||||
self.check_for_acc_head_of_supplier()
|
||||
self.check_for_stopped_status()
|
||||
|
||||
self.po_list, self.pr_list = [], []
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
self.validate_supplier(d)
|
||||
self.validate_po_pr(d)
|
||||
if not d.purchase_order in self.po_list:
|
||||
self.po_list.append(d.purchase_order)
|
||||
if not d.purhcase_receipt in self.pr_list:
|
||||
self.pr_list.append(d.purchase_receipt)
|
||||
# tds
|
||||
get_obj('TDS Control').validate_first_entry(self)
|
||||
if not flt(self.doc.ded_amount):
|
||||
self.get_tds()
|
||||
self.doc.save()
|
||||
|
||||
if not self.doc.is_opening:
|
||||
self.doc.is_opening = 'No'
|
||||
|
||||
self.set_aging_date()
|
||||
|
||||
#set against account for credit to
|
||||
self.set_against_expense_account()
|
||||
|
||||
#FY validation
|
||||
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
|
||||
|
||||
#get Purchase Common Obj
|
||||
pc_obj = get_obj(dt='Purchase Common')
|
||||
|
||||
# get total in words
|
||||
self.doc.in_words = pc_obj.get_total_in_words('Rs', self.doc.grand_total)
|
||||
self.doc.in_words_import = pc_obj.get_total_in_words(self.doc.currency, self.doc.grand_total_import)
|
||||
# ***************************** SUBMIT *****************************
|
||||
# Check Ref Document docstatus
|
||||
# -----------------------------
|
||||
def check_prev_docstatus(self):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if d.purchase_order:
|
||||
submitted = sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
|
||||
if not submitted:
|
||||
msgprint("Purchase Order : "+ cstr(d.purchase_order) +" is not submitted")
|
||||
raise Exception , "Validation Error."
|
||||
if d.purchase_receipt:
|
||||
submitted = sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
|
||||
if not submitted:
|
||||
msgprint("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted")
|
||||
raise Exception , "Validation Error."
|
||||
|
||||
def update_against_document_in_jv(self, against_document_no, against_document_doctype):
|
||||
get_obj('GL Control').update_against_document_in_jv( self,'advance_allocation_details', against_document_no, against_document_doctype, self.doc.credit_to, 'debit',self.doc.doctype)
|
||||
|
||||
# On Submit
|
||||
# ----------
|
||||
def on_submit(self):
|
||||
self.check_prev_docstatus()
|
||||
|
||||
# Check for Approving Authority
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype,self.doc.company, self.doc.grand_total)
|
||||
|
||||
|
||||
# this sequence because outstanding may get -negative
|
||||
get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist)
|
||||
self.update_against_document_in_jv(self.doc.name, self.doc.doctype)
|
||||
get_obj(dt = 'Purchase Common').update_prevdoc_detail(self, is_submit = 1)
|
||||
|
||||
|
||||
|
||||
# ********************************* CANCEL *********************************
|
||||
# Check Next Document's docstatus
|
||||
# --------------------------------
|
||||
def check_next_docstatus(self):
|
||||
submit_jv = sql("select t1.name from `tabJournal Voucher` t1,`tabJournal Voucher Detail` t2 where t1.name = t2.parent and t2.against_voucher = '%s' and t1.docstatus = 1" % (self.doc.name))
|
||||
if submit_jv:
|
||||
msgprint("Journal Voucher : " + cstr(submit_jv[0][0]) + " has been created against " + cstr(self.doc.doctype) + ". So " + cstr(self.doc.doctype) + " cannot be Cancelled.")
|
||||
raise Exception, "Validation Error."
|
||||
|
||||
# On Cancel
|
||||
# ----------
|
||||
def on_cancel(self):
|
||||
self.check_next_docstatus()
|
||||
|
||||
# Check whether tds payment voucher has been created against this voucher
|
||||
self.check_tds_payment_voucher()
|
||||
|
||||
get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist, cancel=1)
|
||||
get_obj(dt = 'Purchase Common').update_prevdoc_detail(self, is_submit = 0)
|
||||
|
||||
|
||||
# Check whether tds payment voucher has been created against this voucher
|
||||
#---------------------------------------------------------------------------
|
||||
def check_tds_payment_voucher(self):
|
||||
tdsp = sql("select parent from `tabTDS Payment Detail` where voucher_no = '%s' and docstatus = 1 and parent not like 'old%'")
|
||||
if tdsp:
|
||||
msgprint("TDS Payment voucher '%s' has been made against this voucher. Please cancel the payment voucher to proceed." % (tdsp and tdsp[0][0] or ''))
|
||||
raise Exception
|
||||
|
||||
# on update
|
||||
def on_update(self):
|
||||
pass
|
||||
|
||||
########################################################################
|
||||
# Repair Outstanding
|
||||
#######################################################################
|
||||
def repair_pv_outstanding(self):
|
||||
get_obj(dt = 'GL Control').repair_voucher_outstanding(self)
|
||||
1238
erpnext/accounts/doctype/payable_voucher/payable_voucher.txt
Normal file
1238
erpnext/accounts/doctype/payable_voucher/payable_voucher.txt
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user