mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 03:01:22 +00:00
moved directory structure
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
# DocType Mapper, Delivery Note-Sales Invoice
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-03 12:49:42',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-03 12:49:43',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Delivery Note-Sales Invoice',
|
||||
'parentfield': u'table_mapper_details',
|
||||
'parenttype': u'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Delivery Note-Sales Invoice',
|
||||
'parentfield': u'field_mapper_details',
|
||||
'parenttype': u'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': u'DocType Mapper',
|
||||
'from_doctype': u'Delivery Note',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'to_doctype': u'Sales Invoice'
|
||||
},
|
||||
|
||||
# DocType Mapper, Delivery Note-Sales Invoice
|
||||
{
|
||||
'doctype': u'DocType Mapper',
|
||||
'name': u'Delivery Note-Sales Invoice'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt)) / flt(obj.basic_rate) or obj.qty',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'qty'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'parent',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'delivery_note'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'name',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'dn_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'prevdoc_docname',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'sales_order'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'prevdoc_detail_docname',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'so_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: flt(obj.amount) - flt(obj.billed_amt)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: (flt(obj.amount) - flt(obj.billed_amt)) * flt(obj.export_rate)/flt(obj.basic_rate)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'export_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'naming_series',
|
||||
'map': u'No',
|
||||
'match_id': 0,
|
||||
'to_field': u'naming_series'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'incentives',
|
||||
'map': u'No',
|
||||
'match_id': 3,
|
||||
'to_field': u'incentives'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'serial_no',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'serial_no'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'checking_operator': u'=',
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'export_rate',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'export_rate'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_table': u'Delivery Note',
|
||||
'match_id': 0,
|
||||
'to_table': u'Sales Invoice',
|
||||
'validation_logic': u'docstatus=1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'delivery_note_details',
|
||||
'from_table': u'Delivery Note Item',
|
||||
'match_id': 1,
|
||||
'to_field': u'entries',
|
||||
'to_table': u'Sales Invoice Item',
|
||||
'validation_logic': u'(ifnull(amount, 0) = 0 or amount > ifnull(billed_amt, 0)) and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'other_charges',
|
||||
'from_table': u'Sales Taxes and Charges',
|
||||
'match_id': 2,
|
||||
'to_field': u'other_charges',
|
||||
'to_table': u'Sales Taxes and Charges',
|
||||
'validation_logic': u'name is not null'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'sales_team',
|
||||
'from_table': u'Sales Team',
|
||||
'match_id': 3,
|
||||
'to_field': u'sales_team',
|
||||
'to_table': u'Sales Team',
|
||||
'validation_logic': u'name is not null'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,64 @@
|
||||
# DocType Mapper, Project-Sales Invoice
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-09-01 15:47:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-03 12:49:50',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_table': u'Project',
|
||||
'match_id': 0,
|
||||
'name': '__common__',
|
||||
'parent': u'Project-Sales Invoice',
|
||||
'parentfield': u'table_mapper_details',
|
||||
'parenttype': u'DocType Mapper',
|
||||
'to_table': u'Sales Invoice',
|
||||
'validation_logic': u'name is not null'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'checking_operator': u'=',
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'customer',
|
||||
'map': u'Yes',
|
||||
'match_id': 0,
|
||||
'name': '__common__',
|
||||
'parent': u'Project-Sales Invoice',
|
||||
'parentfield': u'field_mapper_details',
|
||||
'parenttype': u'DocType Mapper',
|
||||
'to_field': u'customer'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'from_doctype': u'Project',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'to_doctype': u'Sales Invoice'
|
||||
},
|
||||
|
||||
# DocType Mapper, Project-Sales Invoice
|
||||
{
|
||||
'doctype': 'DocType Mapper',
|
||||
'name': u'Project-Sales Invoice'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,158 @@
|
||||
# DocType Mapper, Purchase Order-Purchase Invoice
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-03 12:49:50',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Purchase Order-Purchase Invoice',
|
||||
'parentfield': u'table_mapper_details',
|
||||
'parenttype': u'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Purchase Order-Purchase Invoice',
|
||||
'parentfield': u'field_mapper_details',
|
||||
'parenttype': u'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': u'DocType Mapper',
|
||||
'from_doctype': u'Purchase Order',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'to_doctype': u'Purchase Invoice'
|
||||
},
|
||||
|
||||
# DocType Mapper, Purchase Order-Purchase Invoice
|
||||
{
|
||||
'doctype': u'DocType Mapper',
|
||||
'name': u'Purchase Order-Purchase Invoice'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: flt(obj.qty) - flt(obj.billed_qty)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'qty'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'purchase_rate',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'rate'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'import_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'parent',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'purchase_order'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'name',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'po_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'naming_series',
|
||||
'map': u'No',
|
||||
'match_id': 0,
|
||||
'to_field': u'naming_series'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'total_tax',
|
||||
'map': u'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': u'total_tax'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'conversion_rate',
|
||||
'map': u'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': u'conversion_rate'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_table': u'Purchase Order',
|
||||
'match_id': 0,
|
||||
'to_table': u'Purchase Invoice',
|
||||
'validation_logic': u'docstatus =1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'po_details',
|
||||
'from_table': u'Purchase Order Item',
|
||||
'match_id': 1,
|
||||
'to_field': u'entries',
|
||||
'to_table': u'Purchase Invoice Item',
|
||||
'validation_logic': u'ifnull(billed_qty,0) < qty and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'purchase_tax_details',
|
||||
'from_table': u'Purchase Taxes and Charges',
|
||||
'match_id': 2,
|
||||
'to_field': u'purchase_tax_details',
|
||||
'to_table': u'Purchase Taxes and Charges',
|
||||
'validation_logic': u'docstatus =1'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,185 @@
|
||||
# DocType Mapper, Purchase Receipt-Purchase Invoice
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-03 12:49:50',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Purchase Receipt-Purchase Invoice',
|
||||
'parentfield': u'table_mapper_details',
|
||||
'parenttype': u'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Purchase Receipt-Purchase Invoice',
|
||||
'parentfield': u'field_mapper_details',
|
||||
'parenttype': u'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': u'DocType Mapper',
|
||||
'from_doctype': u'Purchase Receipt',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'to_doctype': u'Purchase Invoice'
|
||||
},
|
||||
|
||||
# DocType Mapper, Purchase Receipt-Purchase Invoice
|
||||
{
|
||||
'doctype': u'DocType Mapper',
|
||||
'name': u'Purchase Receipt-Purchase Invoice'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: flt(obj.qty) - flt(obj.billed_qty)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'qty'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'purchase_rate',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'rate'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.purchase_rate)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: (flt(obj.qty) - flt(obj.billed_qty)) * flt(obj.import_rate)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'import_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'parent',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'purchase_receipt'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'prevdoc_docname',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'purchase_order'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'name',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'pr_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'prevdoc_detail_docname',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'po_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'naming_series',
|
||||
'map': u'No',
|
||||
'match_id': 0,
|
||||
'to_field': u'naming_series'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'net_total',
|
||||
'map': u'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': u'net_total'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'grand_total',
|
||||
'map': u'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': u'grand_total'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'total_tax',
|
||||
'map': u'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': u'total_tax'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'purchase_receipt_details',
|
||||
'from_table': u'Purchase Receipt Item',
|
||||
'match_id': 1,
|
||||
'to_field': u'entries',
|
||||
'to_table': u'Purchase Invoice Item',
|
||||
'validation_logic': u'ifnull(billed_qty,0) < qty'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_table': u'Purchase Receipt',
|
||||
'match_id': 0,
|
||||
'to_table': u'Purchase Invoice',
|
||||
'validation_logic': u'docstatus=1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'purchase_tax_details',
|
||||
'from_table': u'Purchase Taxes and Charges',
|
||||
'match_id': 2,
|
||||
'to_field': u'purchase_tax_details',
|
||||
'to_table': u'Purchase Taxes and Charges',
|
||||
'validation_logic': u'docstatus=1'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,190 @@
|
||||
# DocType Mapper, Sales Order-Sales Invoice
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-03 12:49:42',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-03 12:49:42',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Sales Order-Sales Invoice',
|
||||
'parentfield': u'table_mapper_details',
|
||||
'parenttype': u'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Sales Order-Sales Invoice',
|
||||
'parentfield': u'field_mapper_details',
|
||||
'parenttype': u'DocType Mapper'
|
||||
},
|
||||
|
||||
# These values are common for all DocType Mapper
|
||||
{
|
||||
'doctype': u'DocType Mapper',
|
||||
'from_doctype': u'Sales Order',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'ref_doc_submitted': 1,
|
||||
'to_doctype': u'Sales Invoice'
|
||||
},
|
||||
|
||||
# DocType Mapper, Sales Order-Sales Invoice
|
||||
{
|
||||
'doctype': u'DocType Mapper',
|
||||
'name': u'Sales Order-Sales Invoice'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'checking_operator': u'=',
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'customer',
|
||||
'map': u'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': u'customer'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: obj.basic_rate and (flt(obj.amount) - flt(obj.billed_amt))/flt(obj.basic_rate) or obj.qty',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'qty'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'parent',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'sales_order'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'name',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'so_detail'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval:flt(obj.amount) - flt(obj.billed_amt)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'eval: (flt(obj.amount) - flt(obj.billed_amt))* flt(obj.export_rate)/flt(obj.basic_rate)',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'export_amount'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'checking_operator': u'=',
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'project_name',
|
||||
'map': u'Yes',
|
||||
'match_id': 0,
|
||||
'to_field': u'project_name'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'reserved_warehouse',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'warehouse'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'naming_series',
|
||||
'map': u'No',
|
||||
'match_id': 0,
|
||||
'to_field': u'naming_series'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'incentives',
|
||||
'map': u'No',
|
||||
'match_id': 3,
|
||||
'to_field': u'incentives'
|
||||
},
|
||||
|
||||
# Field Mapper Detail
|
||||
{
|
||||
'checking_operator': u'=',
|
||||
'doctype': u'Field Mapper Detail',
|
||||
'from_field': u'export_rate',
|
||||
'map': u'Yes',
|
||||
'match_id': 1,
|
||||
'to_field': u'export_rate'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_table': u'Sales Order',
|
||||
'match_id': 0,
|
||||
'to_table': u'Sales Invoice',
|
||||
'validation_logic': u'docstatus=1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'sales_order_detail',
|
||||
'from_table': u'Sales Order Item',
|
||||
'match_id': 1,
|
||||
'to_field': u'entries',
|
||||
'to_table': u'Sales Invoice Item',
|
||||
'validation_logic': u'(ifnull(amount, 0) = 0 or amount > ifnull(billed_amt, 0)) and docstatus = 1'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'other_charges',
|
||||
'from_table': u'Sales Taxes and Charges',
|
||||
'match_id': 2,
|
||||
'to_field': u'other_charges',
|
||||
'to_table': u'Sales Taxes and Charges',
|
||||
'validation_logic': u'name is not null'
|
||||
},
|
||||
|
||||
# Table Mapper Detail
|
||||
{
|
||||
'doctype': u'Table Mapper Detail',
|
||||
'from_field': u'sales_team',
|
||||
'from_table': u'Sales Team',
|
||||
'match_id': 3,
|
||||
'to_field': u'sales_team',
|
||||
'to_table': u'Sales Team',
|
||||
'validation_logic': u'name is not null'
|
||||
}
|
||||
]
|
||||
1
accounts/GL Mapper/Journal Voucher/Journal Voucher.txt
Normal file
1
accounts/GL Mapper/Journal Voucher/Journal Voucher.txt
Normal file
@@ -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 d.against_jv 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 'Purchase Invoice') or (d.against_invoice and 'Sales Invoice') or (d.against_jv and 'Journal 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'}]
|
||||
233
accounts/GL Mapper/POS with write off/POS with write off.txt
Normal file
233
accounts/GL Mapper/POS with write off/POS with write off.txt
Normal file
@@ -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
accounts/GL Mapper/POS/POS.txt
Normal file
1
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,131 @@
|
||||
# GL Mapper, Purchase Invoice with write off
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-23 11:43:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-23 11:43:56',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all GL Mapper
|
||||
{
|
||||
'doc_type': u'Purchase Invoice with write off',
|
||||
'doctype': 'GL Mapper',
|
||||
'name': '__common__'
|
||||
},
|
||||
|
||||
# These values are common for all GL Mapper Detail
|
||||
{
|
||||
'doctype': u'GL Mapper Detail',
|
||||
'name': '__common__',
|
||||
'parent': u'Purchase Invoice with write off',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'GL Mapper'
|
||||
},
|
||||
|
||||
# GL Mapper, Purchase Invoice with write off
|
||||
{
|
||||
'doctype': 'GL Mapper',
|
||||
'name': u'Purchase Invoice with write off'
|
||||
},
|
||||
|
||||
# GL Mapper Detail
|
||||
{
|
||||
'account': u'expense_head',
|
||||
'against': u'parent:credit_to',
|
||||
'aging_date': u'parent:aging_date',
|
||||
'company': u'parent:company',
|
||||
'cost_center': u'cost_center',
|
||||
'credit': u'value:0',
|
||||
'debit': u'amount',
|
||||
'doctype': u'GL Mapper Detail',
|
||||
'fiscal_year': u'parent:fiscal_year',
|
||||
'is_opening': u'parent:is_opening',
|
||||
'posting_date': u'parent:posting_date',
|
||||
'remarks': u'parent:remarks',
|
||||
'table_field': u'entries',
|
||||
'transaction_date': u'parent:voucher_date',
|
||||
'voucher_no': u'parent:name',
|
||||
'voucher_type': u'parent:doctype'
|
||||
},
|
||||
|
||||
# GL Mapper Detail
|
||||
{
|
||||
'account': u'account_head',
|
||||
'against': u'parent:credit_to',
|
||||
'aging_date': u'parent:aging_date',
|
||||
'company': u'parent:company',
|
||||
'cost_center': u'cost_center',
|
||||
'credit': u"value:d.fields.get('category') != 'For Valuation' and d.fields.get('add_deduct_tax') == 'Deduct' and d.fields.get('tax_amount') or 0",
|
||||
'debit': u"value:d.fields.get('category') != 'For Valuation' and d.fields.get('add_deduct_tax') == 'Add' and d.fields.get('tax_amount') or 0",
|
||||
'doctype': u'GL Mapper Detail',
|
||||
'fiscal_year': u'parent:fiscal_year',
|
||||
'is_opening': u'parent:is_opening',
|
||||
'posting_date': u'parent:posting_date',
|
||||
'remarks': u'parent:remarks',
|
||||
'table_field': u'purchase_tax_details',
|
||||
'transaction_date': u'parent:voucher_date',
|
||||
'voucher_no': u'parent:name',
|
||||
'voucher_type': u'parent:doctype'
|
||||
},
|
||||
|
||||
# GL Mapper Detail
|
||||
{
|
||||
'account': u'tax_code',
|
||||
'against': u'credit_to',
|
||||
'aging_date': u'aging_date',
|
||||
'company': u'company',
|
||||
'credit': u'ded_amount',
|
||||
'debit': u'value:0',
|
||||
'doctype': u'GL Mapper Detail',
|
||||
'fiscal_year': u'fiscal_year',
|
||||
'is_opening': u'is_opening',
|
||||
'posting_date': u'posting_date',
|
||||
'remarks': u'remarks',
|
||||
'transaction_date': u'voucher_date',
|
||||
'voucher_no': u'name',
|
||||
'voucher_type': u'doctype'
|
||||
},
|
||||
|
||||
# GL Mapper Detail
|
||||
{
|
||||
'account': u'credit_to',
|
||||
'against': u'against_expense_account',
|
||||
'against_voucher': u'name',
|
||||
'against_voucher_type': u"value:'Purchase Invoice'",
|
||||
'aging_date': u'aging_date',
|
||||
'company': u'company',
|
||||
'credit': u'total_amount_to_pay',
|
||||
'debit': u'value:0',
|
||||
'doctype': u'GL Mapper Detail',
|
||||
'fiscal_year': u'fiscal_year',
|
||||
'is_opening': u'is_opening',
|
||||
'posting_date': u'posting_date',
|
||||
'remarks': u'remarks',
|
||||
'transaction_date': u'voucher_date',
|
||||
'voucher_no': u'name',
|
||||
'voucher_type': u'doctype'
|
||||
},
|
||||
|
||||
# GL Mapper Detail
|
||||
{
|
||||
'account': u'write_off_account',
|
||||
'against': u'credit_to',
|
||||
'aging_date': u'aging_date',
|
||||
'company': u'company',
|
||||
'cost_center': u'write_off_cost_center',
|
||||
'credit': u'write_off_amount',
|
||||
'debit': u'value:0',
|
||||
'doctype': u'GL Mapper Detail',
|
||||
'fiscal_year': u'fiscal_year',
|
||||
'is_opening': u'is_opening',
|
||||
'posting_date': u'posting_date',
|
||||
'remarks': u'remarks',
|
||||
'transaction_date': u'voucher_date',
|
||||
'voucher_no': u'name',
|
||||
'voucher_type': u'doctype'
|
||||
}
|
||||
]
|
||||
1
accounts/GL Mapper/Purchase Invoice/Purchase Invoice.txt
Normal file
1
accounts/GL Mapper/Purchase Invoice/Purchase Invoice.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'doc_type': 'Purchase Invoice', 'modified_by': 'nabin@webnotestech.com', 'name': 'Purchase Invoice', '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': 'Purchase Invoice', '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': 'Purchase Invoice', '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': 'Purchase Invoice', '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': 'Purchase Invoice', '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:'Purchase Invoice'", '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'}]
|
||||
1
accounts/GL Mapper/Sales Invoice/Sales Invoice.txt
Normal file
1
accounts/GL Mapper/Sales Invoice/Sales Invoice.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'doc_type': 'Sales Invoice', 'modified_by': 'Administrator', 'name': 'Sales Invoice', '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': 'Sales Invoice', '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': 'Sales Invoice', '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': 'Sales Invoice', '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:'Sales Invoice'", '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'}]
|
||||
28
accounts/Print Format/Cheque Printing Format/Cheque Printing Format.txt
Executable file
28
accounts/Print Format/Cheque Printing Format/Cheque Printing Format.txt
Executable file
@@ -0,0 +1,28 @@
|
||||
# Print Format, Cheque Printing Format
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-11 13:16:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-13 12:24:20',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Print Format
|
||||
{
|
||||
'doc_type': u'Journal Voucher',
|
||||
'doctype': 'Print Format',
|
||||
'html': u'<!-- 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': u'Accounts',
|
||||
'name': '__common__',
|
||||
'standard': u'Yes'
|
||||
},
|
||||
|
||||
# Print Format, Cheque Printing Format
|
||||
{
|
||||
'doctype': 'Print Format',
|
||||
'name': u'Cheque Printing Format'
|
||||
}
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
28
accounts/Print Format/POS Invoice/POS Invoice.txt
Normal file
28
accounts/Print Format/POS Invoice/POS Invoice.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# Print Format, POS Invoice
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-12-21 11:08:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-20 12:29:49',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Print Format
|
||||
{
|
||||
'doc_type': u'Sales Invoice',
|
||||
'doctype': 'Print Format',
|
||||
'html': u'<html>\n<head>\n<!--Other charges function-->\n<script>\nvar make_row = function(title,val,bold){\nvar bstart = \'<b>\'; var bend = \'</b>\';\nreturn \'<tr><td style="width:50%">\'+(bold?bstart:\'\')+title+(bold?bend:\'\')+\'</td>\'\n +\'<td style="width:20%">\'+doc.currency+\'</td>\'\n +\'<td style="width:30%;text-align:right">\'+(val?val:\'0.00\')+\'</td>\'\n +\'</tr>\'\n}\nvar make_row1 = function(title,val,bold){\n var bstart = \'<b>\'; var bend = \'</b>\';\n \n return \'<tr style="font-family:courier new; line-height:150%"><td style="width:50%">\'+(bold?bstart:\'\')+title+(bold?bend:\'\')+\'</td>\'\n +\'<td style="width:50%;text-align:right">\'+(bold?bstart:\'\')+(val?val:\'0.00\')+(bold?bend:\'\')+\'</td>\'\n +\'</tr>\'\n}\n\nfunction get_letter_head() {\n // add letter head\n var cp = wn.boot.control_panel;\n if(doc.letter_head)\n var lh= cstr(_p.letter_heads[doc.letter_head]);\n else if(cp.letter_head)\n var lh= cp.letter_head;\n else \n var lh= \'\';\n \n return lh;\n}\n\nfunction get_tax_details(){\n var cl = getchildren(\'Sales Taxes and Charges\',doc.name,\'other_charges\');\n var out = \'\';\n\n out += \'<div><table style="float: right;">\';\n for(var i=0;i<cl.length;i++){\n if(cl[i].tax_amount) {\n out += make_row1(cl[i].description,fmt_money(convert_rate(cl[i].tax_amount)),0);\n }\n }\n out += make_row1(\'TOTAL\',doc.currency + " " + fmt_money(convert_rate(doc.grand_total)),1);\n out +=\'</table></div>\';\n return out;\n}\n\nfunction convert_rate(val){ \n var new_val = flt(val)/flt(doc.conversion_rate);\n return new_val;\n}\n</script>\n<style>\n table, td, tr, div, span {\n font-family: courier new;\n line-height: 200%;\n }\n</style>\n</head>\n\n<body>\n<table width="100%" style="font-family: courier new; line-height:200%">\n<tr>\n <td align="left">NO: <script>doc.name</script></td>\n <td align="right">DATE: <script>date.str_to_user(doc.posting_date)</script></td>\n</tr>\n<tr>\n <td>M/s <script>doc.contact_display</script></td>\n</tr>\n</table>\n<!--Item Table-->\n<div>\n<script>\nvar t = print_table(\'Sales Invoice\', doc.name, \'entries\', \'Sales Invoice Item\',\n [\'description\',\'qty\',\'export_rate\',\'export_amount\'], [\'ITEM\', \'QTY\',\'RATE\',\'AMOUNT\'],\n [\'35%\',\'20%\',\'20%\',\'25%\']);\nif(t.appendChild) { // single\n out = t.innerHTML.replace(/style="/gi,\'style="font-family:courier new;line-height:150%;\');\n} else { //multiple\n out = \'<table class="None" border="0px" width="100%" style="border:0px; font-family:courier-new">\';\n\n for(var i=0;i<t.length;i++) {\n if(i==0) {\n out += \'<tr>\' + t[i].childNodes[0].childNodes[0].childNodes[0].innerHTML\n .replace(/style="border: 1px solid rgb\\(0, 0, 0\\);/gi,\'style="font-family:courier new;\')\n + \'</tr>\';\n }\n out += \'<tr>\' + t[i].childNodes[0].childNodes[0].childNodes[1].innerHTML\n .replace(/style="border: 1px solid rgb\\(0, 0, 0\\);/gi,\'style="font-family:courier new;\')\n + \'</tr>\';\n }\n out += \'</table>\';\n}\nout;\n</script>\n</div>\n<!--Tax table-->\n<div><script>get_tax_details();</script></div><br />\n<table style="font-family:courier new;">\n <tr><td><b><script>doc.terms</script></b></td></tr>\n <tr><td nowrap><b>For <script>doc.company</script></b></td></tr>\n <tr><td> </td></tr>\n <tr><td nowrap><b>Signatory</b></td></tr>\n</table>\n</body>\n</html>\n',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'standard': u'Yes'
|
||||
},
|
||||
|
||||
# Print Format, POS Invoice
|
||||
{
|
||||
'doctype': 'Print Format',
|
||||
'name': u'POS Invoice'
|
||||
}
|
||||
]
|
||||
28
accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.txt
Executable file
28
accounts/Print Format/Payment Receipt Voucher/Payment Receipt Voucher.txt
Executable file
@@ -0,0 +1,28 @@
|
||||
# Print Format, Payment Receipt Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-11 13:16:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-13 12:24:59',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Print Format
|
||||
{
|
||||
'doc_type': u'Journal Voucher',
|
||||
'doctype': 'Print Format',
|
||||
'html': u'<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 Cheque</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': u'Accounts',
|
||||
'name': '__common__',
|
||||
'standard': u'Yes'
|
||||
},
|
||||
|
||||
# Print Format, Payment Receipt Voucher
|
||||
{
|
||||
'doctype': 'Print Format',
|
||||
'name': u'Payment Receipt Voucher'
|
||||
}
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
243
accounts/__init__.py
Normal file
243
accounts/__init__.py
Normal file
@@ -0,0 +1,243 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import flt
|
||||
from webnotes.model.code import get_obj
|
||||
|
||||
install_docs = [
|
||||
{"doctype":"Role", "role_name":"Accounts Manager", "name":"Accounts Manager"},
|
||||
{"doctype":"Role", "role_name":"Accounts User", "name":"Accounts User"}
|
||||
]
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_default_bank_account():
|
||||
"""
|
||||
Get default bank account for a company
|
||||
"""
|
||||
company = webnotes.form_dict.get('company')
|
||||
if not company: return
|
||||
res = webnotes.conn.sql("""\
|
||||
SELECT default_bank_account FROM `tabCompany`
|
||||
WHERE name=%s AND docstatus<2""", company)
|
||||
|
||||
if res: return res[0][0]
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_new_jv_details():
|
||||
"""
|
||||
Get details which will help create new jv on sales/purchase return
|
||||
"""
|
||||
doclist = webnotes.form_dict.get('doclist')
|
||||
fiscal_year = webnotes.form_dict.get('fiscal_year')
|
||||
if not (isinstance(doclist, basestring) and isinstance(fiscal_year, basestring)): return
|
||||
|
||||
import json
|
||||
doclist = json.loads(doclist)
|
||||
doc, children = doclist[0], doclist[1:]
|
||||
|
||||
if doc.get('return_type')=='Sales Return':
|
||||
if doc.get('sales_invoice_no'):
|
||||
return get_invoice_details(doc, children, fiscal_year)
|
||||
elif doc.get('delivery_note_no'):
|
||||
return get_delivery_note_details(doc, children, fiscal_year)
|
||||
|
||||
elif doc.get('purchase_receipt_no'):
|
||||
return get_purchase_receipt_details(doc, children, fiscal_year)
|
||||
|
||||
|
||||
def get_invoice_details(doc, children, fiscal_year):
|
||||
"""
|
||||
Gets details from an invoice to make new jv
|
||||
Returns [{
|
||||
'account': ,
|
||||
'balance': ,
|
||||
'debit': ,
|
||||
'credit': ,
|
||||
'against_invoice': ,
|
||||
'against_payable':
|
||||
}, { ... }, ...]
|
||||
"""
|
||||
if doc.get('return_type')=='Sales Return':
|
||||
obj = get_obj('Sales Invoice', doc.get('sales_invoice_no'), with_children=1)
|
||||
else:
|
||||
obj = get_obj('Purchase Invoice', doc.get('purchase_invoice_no'), with_children=1)
|
||||
if not obj.doc.docstatus==1: return
|
||||
|
||||
# Build invoice account jv detail record
|
||||
invoice_rec = get_invoice_account_jv_record(doc, children, fiscal_year, obj)
|
||||
|
||||
# Build item accountwise jv detail records
|
||||
item_accountwise_list = get_item_accountwise_jv_record(doc, children, fiscal_year, obj)
|
||||
|
||||
return [invoice_rec] + item_accountwise_list
|
||||
|
||||
|
||||
def get_invoice_account_jv_record(doc, children, fiscal_year, obj):
|
||||
"""
|
||||
Build customer/supplier account jv detail record
|
||||
"""
|
||||
# Calculate total return amount
|
||||
total_amt = sum([(flt(ch.get('rate')) * flt(ch.get('returned_qty'))) for ch in children])
|
||||
|
||||
ret = {}
|
||||
|
||||
if doc.get('return_type')=='Sales Return':
|
||||
account = obj.doc.debit_to
|
||||
ret['against_invoice'] = doc.get('sales_invoice_no')
|
||||
ret['credit'] = total_amt
|
||||
else:
|
||||
account = obj.doc.credit_to
|
||||
ret['against_voucher'] = doc.get('purchase_invoice_no')
|
||||
ret['debit'] = total_amt
|
||||
|
||||
ret.update({
|
||||
'account': account,
|
||||
'balance': get_obj('GL Control').get_bal(account + "~~~" + fiscal_year)
|
||||
})
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def get_item_accountwise_jv_record(doc, children, fiscal_year, obj):
|
||||
"""
|
||||
Build item accountwise jv detail records
|
||||
"""
|
||||
if doc.get('return_type')=='Sales Return':
|
||||
amt_field = 'debit'
|
||||
ac_field = 'income_account'
|
||||
else:
|
||||
amt_field = 'credit'
|
||||
ac_field = 'expense_head'
|
||||
|
||||
inv_children = dict([[ic.fields.get('item_code'), ic] for ic in obj.doclist if ic.fields.get('item_code')])
|
||||
|
||||
accwise_list = []
|
||||
|
||||
for ch in children:
|
||||
inv_ch = inv_children.get(ch.get('item_code'))
|
||||
if not inv_ch: continue
|
||||
|
||||
amount = flt(ch.get('rate')) * flt(ch.get('returned_qty'))
|
||||
|
||||
accounts = [[jvd['account'], jvd['cost_center']] for jvd in accwise_list]
|
||||
|
||||
if [inv_ch.fields.get(ac_field), inv_ch.fields.get('cost_center')] not in accounts:
|
||||
rec = {
|
||||
'account': inv_ch.fields.get(ac_field),
|
||||
'cost_center': inv_ch.fields.get('cost_center'),
|
||||
'balance': get_obj('GL Control').get_bal(inv_ch.fields.get(ac_field) + "~~~" + fiscal_year)
|
||||
}
|
||||
rec[amt_field] = amount
|
||||
accwise_list.append(rec)
|
||||
else:
|
||||
rec = accwise_list[accounts.index([inv_ch.fields.get(ac_field), inv_ch.fields.get('cost_center')])]
|
||||
rec[amt_field] = rec[amt_field] + amount
|
||||
|
||||
return accwise_list
|
||||
|
||||
|
||||
def get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list):
|
||||
"""
|
||||
Get invoice details and make jv detail records
|
||||
"""
|
||||
for inv in inv_list:
|
||||
if not inv[0]: continue
|
||||
|
||||
if doc.get('return_type')=='Sales Return':
|
||||
doc['sales_invoice_no'] = inv[0]
|
||||
else:
|
||||
doc['purchase_invoice_no'] = inv[0]
|
||||
|
||||
jv_details = get_invoice_details(doc, children, fiscal_year)
|
||||
|
||||
if jv_details and len(jv_details)>1: jv_details_list.extend(jv_details)
|
||||
|
||||
return jv_details_list
|
||||
|
||||
|
||||
def get_prev_doc_list(obj, prev_doctype):
|
||||
"""
|
||||
Returns a list of previous doc's names
|
||||
"""
|
||||
prevdoc_list = []
|
||||
for ch in obj.doclist:
|
||||
if ch.fields.get('prevdoc_docname') and ch.fields.get('prevdoc_doctype')==prev_doctype:
|
||||
prevdoc_list.append(ch.fields.get('prevdoc_docname'))
|
||||
return prevdoc_list
|
||||
|
||||
|
||||
def get_inv_list(table, field, value):
|
||||
"""
|
||||
Returns invoice list
|
||||
"""
|
||||
if isinstance(value, basestring):
|
||||
return webnotes.conn.sql("""\
|
||||
SELECT DISTINCT parent FROM `%s`
|
||||
WHERE %s='%s' AND docstatus=1""" % (table, field, value))
|
||||
elif isinstance(value, list):
|
||||
return webnotes.conn.sql("""\
|
||||
SELECT DISTINCT parent FROM `%s`
|
||||
WHERE %s IN ("%s") AND docstatus=1""" % (table, field, '", "'.join(value)))
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
def get_delivery_note_details(doc, children, fiscal_year):
|
||||
"""
|
||||
Gets sales invoice numbers from delivery note details
|
||||
and returns detail records for jv
|
||||
"""
|
||||
jv_details_list = []
|
||||
|
||||
dn_obj = get_obj('Delivery Note', doc['delivery_note_no'], with_children=1)
|
||||
|
||||
inv_list = get_inv_list('tabSales Invoice Item', 'delivery_note', doc['delivery_note_no'])
|
||||
|
||||
if inv_list:
|
||||
jv_details_list = get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list)
|
||||
|
||||
if not (inv_list and jv_details_list):
|
||||
so_list = get_prev_doc_list(dn_obj, 'Sales Order')
|
||||
inv_list = get_inv_list('tabSales Invoice Item', 'sales_order', so_list)
|
||||
if inv_list:
|
||||
jv_details_list = get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list)
|
||||
|
||||
return jv_details_list
|
||||
|
||||
|
||||
def get_purchase_receipt_details(doc, children, fiscal_year):
|
||||
"""
|
||||
Gets purchase invoice numbers from purchase receipt details
|
||||
and returns detail records for jv
|
||||
"""
|
||||
jv_details_list = []
|
||||
|
||||
pr_obj = get_obj('Purchase Receipt', doc['purchase_receipt_no'], with_children=1)
|
||||
|
||||
inv_list = get_inv_list('tabPurchase Invoice Item', 'purchase_receipt', doc['purchase_receipt_no'])
|
||||
|
||||
if inv_list:
|
||||
jv_details_list = get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list)
|
||||
|
||||
if not (inv_list and jv_details_list):
|
||||
po_list = get_prev_doc_list(pr_obj, 'Purchase Order')
|
||||
inv_list = get_inv_list('tabPurchase Invoice Item', 'purchase_order', po_list)
|
||||
if inv_list:
|
||||
jv_details_list = get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list)
|
||||
|
||||
return jv_details_list
|
||||
1
accounts/doctype/__init__.py
Normal file
1
accounts/doctype/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
1
accounts/doctype/account/__init__.py
Normal file
1
accounts/doctype/account/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
120
accounts/doctype/account/account.js
Normal file
120
accounts/doctype/account/account.js
Normal file
@@ -0,0 +1,120 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
// Onload
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
}
|
||||
|
||||
cur_frm.cscript.set_breadcrumbs = function(barea) {
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(cur_frm.docname);
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!Accounts Browser/Account">\
|
||||
Chart of Accounts</a>');
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!accounts-home">Accounts</a>');
|
||||
}
|
||||
|
||||
// Refresh
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.toggle_display('account_name', doc.__islocal);
|
||||
|
||||
// hide fields if group
|
||||
cur_frm.toggle_display(['account_type', 'master_type', 'master_name', 'freeze_account',
|
||||
'credit_days', 'credit_limit', 'tax_rate'], doc.group_or_ledger=='Ledger')
|
||||
|
||||
// read-only for root accounts
|
||||
root_acc = ['Application of Funds (Assets)','Expenses','Income','Source of Funds (Liabilities)'];
|
||||
if(in_list(root_acc, doc.account_name)) {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root account and cannot be edited.");
|
||||
} else {
|
||||
// credit days and type if customer or supplier
|
||||
cur_frm.set_intro(null);
|
||||
cur_frm.toggle_display(['credit_days', 'credit_limit'],
|
||||
in_list(['Customer', 'Supplier'], doc.master_type))
|
||||
|
||||
// hide tax_rate
|
||||
cur_frm.cscript.account_type(doc, cdt, cdn);
|
||||
|
||||
// show / hide convert buttons
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
}
|
||||
}
|
||||
|
||||
// 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.group_or_ledger=='Ledger') {
|
||||
cur_frm.toggle_display(['tax_rate'],
|
||||
doc.account_type == 'Tax');
|
||||
cur_frm.toggle_display(['master_type', 'master_name'],
|
||||
cstr(doc.account_type)=='');
|
||||
}
|
||||
}
|
||||
|
||||
// Hide/unhide group or ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
||||
cur_frm.add_custom_button('Convert to Ledger',
|
||||
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
||||
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
|
||||
cur_frm.add_custom_button('Convert to Group',
|
||||
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
|
||||
}
|
||||
}
|
||||
// Convert group to ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
||||
$c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) {
|
||||
if(r.message == 1) {
|
||||
cur_frm.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Convert ledger to group
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
|
||||
$c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) {
|
||||
if(r.message == 1) {
|
||||
cur_frm.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 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';
|
||||
}
|
||||
}
|
||||
|
||||
// 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';
|
||||
}
|
||||
291
accounts/doctype/account/account.py
Normal file
291
accounts/doctype/account/account.py
Normal file
@@ -0,0 +1,291 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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]
|
||||
elif self.doc.account_name not in ['Income','Source of Funds (Liabilities)',\
|
||||
'Expenses','Application of Funds (Assets)']:
|
||||
msgprint("Parent Account is mandatory", raise_exception=1)
|
||||
|
||||
|
||||
# Account name must be unique
|
||||
def validate_duplicate_account(self):
|
||||
if (self.doc.fields.get('__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)
|
||||
elif self.doc.master_type or self.doc.account_type:
|
||||
msgprint("Cannot covert to Group because Master Type or Account Type is selected.",
|
||||
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)
|
||||
|
||||
# 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')
|
||||
|
||||
def validate_mandatory(self):
|
||||
if not self.doc.debit_or_credit:
|
||||
msgprint("Debit or Credit field is mandatory", raise_exception=1)
|
||||
if not self.doc.is_pl_account:
|
||||
msgprint("Is PL Account field is mandatory", raise_exception=1)
|
||||
|
||||
|
||||
# VALIDATE
|
||||
def validate(self):
|
||||
self.validate_master_name()
|
||||
self.validate_rate_for_tax()
|
||||
self.validate_parent()
|
||||
self.validate_duplicate_account()
|
||||
self.validate_root_details()
|
||||
self.validate_mandatory()
|
||||
|
||||
# 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('Global Defaults', 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 (Sales Invoice / Purchase Invoice / Journal Voucher) 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
|
||||
from webnotes.utils.nestedset import update_remove_node
|
||||
update_remove_node('Account', self.doc.name)
|
||||
|
||||
# delete all cancelled gl entry of this account
|
||||
sql("delete from `tabGL Entry` where account = %s and ifnull(is_cancelled, 'No') = 'Yes'", self.doc.name)
|
||||
|
||||
#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()
|
||||
# intiate balances
|
||||
self.set_year_balance()
|
||||
|
||||
# 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))
|
||||
396
accounts/doctype/account/account.txt
Normal file
396
accounts/doctype/account/account.txt
Normal file
@@ -0,0 +1,396 @@
|
||||
# DocType, Account
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:50',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-11 13:58:44',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1325570645',
|
||||
'allow_copy': 1,
|
||||
'allow_trash': 1,
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'description': u'An **Account** is heading under which financial and business transactions are carried on. For example, \u201cTravel Expense\u201d is an account, \u201cCustomer Zoe\u201d, \u201cSupplier Mae\u201d are accounts. \n\n**Note:** ERPNext creates accounts for Customers and Suppliers automatically.\n\n### Groups and Ledgers\n\nThere are two main kinds of Accounts in ERPNext - Group and Ledger. Groups can have sub-groups and ledgers within them, whereas ledgers are the leaf nodes of your chart and cannot be further classified.\n\nAccounting Transactions can only be made against Ledger Accounts (not Groups)\n',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': u'debit_or_credit, group_or_ledger',
|
||||
'section_style': u'Tray',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Account',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Account',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocType, Account
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Account'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Auditor',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Auditor',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 2,
|
||||
'role': u'Auditor',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Purchase User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts User',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 2,
|
||||
'role': u'Accounts Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 2,
|
||||
'role': u'Accounts User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'properties',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Account Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Account Name',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'account_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'level',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'label': u'Level',
|
||||
'oldfieldname': u'level',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'default': u'Ledger',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'group_or_ledger',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Group or Ledger',
|
||||
'oldfieldname': u'group_or_ledger',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nLedger\nGroup',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'debit_or_credit',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Debit or Credit',
|
||||
'oldfieldname': u'debit_or_credit',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_pl_account',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Is PL Account',
|
||||
'oldfieldname': u'is_pl_account',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'Yes\nNo',
|
||||
'permlevel': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Company',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'parent_account',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Parent Account',
|
||||
'oldfieldname': u'parent_account',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Setting Account Type helps in selecting this Account in transactions.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account_type',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Account Type',
|
||||
'oldfieldname': u'account_type',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nFixed Asset Account\nBank or Cash\nExpense Account\nTax\nIncome Account\nChargeable',
|
||||
'permlevel': 0,
|
||||
'search_index': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Rate at which this tax is applied',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'tax_rate',
|
||||
'fieldtype': u'Currency',
|
||||
'hidden': 0,
|
||||
'label': u'Rate',
|
||||
'oldfieldname': u'tax_rate',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'If the account is frozen, entries are allowed for the "Account Manager" only.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'freeze_account',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Frozen',
|
||||
'oldfieldname': u'freeze_account',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'No\nYes',
|
||||
'permlevel': 2
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit_days',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'label': u'Credit Days',
|
||||
'oldfieldname': u'credit_days',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit_limit',
|
||||
'fieldtype': u'Currency',
|
||||
'hidden': 1,
|
||||
'label': u'Credit Limit',
|
||||
'oldfieldname': u'credit_limit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'If this Account represents a Customer, Supplier or Employee, set it here.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'master_type',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Master Type',
|
||||
'oldfieldname': u'master_type',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nSupplier\nCustomer\nEmployee',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'master_name',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Master Name',
|
||||
'oldfieldname': u'master_name',
|
||||
'oldfieldtype': u'Link',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/account_balance/__init__.py
Normal file
1
accounts/doctype/account_balance/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
177
accounts/doctype/account_balance/account_balance.txt
Normal file
177
accounts/doctype/account_balance/account_balance.txt
Normal file
@@ -0,0 +1,177 @@
|
||||
# DocType, Account Balance
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:40',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:40',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1322549700',
|
||||
'autoname': u'_ACB.######',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'istable': 0,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': u'account, period, fiscal_year, balance',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Account Balance',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Account Balance',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocType, Account Balance
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Account Balance'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Accounts User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Account',
|
||||
'options': u'Account',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'period',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Period',
|
||||
'oldfieldname': u'period',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Period',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'opening',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Opening',
|
||||
'oldfieldname': u'opening',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'debit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Debit',
|
||||
'oldfieldname': u'debit',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Credit',
|
||||
'oldfieldname': u'credit',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'balance',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Balance',
|
||||
'oldfieldname': u'balance',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Fiscal Year',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'start_date',
|
||||
'fieldtype': u'Date',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'Start Date',
|
||||
'oldfieldname': u'start_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'end_date',
|
||||
'fieldtype': u'Date',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'End Date',
|
||||
'oldfieldname': u'end_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'search_index': 1
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/bank_reconciliation/__init__.py
Normal file
1
accounts/doctype/bank_reconciliation/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
20
accounts/doctype/bank_reconciliation/bank_reconciliation.js
Normal file
20
accounts/doctype/bank_reconciliation/bank_reconciliation.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
||||
// add page head
|
||||
var ph = new PageHeader(cur_frm.fields_dict['head_html'].wrapper, 'Bank Reconciliation', '');
|
||||
}
|
||||
79
accounts/doctype/bank_reconciliation/bank_reconciliation.py
Normal file
79
accounts/doctype/bank_reconciliation/bank_reconciliation.py
Normal file
@@ -0,0 +1,79 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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.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.doclist = 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 = cstr(d[5])
|
||||
nl.voucher_id = cstr(d[0])
|
||||
nl.cheque_number = cstr(d[1])
|
||||
nl.cheque_date = cstr(d[2])
|
||||
nl.debit = flt(d[3])
|
||||
nl.credit = flt(d[4])
|
||||
nl.against_account = cstr(d[6])
|
||||
self.doc.total_amount += flt(flt(d[4]) - flt(d[3]))
|
||||
|
||||
def update_details(self):
|
||||
vouchers = []
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.clearance_date:
|
||||
if getdate(d.clearance_date) < getdate(d.cheque_date):
|
||||
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %
|
||||
d.idx, raise_exception=1)
|
||||
if getdate(d.clearance_date) < getdate(d.posting_date):
|
||||
msgprint("Clearance Date can not be before Posting Date (Row #%s)" %
|
||||
d.idx, raise_exception=1)
|
||||
|
||||
sql("update `tabJournal Voucher` set clearance_date = %s, modified = %s where name=%s", (d.clearance_date, nowdate(), d.voucher_id))
|
||||
vouchers.append(d.voucher_id)
|
||||
|
||||
if vouchers:
|
||||
msgprint("Clearance Date updated in %s" % vouchers)
|
||||
else:
|
||||
msgprint("Clearance Date not mentioned")
|
||||
167
accounts/doctype/bank_reconciliation/bank_reconciliation.txt
Normal file
167
accounts/doctype/bank_reconciliation/bank_reconciliation.txt
Normal file
@@ -0,0 +1,167 @@
|
||||
# DocType, Bank Reconciliation
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:40',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:40',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1294312169',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 1,
|
||||
'hide_toolbar': 1,
|
||||
'issingle': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 12
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Bank Reconciliation',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Bank Reconciliation',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Bank Reconciliation
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Bank Reconciliation'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'head_html',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'Head HTML',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'Select account head of the bank where cheque was deposited.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'bank_account',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Bank Account',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'from_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'From Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'to_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'To Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'get_non_reconciled_entries',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Get Non Reconciled Entries',
|
||||
'options': u'get_details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'entries',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Entries',
|
||||
'options': u'Bank Reconciliation Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'update_clearance_date',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Update Clearance Date',
|
||||
'options': u'update_details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Total Amount',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/bank_reconciliation_detail/__init__.py
Normal file
1
accounts/doctype/bank_reconciliation_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,132 @@
|
||||
# DocType, Bank Reconciliation Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:41',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:41',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'no_copy': 0,
|
||||
'parent': u'Bank Reconciliation Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocType, Bank Reconciliation Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Bank Reconciliation Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'voucher_id',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Voucher ID',
|
||||
'oldfieldname': u'voucher_id',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Journal Voucher',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'against_account',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Against Account',
|
||||
'oldfieldname': u'against_account',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'The date at which current entry will get or has actually executed.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'posting_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Posting Date',
|
||||
'oldfieldname': u'posting_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cheque_number',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Cheque Number',
|
||||
'oldfieldname': u'cheque_number',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cheque_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Cheque Date',
|
||||
'oldfieldname': u'cheque_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'debit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Debit',
|
||||
'oldfieldname': u'debit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Credit',
|
||||
'oldfieldname': u'credit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'clearance_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Clearance Date',
|
||||
'oldfieldname': u'clearance_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/budget_control/__init__.py
Normal file
1
accounts/doctype/budget_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
95
accounts/doctype/budget_control/budget_control.py
Normal file
95
accounts/doctype/budget_control/budget_control.py
Normal file
@@ -0,0 +1,95 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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
accounts/doctype/budget_control/budget_control.txt
Normal file
31
accounts/doctype/budget_control/budget_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, Budget Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:41',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:41',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'nabin@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 23
|
||||
},
|
||||
|
||||
# DocType, Budget Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Budget Control'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/budget_detail/__init__.py
Normal file
1
accounts/doctype/budget_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
94
accounts/doctype/budget_detail/budget_detail.txt
Normal file
94
accounts/doctype/budget_detail/budget_detail.txt
Normal file
@@ -0,0 +1,94 @@
|
||||
# DocType, Budget Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:41',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:41',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'CBD/.######',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Budget Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# DocType, Budget Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Budget Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Account',
|
||||
'oldfieldname': u'account',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'budget_allocated',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Budget Allocated',
|
||||
'oldfieldname': u'budget_allocated',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'actual',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Actual',
|
||||
'oldfieldname': u'actual',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/budget_distribution/__init__.py
Normal file
1
accounts/doctype/budget_distribution/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
30
accounts/doctype/budget_distribution/budget_distribution.js
Normal file
30
accounts/doctype/budget_distribution/budget_distribution.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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(make_doclist(doc.doctype, doc.name))},callback1);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
cur_frm.toggle_display('distribution_id', doc.__islocal);
|
||||
}
|
||||
44
accounts/doctype/budget_distribution/budget_distribution.py
Normal file
44
accounts/doctype/budget_distribution/budget_distribution.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import flt
|
||||
from webnotes.model.doc import addchild
|
||||
from webnotes.model.doclist import getlist
|
||||
from webnotes import msgprint
|
||||
|
||||
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 be equal to 100%%. Currently it is %s%%" % total, raise_exception=1)
|
||||
160
accounts/doctype/budget_distribution/budget_distribution.txt
Normal file
160
accounts/doctype/budget_distribution/budget_distribution.txt
Normal file
@@ -0,0 +1,160 @@
|
||||
# DocType, Budget Distribution
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:50',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-11 14:37:30',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:distribution_id',
|
||||
'colour': u'White:FFF',
|
||||
'description': u'**Budget Distribution** helps you distribute your budget across months if you have seasonality in your business.\n\nTo distribute a budget using this distribution, set this **Budget Distribution** in the **Cost Center**',
|
||||
'doctype': 'DocType',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'name_case': u'Title Case',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Budget Distribution',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Budget Distribution',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Budget Distribution
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Budget Distribution'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 2,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 2,
|
||||
'role': u'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Name of the Budget Distribution',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'distribution_id',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Distribution Name',
|
||||
'oldfieldname': u'distribution_id',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'budget_distribution_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Budget Distribution Details',
|
||||
'oldfieldname': u'budget_distribution_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Budget Distribution Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/budget_distribution_detail/__init__.py
Normal file
1
accounts/doctype/budget_distribution_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,64 @@
|
||||
# DocType, Budget Distribution Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:47',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-11 14:32:16',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'BDD/.#####',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tray',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Budget Distribution Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# DocType, Budget Distribution Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Budget Distribution Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'month',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Month',
|
||||
'oldfieldname': u'month',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 2,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'percentage_allocation',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Percentage Allocation',
|
||||
'oldfieldname': u'percentage_allocation',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/c_form/__init__.py
Normal file
1
accounts/doctype/c_form/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
29
accounts/doctype/c_form/c_form.js
Normal file
29
accounts/doctype/c_form/c_form.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//c-form js file
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict.invoice_details.grid.get_field("invoice_no").get_query = function(doc) {
|
||||
cond = ""
|
||||
if (doc.customer) cond += ' AND `tabSales Invoice`.`customer` = "' + cstr(doc.customer) + '"';
|
||||
if (doc.company) cond += ' AND `tabSales Invoice`.`company` = "' + cstr(doc.company) + '"';
|
||||
return 'SELECT `tabSales Invoice`.`name` FROM `tabSales Invoice` WHERE `tabSales Invoice`.`docstatus` = 1 and `tabSales Invoice`.`c_form_applicable` = "Yes" and ifnull(`tabSales Invoice`.c_form_no, "") = ""'+cond+' AND `tabSales Invoice`.%(key)s LIKE "%s" ORDER BY `tabSales Invoice`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.cscript.invoice_no = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
get_server_fields('get_invoice_details', d.invoice_no, 'invoice_details', doc, cdt, cdn, 1);
|
||||
}
|
||||
86
accounts/doctype/c_form/c_form.py
Normal file
86
accounts/doctype/c_form/c_form.py
Normal file
@@ -0,0 +1,86 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import add_days, cint, cstr, date_diff, default_fields, flt, getdate, now, nowdate
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
|
||||
|
||||
|
||||
def on_update(self):
|
||||
""" Update C-Form No on invoices"""
|
||||
|
||||
if len(getlist(self.doclist, 'invoice_details')):
|
||||
inv = "'" + "', '".join([d.invoice_no for d in getlist(self.doclist, 'invoice_details')]) + "'"
|
||||
sql("""update `tabSales Invoice` set c_form_no = '%s', modified ='%s'
|
||||
where name in (%s)"""%(self.doc.name, self.doc.modified, inv))
|
||||
sql("""update `tabSales Invoice` set c_form_no = '', modified = %s where name not
|
||||
in (%s) and ifnull(c_form_no, '') = %s""", (self.doc.modified, self.doc.name, inv))
|
||||
else:
|
||||
msgprint("Please enter atleast 1 invoice in the table below", raise_exception=1)
|
||||
|
||||
self.calculate_total_invoiced_amount()
|
||||
|
||||
def calculate_total_invoiced_amount(self):
|
||||
total = 0
|
||||
for d in getlist(self.doclist, 'invoice_details'):
|
||||
total += flt(d.grand_total)
|
||||
webnotes.conn.set(self.doc, 'total_invoiced_amount', total)
|
||||
|
||||
|
||||
def get_invoice_details(self, invoice_no):
|
||||
""" Pull details from invoices for referrence """
|
||||
|
||||
inv = sql("""select posting_date, territory, net_total, grand_total from
|
||||
`tabSales Invoice` where name = %s""", invoice_no)
|
||||
ret = {
|
||||
'invoice_date' : inv and getdate(inv[0][0]).strftime('%Y-%m-%d') or '',
|
||||
'territory' : inv and inv[0][1] or '',
|
||||
'net_total' : inv and flt(inv[0][2]) or '',
|
||||
'grand_total' : inv and flt(inv[0][3]) or ''
|
||||
}
|
||||
return ret
|
||||
|
||||
|
||||
def validate_invoice(self):
|
||||
"""Validate invoice that c-form is applicable and no other c-form is
|
||||
received for that"""
|
||||
|
||||
for d in getlist(self.doclist, 'invoice_details'):
|
||||
inv = sql("""select c_form_applicable, c_form_no from
|
||||
`tabSales Invoice` where name = %s""", invoice_no)
|
||||
if not inv:
|
||||
msgprint("Invoice: %s is not exists in the system, please check." % d.invoice_no, raise_exception=1)
|
||||
elif inv[0][0] != 'Yes':
|
||||
msgprint("C-form is not applicable for Invoice: %s" % d.invoice_no, raise_exception=1)
|
||||
elif inv[0][1] and inv[0][1] != self.doc.name:
|
||||
msgprint("""Invoice %s is tagged in another C-form: %s. \nIf you want to change C-form no for this invoice,
|
||||
please remove invoice no from the previous c-form and then try again""" % (d.invoice_no, inv[0][1]), raise_exception=1)
|
||||
229
accounts/doctype/c_form/c_form.txt
Normal file
229
accounts/doctype/c_form/c_form.txt
Normal file
@@ -0,0 +1,229 @@
|
||||
# DocType, C-Form
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-12-14 11:40:47',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-06 17:29:50',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1333712835',
|
||||
'allow_attach': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'max_attachments': 3,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 19
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'C-Form',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'C-Form',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, C-Form
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'C-Form'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts User',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'naming_series',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Series',
|
||||
'options': u'\nC-FORM/',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'c_form_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'C-Form No',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'received_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Received Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'customer',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Customer',
|
||||
'options': u'Customer',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Company',
|
||||
'options': u'link:Company',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Fiscal Year',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'quarter',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Quarter',
|
||||
'options': u'\nI\nII\nIII\nIV',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Total Amount',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'state',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'State',
|
||||
'options': u"link:State\ncountry='India'",
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'section_break0',
|
||||
'fieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'invoice_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Invoice Details',
|
||||
'options': u'C-Form Invoice Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_invoiced_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Total Invoiced Amount',
|
||||
'permlevel': 1,
|
||||
'print_hide': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'file_list',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'File List',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/c_form_invoice_detail/__init__.py
Normal file
1
accounts/doctype/c_form_invoice_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,91 @@
|
||||
# DocType, C-Form Invoice Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:41',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:41',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'C-Form Invoice Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# DocType, C-Form Invoice Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'C-Form Invoice Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'invoice_no',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Invoice No',
|
||||
'options': u'Sales Invoice',
|
||||
'permlevel': 0,
|
||||
'width': u'160px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'invoice_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Invoice Date',
|
||||
'permlevel': 1,
|
||||
'width': u'120px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'territory',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Territory',
|
||||
'options': u'Territory',
|
||||
'permlevel': 1,
|
||||
'width': u'120px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'net_total',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Net Total',
|
||||
'permlevel': 1,
|
||||
'width': u'120px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'grand_total',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Grand Total',
|
||||
'permlevel': 1,
|
||||
'width': u'120px'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/cost_center/__init__.py
Normal file
1
accounts/doctype/cost_center/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
94
accounts/doctype/cost_center/cost_center.js
Normal file
94
accounts/doctype/cost_center/cost_center.js
Normal file
@@ -0,0 +1,94 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
cur_frm.cscript.set_breadcrumbs = function(barea) {
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(cur_frm.docname);
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!Accounts Browser/Cost Center">\
|
||||
Chart of Cost Centers</a>');
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!accounts-home">Accounts</a>');
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
var intro_txt = '';
|
||||
cur_frm.toggle_display('cost_center_name', doc.__islocal);
|
||||
cur_frm.toggle_enable(['group_or_ledger', 'company_name'], doc.__islocal);
|
||||
|
||||
if(!doc.__islocal && doc.group_or_ledger=='Group') {
|
||||
intro_txt += '<p><b>Note:</b> This is Cost Center is a <i>Group</i>, \
|
||||
Accounting Entries are not allowed against groups.</p>';
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
|
||||
cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger')
|
||||
cur_frm.set_intro(intro_txt);
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
|
||||
// Hide/unhide group or ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
||||
cur_frm.add_custom_button('Convert to Ledger',
|
||||
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
||||
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
|
||||
cur_frm.add_custom_button('Convert to Group',
|
||||
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
|
||||
}
|
||||
}
|
||||
|
||||
// Convert group to ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
||||
$c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) {
|
||||
if(r.message == 1) {
|
||||
cur_frm.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Convert ledger to group
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
|
||||
$c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) {
|
||||
if(r.message == 1) {
|
||||
cur_frm.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
92
accounts/doctype/cost_center/cost_center.py
Normal file
92
accounts/doctype/cost_center/cost_center.py
Normal file
@@ -0,0 +1,92 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.model.doclist import getlist
|
||||
from webnotes import msgprint
|
||||
|
||||
from webnotes.utils.nestedset import DocTypeNestedSet
|
||||
|
||||
class DocType(DocTypeNestedSet):
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
self.nsm_parent_field = 'parent_cost_center'
|
||||
|
||||
def autoname(self):
|
||||
self.doc.name = self.doc.cost_center_name + ' - ' + self.doc.company_abbr
|
||||
|
||||
def get_abbr(self):
|
||||
abbr = webnotes.conn.sql("select abbr from tabCompany where company_name=%s",
|
||||
self.doc.company_name)[0][0] or ''
|
||||
ret = {
|
||||
'company_abbr' : abbr
|
||||
}
|
||||
return ret
|
||||
|
||||
def validate_mandatory(self):
|
||||
if not self.doc.group_or_ledger:
|
||||
msgprint("Please select Group or Ledger value", raise_exception=1)
|
||||
|
||||
if self.doc.cost_center_name != 'Root' and not self.doc.parent_cost_center:
|
||||
msgprint("Please enter parent cost center", raise_exception=1)
|
||||
|
||||
def convert_group_to_ledger(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Cost Center: %s has existing child. You can not convert this cost center to ledger" % (self.doc.name), raise_exception=1)
|
||||
elif self.check_gle_exists():
|
||||
msgprint("Cost Center with existing transaction can not be converted to ledger.", raise_exception=1)
|
||||
else:
|
||||
self.doc.group_or_ledger = 'Ledger'
|
||||
self.doc.save()
|
||||
return 1
|
||||
|
||||
def convert_ledger_to_group(self):
|
||||
if self.check_gle_exists():
|
||||
msgprint("Cost Center with existing transaction can not be converted to group.", raise_exception=1)
|
||||
else:
|
||||
self.doc.group_or_ledger = 'Group'
|
||||
self.doc.save()
|
||||
return 1
|
||||
|
||||
def check_gle_exists(self):
|
||||
return webnotes.conn.sql("select name from `tabGL Entry` where cost_center = %s and \
|
||||
ifnull(is_cancelled, 'No') = 'No'", (self.doc.name))
|
||||
|
||||
def check_if_child_exists(self):
|
||||
return webnotes.conn.sql("select name from `tabCost Center` where \
|
||||
parent_cost_center = %s and docstatus != 2", self.doc.name)
|
||||
|
||||
def validate_budget_details(self):
|
||||
check_acc_list = []
|
||||
for d in getlist(self.doclist, 'budget_details'):
|
||||
if self.doc.group_or_ledger=="Group":
|
||||
msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1)
|
||||
|
||||
if [d.account, d.fiscal_year] in check_acc_list:
|
||||
msgprint("Account " + d.account + "has been entered more than once for fiscal year " + d.fiscal_year, raise_exception=1)
|
||||
else:
|
||||
check_acc_list.append([d.account, d.fiscal_year])
|
||||
|
||||
def validate(self):
|
||||
"""
|
||||
Cost Center name must be unique
|
||||
"""
|
||||
if (self.doc.__islocal or not self.doc.name) and webnotes.conn.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=1)
|
||||
|
||||
self.validate_mandatory()
|
||||
self.validate_budget_details()
|
||||
319
accounts/doctype/cost_center/cost_center.txt
Normal file
319
accounts/doctype/cost_center/cost_center.txt
Normal file
@@ -0,0 +1,319 @@
|
||||
# DocType, Cost Center
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:47',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-11 14:41:39',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1317365120',
|
||||
'allow_copy': 1,
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:cost_center_name',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'description': u'**Chart of Accounts** is mainly for reporting information for governmental purposes and less for how business actually performs. \n\nMost businesses have multiple activities like different product lines, market segments, areas of business that share some common overheads but should ideally have their own structure to report whether they are profitable or not. For this purpose, there is an alternate structure, called the **Cost Centers**.\n\nA tree of **Cost Centers** to cab be designed to reflect the different units of an organization. Each Income / Expense entry is also tagged against a **Cost Center** and hence you can get Profit and Loss against a **Cost Center** too.\n\n### Budgeting\n\n**Cost Centers** can be used for budgeting purposes too. A budget can be set against each **Account** and the system will either stop, warn or ignore the budget based on the settings in the **Company** master.\n\nBudgets can also be distributed seasonally using **Budget Distribution**.',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': u'name,parent_cost_center',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Cost Center',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Cost Center',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Cost Center
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Cost Center'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sb0',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Cost Center Details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cost_center_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 0,
|
||||
'label': u'Cost Center Name',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'cost_center_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'parent_cost_center',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Parent Cost Center',
|
||||
'oldfieldname': u'parent_cost_center',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Cost Center',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company_name',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company_name',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company_abbr',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'Company Abbr',
|
||||
'oldfieldname': u'company_abbr',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cb0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'group_or_ledger',
|
||||
'fieldtype': u'Select',
|
||||
'hidden': 0,
|
||||
'label': u'Group or Ledger',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'group_or_ledger',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nGroup\nLedger',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Define Budget for this Cost Center. To set budget action, see <a href="#!List/Company">Company Master</a>',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sb1',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Budget',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Select Budget Distribution, if you want to track based on seasonality.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'distribution_id',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Distribution Id',
|
||||
'oldfieldname': u'distribution_id',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Budget Distribution',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Add rows to set annual budgets on Accounts.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'budget_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Budget Details',
|
||||
'oldfieldname': u'budget_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Budget Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lft',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'lft',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'lft',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'rgt',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'rgt',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'rgt',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'reqd': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'old_parent',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 1,
|
||||
'label': u'old_parent',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'old_parent',
|
||||
'oldfieldtype': u'Data',
|
||||
'options': u'Cost Center',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/fiscal_year/__init__.py
Normal file
1
accounts/doctype/fiscal_year/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
3
accounts/doctype/fiscal_year/fiscal_year.js
Normal file
3
accounts/doctype/fiscal_year/fiscal_year.js
Normal file
@@ -0,0 +1,3 @@
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
cur_frm.toggle_enable('year_start_date', doc.__islocal)
|
||||
}
|
||||
221
accounts/doctype/fiscal_year/fiscal_year.py
Normal file
221
accounts/doctype/fiscal_year/fiscal_year.py
Normal file
@@ -0,0 +1,221 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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):
|
||||
if not self.doc.company:
|
||||
msgprint("Please select company", raise_exception=1)
|
||||
|
||||
if not in_transaction:
|
||||
sql("start transaction")
|
||||
|
||||
self.rebuid_account_tree()
|
||||
self.clear_account_balances()
|
||||
self.create_account_balances()
|
||||
self.update_opening(self.doc.company)
|
||||
self.post_entries()
|
||||
sql("commit")
|
||||
|
||||
msgprint("Account balance reposted for fiscal year: " + self.doc.name)
|
||||
|
||||
def rebuid_account_tree(self):
|
||||
from webnotes.utils.nestedset import rebuild_tree
|
||||
rebuild_tree('Account', 'parent_account')
|
||||
|
||||
def clear_account_balances(self):
|
||||
# balances clear - `tabAccount Balance` for fiscal year
|
||||
sql("update `tabAccount Balance` t1, tabAccount t2 set t1.opening=0, t1.balance=0, t1.debit=0, t1.credit=0 where t1.fiscal_year=%s and t2.company = %s and t1.account = t2.name", (self.doc.name, self.doc.company))
|
||||
|
||||
def create_account_balances(self):
|
||||
# get periods
|
||||
period_list = self.get_period_list()
|
||||
cnt = 0
|
||||
|
||||
# get accounts
|
||||
al = 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, company):
|
||||
"""
|
||||
set opening from last year closing
|
||||
|
||||
"""
|
||||
|
||||
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 for update" % (self.doc.past_year, company))
|
||||
|
||||
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):
|
||||
sql("LOCK TABLE `tabGL Entry` WRITE")
|
||||
# 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", (self.doc.name, self.doc.company))
|
||||
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': entry[4]=='No' and flt(entry[2]) or 0
|
||||
,'credit': entry[4]=='No' and flt(entry[3]) or 0
|
||||
,'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 `tabPurchase Invoice` set outstanding_amount = 0 where fiscal_year=%s and company=%s", (self.doc.name, self.doc.company))
|
||||
sql("update `tabSales Invoice` 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] == 'Purchase Invoice':
|
||||
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)
|
||||
|
||||
def validate(self):
|
||||
if sql("select name from `tabFiscal Year` where year_start_date < %s", self.doc.year_start_date) and not self.doc.past_year:
|
||||
msgprint("Please enter Past Year", raise_exception=1)
|
||||
|
||||
|
||||
# on update
|
||||
def on_update(self):
|
||||
self.create_periods()
|
||||
self.create_account_balances()
|
||||
|
||||
if self.doc.fields.get('localname', '')[:15] == 'New Fiscal Year':
|
||||
for d in sql("select name from tabCompany"):
|
||||
self.update_opening(d[0])
|
||||
135
accounts/doctype/fiscal_year/fiscal_year.txt
Normal file
135
accounts/doctype/fiscal_year/fiscal_year.txt
Normal file
@@ -0,0 +1,135 @@
|
||||
# DocType, Fiscal Year
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:47',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-11 14:56:41',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1322549700',
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:year',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'description': u'**Fiscal Year** represents a Financial Year. All accounting entries and other major transactions are tracked against **Fiscal Year**.',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tabbed',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Fiscal Year',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Fiscal Year',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Fiscal Year
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Fiscal Year'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'year_details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Fiscal Year Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'For e.g. 2012, 2012-13',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'year',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Year Name',
|
||||
'oldfieldname': u'year',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'year_start_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Year Start Date',
|
||||
'oldfieldname': u'year_start_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'No',
|
||||
'description': u'Entries are not allowed against this Fiscal Year if the year is closed.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_fiscal_year_closed',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Year Closed',
|
||||
'oldfieldname': u'is_fiscal_year_closed',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nNo\nYes',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/form_16a/__init__.py
Normal file
1
accounts/doctype/form_16a/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
48
accounts/doctype/form_16a/form_16a.js
Normal file
48
accounts/doctype/form_16a/form_16a.js
Normal file
@@ -0,0 +1,48 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
126
accounts/doctype/form_16a/form_16a.py
Normal file
126
accounts/doctype/form_16a/form_16a.py
Normal file
@@ -0,0 +1,126 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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.doclist = 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.doclist = 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)
|
||||
437
accounts/doctype/form_16a/form_16a.txt
Normal file
437
accounts/doctype/form_16a/form_16a.txt
Normal file
@@ -0,0 +1,437 @@
|
||||
# DocType, Form 16A
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:41',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:41',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1308123438',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 0,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 75
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Form 16A',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Form 16A',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Form 16A
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Form 16A'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'basic_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Basic Info',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'from_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'From Date',
|
||||
'oldfieldname': u'from_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'to_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'To Date',
|
||||
'oldfieldname': u'to_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'tds_category',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'TDS Category',
|
||||
'oldfieldname': u'tds_category',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'TDS Category',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'party_name',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 0,
|
||||
'in_filter': 1,
|
||||
'label': u'Party Name',
|
||||
'oldfieldname': u'party_name',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'party_address',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Address',
|
||||
'oldfieldname': u'party_address',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'pan_number',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 0,
|
||||
'label': u'PAN No',
|
||||
'oldfieldname': u'pan_number',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Company ',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company_address',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Company Address',
|
||||
'oldfieldname': u'company_address',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'registration_details',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Registration Details',
|
||||
'oldfieldname': u'registration_details',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'return_details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Return Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'get_return_details',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Get Return Details',
|
||||
'oldfieldtype': u'Button',
|
||||
'options': u'get_return_ack_details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'form_16A_ack_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Form 16A Ack Details',
|
||||
'oldfieldname': u'form_16A_ack_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Form 16A Ack Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'payment_details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Payment Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'get_tds',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Get TDS',
|
||||
'oldfieldtype': u'Button',
|
||||
'options': u'get_tds',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'form_16A_tax_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Tax Details',
|
||||
'oldfieldname': u'form_16A_tax_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Form 16A Tax Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Total Amount',
|
||||
'oldfieldname': u'total_amount',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'in_words',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'In Words',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'section_break0',
|
||||
'fieldtype': u'Section Break',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'options': u'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break2',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'place',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Place',
|
||||
'oldfieldname': u'place',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'dt',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Date',
|
||||
'oldfieldname': u'dt',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break3',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'full_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Full Name',
|
||||
'oldfieldname': u'full_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'designation',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Designation',
|
||||
'oldfieldname': u'designation',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/form_16a_ack_detail/__init__.py
Normal file
1
accounts/doctype/form_16a_ack_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
61
accounts/doctype/form_16a_ack_detail/form_16a_ack_detail.txt
Normal file
61
accounts/doctype/form_16a_ack_detail/form_16a_ack_detail.txt
Normal file
@@ -0,0 +1,61 @@
|
||||
# DocType, Form 16A Ack Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:42',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:42',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Form 16A Ack Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Form 16A Ack Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Form 16A Ack Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'quarter',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Quarter',
|
||||
'oldfieldname': u'quarter',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nApr-Jun\nJul-Sept\nOct-Dec\nJan-Mar'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'ack_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Acknowledgement No.',
|
||||
'oldfieldname': u'ack_no',
|
||||
'oldfieldtype': u'Data'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/form_16a_tax_detail/__init__.py
Normal file
1
accounts/doctype/form_16a_tax_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
140
accounts/doctype/form_16a_tax_detail/form_16a_tax_detail.txt
Normal file
140
accounts/doctype/form_16a_tax_detail/form_16a_tax_detail.txt
Normal file
@@ -0,0 +1,140 @@
|
||||
# DocType, Form 16A Tax Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:42',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:42',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Form 16A Tax Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Form 16A Tax Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Form 16A Tax Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amount_paid',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Amount paid / credited',
|
||||
'oldfieldname': u'amount_paid',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'date_of_payment',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Date of payment / credit',
|
||||
'oldfieldname': u'date_of_payment',
|
||||
'oldfieldtype': u'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'tds_main',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'TDS(Main)',
|
||||
'oldfieldname': u'tds_main',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'surcharge',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Surcharge',
|
||||
'oldfieldname': u'surcharge',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cess_on_tds',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Cess on TDS',
|
||||
'oldfieldname': u'cess_on_tds',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_tax_deposited',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Total Tax Deposited',
|
||||
'oldfieldname': u'total_tax_deposited',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cheque_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Cheque / DD No.',
|
||||
'oldfieldname': u'cheque_no',
|
||||
'oldfieldtype': u'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'bsr_code',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'BSR Code',
|
||||
'oldfieldname': u'bsr_code',
|
||||
'oldfieldtype': u'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'tax_deposited_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Tax Deposited Date',
|
||||
'oldfieldname': u'tax_deposited_date',
|
||||
'oldfieldtype': u'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'challan_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Challan No.',
|
||||
'oldfieldname': u'challan_no',
|
||||
'oldfieldtype': u'Data'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/gl_control/__init__.py
Normal file
1
accounts/doctype/gl_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
668
accounts/doctype/gl_control/gl_control.py
Normal file
668
accounts/doctype/gl_control/gl_control.py
Normal file
@@ -0,0 +1,668 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist, clone
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
|
||||
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 = []
|
||||
|
||||
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 = webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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(webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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.doc.freeze_account='No'
|
||||
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 = webnotes.conn.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','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 = webnotes.conn.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:
|
||||
#toggle debit, credit if negative entry
|
||||
if flt(le.debit) < 0 or flt(le.credit) < 0:
|
||||
tmp=le.debit
|
||||
le.debit, le.credit = abs(flt(le.credit)), abs(flt(tmp))
|
||||
|
||||
# toggled debit/credit in two separate condition because both should be executed at the
|
||||
# time of cancellation when there is negative amount (tax discount)
|
||||
if cancel:
|
||||
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'):
|
||||
self.entries = []
|
||||
# get entries
|
||||
le_map_list = webnotes.conn.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)
|
||||
webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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 = webnotes.conn.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.doclist = 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 == 'Purchase Invoice Advance':
|
||||
add.tds_amount = flt(d[4])
|
||||
|
||||
return obj.doclist
|
||||
|
||||
# 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):
|
||||
webnotes.conn.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
|
||||
webnotes.conn.sql("update `tabJournal Voucher Detail` set %s = '%s' where name = '%s'" % (doctype=='Purchase Invoice' 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 = webnotes.conn.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
|
||||
webnotes.conn.sql("update `tabJournal Voucher Detail` set %s = '%s', %s = '%s' where name = '%s'" % (dr_or_cr, flt(allocate), doctype == "Purchase Invoice" 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 = webnotes.conn.sql("select t2.%s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t1.name = t2.parent and ifnull(t2.against_voucher, '') = '' and ifnull(t2.against_invoice, '') = '' 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
|
||||
|
||||
|
||||
######################################################################################################################
|
||||
|
||||
#------------------------------------------
|
||||
def reconcile_against_document(self, args):
|
||||
"""
|
||||
Cancel JV, Update aginst document, split if required and resubmit jv
|
||||
"""
|
||||
|
||||
for d in args:
|
||||
self.check_if_jv_modified(d)
|
||||
|
||||
against_fld = {
|
||||
'Journal Voucher' : 'against_jv',
|
||||
'Sales Invoice' : 'against_invoice',
|
||||
'Purchase Invoice' : 'against_voucher'
|
||||
}
|
||||
|
||||
d['against_fld'] = against_fld[d['against_voucher_type']]
|
||||
|
||||
# cancel JV
|
||||
jv_obj = get_obj('Journal Voucher', d['voucher_no'], with_children=1)
|
||||
self.make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj =1)
|
||||
|
||||
# update ref in JV Detail
|
||||
self.update_against_doc(d, jv_obj)
|
||||
|
||||
# re-submit JV
|
||||
jv_obj = get_obj('Journal Voucher', d['voucher_no'], with_children =1)
|
||||
self.make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel = 0, adv_adj =1)
|
||||
|
||||
#------------------------------------------
|
||||
def update_against_doc(self, d, jv_obj):
|
||||
"""
|
||||
Updates against document, if partial amount splits into rows
|
||||
"""
|
||||
|
||||
webnotes.conn.sql("""
|
||||
update `tabJournal Voucher Detail` t1, `tabJournal Voucher` t2
|
||||
set t1.%(dr_or_cr)s = '%(allocated_amt)s', t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now()
|
||||
where t1.name = '%(voucher_detail_no)s' and t1.parent = t2.name""" % d)
|
||||
|
||||
if d['allocated_amt'] < d['unadjusted_amt']:
|
||||
jvd = webnotes.conn.sql("select cost_center, balance, against_account, is_advance from `tabJournal Voucher Detail` where name = '%s'" % d['voucher_detail_no'])
|
||||
# new entry with balance amount
|
||||
ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail', 1)
|
||||
ch.account = d['account']
|
||||
ch.cost_center = cstr(jvd[0][0])
|
||||
ch.balance = cstr(jvd[0][1])
|
||||
ch.fields[d['dr_or_cr']] = flt(d['unadjusted_amt']) - flt(d['allocated_amt'])
|
||||
ch.fields[d['dr_or_cr']== 'debit' and 'credit' or 'debit'] = 0
|
||||
ch.against_account = cstr(jvd[0][2])
|
||||
ch.is_advance = cstr(jvd[0][3])
|
||||
ch.docstatus = 1
|
||||
ch.save(1)
|
||||
|
||||
#------------------------------------------
|
||||
def check_if_jv_modified(self, args):
|
||||
"""
|
||||
check if there is already a voucher reference
|
||||
check if amount is same
|
||||
check if jv is submitted
|
||||
"""
|
||||
ret = webnotes.conn.sql("""
|
||||
select t2.%(dr_or_cr)s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
|
||||
where t1.name = t2.parent and t2.account = '%(account)s'
|
||||
and ifnull(t2.against_voucher, '')='' and ifnull(t2.against_invoice, '')='' and ifnull(t2.against_jv, '')=''
|
||||
and t1.name = '%(voucher_no)s' and t2.name = '%(voucher_detail_no)s'
|
||||
and t1.docstatus=1 and t2.%(dr_or_cr)s = %(unadjusted_amt)s
|
||||
""" % (args))
|
||||
|
||||
if not ret:
|
||||
msgprint("Payment Entry has been modified after you pulled it. Please pull it again.", raise_exception=1)
|
||||
|
||||
|
||||
def repost_illegal_cancelled(self, after_date='2011-01-01'):
|
||||
"""
|
||||
Find vouchers that are not cancelled correctly and repost them
|
||||
"""
|
||||
vl = webnotes.conn.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 = webnotes.conn.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)
|
||||
|
||||
|
||||
def manage_recurring_invoices():
|
||||
"""
|
||||
Create recurring invoices on specific date by copying the original one
|
||||
and notify the concerned people
|
||||
"""
|
||||
rv = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` \
|
||||
where ifnull(convert_into_recurring_invoice, 0) = 1 and next_date = %s \
|
||||
and next_date <= ifnull(end_date, '2199-12-31') and docstatus=1""", nowdate())
|
||||
|
||||
|
||||
exception_list = []
|
||||
for d in rv:
|
||||
if not webnotes.conn.sql("""select name from `tabSales Invoice` \
|
||||
where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])):
|
||||
try:
|
||||
prev_rv = get_obj('Sales Invoice', d[0], with_children=1)
|
||||
new_rv = create_new_invoice(prev_rv)
|
||||
|
||||
send_notification(new_rv)
|
||||
webnotes.conn.commit()
|
||||
except Exception, e:
|
||||
webnotes.conn.rollback()
|
||||
|
||||
webnotes.conn.begin()
|
||||
webnotes.conn.sql("update `tabSales Invoice` set \
|
||||
convert_into_recurring_invoice = 0 where name = %s", d[0])
|
||||
notify_errors(d[0], prev_rv.doc.owner)
|
||||
webnotes.conn.commit()
|
||||
|
||||
exception_list.append(e)
|
||||
finally:
|
||||
webnotes.conn.begin()
|
||||
|
||||
if exception_list:
|
||||
exception_message = "\n\n".join([cstr(d) for d in exception_list])
|
||||
raise Exception, exception_message
|
||||
|
||||
|
||||
def notify_errors(inv, owner):
|
||||
exception_msg = """
|
||||
Dear User,
|
||||
|
||||
An error occured while creating recurring invoice from %s.
|
||||
|
||||
May be there are some invalid email ids mentioned in the invoice.
|
||||
|
||||
To stop sending repetitive error notifications from the system, we have unchecked \
|
||||
"Convert into Recurring" field in the invoice %s.
|
||||
|
||||
|
||||
Please correct the invoice and make the invoice recurring again.
|
||||
|
||||
<b>It is necessary to take this action today itself for the above mentioned recurring invoice \
|
||||
to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \
|
||||
of this invoice for generating the recurring invoice.</b>
|
||||
|
||||
Regards,
|
||||
Administrator
|
||||
|
||||
""" % (inv, inv)
|
||||
subj = "[Urgent] Error while creating recurring invoice from %s" % inv
|
||||
import webnotes.utils
|
||||
recipients = webnotes.utils.get_system_managers_list()
|
||||
recipients += ['support@erpnext.com', owner]
|
||||
assign_task_to_owner(inv, exception_msg, recipients)
|
||||
sendmail(recipients, subject=subj, msg = exception_msg)
|
||||
|
||||
|
||||
|
||||
def assign_task_to_owner(inv, msg, users):
|
||||
for d in users:
|
||||
if d.lower() == 'administrator':
|
||||
d = webnotes.conn.sql("select ifnull(email_id, '') \
|
||||
from `tabProfile` where name = 'Administrator'")[0][0]
|
||||
from webnotes.widgets.form import assign_to
|
||||
args = {
|
||||
'assign_to' : d,
|
||||
'doctype' : 'Sales Invoice',
|
||||
'name' : inv,
|
||||
'description' : msg,
|
||||
'priority' : 'Urgent'
|
||||
}
|
||||
assign_to.add(args)
|
||||
|
||||
|
||||
def create_new_invoice(prev_rv):
|
||||
# clone rv
|
||||
new_rv = clone(prev_rv)
|
||||
|
||||
mdict = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
||||
mcount = mdict[prev_rv.doc.recurring_type]
|
||||
|
||||
# update new rv
|
||||
|
||||
new_rv.doc.posting_date = new_rv.doc.next_date
|
||||
new_rv.doc.aging_date = new_rv.doc.next_date
|
||||
new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date)))
|
||||
new_rv.doc.invoice_period_from_date = get_next_date(new_rv.doc.invoice_period_from_date, mcount)
|
||||
new_rv.doc.invoice_period_to_date = get_next_date(new_rv.doc.invoice_period_to_date, mcount)
|
||||
new_rv.doc.owner = prev_rv.doc.owner
|
||||
new_rv.doc.save()
|
||||
|
||||
# submit and after submit
|
||||
new_rv.submit()
|
||||
new_rv.update_after_submit()
|
||||
|
||||
return new_rv
|
||||
|
||||
def get_next_date(dt, mcount):
|
||||
import datetime
|
||||
m = getdate(dt).month + mcount
|
||||
y = getdate(dt).year
|
||||
d = getdate(dt).day
|
||||
if m > 12:
|
||||
m, y = m-12, y+1
|
||||
try:
|
||||
next_month_date = datetime.date(y, m, d)
|
||||
except:
|
||||
import calendar
|
||||
last_day = calendar.monthrange(y, m)[1]
|
||||
next_month_date = datetime.date(y, m, last_day)
|
||||
return next_month_date.strftime("%Y-%m-%d")
|
||||
|
||||
|
||||
def send_notification(new_rv):
|
||||
"""Notify concerned persons about recurring invoice generation"""
|
||||
subject = "Invoice : " + new_rv.doc.name
|
||||
|
||||
com = new_rv.doc.company # webnotes.conn.get_value('Control Panel', '', 'letter_head')
|
||||
|
||||
hd = '''<div><h2>%s</h2></div>
|
||||
<div><h3>Invoice: %s</h3></div>
|
||||
<table cellspacing= "5" cellpadding="5" width = "100%%">
|
||||
<tr>
|
||||
<td width = "50%%"><b>Customer</b><br>%s<br>%s</td>
|
||||
<td width = "50%%">Invoice Date : %s<br>Invoice Period : %s to %s <br>Due Date : %s</td>
|
||||
</tr>
|
||||
</table>
|
||||
''' % (com, new_rv.doc.name, new_rv.doc.customer_name, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \
|
||||
getdate(new_rv.doc.invoice_period_from_date).strftime("%d-%m-%Y"), getdate(new_rv.doc.invoice_period_to_date).strftime("%d-%m-%Y"),\
|
||||
getdate(new_rv.doc.due_date).strftime("%d-%m-%Y"))
|
||||
|
||||
|
||||
tbl = '''<table border="1px solid #CCC" width="100%%" cellpadding="0px" cellspacing="0px">
|
||||
<tr>
|
||||
<td width = "15%%" bgcolor="#CCC" align="left"><b>Item</b></td>
|
||||
<td width = "40%%" bgcolor="#CCC" align="left"><b>Description</b></td>
|
||||
<td width = "15%%" bgcolor="#CCC" align="center"><b>Qty</b></td>
|
||||
<td width = "15%%" bgcolor="#CCC" align="center"><b>Rate</b></td>
|
||||
<td width = "15%%" bgcolor="#CCC" align="center"><b>Amount</b></td>
|
||||
</tr>
|
||||
'''
|
||||
for d in getlist(new_rv.doclist, 'entries'):
|
||||
tbl += '<tr><td>' + d.item_code +'</td><td>' + d.description+'</td><td>' + cstr(d.qty) +'</td><td>' + cstr(d.basic_rate) +'</td><td>' + cstr(d.amount) +'</td></tr>'
|
||||
tbl += '</table>'
|
||||
|
||||
totals =''' <table cellspacing= "5" cellpadding="5" width = "100%%">
|
||||
<tr>
|
||||
<td width = "50%%"></td>
|
||||
<td width = "50%%">
|
||||
<table width = "100%%">
|
||||
<tr>
|
||||
<td width = "50%%">Net Total: </td><td>%s </td>
|
||||
</tr><tr>
|
||||
<td width = "50%%">Total Tax: </td><td>%s </td>
|
||||
</tr><tr>
|
||||
<td width = "50%%">Grand Total: </td><td>%s</td>
|
||||
</tr><tr>
|
||||
<td width = "50%%">In Words: </td><td>%s</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>Terms and Conditions:</td></tr>
|
||||
<tr><td>%s</td></tr>
|
||||
</table>
|
||||
''' % (new_rv.doc.net_total, new_rv.doc.other_charges_total,new_rv.doc.grand_total, new_rv.doc.in_words,new_rv.doc.terms)
|
||||
|
||||
|
||||
msg = hd + tbl + totals
|
||||
recipients = new_rv.doc.notification_email_address.replace('\n', '').replace(' ', '').split(",")
|
||||
sendmail(recipients, subject=subject, msg = msg)
|
||||
31
accounts/doctype/gl_control/gl_control.txt
Normal file
31
accounts/doctype/gl_control/gl_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, GL Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:42',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:42',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 288
|
||||
},
|
||||
|
||||
# DocType, GL Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'GL Control'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/gl_entry/__init__.py
Normal file
1
accounts/doctype/gl_entry/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
300
accounts/doctype/gl_entry/gl_entry.py
Normal file
300
accounts/doctype/gl_entry/gl_entry.py
Normal file
@@ -0,0 +1,300 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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
|
||||
|
||||
|
||||
# COMMMENTED below to allow zero amount (+ and -) entry in tax table
|
||||
# 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('Global Defaults', None, 'acc_frozen_upto')
|
||||
if acc_frozen_upto:
|
||||
bde_auth_role = get_value( 'Global Defaults', 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': self.doc.is_opening=='No' and flt(debit) or 0
|
||||
,'credit':self.doc.is_opening=='No' and flt(credit) or 0
|
||||
,'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
|
||||
}
|
||||
|
||||
# Update account balance for current 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)
|
||||
|
||||
# Future year balances
|
||||
# Update opening only where period_type is Year
|
||||
sql("""update `tabAccount Balance` ab, `tabAccount` a, `tabFiscal Year` fy
|
||||
set
|
||||
ab.opening = ifnull(ab.opening,0) + %(diff)s
|
||||
where
|
||||
a.lft <= %(lft)s
|
||||
and a.rgt >= %(rgt)s
|
||||
and ab.account = a.name
|
||||
and ifnull(a.is_pl_account, 'No') = 'No'
|
||||
and ab.period = ab.fiscal_year
|
||||
and fy.name = ab.fiscal_year
|
||||
and fy.year_start_date > '%(posting_date)s'""" % p)
|
||||
|
||||
# Update balance for all period for future years
|
||||
sql("""update `tabAccount Balance` ab, `tabAccount` a, `tabFiscal Year` fy
|
||||
set
|
||||
ab.balance = ifnull(ab.balance,0) + %(diff)s
|
||||
where
|
||||
a.lft <= %(lft)s
|
||||
and a.rgt >= %(rgt)s
|
||||
and ab.account = a.name
|
||||
and ifnull(a.is_pl_account, 'No') = 'No'
|
||||
and fy.name = ab.fiscal_year
|
||||
and fy.year_start_date > '%(posting_date)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=='Purchase Invoice':
|
||||
# amount to debit
|
||||
bal = -bal
|
||||
|
||||
# Check if tds applicable
|
||||
tds = sql("select total_tds_on_voucher from `tabPurchase Invoice` 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=='Sales Invoice') 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()
|
||||
303
accounts/doctype/gl_entry/gl_entry.txt
Normal file
303
accounts/doctype/gl_entry/gl_entry.txt
Normal file
@@ -0,0 +1,303 @@
|
||||
# DocType, GL Entry
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:42',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:42',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1319016431',
|
||||
'autoname': u'GL.#######',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': u'voucher_no,account,posting_date,against_voucher',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 103
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'GL Entry',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'GL Entry',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocType, GL Entry
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'GL Entry'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Accounts User',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'The date at which current entry will get or has actually executed.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'posting_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Posting Date',
|
||||
'oldfieldname': u'posting_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'The date at which current entry is made in system.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'transaction_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Transaction Date',
|
||||
'oldfieldname': u'transaction_date',
|
||||
'oldfieldtype': u'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'aging_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Aging Date',
|
||||
'oldfieldname': u'aging_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Account',
|
||||
'oldfieldname': u'account',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cost_center',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Cost Center',
|
||||
'oldfieldname': u'cost_center',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Cost Center',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'debit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Debit Amt',
|
||||
'oldfieldname': u'debit',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Credit Amt',
|
||||
'oldfieldname': u'credit',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'against',
|
||||
'fieldtype': u'Text',
|
||||
'in_filter': 1,
|
||||
'label': u'Against',
|
||||
'oldfieldname': u'against',
|
||||
'oldfieldtype': u'Text'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'against_voucher',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Against Voucher',
|
||||
'oldfieldname': u'against_voucher',
|
||||
'oldfieldtype': u'Data',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'against_voucher_type',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 0,
|
||||
'label': u'Against Voucher Type',
|
||||
'oldfieldname': u'against_voucher_type',
|
||||
'oldfieldtype': u'Data',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'voucher_type',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Voucher Type',
|
||||
'oldfieldname': u'voucher_type',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'Journal Voucher\nSales Invoice\nPurchase Invoice',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'voucher_no',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Voucher No',
|
||||
'oldfieldname': u'voucher_no',
|
||||
'oldfieldtype': u'Data',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'remarks',
|
||||
'fieldtype': u'Text',
|
||||
'in_filter': 1,
|
||||
'label': u'Remarks',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'remarks',
|
||||
'oldfieldtype': u'Text',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_cancelled',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Is Cancelled',
|
||||
'oldfieldname': u'is_cancelled',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'No\nYes',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_opening',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Is Opening',
|
||||
'oldfieldname': u'is_opening',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'No\nYes',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_advance',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 0,
|
||||
'label': u'Is Advance',
|
||||
'oldfieldname': u'is_advance',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'No\nYes',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Company',
|
||||
'search_index': 0
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/journal_voucher/__init__.py
Normal file
1
accounts/doctype/journal_voucher/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
199
accounts/doctype/journal_voucher/journal_voucher.js
Normal file
199
accounts/doctype/journal_voucher/journal_voucher.js
Normal file
@@ -0,0 +1,199 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if (!doc.voucher_date) doc.voucher_date = dateutil.obj_to_str(new Date());
|
||||
|
||||
var cp = wn.control_panel;
|
||||
if(cp.country == 'India') $(cur_frm.fields_dict.tds.row.wrapper).toggle(true);
|
||||
else $(cur_frm.fields_dict.tds.row.wrapper).toggle(false);
|
||||
|
||||
cur_frm.cscript.load_defaults(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc) {
|
||||
cur_frm.cscript.is_opening(doc)
|
||||
erpnext.hide_naming_series();
|
||||
}
|
||||
|
||||
cur_frm.cscript.load_defaults = function(doc, cdt, cdn) {
|
||||
if(!cur_frm.doc.__islocal || !cur_frm.doc.company) { return; }
|
||||
|
||||
doc = locals[doc.doctype][doc.name];
|
||||
var fields_to_refresh = LocalDB.set_default_values(doc);
|
||||
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
|
||||
|
||||
fields_to_refresh = null;
|
||||
var children = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
||||
if(!children) { return; }
|
||||
for(var i=0; i<children.length; i++) {
|
||||
LocalDB.set_default_values(children[i]);
|
||||
}
|
||||
refresh_field('entries');
|
||||
}
|
||||
|
||||
|
||||
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.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 `tabPurchase Invoice`.name, `tabPurchase Invoice`.credit_to, `tabPurchase Invoice`.outstanding_amount,`tabPurchase Invoice`.bill_no, `tabPurchase Invoice`.bill_date FROM `tabPurchase Invoice` WHERE `tabPurchase Invoice`.credit_to='"+d.account+"' AND `tabPurchase Invoice`.outstanding_amount > 0 AND `tabPurchase Invoice`.docstatus = 1 AND `tabPurchase Invoice`.%(key)s LIKE '%s' ORDER BY `tabPurchase Invoice`.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 `tabSales Invoice`.name, `tabSales Invoice`.debit_to, `tabSales Invoice`.outstanding_amount FROM `tabSales Invoice` WHERE `tabSales Invoice`.debit_to='"+d.account+"' AND `tabSales Invoice`.outstanding_amount > 0 AND `tabSales Invoice`.docstatus = 1 AND `tabSales Invoice`.%(key)s LIKE '%s' ORDER BY `tabSales Invoice`.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 & Sales Invoice
|
||||
// -----------------------------------------------
|
||||
|
||||
cur_frm.cscript.against_voucher = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.against_voucher && !flt(d.debit)) {
|
||||
args = {'doctype': 'Purchase Invoice', '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': 'Sales Invoice', '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 Sales Invoice *****************
|
||||
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){
|
||||
wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name);
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
||||
if(doc.voucher_type == 'Bank Voucher' && cstr(doc.company)) {
|
||||
var children = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
||||
if(!children || children.length==0) {
|
||||
$c('accounts.get_default_bank_account', {company: doc.company }, function(r, rt) {
|
||||
if(!r.exc) {
|
||||
var jvd = LocalDB.add_child(doc, 'Journal Voucher Detail', 'entries');
|
||||
jvd.account = cstr(r.message);
|
||||
refresh_field('entries');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
465
accounts/doctype/journal_voucher/journal_voucher.py
Normal file
465
accounts/doctype/journal_voucher/journal_voucher.py
Normal file
@@ -0,0 +1,465 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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'] == 'Purchase Invoice':
|
||||
return {'debit': o_s and flt(o_s[0][0]) or 0}
|
||||
if args['doctype'] == 'Sales Invoice':
|
||||
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 `tabSales Invoice` 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 `tabPurchase Invoice` 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='Global Defaults'")
|
||||
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 `tabSales Invoice` 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 `tabPurchase Invoice` 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 `tabSales Invoice` 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 `tabPurchase Invoice` where docstatus = 1 and company = '%s' and outstanding_amount > 0 %s" % (self.doc.company, cond))
|
||||
|
||||
|
||||
# -------------------------
|
||||
# get outstanding invoices
|
||||
# -------------------------
|
||||
def get_outstanding_invoices(self):
|
||||
self.doclist = 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
|
||||
792
accounts/doctype/journal_voucher/journal_voucher.txt
Normal file
792
accounts/doctype/journal_voucher/journal_voucher.txt
Normal file
@@ -0,0 +1,792 @@
|
||||
# DocType, Journal Voucher
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-05-01 17:10:24',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-04 10:05:25',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1311251040',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'is_submittable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'search_fields': u'voucher_type,posting_date, due_date, cheque_no',
|
||||
'section_style': u'Tabbed',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': u' ',
|
||||
'tag_fields': u'voucher_type',
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Journal Voucher',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Journal Voucher',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Journal Voucher
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Journal Voucher'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Accounts User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'basic_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Basic Info',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'To manage multiple series please go to Setup > Manage Series',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'naming_series',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Series',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'naming_series',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'JV',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'voucher_type',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Voucher Type',
|
||||
'oldfieldname': u'voucher_type',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nJournal Entry\nBank Voucher\nCash Voucher\nCredit Card Voucher\nDebit Note\nCredit Note\nContra Voucher\nExcise Voucher\nWrite Off Voucher',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'The date at which current entry will get or has actually executed.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'posting_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Posting Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'posting_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'2_add_edit_gl_entries',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Journal Entries',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'options': u'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'entries',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Entries',
|
||||
'oldfieldname': u'entries',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Journal Voucher Detail',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'section_break99',
|
||||
'fieldtype': u'Section Break',
|
||||
'options': u'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_debit',
|
||||
'fieldtype': u'Currency',
|
||||
'in_filter': 1,
|
||||
'label': u'Total Debit',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'total_debit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_credit',
|
||||
'fieldtype': u'Currency',
|
||||
'in_filter': 1,
|
||||
'label': u'Total Credit',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'total_credit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break99',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'difference',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Difference',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'difference',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'get_balance',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Make Difference Entry',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'reference',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Reference',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cheque_no',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Cheque No',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'cheque_no',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cheque_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Cheque Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'cheque_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'clearance_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Clearance Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'clearance_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break98',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'user_remark',
|
||||
'fieldtype': u'Small Text',
|
||||
'in_filter': 1,
|
||||
'label': u'User Remark',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'user_remark',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'User Remark will be added to Auto Remark',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'remark',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Remark',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'remark',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'bill_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Bill No',
|
||||
'oldfieldname': u'bill_no',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'bill_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Bill Date',
|
||||
'oldfieldname': u'bill_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'due_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Due Date',
|
||||
'oldfieldname': u'due_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'addtional_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'More Info',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break2',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'No',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_opening',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Is Opening',
|
||||
'oldfieldname': u'is_opening',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'No\nYes',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'For opening invoice entry, this date will reflect in the period-wise aging report.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'aging_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Aging Date',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': u'aging_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Accounts Receivable',
|
||||
'depends_on': u"eval:doc.voucher_type == 'Write Off Voucher'",
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'write_off_based_on',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Write Off Based On',
|
||||
'options': u'Accounts Receivable\nAccounts Payable',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u"eval:doc.voucher_type == 'Write Off Voucher'",
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'write_off_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Write Off Amount <=',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u"eval:doc.voucher_type == 'Write Off Voucher'",
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'get_outstanding_invoices',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Get Outstanding Invoices',
|
||||
'options': u'get_outstanding_invoices',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': u'Server'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Today',
|
||||
'description': u'Date of entry (not posting to ledgers)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'voucher_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Voucher Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'voucher_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break3',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'pay_to_recd_from',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 0,
|
||||
'label': u'Pay To / Recd From',
|
||||
'no_copy': 1,
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_amount',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'Total Amount',
|
||||
'no_copy': 1,
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'total_amount_in_words',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'Total Amount in Words',
|
||||
'no_copy': 1,
|
||||
'permlevel': 1,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:Fiscal Year',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Company',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'select_print_heading',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Select Print Heading',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'select_print_heading',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Print Heading',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amended_from',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'amended_from',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Journal Voucher',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'The date at which current entry is corrected in the system.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amendment_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Amendment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'amendment_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cancel_reason',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Cancel Reason',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'cancel_reason',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'section_break0',
|
||||
'fieldtype': u'Section Break',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'options': u'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'view_ledger_entry',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'View Ledger Entry',
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'tds',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'TDS',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'default': u'No',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'tds_applicable',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'TDS Applicable',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'tds_applicable',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'tds_category',
|
||||
'fieldtype': u'Select',
|
||||
'hidden': 0,
|
||||
'in_filter': 1,
|
||||
'label': u'TDS Category',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'tds_category',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'link:TDS Category',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'supplier_account',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 0,
|
||||
'label': u'Supplier Account',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'supplier_account',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'get_tds',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Get TDS',
|
||||
'no_copy': 0,
|
||||
'oldfieldtype': u'Button',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Tax Code will be populated based on account head mentioned in TDS Category master',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'tax_code',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'TDS Account Head',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'tax_code',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'rate',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Rate',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'rate',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'ded_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Amount',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'ded_amount',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'trigger': u'Client'
|
||||
}
|
||||
]
|
||||
39
accounts/doctype/journal_voucher/journal_voucher_list.js
Normal file
39
accounts/doctype/journal_voucher/journal_voucher_list.js
Normal file
@@ -0,0 +1,39 @@
|
||||
wn.doclistviews['Journal Voucher'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d);
|
||||
this.fields = this.fields.concat([
|
||||
'`tabJournal Voucher`.voucher_type',
|
||||
'`tabJournal Voucher`.remark',
|
||||
'`tabJournal Voucher`.total_debit',
|
||||
'`tabJournal Voucher`.company',
|
||||
"`tabJournal Voucher`.posting_date",
|
||||
]);
|
||||
this.stats = this.stats.concat(['voucher_type', 'company']);
|
||||
},
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
if(!data.remark) data.remark = '';
|
||||
if(data.remark.length> 30) {
|
||||
data.remark = '<span title="'+data.remark+'">' + data.remark.substr(0,30)
|
||||
+ '...</span>';
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '5%', content: 'avatar'},
|
||||
{width: '3%', content: 'docstatus'},
|
||||
{width: '12%', content: 'name'},
|
||||
{width: '15%', content: 'voucher_type'},
|
||||
{width: '32%', content: 'remark+tags', css: {'color':'#222'}},
|
||||
{
|
||||
width: '18%',
|
||||
content: function(parent, data) {
|
||||
$(parent).html(wn.boot.company[data.company].default_currency + ' ' + fmt_money(data.total_debit))
|
||||
},
|
||||
css: {'text-align':'right'}
|
||||
},
|
||||
{width: '12%', content:'posting_date',
|
||||
css: {'text-align': 'right', 'color':'#777'},
|
||||
title: "Journal Voucher Date", type: "date"}
|
||||
],
|
||||
});
|
||||
1
accounts/doctype/journal_voucher_detail/__init__.py
Normal file
1
accounts/doctype/journal_voucher_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,183 @@
|
||||
# DocType, Journal Voucher Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-02 16:01:23',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-30 16:05:46',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'JVD.######',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tray',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Journal Voucher Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# DocType, Journal Voucher Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Journal Voucher Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Account',
|
||||
'oldfieldname': u'account',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client',
|
||||
'width': u'250px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'debit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Debit',
|
||||
'oldfieldname': u'debit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Credit',
|
||||
'oldfieldname': u'credit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cost_center',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Cost Center',
|
||||
'oldfieldname': u'cost_center',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Cost Center',
|
||||
'permlevel': 0,
|
||||
'search_index': 0,
|
||||
'width': u'180px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'balance',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Account Balance',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'balance',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'against_voucher',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Against Payable',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'against_voucher',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Purchase Invoice',
|
||||
'permlevel': 0,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'against_invoice',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Against Receivable',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'against_invoice',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Sales Invoice',
|
||||
'permlevel': 0,
|
||||
'search_index': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'against_jv',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Against JV',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'against_jv',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Journal Voucher',
|
||||
'permlevel': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_advance',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Is Advance',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'is_advance',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'No\nYes',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'against_account',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Against Account',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'against_account',
|
||||
'oldfieldtype': u'Text',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/lease_agreement/__init__.py
Normal file
1
accounts/doctype/lease_agreement/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
94
accounts/doctype/lease_agreement/lease_agreement.js
Normal file
94
accounts/doctype/lease_agreement/lease_agreement.js
Normal file
@@ -0,0 +1,94 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$.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 `tabSales Invoice` tv WHERE debit_to='"+doc.account+"' and tv.%(key)s like '%s' ORDER BY tv.name LIMIT 50"
|
||||
}
|
||||
54
accounts/doctype/lease_agreement/lease_agreement.py
Normal file
54
accounts/doctype/lease_agreement/lease_agreement.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
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]
|
||||
276
accounts/doctype/lease_agreement/lease_agreement.txt
Normal file
276
accounts/doctype/lease_agreement/lease_agreement.txt
Normal file
@@ -0,0 +1,276 @@
|
||||
# DocType, Lease Agreement
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:44',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:44',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1311555967',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 24
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Lease Agreement',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Lease Agreement',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'role': u'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocType, Lease Agreement
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Lease Agreement'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'naming_series',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Naming Series',
|
||||
'no_copy': 1,
|
||||
'options': u'\nLA',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lessee_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Lessee Info.',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Account',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lessee_father',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Lessee Father',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lessee_nic',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Lessee NIC',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lessee_contact',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Lessee Contact',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lessee_address',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Lessee Address',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'vehicle_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Vehicle Info.',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'model_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Model No',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'engine_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Engine No',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'chassis_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Chassis No',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'invoice_and_payment_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Invoice and Payment Info.',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'invoice',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Invoice',
|
||||
'options': u'Sales Invoice',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'invoice_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Invoice Amount',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'down_payment',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Down Payment',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'start_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Start Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'no_of_installments',
|
||||
'fieldtype': u'Int',
|
||||
'label': u'No of Installments',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'installment_amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Installment Amount',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'generate',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Generate',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'installments',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Installments',
|
||||
'options': u'Lease Installment',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'installment_reciept',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Installment Reciept',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/lease_installment/__init__.py
Normal file
1
accounts/doctype/lease_installment/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
86
accounts/doctype/lease_installment/lease_installment.txt
Normal file
86
accounts/doctype/lease_installment/lease_installment.txt
Normal file
@@ -0,0 +1,86 @@
|
||||
# DocType, Lease Installment
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:44',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:44',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Lease Installment',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# DocType, Lease Installment
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Lease Installment'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amount',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Amount',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'due_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Due Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cheque_number',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Cheque Number',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cheque_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Cheque Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'jv_number',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 0,
|
||||
'label': u'JV Number',
|
||||
'options': u'Journal Voucher',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/mis_control/__init__.py
Normal file
1
accounts/doctype/mis_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
419
accounts/doctype/mis_control/mis_control.py
Normal file
419
accounts/doctype/mis_control/mis_control.py
Normal file
@@ -0,0 +1,419 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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 = doc
|
||||
self.doclist = doclist
|
||||
self.account_list = []
|
||||
self.ac_details = {} # key: account id, values: debit_or_credit, lft, rgt
|
||||
|
||||
self.roles = webnotes.user.get_roles()
|
||||
|
||||
self.period_list = []
|
||||
self.period_start_date = {}
|
||||
self.period_end_date = {}
|
||||
|
||||
self.fs_list = []
|
||||
self.root_bal = []
|
||||
self.flag = 0
|
||||
|
||||
# Get defaults on load of MIS, MIS - Comparison Report and Financial statements
|
||||
# ----------------------------------------------------
|
||||
def get_comp(self):
|
||||
ret = {}
|
||||
type = []
|
||||
comp = []
|
||||
# ------ get period -----------
|
||||
ret['period'] = ['Annual','Half Yearly','Quarterly','Monthly']
|
||||
|
||||
# ---- get companies ---------
|
||||
res = sql("select name from `tabCompany`")
|
||||
for r in res:
|
||||
comp.append(r[0])
|
||||
#comp.append(r[0] for r in res)
|
||||
ret['company'] = comp
|
||||
|
||||
#--- to get fiscal year and start_date of that fiscal year -----
|
||||
res = sql("select name, year_start_date from `tabFiscal Year`")
|
||||
ret['fiscal_year'] = [r[0] for r in res]
|
||||
ret['start_dates'] = {}
|
||||
for r in res:
|
||||
ret['start_dates'][r[0]] = str(r[1])
|
||||
|
||||
#--- from month and to month (for MIS - Comparison Report) -------
|
||||
month_list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
|
||||
fiscal_start_month = sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(get_defaults()['fiscal_year']))
|
||||
fiscal_start_month = fiscal_start_month and fiscal_start_month[0][0] or 1
|
||||
mon = ['']
|
||||
for i in range(fiscal_start_month,13): mon.append(month_list[i-1])
|
||||
for i in range(0,fiscal_start_month-1): mon.append(month_list[i])
|
||||
ret['month'] = mon
|
||||
|
||||
# ------------------------ get MIS Type on basis of roles of session user ------------------------------------------
|
||||
if has_common(self.roles, ['Sales Manager']):
|
||||
type.append('Sales')
|
||||
if has_common(self.roles, ['Purchase Manager']):
|
||||
type.append('Purchase')
|
||||
ret['type'] = type
|
||||
return ret
|
||||
|
||||
# Gets Transactions type and Group By options based on module
|
||||
#------------------------------------------------------------------
|
||||
def get_trans_group(self,module):
|
||||
ret = {}
|
||||
st,group = [],[]
|
||||
if module == 'Sales':
|
||||
st = ['Quotation','Sales Order','Delivery Note','Sales Invoice']
|
||||
group = ['Item','Item Group','Customer','Customer Group','Cost Center']
|
||||
elif module == 'Purchase':
|
||||
st = ['Purchase Order','Purchase Receipt','Purchase Invoice']
|
||||
group = ['Item','Item Group','Supplier','Supplier Type']
|
||||
|
||||
ret['stmt_type'] = st
|
||||
ret['group_by'] = group
|
||||
|
||||
return ret
|
||||
|
||||
# Get Days based on month (for MIS Comparison Report)
|
||||
# --------------------------------------------------------
|
||||
def get_days(self,month):
|
||||
days = []
|
||||
ret = {}
|
||||
if month == 'Jan' or month == 'Mar' or month == 'May' or month == 'Jul' or month == 'Aug' or month == 'Oct' or month == 'Dec':
|
||||
for i in range(1,32):
|
||||
days.append(i)
|
||||
elif month == 'Apr' or month == 'Jun' or month == 'Sep' or month == 'Nov':
|
||||
for i in range(1,31):
|
||||
days.append(i)
|
||||
elif month == 'Feb':
|
||||
for i in range(1,29):
|
||||
days.append(i)
|
||||
ret['days'] = days
|
||||
return ret
|
||||
|
||||
# Get from date and to date based on fiscal year (for in summary - comparison report)
|
||||
# -----------------------------------------------------------------------------------------------------
|
||||
def dates(self,fiscal_year,from_date,to_date):
|
||||
import datetime
|
||||
ret = ''
|
||||
start_date = cstr(sql("select year_start_date from `tabFiscal Year` where name = %s",fiscal_year)[0][0])
|
||||
st_mon = cint(from_date.split('-')[1])
|
||||
ed_mon = cint(to_date.split('-')[1])
|
||||
st_day = cint(from_date.split('-')[2])
|
||||
ed_day = cint(to_date.split('-')[2])
|
||||
fiscal_start_month = cint(start_date.split('-')[1])
|
||||
next_fiscal_year = cint(start_date.split('-')[0]) + 1
|
||||
current_year = ''
|
||||
next_year = ''
|
||||
|
||||
#CASE - 1 : Jan - Mar (Valid)
|
||||
if st_mon < fiscal_start_month and ed_mon < fiscal_start_month:
|
||||
current_year = cint(start_date.split('-')[0]) + 1
|
||||
next_year = cint(start_date.split('-')[0]) + 1
|
||||
|
||||
# Case - 2 : Apr - Dec (Valid)
|
||||
elif st_mon >= fiscal_start_month and ed_mon <= 12 and ed_mon >= fiscal_start_month:
|
||||
current_year = cint(start_date.split('-')[0])
|
||||
next_year = cint(start_date.split('-')[0])
|
||||
|
||||
# Case 3 : Jan - May (Invalid)
|
||||
elif st_mon < fiscal_start_month and ed_mon >= fiscal_start_month:
|
||||
current_year = cint(start_date.split('-')[0]) + 1
|
||||
next_year = cint(start_date.split('-')[0]) + 2
|
||||
|
||||
# check whether from date is within fiscal year
|
||||
if datetime.date(current_year, st_mon, st_day) >= datetime.date(cint(start_date.split('-')[0]), cint(start_date.split('-')[1]), cint(start_date.split('-')[2])) and datetime.date(cint(current_year), cint(st_mon), cint(st_day)) < datetime.date((cint(start_date.split('-')[0])+1), cint(start_date.split('-')[1]), cint(start_date.split('-')[2])):
|
||||
begin_date = cstr(current_year)+"-"+cstr(st_mon)+"-"+cstr(st_day)
|
||||
else:
|
||||
msgprint("Please enter appropriate from date.")
|
||||
raise Exception
|
||||
# check whether to date is within fiscal year
|
||||
if datetime.date(next_year, ed_mon, ed_day) >= datetime.date(cint(start_date.split('-')[0]), cint(start_date.split('-')[1]), cint(start_date.split('-')[2])) and datetime.date(cint(next_year), cint(ed_mon), cint(ed_day)) < datetime.date(cint(start_date.split('-')[0])+1, cint(start_date.split('-')[1]), cint(start_date.split('-')[2])):
|
||||
end_date = cstr(next_year)+"-"+cstr(ed_mon)+"-"+cstr(ed_day)
|
||||
else:
|
||||
msgprint("Please enter appropriate to date.")
|
||||
raise Exception
|
||||
ret = begin_date+'~~~'+end_date
|
||||
return ret
|
||||
|
||||
# Get MIS Totals
|
||||
# ---------------
|
||||
def get_totals(self, args):
|
||||
args = eval(args)
|
||||
#msgprint(args)
|
||||
totals = sql("SELECT %s FROM %s WHERE %s %s %s %s" %(cstr(args['query_val']), cstr(args['tables']), cstr(args['company']), cstr(args['cond']), cstr(args['add_cond']), cstr(args['fil_cond'])), as_dict = 1)[0]
|
||||
#msgprint(totals)
|
||||
tot_keys = totals.keys()
|
||||
# return in flt because JSON doesn't accept Decimal
|
||||
for d in tot_keys:
|
||||
totals[d] = flt(totals[d])
|
||||
return totals
|
||||
|
||||
# Get Statement
|
||||
# -------------
|
||||
|
||||
def get_statement(self, arg):
|
||||
self.return_data = []
|
||||
|
||||
# define periods
|
||||
arg = eval(arg)
|
||||
pl = ''
|
||||
|
||||
self.define_periods(arg['year'], arg['period']) # declares 1.period_list i.e. (['Jan','Feb','Mar'...] or ['Q1','Q2'...] or ['FY2009-2010']) based on period
|
||||
# 2.period_start_date dict {'Jan':'01-01-2009'...}
|
||||
# 3.period_start_date dict {'Jan':'31-01-2009'...}
|
||||
self.return_data.append([4,'']+self.period_list)
|
||||
|
||||
|
||||
if arg['statement'] == 'Balance Sheet': pl = 'No'
|
||||
if arg['statement'] == 'Profit & Loss': pl = 'Yes'
|
||||
|
||||
self.get_children('',0,pl,arg['company'], arg['year'])
|
||||
|
||||
#self.balance_pl_statement(acct, arg['statement'])
|
||||
#msgprint(self.return_data)
|
||||
return self.return_data
|
||||
|
||||
# Get Children
|
||||
# ------------
|
||||
def get_children(self, parent_account, level, pl, company, fy):
|
||||
cl = sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company))
|
||||
level0_diff = [0 for p in self.period_list]
|
||||
if pl=='Yes' and level==0: # switch for income & expenses
|
||||
cl = [c for c in cl]
|
||||
cl.reverse()
|
||||
if cl:
|
||||
for c in cl:
|
||||
self.ac_details[c[1]] = [c[2], c[3], c[4]]
|
||||
bal_list = self.get_period_balance(c[1], level, pl, company, fy)
|
||||
if level==0: # top level - put balances as totals
|
||||
self.return_data.append([level, c[0]] + ['' for b in bal_list])
|
||||
totals = bal_list
|
||||
for i in range(len(totals)): # make totals
|
||||
if c[2]=='Credit':
|
||||
level0_diff[i] += flt(totals[i])
|
||||
else:
|
||||
level0_diff[i] -= flt(totals[i])
|
||||
else:
|
||||
self.return_data.append([level, c[0]]+bal_list)
|
||||
|
||||
if level < 2:
|
||||
self.get_children(c[1], level+1, pl, company, fy)
|
||||
|
||||
# make totals - for top level
|
||||
# ---------------------------
|
||||
if level==0:
|
||||
# add rows for profit / loss in B/S
|
||||
if pl=='No':
|
||||
if c[2]=='Credit':
|
||||
self.return_data.append([1, 'Total Liabilities'] + totals)
|
||||
level0_diff = [-i for i in level0_diff] # convert to debit
|
||||
self.return_data.append([5, 'Profit/Loss (Provisional)'] + level0_diff)
|
||||
for i in range(len(totals)): # make totals
|
||||
level0_diff[i] = flt(totals[i]) + level0_diff[i]
|
||||
self.return_data.append([4, 'Total '+c[0]] + level0_diff)
|
||||
else:
|
||||
self.return_data.append([4, 'Total '+c[0]] + totals)
|
||||
|
||||
# add rows for profit / loss in P/L
|
||||
else:
|
||||
if c[2]=='Debit':
|
||||
self.return_data.append([1, 'Total Expenses (before Profit)'] + totals)
|
||||
self.return_data.append([5, 'Profit/Loss (Provisional)'] + level0_diff)
|
||||
for i in range(len(totals)): # make totals
|
||||
level0_diff[i] = flt(totals[i]) + level0_diff[i]
|
||||
self.return_data.append([4, 'Total '+c[0]] + level0_diff)
|
||||
else:
|
||||
self.return_data.append([4, 'Total '+c[0]] + totals)
|
||||
|
||||
# Define Periods
|
||||
# --------------
|
||||
|
||||
def define_periods(self, year, period):
|
||||
|
||||
# get year start date
|
||||
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", year)
|
||||
ysd = ysd and ysd[0][0] or ''
|
||||
|
||||
self.ysd = ysd
|
||||
|
||||
# year
|
||||
if period == 'Annual':
|
||||
pn = 'FY'+year
|
||||
self.period_list.append(pn)
|
||||
self.period_start_date[pn] = ysd
|
||||
self.period_end_date[pn] = get_last_day(get_first_day(ysd,0,11))
|
||||
|
||||
# quarter
|
||||
if period == 'Quarterly':
|
||||
for i in range(4):
|
||||
pn = 'Q'+str(i+1)
|
||||
self.period_list.append(pn)
|
||||
|
||||
self.period_start_date[pn] = get_first_day(ysd,0,i*3)
|
||||
self.period_end_date[pn] = get_last_day(get_first_day(ysd,0,((i+1)*3)-1))
|
||||
|
||||
# month
|
||||
if period == 'Monthly':
|
||||
mlist = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
|
||||
for i in range(12):
|
||||
fd = get_first_day(ysd,0,i)
|
||||
pn = mlist[fd.month-1]
|
||||
self.period_list.append(pn)
|
||||
|
||||
self.period_start_date[pn] = fd
|
||||
self.period_end_date[pn] = get_last_day(fd)
|
||||
|
||||
# Get Balance For A Period
|
||||
# ------------------------
|
||||
|
||||
def get_period_balance(self, acc, level, pl, company, fy):
|
||||
debit_or_credit, lft, rgt = self.ac_details[acc]
|
||||
ret = []
|
||||
for p in self.period_list:
|
||||
sd, ed = self.period_start_date[p].strftime('%Y-%m-%d'), self.period_end_date[p].strftime('%Y-%m-%d')
|
||||
cond = "and t1.voucher_type != 'Period Closing Voucher'"
|
||||
if pl=='No':
|
||||
sd = self.ysd.strftime('%Y-%m-%d')
|
||||
cond = ""
|
||||
|
||||
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.company = '%s' AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s and ifnull(t1.is_opening,'No') = 'No' and ifnull(t1.is_cancelled, 'No') = 'No' %s" % (sd,ed,company,lft,rgt, cond))
|
||||
|
||||
|
||||
bal = bal and (flt(bal[0][0]) - flt(bal[0][1])) or 0
|
||||
if debit_or_credit == 'Credit' and bal:
|
||||
bal = -bal
|
||||
if pl=='No':
|
||||
op = sql("select opening from `tabAccount Balance` where account=%s and period=%s", (acc, fy))
|
||||
op = op and op[0][0] or 0
|
||||
bal += flt(op)
|
||||
|
||||
ret.append(bal)
|
||||
return ret
|
||||
|
||||
# Get Dashboard Amounts
|
||||
# ---------------------
|
||||
|
||||
def get_balance(self, acc, sd, ed, company, fy):
|
||||
a = sql("select account_name, name, debit_or_credit, lft, rgt, is_pl_account from `tabAccount` where account_name=%s and company=%s", (acc, company), as_dict=1)
|
||||
if a:
|
||||
a = a[0]
|
||||
bal = sql("select SUM(IFNULL(t1.debit,0)), SUM(IFNULL(t1.credit,0)) from `tabGL Entry` t1, `tabAccount` t2 WHERE t1.posting_date >= %s AND t1.posting_date <= %s AND t1.account = t2.name AND t2.lft >= %s AND t2.rgt <= %s and ifnull(is_opening, 'No') = 'No' and ifnull(t1.is_cancelled, 'No') = 'No'", (sd,ed,a['lft'],a['rgt']))
|
||||
if a['debit_or_credit']=='Debit':
|
||||
bal = flt(flt(bal[0][0]) - flt(bal[0][1]))
|
||||
else:
|
||||
bal = flt(flt(bal[0][1]) - flt(bal[0][0]))
|
||||
|
||||
if a['is_pl_account']=='No':
|
||||
op = sql("select opening from `tabAccount Balance` where account=%s and period=%s", (acc, fy))
|
||||
op = op and op[0][0] or 0
|
||||
bal += flt(op)
|
||||
|
||||
return flt(bal)
|
||||
|
||||
else:
|
||||
msgprint("Did not find %s for %s" % (acc, company))
|
||||
return 0
|
||||
|
||||
def get_cur_balance(self, acc, company):
|
||||
bal = sql("select IFNULL(t1.balance,0) from `tabAccount Balance` t1, `tabAccount` t2 where t1.account = %s and t1.period=%s and t1.account = t2.name and t2.company=%s", (acc, self.fiscal_year, company))
|
||||
return bal and flt(bal[0][0]) or 0
|
||||
|
||||
def get_top_5_cust(self, company):
|
||||
rec_grp = sql("select receivables_group from tabCompany where name=%s", company)
|
||||
if rec_grp:
|
||||
pa_lft_rgt = sql("select lft, rgt from tabAccount where name=%s and company=%s", (rec_grp[0][0], company))[0]
|
||||
return sql("select t1.account_name, SUM(t2.debit) from tabAccount t1, `tabGL Entry` t2 where t1.lft > %s and t1.rgt < %s and t2.account = t1.name and ifnull(t2.is_cancelled, 'No') = 'No' GROUP BY t1.name ORDER BY SUM(t2.debit) desc limit 5", (pa_lft_rgt[0], pa_lft_rgt[1]))
|
||||
else:
|
||||
return []
|
||||
|
||||
def get_top_5_exp(self, company):
|
||||
a = sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where account_name=%s and company=%s", ('Expenses', company), as_dict=1)[0]
|
||||
return sql("select t1.account_name, SUM(t2.debit) from tabAccount t1, `tabGL Entry` t2 where t1.lft>%s and t1.rgt<%s and t1.group_or_ledger = 'Ledger' and t2.account = t1.name and ifnull(t2.is_cancelled, 'No') = 'No' and t2.voucher_type != 'Period Closing Voucher' GROUP BY t1.name ORDER BY SUM(t2.debit) desc limit 5", (a['lft'],a['rgt']))
|
||||
|
||||
def bl(self, acc, company):
|
||||
dt = getdate(nowdate())
|
||||
|
||||
r = []
|
||||
# cur
|
||||
r.append(self.get_cur_balance(acc, company))
|
||||
# this month
|
||||
r.append(self.get_balance(acc, get_first_day(dt), get_last_day(dt), company, self.fiscal_year))
|
||||
# last month
|
||||
r.append(self.get_balance(acc, get_first_day(dt,0,-1), get_last_day(get_first_day(dt,0,-1)), company, self.fiscal_year))
|
||||
return r
|
||||
|
||||
def bl_bs(self, acc, company, sd):
|
||||
dt = getdate(nowdate())
|
||||
r = []
|
||||
# cur
|
||||
r.append(self.get_cur_balance(acc, company))
|
||||
# last month
|
||||
r.append(self.get_balance(acc, sd, get_last_day(get_first_day(dt,0,-1)), company, self.fiscal_year))
|
||||
# opening
|
||||
r.append(self.get_balance(acc, sd, sd, company, self.fiscal_year))
|
||||
return r
|
||||
|
||||
def get_dashboard_values(self, arg=''):
|
||||
d = get_defaults()
|
||||
self.fiscal_year = d['fiscal_year']
|
||||
if arg:
|
||||
company = arg
|
||||
else:
|
||||
company = d['company']
|
||||
|
||||
r = {}
|
||||
r['Income'] = self.bl('Income', company)
|
||||
r['Expenses'] = self.bl('Expenses', company)
|
||||
|
||||
r['Profit'] = []
|
||||
for i in range(3):
|
||||
r['Profit'].append(r['Income'][i] - r['Expenses'][i])
|
||||
|
||||
r['Current Assets'] = self.bl_bs('Current Assets', company, getdate(d['year_start_date']))
|
||||
r['Current Liabilities'] = self.bl_bs('Current Liabilities', company, getdate(d['year_start_date']))
|
||||
|
||||
r['Working Capital'] = []
|
||||
for i in range(3):
|
||||
r['Working Capital'].append(r['Current Assets'][i] - r['Current Liabilities'][i])
|
||||
|
||||
r['Bank Accounts'] = self.bl_bs('Bank Accounts', company, getdate(d['year_start_date']))
|
||||
|
||||
r['Top Customers'] = convert_to_lists(self.get_top_5_cust(company))
|
||||
r['Top Expenses'] = convert_to_lists(self.get_top_5_exp(company))
|
||||
|
||||
return r
|
||||
31
accounts/doctype/mis_control/mis_control.txt
Normal file
31
accounts/doctype/mis_control/mis_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, MIS Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:49',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:49',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 120
|
||||
},
|
||||
|
||||
# DocType, MIS Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'MIS Control'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/mode_of_payment/__init__.py
Normal file
1
accounts/doctype/mode_of_payment/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
26
accounts/doctype/mode_of_payment/mode_of_payment.js
Normal file
26
accounts/doctype/mode_of_payment/mode_of_payment.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
71
accounts/doctype/mode_of_payment/mode_of_payment.txt
Normal file
71
accounts/doctype/mode_of_payment/mode_of_payment.txt
Normal file
@@ -0,0 +1,71 @@
|
||||
# DocType, Mode of Payment
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:44',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:44',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'field:mode_of_payment',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'mode_of_payment',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Mode of Payment',
|
||||
'name': '__common__',
|
||||
'oldfieldname': u'mode_of_payment',
|
||||
'oldfieldtype': u'Data',
|
||||
'parent': u'Mode of Payment',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Mode of Payment',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'Accounts Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Mode of Payment
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Mode of Payment'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/multi_ledger_report/__init__.py
Executable file
1
accounts/doctype/multi_ledger_report/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
19
accounts/doctype/multi_ledger_report/multi_ledger_report.js
Executable file
19
accounts/doctype/multi_ledger_report/multi_ledger_report.js
Executable file
@@ -0,0 +1,19 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.export_report = function(doc, cdt, cdn) {
|
||||
$c_obj_csv(make_doclist(cdt, cdn), 'get_report_data', '');
|
||||
}
|
||||
150
accounts/doctype/multi_ledger_report/multi_ledger_report.py
Executable file
150
accounts/doctype/multi_ledger_report/multi_ledger_report.py
Executable file
@@ -0,0 +1,150 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
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 ''
|
||||
|
||||
|
||||
def validate_date(self):
|
||||
"""check for from date and to date within same year"""
|
||||
if not 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) and %s between year_start_date and date_sub(date_add(year_start_date,interval 1 year), interval 1 day)",(self.doc.from_date, self.doc.to_date)):
|
||||
msgprint("From Date and To Date must be within same year")
|
||||
raise Exception
|
||||
|
||||
if not self.doc.from_date or not self.doc.to_date:
|
||||
msgprint("From Date and To Date is mandatory")
|
||||
raise Exception
|
||||
|
||||
|
||||
def add_header(self):
|
||||
title = 'Ledger Balances Between ' + getdate(self.doc.from_date).strftime('%d-%m-%Y') + ' and ' + getdate(self.doc.to_date).strftime('%d-%m-%Y')
|
||||
return [[title], ['Account', 'Posting Date', 'Voucher Type', 'Voucher No', 'Debit', 'Credit', 'Remarks']]
|
||||
|
||||
|
||||
|
||||
def get_account_subtree(self, acc):
|
||||
return sql("""
|
||||
SELECT
|
||||
CONCAT(REPEAT(' ', COUNT(parent.name) - (sub_tree.depth + 1)), node.name) as account,
|
||||
node.lft AS lft, node.rgt AS rgt,
|
||||
node.debit_or_credit as dr_or_cr, node.group_or_ledger as group_or_ledger, node.is_pl_account as is_pl_account
|
||||
FROM tabAccount AS node,
|
||||
tabAccount AS parent,
|
||||
tabAccount AS sub_parent,
|
||||
(
|
||||
SELECT node.name, (COUNT(parent.name) - 1) AS depth
|
||||
FROM tabAccount AS node, tabAccount AS parent
|
||||
WHERE node.lft BETWEEN parent.lft AND parent.rgt
|
||||
AND node.name = %s
|
||||
GROUP BY node.name
|
||||
ORDER BY node.lft
|
||||
)AS sub_tree
|
||||
WHERE node.lft BETWEEN parent.lft AND parent.rgt
|
||||
AND node.lft BETWEEN sub_parent.lft AND sub_parent.rgt
|
||||
AND sub_parent.name = sub_tree.name
|
||||
GROUP BY node.name
|
||||
ORDER BY node.lft""", acc, as_dict = 1, as_utf8=1)
|
||||
|
||||
|
||||
|
||||
def get_acc_summary(self, glc, acc_det):
|
||||
from_date_year = self.get_year(add_days(self.doc.from_date, -1))
|
||||
to_date_year = self.get_year(self.doc.to_date)
|
||||
acc = acc_det['account'].strip()
|
||||
|
||||
if from_date_year == to_date_year:
|
||||
debit_on_fromdate, credit_on_fromdate, opening = glc.get_as_on_balance(acc, from_date_year, add_days(self.doc.from_date, -1), acc_det['dr_or_cr'], acc_det['lft'], acc_det['rgt']) # opening = closing of prev_date
|
||||
elif acc_det['is_pl_account'] == 'No': # if there is no previous year in system and not pl account
|
||||
opening = sql("select opening from `tabAccount Balance` where account = %s and period = %s", (acc, to_date_year))
|
||||
debit_on_fromdate, credit_on_fromdate, opening = 0, 0, flt(opening[0][0])
|
||||
else: # if pl account and there is no previous year in system
|
||||
debit_on_fromdate, credit_on_fromdate, opening = 0,0,0
|
||||
|
||||
# closing balance
|
||||
#--------------------------------
|
||||
debit_on_todate, credit_on_todate, closing = glc.get_as_on_balance(acc, to_date_year, self.doc.to_date, acc_det['dr_or_cr'], acc_det['lft'], acc_det['rgt'])
|
||||
|
||||
# transaction betn the period
|
||||
#----------------------------------------
|
||||
debit = flt(debit_on_todate) - flt(debit_on_fromdate)
|
||||
credit = flt(credit_on_todate) - flt(credit_on_fromdate)
|
||||
|
||||
# Debit / Credit
|
||||
if acc_det['dr_or_cr'] == 'Credit':
|
||||
opening, closing = -1*opening, -1*closing
|
||||
|
||||
return flt(opening>0 and opening or 0), flt(opening<0 and -opening or 0), \
|
||||
debit, credit, flt(closing>0.01 and closing or 0), flt(closing<-0.01 and -closing or 0)
|
||||
|
||||
|
||||
def show_gl_entries(self, acc):
|
||||
"""Get gl entries for the period and account"""
|
||||
gle = sql("select posting_date, voucher_type, voucher_no, debit, credit, remarks from `tabGL Entry` WHERE account = %s and posting_date >= %s AND posting_date <= %s and ifnull(is_opening, 'No') = 'No' and ifnull(is_cancelled, 'No') = 'No'", (acc, self.doc.from_date, self.doc.to_date), as_dict=1, as_utf8=1)
|
||||
entries, dr, cr = [], 0, 0
|
||||
for d in gle:
|
||||
entries.append(['', d['posting_date'], d['voucher_type'], d['voucher_no'], d['debit'], d['credit'], d['remarks']])
|
||||
return entries
|
||||
|
||||
|
||||
|
||||
|
||||
# Get Report Data
|
||||
def get_report_data(self):
|
||||
self.validate_date()
|
||||
|
||||
res = []
|
||||
res += self.add_header()
|
||||
|
||||
glc = get_obj('GL Control')
|
||||
|
||||
for d in getlist(self.doclist, 'ledger_details'):
|
||||
# Fetch acc details
|
||||
sub_tree = self.get_account_subtree(d.account)
|
||||
|
||||
for acc_det in sub_tree:
|
||||
acc_summary = self.get_acc_summary(glc, acc_det)
|
||||
if acc_summary[0] or acc_summary[1] or acc_summary[2] or acc_summary[3] or acc_summary[4] or acc_summary[5]:
|
||||
res.append([acc_det['account']])
|
||||
# Show gl entries if account is ledger
|
||||
if acc_det['group_or_ledger'] == 'Ledger' and (acc_summary[2] or acc_summary[3]):
|
||||
gle = self.show_gl_entries(acc_det['account'].strip())
|
||||
res += gle
|
||||
|
||||
# Totals
|
||||
res.append(['', '', '', 'Total Debit/Credit', acc_summary[2], acc_summary[3]])
|
||||
res.append(['', '', '', 'Opening Balance', acc_summary[0], acc_summary[1]])
|
||||
res.append(['', '', '', 'Closing Balance', acc_summary[4], acc_summary[5]])
|
||||
|
||||
return res
|
||||
124
accounts/doctype/multi_ledger_report/multi_ledger_report.txt
Executable file
124
accounts/doctype/multi_ledger_report/multi_ledger_report.txt
Executable file
@@ -0,0 +1,124 @@
|
||||
# DocType, Multi Ledger Report
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:44',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:44',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1306229235',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Other',
|
||||
'hide_heading': 0,
|
||||
'issingle': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 9
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Multi Ledger Report',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Multi Ledger Report',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Multi Ledger Report
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Multi Ledger Report'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Accounts User'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'select_date_range',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Select Date Range'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'from_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'From Date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'to_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'To Date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'select_ledgers',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Select ledgers'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'ledger_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Multi Ledger Report Details',
|
||||
'options': u'Multi Ledger Report Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'export_report',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Export Report',
|
||||
'trigger': u'Client'
|
||||
}
|
||||
]
|
||||
1
accounts/doctype/multi_ledger_report_detail/__init__.py
Executable file
1
accounts/doctype/multi_ledger_report_detail/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
51
accounts/doctype/multi_ledger_report_detail/multi_ledger_report_detail.txt
Executable file
51
accounts/doctype/multi_ledger_report_detail/multi_ledger_report_detail.txt
Executable file
@@ -0,0 +1,51 @@
|
||||
# DocType, Multi Ledger Report Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:35:44',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:35:44',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Accounts',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Account',
|
||||
'name': '__common__',
|
||||
'options': u'Account',
|
||||
'parent': u'Multi Ledger Report Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'width': u'300px'
|
||||
},
|
||||
|
||||
# DocType, Multi Ledger Report Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Multi Ledger Report Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user