mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
Merge branch 'develop' into payment_entry_validations_and_trigger_develop
This commit is contained in:
@@ -154,7 +154,8 @@
|
|||||||
"before": true,
|
"before": true,
|
||||||
"beforeEach": true,
|
"beforeEach": true,
|
||||||
"onScan": true,
|
"onScan": true,
|
||||||
|
"html2canvas": true,
|
||||||
"extend_cscript": true,
|
"extend_cscript": true,
|
||||||
"localforage": true,
|
"localforage": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,3 +13,6 @@
|
|||||||
|
|
||||||
# This commit just changes spaces to tabs for indentation in some files
|
# This commit just changes spaces to tabs for indentation in some files
|
||||||
5f473611bd6ed57703716244a054d3fb5ba9cd23
|
5f473611bd6ed57703716244a054d3fb5ba9cd23
|
||||||
|
|
||||||
|
# Whitespace fix throughout codebase
|
||||||
|
4551d7d6029b6f587f6c99d4f8df5519241c6a86
|
||||||
|
|||||||
12
.github/helper/documentation.py
vendored
12
.github/helper/documentation.py
vendored
@@ -32,11 +32,15 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
if response.ok:
|
if response.ok:
|
||||||
payload = response.json()
|
payload = response.json()
|
||||||
title = payload.get("title", "").lower()
|
title = (payload.get("title") or "").lower().strip()
|
||||||
head_sha = payload.get("head", {}).get("sha")
|
head_sha = (payload.get("head") or {}).get("sha")
|
||||||
body = payload.get("body", "").lower()
|
body = (payload.get("body") or "").lower()
|
||||||
|
|
||||||
if title.startswith("feat") and head_sha and "no-docs" not in body:
|
if (title.startswith("feat")
|
||||||
|
and head_sha
|
||||||
|
and "no-docs" not in body
|
||||||
|
and "backport" not in body
|
||||||
|
):
|
||||||
if docs_link_exists(body):
|
if docs_link_exists(body):
|
||||||
print("Documentation Link Found. You're Awesome! 🎉")
|
print("Documentation Link Found. You're Awesome! 🎉")
|
||||||
|
|
||||||
|
|||||||
8
.github/workflows/patch.yml
vendored
8
.github/workflows/patch.yml
vendored
@@ -1,6 +1,12 @@
|
|||||||
name: Patch
|
name: Patch
|
||||||
|
|
||||||
on: [pull_request, workflow_dispatch]
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.js'
|
||||||
|
- '**.md'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|||||||
6
.github/workflows/server-tests.yml
vendored
6
.github/workflows/server-tests.yml
vendored
@@ -2,9 +2,15 @@ name: Server
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.js'
|
||||||
|
- '**.md'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [ develop ]
|
branches: [ develop ]
|
||||||
|
paths-ignore:
|
||||||
|
- '**.js'
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|||||||
4
.github/workflows/ui-tests.yml
vendored
4
.github/workflows/ui-tests.yml
vendored
@@ -2,6 +2,8 @@ name: UI
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -102,7 +104,7 @@ jobs:
|
|||||||
- name: UI Tests
|
- name: UI Tests
|
||||||
run: cd ~/frappe-bench/ && bench --site test_site run-ui-tests erpnext --headless
|
run: cd ~/frappe-bench/ && bench --site test_site run-ui-tests erpnext --headless
|
||||||
env:
|
env:
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: 60a8e3bf-08f5-45b1-9269-2b207d7d30cd
|
||||||
|
|
||||||
- name: Show bench console if tests failed
|
- name: Show bench console if tests failed
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
|
|||||||
113
cypress/integration/test_organizational_chart_desktop.js
Normal file
113
cypress/integration/test_organizational_chart_desktop.js
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
context('Organizational Chart', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.login();
|
||||||
|
cy.visit('/app/website');
|
||||||
|
cy.awesomebar('Organizational Chart');
|
||||||
|
cy.wait(500);
|
||||||
|
cy.url().should('include', '/organizational-chart');
|
||||||
|
|
||||||
|
cy.window().its('frappe.csrf_token').then(csrf_token => {
|
||||||
|
return cy.request({
|
||||||
|
url: `/api/method/erpnext.tests.ui_test_helpers.create_employee_records`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-Frappe-CSRF-Token': csrf_token
|
||||||
|
},
|
||||||
|
timeout: 60000
|
||||||
|
}).then(res => {
|
||||||
|
expect(res.status).eq(200);
|
||||||
|
cy.get('.frappe-control[data-fieldname=company] input').focus().as('input');
|
||||||
|
cy.get('@input')
|
||||||
|
.clear({ force: true })
|
||||||
|
.type('Test Org Chart{enter}', { force: true })
|
||||||
|
.blur({ force: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders root nodes and loads children for the first expandable node', () => {
|
||||||
|
// check rendered root nodes and the node name, title, connections
|
||||||
|
cy.get('.hierarchy').find('.root-level ul.node-children').children()
|
||||||
|
.should('have.length', 2)
|
||||||
|
.first()
|
||||||
|
.as('first-child');
|
||||||
|
|
||||||
|
cy.get('@first-child').get('.node-name').contains('Test Employee 1');
|
||||||
|
cy.get('@first-child').get('.node-info').find('.node-title').contains('CEO');
|
||||||
|
cy.get('@first-child').get('.node-info').find('.node-connections').contains('· 2 Connections');
|
||||||
|
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
// children of 1st root visible
|
||||||
|
cy.get(`div[data-parent="${employee_records.message[0]}"]`).as('child-node');
|
||||||
|
cy.get('@child-node')
|
||||||
|
.should('have.length', 1)
|
||||||
|
.should('be.visible');
|
||||||
|
cy.get('@child-node').get('.node-name').contains('Test Employee 3');
|
||||||
|
|
||||||
|
// connectors between first root node and immediate child
|
||||||
|
cy.get(`path[data-parent="${employee_records.message[0]}"]`)
|
||||||
|
.should('be.visible')
|
||||||
|
.invoke('attr', 'data-child')
|
||||||
|
.should('equal', employee_records.message[2]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides active nodes children and connectors on expanding sibling node', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
// click sibling
|
||||||
|
cy.get(`#${employee_records.message[1]}`)
|
||||||
|
.click()
|
||||||
|
.should('have.class', 'active');
|
||||||
|
|
||||||
|
// child nodes and connectors hidden
|
||||||
|
cy.get(`[data-parent="${employee_records.message[0]}"]`).should('not.be.visible');
|
||||||
|
cy.get(`path[data-parent="${employee_records.message[0]}"]`).should('not.be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('collapses previous level nodes and refreshes connectors on expanding child node', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
// click child node
|
||||||
|
cy.get(`#${employee_records.message[3]}`)
|
||||||
|
.click()
|
||||||
|
.should('have.class', 'active');
|
||||||
|
|
||||||
|
// previous level nodes: parent should be on active-path; other nodes should be collapsed
|
||||||
|
cy.get(`#${employee_records.message[0]}`).should('have.class', 'collapsed');
|
||||||
|
cy.get(`#${employee_records.message[1]}`).should('have.class', 'active-path');
|
||||||
|
|
||||||
|
// previous level connectors refreshed
|
||||||
|
cy.get(`path[data-parent="${employee_records.message[1]}"]`)
|
||||||
|
.should('have.class', 'collapsed-connector');
|
||||||
|
|
||||||
|
// child node's children and connectors rendered
|
||||||
|
cy.get(`[data-parent="${employee_records.message[3]}"]`).should('be.visible');
|
||||||
|
cy.get(`path[data-parent="${employee_records.message[3]}"]`).should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('expands previous level nodes', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
cy.get(`#${employee_records.message[0]}`)
|
||||||
|
.click()
|
||||||
|
.should('have.class', 'active');
|
||||||
|
|
||||||
|
cy.get(`[data-parent="${employee_records.message[0]}"]`)
|
||||||
|
.should('be.visible');
|
||||||
|
|
||||||
|
cy.get('ul.hierarchy').children().should('have.length', 2);
|
||||||
|
cy.get(`#connectors`).children().should('have.length', 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('edit node navigates to employee master', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
cy.get(`#${employee_records.message[0]}`).find('.btn-edit-node')
|
||||||
|
.click();
|
||||||
|
|
||||||
|
cy.url().should('include', `/employee/${employee_records.message[0]}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
190
cypress/integration/test_organizational_chart_mobile.js
Normal file
190
cypress/integration/test_organizational_chart_mobile.js
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
context('Organizational Chart Mobile', () => {
|
||||||
|
before(() => {
|
||||||
|
cy.login();
|
||||||
|
cy.viewport(375, 667);
|
||||||
|
cy.visit('/app/website');
|
||||||
|
cy.awesomebar('Organizational Chart');
|
||||||
|
|
||||||
|
cy.window().its('frappe.csrf_token').then(csrf_token => {
|
||||||
|
return cy.request({
|
||||||
|
url: `/api/method/erpnext.tests.ui_test_helpers.create_employee_records`,
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-Frappe-CSRF-Token': csrf_token
|
||||||
|
},
|
||||||
|
timeout: 60000
|
||||||
|
}).then(res => {
|
||||||
|
expect(res.status).eq(200);
|
||||||
|
cy.get('.frappe-control[data-fieldname=company] input').focus().as('input');
|
||||||
|
cy.get('@input')
|
||||||
|
.clear({ force: true })
|
||||||
|
.type('Test Org Chart{enter}', { force: true })
|
||||||
|
.blur({ force: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders root nodes', () => {
|
||||||
|
// check rendered root nodes and the node name, title, connections
|
||||||
|
cy.get('.hierarchy-mobile').find('.root-level').children()
|
||||||
|
.should('have.length', 2)
|
||||||
|
.first()
|
||||||
|
.as('first-child');
|
||||||
|
|
||||||
|
cy.get('@first-child').get('.node-name').contains('Test Employee 1');
|
||||||
|
cy.get('@first-child').get('.node-info').find('.node-title').contains('CEO');
|
||||||
|
cy.get('@first-child').get('.node-info').find('.node-connections').contains('· 2');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('expands root node', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
cy.get(`#${employee_records.message[1]}`)
|
||||||
|
.click()
|
||||||
|
.should('have.class', 'active');
|
||||||
|
|
||||||
|
// other root node removed
|
||||||
|
cy.get(`#${employee_records.message[0]}`).should('not.exist');
|
||||||
|
|
||||||
|
// children of active root node
|
||||||
|
cy.get('.hierarchy-mobile').find('.level').first().find('ul.node-children').children()
|
||||||
|
.should('have.length', 2);
|
||||||
|
|
||||||
|
cy.get(`div[data-parent="${employee_records.message[1]}"]`).first().as('child-node');
|
||||||
|
cy.get('@child-node').should('be.visible');
|
||||||
|
|
||||||
|
cy.get('@child-node')
|
||||||
|
.get('.node-name')
|
||||||
|
.contains('Test Employee 4');
|
||||||
|
|
||||||
|
// connectors between root node and immediate children
|
||||||
|
cy.get(`path[data-parent="${employee_records.message[1]}"]`).as('connectors');
|
||||||
|
cy.get('@connectors')
|
||||||
|
.should('have.length', 2)
|
||||||
|
.should('be.visible');
|
||||||
|
|
||||||
|
cy.get('@connectors')
|
||||||
|
.first()
|
||||||
|
.invoke('attr', 'data-child')
|
||||||
|
.should('eq', employee_records.message[3]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('expands child node', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
cy.get(`#${employee_records.message[3]}`)
|
||||||
|
.click()
|
||||||
|
.should('have.class', 'active')
|
||||||
|
.as('expanded_node');
|
||||||
|
|
||||||
|
// 2 levels on screen; 1 on active path; 1 collapsed
|
||||||
|
cy.get('.hierarchy-mobile').children().should('have.length', 2);
|
||||||
|
cy.get(`#${employee_records.message[1]}`).should('have.class', 'active-path');
|
||||||
|
|
||||||
|
// children of expanded node visible
|
||||||
|
cy.get('@expanded_node')
|
||||||
|
.next()
|
||||||
|
.should('have.class', 'node-children')
|
||||||
|
.as('node-children');
|
||||||
|
|
||||||
|
cy.get('@node-children').children().should('have.length', 1);
|
||||||
|
cy.get('@node-children')
|
||||||
|
.first()
|
||||||
|
.get('.node-card')
|
||||||
|
.should('have.class', 'active-child')
|
||||||
|
.contains('Test Employee 7');
|
||||||
|
|
||||||
|
// orphan connectors removed
|
||||||
|
cy.get(`#connectors`).children().should('have.length', 2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders sibling group', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
// sibling group visible for parent
|
||||||
|
cy.get(`#${employee_records.message[1]}`)
|
||||||
|
.next()
|
||||||
|
.as('sibling_group');
|
||||||
|
|
||||||
|
cy.get('@sibling_group')
|
||||||
|
.should('have.attr', 'data-parent', 'undefined')
|
||||||
|
.should('have.class', 'node-group')
|
||||||
|
.and('have.class', 'collapsed');
|
||||||
|
|
||||||
|
cy.get('@sibling_group').get('.avatar-group').children().as('siblings');
|
||||||
|
cy.get('@siblings').should('have.length', 1);
|
||||||
|
cy.get('@siblings')
|
||||||
|
.first()
|
||||||
|
.should('have.attr', 'title', 'Test Employee 1');
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('expands previous level nodes', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
cy.get(`#${employee_records.message[6]}`)
|
||||||
|
.click()
|
||||||
|
.should('have.class', 'active');
|
||||||
|
|
||||||
|
// clicking on previous level node should remove all the nodes ahead
|
||||||
|
// and expand that node
|
||||||
|
cy.get(`#${employee_records.message[3]}`).click();
|
||||||
|
cy.get(`#${employee_records.message[3]}`)
|
||||||
|
.should('have.class', 'active')
|
||||||
|
.should('not.have.class', 'active-path');
|
||||||
|
|
||||||
|
cy.get(`#${employee_records.message[6]}`).should('have.class', 'active-child');
|
||||||
|
cy.get('.hierarchy-mobile').children().should('have.length', 2);
|
||||||
|
cy.get(`#connectors`).children().should('have.length', 2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('expands sibling group', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
// sibling group visible for parent
|
||||||
|
cy.get(`#${employee_records.message[6]}`).click();
|
||||||
|
|
||||||
|
cy.get(`#${employee_records.message[3]}`)
|
||||||
|
.next()
|
||||||
|
.click();
|
||||||
|
|
||||||
|
// siblings of parent should be visible
|
||||||
|
cy.get('.hierarchy-mobile').prev().as('sibling_group');
|
||||||
|
cy.get('@sibling_group')
|
||||||
|
.should('exist')
|
||||||
|
.should('have.class', 'sibling-group')
|
||||||
|
.should('not.have.class', 'collapsed');
|
||||||
|
|
||||||
|
cy.get(`#${employee_records.message[1]}`)
|
||||||
|
.should('be.visible')
|
||||||
|
.should('have.class', 'active');
|
||||||
|
|
||||||
|
cy.get(`[data-parent="${employee_records.message[1]}"]`)
|
||||||
|
.should('be.visible')
|
||||||
|
.should('have.length', 2)
|
||||||
|
.should('have.class', 'active-child');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('goes to the respective level after clicking on non-collapsed sibling group', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(() => {
|
||||||
|
// click on non-collapsed sibling group
|
||||||
|
cy.get('.hierarchy-mobile')
|
||||||
|
.prev()
|
||||||
|
.click();
|
||||||
|
|
||||||
|
// should take you to that level
|
||||||
|
cy.get('.hierarchy-mobile').find('li.level .node-card').should('have.length', 2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('edit node navigates to employee master', () => {
|
||||||
|
cy.call('erpnext.tests.ui_test_helpers.get_employee_records').then(employee_records => {
|
||||||
|
cy.get(`#${employee_records.message[0]}`).find('.btn-edit-node')
|
||||||
|
.click();
|
||||||
|
|
||||||
|
cy.url().should('include', `/employee/${employee_records.message[0]}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -5,7 +5,7 @@ import frappe
|
|||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
__version__ = '13.8.0'
|
__version__ = '13.9.0'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
|||||||
@@ -450,5 +450,3 @@ def get_deferred_booking_accounts(doctype, voucher_detail_no, dr_or_cr):
|
|||||||
return debit_account
|
return debit_account
|
||||||
else:
|
else:
|
||||||
return credit_account
|
return credit_account
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -113,5 +113,3 @@ def disable_dimension():
|
|||||||
dimension2 = frappe.get_doc("Accounting Dimension", "Location")
|
dimension2 = frappe.get_doc("Accounting Dimension", "Location")
|
||||||
dimension2.disabled = 1
|
dimension2.disabled = 1
|
||||||
dimension2.save()
|
dimension2.save()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"book_asset_depreciation_entry_automatically",
|
"book_asset_depreciation_entry_automatically",
|
||||||
"unlink_advance_payment_on_cancelation_of_order",
|
"unlink_advance_payment_on_cancelation_of_order",
|
||||||
"post_change_gl_entries",
|
"post_change_gl_entries",
|
||||||
|
"enable_discount_accounting",
|
||||||
"tax_settings_section",
|
"tax_settings_section",
|
||||||
"determine_address_tax_category_from",
|
"determine_address_tax_category_from",
|
||||||
"column_break_19",
|
"column_break_19",
|
||||||
@@ -260,6 +261,13 @@
|
|||||||
"fieldname": "post_change_gl_entries",
|
"fieldname": "post_change_gl_entries",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Create Ledger Entries for Change Amount"
|
"label": "Create Ledger Entries for Change Amount"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"description": "If enabled, additional ledger entries will be made for discounts in a separate Discount Account",
|
||||||
|
"fieldname": "enable_discount_accounting",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Enable Discount Accounting"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
@@ -267,7 +275,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-08-09 13:08:01.335416",
|
"modified": "2021-08-09 13:08:04.335416",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Accounts Settings",
|
"name": "Accounts Settings",
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class AccountsSettings(Document):
|
|||||||
|
|
||||||
self.validate_stale_days()
|
self.validate_stale_days()
|
||||||
self.enable_payment_schedule_in_print()
|
self.enable_payment_schedule_in_print()
|
||||||
|
self.toggle_discount_accounting_fields()
|
||||||
|
|
||||||
def validate_stale_days(self):
|
def validate_stale_days(self):
|
||||||
if not self.allow_stale and cint(self.stale_days) <= 0:
|
if not self.allow_stale and cint(self.stale_days) <= 0:
|
||||||
@@ -33,3 +34,22 @@ class AccountsSettings(Document):
|
|||||||
for doctype in ("Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"):
|
for doctype in ("Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"):
|
||||||
make_property_setter(doctype, "due_date", "print_hide", show_in_print, "Check", validate_fields_for_doctype=False)
|
make_property_setter(doctype, "due_date", "print_hide", show_in_print, "Check", validate_fields_for_doctype=False)
|
||||||
make_property_setter(doctype, "payment_schedule", "print_hide", 0 if show_in_print else 1, "Check", validate_fields_for_doctype=False)
|
make_property_setter(doctype, "payment_schedule", "print_hide", 0 if show_in_print else 1, "Check", validate_fields_for_doctype=False)
|
||||||
|
|
||||||
|
def toggle_discount_accounting_fields(self):
|
||||||
|
enable_discount_accounting = cint(self.enable_discount_accounting)
|
||||||
|
|
||||||
|
for doctype in ["Sales Invoice Item", "Purchase Invoice Item"]:
|
||||||
|
make_property_setter(doctype, "discount_account", "hidden", not(enable_discount_accounting), "Check", validate_fields_for_doctype=False)
|
||||||
|
if enable_discount_accounting:
|
||||||
|
make_property_setter(doctype, "discount_account", "mandatory_depends_on", "eval: doc.discount_amount", "Code", validate_fields_for_doctype=False)
|
||||||
|
else:
|
||||||
|
make_property_setter(doctype, "discount_account", "mandatory_depends_on", "", "Code", validate_fields_for_doctype=False)
|
||||||
|
|
||||||
|
for doctype in ["Sales Invoice", "Purchase Invoice"]:
|
||||||
|
make_property_setter(doctype, "additional_discount_account", "hidden", not(enable_discount_accounting), "Check", validate_fields_for_doctype=False)
|
||||||
|
if enable_discount_accounting:
|
||||||
|
make_property_setter(doctype, "additional_discount_account", "mandatory_depends_on", "eval: doc.discount_amount", "Code", validate_fields_for_doctype=False)
|
||||||
|
else:
|
||||||
|
make_property_setter(doctype, "additional_discount_account", "mandatory_depends_on", "", "Code", validate_fields_for_doctype=False)
|
||||||
|
|
||||||
|
make_property_setter("Item", "default_discount_account", "hidden", not(enable_discount_accounting), "Check", validate_fields_for_doctype=False)
|
||||||
|
|||||||
@@ -105,4 +105,3 @@ def unclear_reference_payment(doctype, docname):
|
|||||||
frappe.db.set_value(doc.payment_document, doc.payment_entry, "clearance_date", None)
|
frappe.db.set_value(doc.payment_document, doc.payment_entry, "clearance_date", None)
|
||||||
|
|
||||||
return doc.payment_entry
|
return doc.payment_entry
|
||||||
|
|
||||||
|
|||||||
31
erpnext/accounts/doctype/campaign_item/campaign_item.json
Normal file
31
erpnext/accounts/doctype/campaign_item/campaign_item.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-06 16:18:25.410476",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"campaign"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "campaign",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Campaign",
|
||||||
|
"options": "Campaign"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-07 10:43:49.717633",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Campaign Item",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
8
erpnext/accounts/doctype/campaign_item/campaign_item.py
Normal file
8
erpnext/accounts/doctype/campaign_item/campaign_item.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class CampaignItem(Document):
|
||||||
|
pass
|
||||||
@@ -18,5 +18,3 @@ class CashFlowMapping(Document):
|
|||||||
frappe._('You can only select a maximum of one option from the list of check boxes.'),
|
frappe._('You can only select a maximum of one option from the list of check boxes.'),
|
||||||
title='Error'
|
title='Error'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,3 @@ def create_cost_center(**args):
|
|||||||
cc.is_group = args.is_group or 0
|
cc.is_group = args.is_group or 0
|
||||||
cc.parent_cost_center = args.parent_cost_center or "_Test Company - _TC"
|
cc.parent_cost_center = args.parent_cost_center or "_Test Company - _TC"
|
||||||
cc.insert()
|
cc.insert()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ def test_create_test_data():
|
|||||||
})
|
})
|
||||||
item_price.insert()
|
item_price.insert()
|
||||||
# create test item pricing rule
|
# create test item pricing rule
|
||||||
if not frappe.db.exists("Pricing Rule","_Test Pricing Rule for _Test Item"):
|
if not frappe.db.exists("Pricing Rule", {"title": "_Test Pricing Rule for _Test Item"}):
|
||||||
item_pricing_rule = frappe.get_doc({
|
item_pricing_rule = frappe.get_doc({
|
||||||
"doctype": "Pricing Rule",
|
"doctype": "Pricing Rule",
|
||||||
"title": "_Test Pricing Rule for _Test Item",
|
"title": "_Test Pricing Rule for _Test Item",
|
||||||
@@ -86,14 +86,15 @@ def test_create_test_data():
|
|||||||
sales_partner.insert()
|
sales_partner.insert()
|
||||||
# create test item coupon code
|
# create test item coupon code
|
||||||
if not frappe.db.exists("Coupon Code", "SAVE30"):
|
if not frappe.db.exists("Coupon Code", "SAVE30"):
|
||||||
|
pricing_rule = frappe.db.get_value("Pricing Rule", {"title": "_Test Pricing Rule for _Test Item"}, ['name'])
|
||||||
coupon_code = frappe.get_doc({
|
coupon_code = frappe.get_doc({
|
||||||
"doctype": "Coupon Code",
|
"doctype": "Coupon Code",
|
||||||
"coupon_name":"SAVE30",
|
"coupon_name":"SAVE30",
|
||||||
"coupon_code":"SAVE30",
|
"coupon_code":"SAVE30",
|
||||||
"pricing_rule": "_Test Pricing Rule for _Test Item",
|
"pricing_rule": pricing_rule,
|
||||||
"valid_from": "2014-01-01",
|
"valid_from": "2014-01-01",
|
||||||
"maximum_use":1,
|
"maximum_use":1,
|
||||||
"used":0
|
"used":0
|
||||||
})
|
})
|
||||||
coupon_code.insert()
|
coupon_code.insert()
|
||||||
|
|
||||||
@@ -123,6 +124,3 @@ class TestCouponCode(unittest.TestCase):
|
|||||||
|
|
||||||
so.submit()
|
so.submit()
|
||||||
self.assertEqual(frappe.db.get_value("Coupon Code", "SAVE30", "used"), 1)
|
self.assertEqual(frappe.db.get_value("Coupon Code", "SAVE30", "used"), 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-06 16:12:42.558878",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"customer_group"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "customer_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Customer Group",
|
||||||
|
"options": "Customer Group"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-07 10:39:21.563506",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Customer Group Item",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class CustomerGroupItem(Document):
|
||||||
|
pass
|
||||||
31
erpnext/accounts/doctype/customer_item/customer_item.json
Normal file
31
erpnext/accounts/doctype/customer_item/customer_item.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-05 14:04:54.266353",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"customer"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "customer",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Customer ",
|
||||||
|
"options": "Customer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-06 10:02:32.967841",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Customer Item",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
8
erpnext/accounts/doctype/customer_item/customer_item.py
Normal file
8
erpnext/accounts/doctype/customer_item/customer_item.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class CustomerItem(Document):
|
||||||
|
pass
|
||||||
@@ -39,4 +39,3 @@ class ModeofPayment(Document):
|
|||||||
message = "POS Profile " + frappe.bold(", ".join(pos_profiles)) + " contains \
|
message = "POS Profile " + frappe.bold(", ".join(pos_profiles)) + " contains \
|
||||||
Mode of Payment " + frappe.bold(str(self.name)) + ". Please remove them to disable this mode."
|
Mode of Payment " + frappe.bold(str(self.name)) + ". Please remove them to disable this mode."
|
||||||
frappe.throw(_(message), title="Not Allowed")
|
frappe.throw(_(message), title="Not Allowed")
|
||||||
|
|
||||||
|
|||||||
@@ -241,4 +241,3 @@ def get_temporary_opening_account(company=None):
|
|||||||
frappe.throw(_("Please add a Temporary Opening account in Chart of Accounts"))
|
frappe.throw(_("Please add a Temporary Opening account in Chart of Accounts"))
|
||||||
|
|
||||||
return accounts[0].name
|
return accounts[0].name
|
||||||
|
|
||||||
|
|||||||
@@ -548,7 +548,7 @@ class PaymentEntry(AccountsController):
|
|||||||
if self.payment_type == "Receive" \
|
if self.payment_type == "Receive" \
|
||||||
and self.base_total_allocated_amount < self.base_received_amount + total_deductions \
|
and self.base_total_allocated_amount < self.base_received_amount + total_deductions \
|
||||||
and self.total_allocated_amount < self.paid_amount + (total_deductions / self.source_exchange_rate):
|
and self.total_allocated_amount < self.paid_amount + (total_deductions / self.source_exchange_rate):
|
||||||
self.unallocated_amount = (self.received_amount + total_deductions -
|
self.unallocated_amount = (self.base_received_amount + total_deductions -
|
||||||
self.base_total_allocated_amount) / self.source_exchange_rate
|
self.base_total_allocated_amount) / self.source_exchange_rate
|
||||||
self.unallocated_amount -= included_taxes
|
self.unallocated_amount -= included_taxes
|
||||||
elif self.payment_type == "Pay" \
|
elif self.payment_type == "Pay" \
|
||||||
|
|||||||
@@ -295,6 +295,34 @@ class TestPaymentEntry(unittest.TestCase):
|
|||||||
outstanding_amount = flt(frappe.db.get_value("Sales Invoice", si.name, "outstanding_amount"))
|
outstanding_amount = flt(frappe.db.get_value("Sales Invoice", si.name, "outstanding_amount"))
|
||||||
self.assertEqual(outstanding_amount, 80)
|
self.assertEqual(outstanding_amount, 80)
|
||||||
|
|
||||||
|
def test_payment_entry_against_si_usd_to_usd_with_deduction_in_base_currency (self):
|
||||||
|
si = create_sales_invoice(customer="_Test Customer USD", debit_to="_Test Receivable USD - _TC",
|
||||||
|
currency="USD", conversion_rate=50, do_not_save=1)
|
||||||
|
|
||||||
|
si.plc_conversion_rate = 50
|
||||||
|
si.save()
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
pe = get_payment_entry("Sales Invoice", si.name, party_amount=20,
|
||||||
|
bank_account="_Test Bank USD - _TC", bank_amount=900)
|
||||||
|
|
||||||
|
pe.source_exchange_rate = 45.263
|
||||||
|
pe.target_exchange_rate = 45.263
|
||||||
|
pe.reference_no = "1"
|
||||||
|
pe.reference_date = "2016-01-01"
|
||||||
|
|
||||||
|
|
||||||
|
pe.append("deductions", {
|
||||||
|
"account": "_Test Exchange Gain/Loss - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"amount": 94.80
|
||||||
|
})
|
||||||
|
|
||||||
|
pe.save()
|
||||||
|
|
||||||
|
self.assertEqual(flt(pe.difference_amount, 2), 0.0)
|
||||||
|
self.assertEqual(flt(pe.unallocated_amount, 2), 0.0)
|
||||||
|
|
||||||
def test_payment_entry_retrieves_last_exchange_rate(self):
|
def test_payment_entry_retrieves_last_exchange_rate(self):
|
||||||
from erpnext.setup.doctype.currency_exchange.test_currency_exchange import test_records, save_new_records
|
from erpnext.setup.doctype.currency_exchange.test_currency_exchange import test_records, save_new_records
|
||||||
|
|
||||||
|
|||||||
@@ -595,7 +595,8 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "scan_barcode",
|
"fieldname": "scan_barcode",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Scan Barcode"
|
"label": "Scan Barcode",
|
||||||
|
"options": "Barcode"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 1,
|
"allow_bulk_edit": 1,
|
||||||
@@ -1553,7 +1554,7 @@
|
|||||||
"icon": "fa fa-file-text",
|
"icon": "fa fa-file-text",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-07-29 13:37:20.636171",
|
"modified": "2021-08-17 20:13:44.255437",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "POS Invoice",
|
"name": "POS Invoice",
|
||||||
|
|||||||
@@ -147,4 +147,3 @@ class TestPOSInvoiceMergeLog(unittest.TestCase):
|
|||||||
frappe.set_user("Administrator")
|
frappe.set_user("Administrator")
|
||||||
frappe.db.sql("delete from `tabPOS Profile`")
|
frappe.db.sql("delete from `tabPOS Profile`")
|
||||||
frappe.db.sql("delete from `tabPOS Invoice`")
|
frappe.db.sql("delete from `tabPOS Invoice`")
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
"actions": [],
|
"actions": [],
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
"autoname": "field:title",
|
"autoname": "naming_series:",
|
||||||
"creation": "2014-02-21 15:02:51",
|
"creation": "2014-02-21 15:02:51",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"applicability_section",
|
"applicability_section",
|
||||||
|
"naming_series",
|
||||||
"title",
|
"title",
|
||||||
"disable",
|
"disable",
|
||||||
"apply_on",
|
"apply_on",
|
||||||
@@ -95,8 +96,7 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Title",
|
"label": "Title",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"reqd": 1,
|
"reqd": 1
|
||||||
"unique": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
@@ -571,6 +571,13 @@
|
|||||||
"fieldname": "is_recursive",
|
"fieldname": "is_recursive",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Is Recursive"
|
"label": "Is Recursive"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "PRLE-.####",
|
||||||
|
"fieldname": "naming_series",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Naming Series",
|
||||||
|
"options": "PRLE-.####"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-gift",
|
"icon": "fa fa-gift",
|
||||||
@@ -634,5 +641,6 @@
|
|||||||
],
|
],
|
||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC",
|
||||||
|
"title_field": "title"
|
||||||
}
|
}
|
||||||
@@ -26,4 +26,3 @@ QUnit.test("test pricing rule", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -25,22 +25,31 @@ product_discount_fields = ['free_item', 'free_qty', 'free_item_uom',
|
|||||||
|
|
||||||
class PromotionalScheme(Document):
|
class PromotionalScheme(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
if not self.selling and not self.buying:
|
||||||
|
frappe.throw(_("Either 'Selling' or 'Buying' must be selected"), title=_("Mandatory"))
|
||||||
if not (self.price_discount_slabs
|
if not (self.price_discount_slabs
|
||||||
or self.product_discount_slabs):
|
or self.product_discount_slabs):
|
||||||
frappe.throw(_("Price or product discount slabs are required"))
|
frappe.throw(_("Price or product discount slabs are required"))
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
data = frappe.get_all('Pricing Rule', fields = ["promotional_scheme_id", "name"],
|
pricing_rules = frappe.get_all(
|
||||||
filters = {'promotional_scheme': self.name}) or {}
|
'Pricing Rule',
|
||||||
|
fields = ["promotional_scheme_id", "name", "creation"],
|
||||||
|
filters = {
|
||||||
|
'promotional_scheme': self.name,
|
||||||
|
'applicable_for': self.applicable_for
|
||||||
|
},
|
||||||
|
order_by = 'creation asc',
|
||||||
|
) or {}
|
||||||
|
self.update_pricing_rules(pricing_rules)
|
||||||
|
|
||||||
self.update_pricing_rules(data)
|
def update_pricing_rules(self, pricing_rules):
|
||||||
|
|
||||||
def update_pricing_rules(self, data):
|
|
||||||
rules = {}
|
rules = {}
|
||||||
count = 0
|
count = 0
|
||||||
|
names = []
|
||||||
for d in data:
|
for rule in pricing_rules:
|
||||||
rules[d.get('promotional_scheme_id')] = d.get('name')
|
names.append(rule.name)
|
||||||
|
rules[rule.get('promotional_scheme_id')] = names
|
||||||
|
|
||||||
docs = get_pricing_rules(self, rules)
|
docs = get_pricing_rules(self, rules)
|
||||||
|
|
||||||
@@ -57,9 +66,9 @@ class PromotionalScheme(Document):
|
|||||||
frappe.msgprint(_("New {0} pricing rules are created").format(count))
|
frappe.msgprint(_("New {0} pricing rules are created").format(count))
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
for d in frappe.get_all('Pricing Rule',
|
for rule in frappe.get_all('Pricing Rule',
|
||||||
{'promotional_scheme': self.name}):
|
{'promotional_scheme': self.name}):
|
||||||
frappe.delete_doc('Pricing Rule', d.name)
|
frappe.delete_doc('Pricing Rule', rule.name)
|
||||||
|
|
||||||
def get_pricing_rules(doc, rules = {}):
|
def get_pricing_rules(doc, rules = {}):
|
||||||
new_doc = []
|
new_doc = []
|
||||||
@@ -73,42 +82,80 @@ def get_pricing_rules(doc, rules = {}):
|
|||||||
def _get_pricing_rules(doc, child_doc, discount_fields, rules = {}):
|
def _get_pricing_rules(doc, child_doc, discount_fields, rules = {}):
|
||||||
new_doc = []
|
new_doc = []
|
||||||
args = get_args_for_pricing_rule(doc)
|
args = get_args_for_pricing_rule(doc)
|
||||||
for d in doc.get(child_doc):
|
applicable_for = frappe.scrub(doc.get('applicable_for'))
|
||||||
|
for idx, d in enumerate(doc.get(child_doc)):
|
||||||
if d.name in rules:
|
if d.name in rules:
|
||||||
pr = frappe.get_doc('Pricing Rule', rules.get(d.name))
|
for applicable_for_value in args.get(applicable_for):
|
||||||
|
temp_args = args.copy()
|
||||||
|
docname = frappe.get_all(
|
||||||
|
'Pricing Rule',
|
||||||
|
fields = ["promotional_scheme_id", "name", applicable_for],
|
||||||
|
filters = {
|
||||||
|
'promotional_scheme_id': d.name,
|
||||||
|
applicable_for: applicable_for_value
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if docname:
|
||||||
|
pr = frappe.get_doc('Pricing Rule', docname[0].get('name'))
|
||||||
|
temp_args[applicable_for] = applicable_for_value
|
||||||
|
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
|
||||||
|
else:
|
||||||
|
pr = frappe.new_doc("Pricing Rule")
|
||||||
|
pr.title = doc.name
|
||||||
|
temp_args[applicable_for] = applicable_for_value
|
||||||
|
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
|
||||||
|
|
||||||
|
new_doc.append(pr)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
pr = frappe.new_doc("Pricing Rule")
|
applicable_for_values = args.get(applicable_for) or []
|
||||||
pr.title = make_autoname("{0}/.####".format(doc.name))
|
for applicable_for_value in applicable_for_values:
|
||||||
|
pr = frappe.new_doc("Pricing Rule")
|
||||||
pr.update(args)
|
pr.title = doc.name
|
||||||
for field in (other_fields + discount_fields):
|
temp_args = args.copy()
|
||||||
pr.set(field, d.get(field))
|
temp_args[applicable_for] = applicable_for_value
|
||||||
|
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
|
||||||
pr.promotional_scheme_id = d.name
|
new_doc.append(pr)
|
||||||
pr.promotional_scheme = doc.name
|
|
||||||
pr.disable = d.disable if d.disable else doc.disable
|
|
||||||
pr.price_or_product_discount = ('Price'
|
|
||||||
if child_doc == 'price_discount_slabs' else 'Product')
|
|
||||||
|
|
||||||
for field in ['items', 'item_groups', 'brands']:
|
|
||||||
if doc.get(field):
|
|
||||||
pr.set(field, [])
|
|
||||||
|
|
||||||
apply_on = frappe.scrub(doc.get('apply_on'))
|
|
||||||
for d in doc.get(field):
|
|
||||||
pr.append(field, {
|
|
||||||
apply_on: d.get(apply_on),
|
|
||||||
'uom': d.uom
|
|
||||||
})
|
|
||||||
|
|
||||||
new_doc.append(pr)
|
|
||||||
|
|
||||||
return new_doc
|
return new_doc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def set_args(args, pr, doc, child_doc, discount_fields, child_doc_fields):
|
||||||
|
pr.update(args)
|
||||||
|
for field in (other_fields + discount_fields):
|
||||||
|
pr.set(field, child_doc_fields.get(field))
|
||||||
|
|
||||||
|
pr.promotional_scheme_id = child_doc_fields.name
|
||||||
|
pr.promotional_scheme = doc.name
|
||||||
|
pr.disable = child_doc_fields.disable if child_doc_fields.disable else doc.disable
|
||||||
|
pr.price_or_product_discount = ('Price'
|
||||||
|
if child_doc == 'price_discount_slabs' else 'Product')
|
||||||
|
|
||||||
|
for field in ['items', 'item_groups', 'brands']:
|
||||||
|
if doc.get(field):
|
||||||
|
pr.set(field, [])
|
||||||
|
|
||||||
|
apply_on = frappe.scrub(doc.get('apply_on'))
|
||||||
|
for d in doc.get(field):
|
||||||
|
pr.append(field, {
|
||||||
|
apply_on: d.get(apply_on),
|
||||||
|
'uom': d.uom
|
||||||
|
})
|
||||||
|
return pr
|
||||||
|
|
||||||
def get_args_for_pricing_rule(doc):
|
def get_args_for_pricing_rule(doc):
|
||||||
args = { 'promotional_scheme': doc.name }
|
args = { 'promotional_scheme': doc.name }
|
||||||
|
applicable_for = frappe.scrub(doc.get('applicable_for'))
|
||||||
|
|
||||||
for d in pricing_rule_fields:
|
for d in pricing_rule_fields:
|
||||||
args[d] = doc.get(d)
|
if d == applicable_for:
|
||||||
|
items = []
|
||||||
|
for applicable_for_values in doc.get(applicable_for):
|
||||||
|
items.append(applicable_for_values.get(applicable_for))
|
||||||
|
args[d] = items
|
||||||
|
else:
|
||||||
|
args[d] = doc.get(d)
|
||||||
return args
|
return args
|
||||||
|
|||||||
@@ -7,4 +7,54 @@ import frappe
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestPromotionalScheme(unittest.TestCase):
|
class TestPromotionalScheme(unittest.TestCase):
|
||||||
pass
|
def test_promotional_scheme(self):
|
||||||
|
ps = make_promotional_scheme()
|
||||||
|
price_rules = frappe.get_all('Pricing Rule', fields = ["promotional_scheme_id", "name", "creation"],
|
||||||
|
filters = {'promotional_scheme': ps.name})
|
||||||
|
self.assertTrue(len(price_rules),1)
|
||||||
|
price_doc_details = frappe.db.get_value('Pricing Rule', price_rules[0].name, ['customer', 'min_qty', 'discount_percentage'], as_dict = 1)
|
||||||
|
self.assertTrue(price_doc_details.customer, '_Test Customer')
|
||||||
|
self.assertTrue(price_doc_details.min_qty, 4)
|
||||||
|
self.assertTrue(price_doc_details.discount_percentage, 20)
|
||||||
|
|
||||||
|
ps.price_discount_slabs[0].min_qty = 6
|
||||||
|
ps.append('customer', {
|
||||||
|
'customer': "_Test Customer 2"})
|
||||||
|
ps.save()
|
||||||
|
price_rules = frappe.get_all('Pricing Rule', fields = ["promotional_scheme_id", "name"],
|
||||||
|
filters = {'promotional_scheme': ps.name})
|
||||||
|
self.assertTrue(len(price_rules), 2)
|
||||||
|
|
||||||
|
price_doc_details = frappe.db.get_value('Pricing Rule', price_rules[1].name, ['customer', 'min_qty', 'discount_percentage'], as_dict = 1)
|
||||||
|
self.assertTrue(price_doc_details.customer, '_Test Customer 2')
|
||||||
|
self.assertTrue(price_doc_details.min_qty, 6)
|
||||||
|
self.assertTrue(price_doc_details.discount_percentage, 20)
|
||||||
|
|
||||||
|
price_doc_details = frappe.db.get_value('Pricing Rule', price_rules[0].name, ['customer', 'min_qty', 'discount_percentage'], as_dict = 1)
|
||||||
|
self.assertTrue(price_doc_details.customer, '_Test Customer')
|
||||||
|
self.assertTrue(price_doc_details.min_qty, 6)
|
||||||
|
|
||||||
|
frappe.delete_doc('Promotional Scheme', ps.name)
|
||||||
|
price_rules = frappe.get_all('Pricing Rule', fields = ["promotional_scheme_id", "name"],
|
||||||
|
filters = {'promotional_scheme': ps.name})
|
||||||
|
self.assertEqual(price_rules, [])
|
||||||
|
|
||||||
|
def make_promotional_scheme():
|
||||||
|
ps = frappe.new_doc('Promotional Scheme')
|
||||||
|
ps.name = '_Test Scheme'
|
||||||
|
ps.append('items',{
|
||||||
|
'item_code': '_Test Item'
|
||||||
|
})
|
||||||
|
ps.selling = 1
|
||||||
|
ps.append('price_discount_slabs',{
|
||||||
|
'min_qty': 4,
|
||||||
|
'discount_percentage': 20,
|
||||||
|
'rule_description': 'Test'
|
||||||
|
})
|
||||||
|
ps.applicable_for = 'Customer'
|
||||||
|
ps.append('customer',{
|
||||||
|
'customer': "_Test Customer"
|
||||||
|
})
|
||||||
|
ps.save()
|
||||||
|
|
||||||
|
return ps
|
||||||
|
|||||||
@@ -106,7 +106,6 @@
|
|||||||
"depends_on": "eval:doc.rate_or_discount==\"Rate\"",
|
"depends_on": "eval:doc.rate_or_discount==\"Rate\"",
|
||||||
"fieldname": "rate",
|
"fieldname": "rate",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Rate"
|
"label": "Rate"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -170,7 +169,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-03-07 11:56:23.424137",
|
"modified": "2021-08-19 15:49:29.598727",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Promotional Scheme Price Discount",
|
"name": "Promotional Scheme Price Discount",
|
||||||
|
|||||||
@@ -283,7 +283,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
|||||||
party: this.frm.doc.supplier,
|
party: this.frm.doc.supplier,
|
||||||
party_type: "Supplier",
|
party_type: "Supplier",
|
||||||
account: this.frm.doc.credit_to,
|
account: this.frm.doc.credit_to,
|
||||||
price_list: this.frm.doc.buying_price_list
|
price_list: this.frm.doc.buying_price_list,
|
||||||
|
fetch_payment_terms_template: cint(!this.frm.doc.ignore_default_payment_terms_template)
|
||||||
}, function() {
|
}, function() {
|
||||||
me.apply_pricing_rule();
|
me.apply_pricing_rule();
|
||||||
me.frm.doc.apply_tds = me.frm.supplier_tds ? 1 : 0;
|
me.frm.doc.apply_tds = me.frm.supplier_tds ? 1 : 0;
|
||||||
@@ -365,7 +366,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
|||||||
items_add(doc, cdt, cdn) {
|
items_add(doc, cdt, cdn) {
|
||||||
var row = frappe.get_doc(cdt, cdn);
|
var row = frappe.get_doc(cdt, cdn);
|
||||||
this.frm.script_manager.copy_from_first_row("items", row,
|
this.frm.script_manager.copy_from_first_row("items", row,
|
||||||
["expense_account", "cost_center", "project"]);
|
["expense_account", "discount_account", "cost_center", "project"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
on_submit() {
|
on_submit() {
|
||||||
@@ -499,6 +500,16 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
'Payment Entry': 'Payment'
|
'Payment Entry': 'Payment'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frm.set_query("additional_discount_account", function() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: frm.doc.company,
|
||||||
|
is_group: 0,
|
||||||
|
report_type: "Profit and Loss",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
frm.fields_dict['items'].grid.get_field('deferred_expense_account').get_query = function(doc) {
|
frm.fields_dict['items'].grid.get_field('deferred_expense_account').get_query = function(doc) {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
@@ -508,6 +519,16 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frm.fields_dict['items'].grid.get_field('discount_account').get_query = function(doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'report_type': 'Profit and Loss',
|
||||||
|
'company': doc.company,
|
||||||
|
"is_group": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -448,6 +448,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
self.make_supplier_gl_entry(gl_entries)
|
self.make_supplier_gl_entry(gl_entries)
|
||||||
self.make_item_gl_entries(gl_entries)
|
self.make_item_gl_entries(gl_entries)
|
||||||
|
self.make_discount_gl_entries(gl_entries)
|
||||||
|
|
||||||
if self.check_asset_cwip_enabled():
|
if self.check_asset_cwip_enabled():
|
||||||
self.get_asset_gl_entry(gl_entries)
|
self.get_asset_gl_entry(gl_entries)
|
||||||
@@ -522,6 +523,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
exchange_rate_map, net_rate_map = get_purchase_document_details(self)
|
exchange_rate_map, net_rate_map = get_purchase_document_details(self)
|
||||||
|
|
||||||
|
enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
|
||||||
|
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if flt(item.base_net_amount):
|
if flt(item.base_net_amount):
|
||||||
account_currency = get_account_currency(item.expense_account)
|
account_currency = get_account_currency(item.expense_account)
|
||||||
@@ -612,7 +615,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if (not item.enable_deferred_expense or self.is_return) else item.deferred_expense_account)
|
if (not item.enable_deferred_expense or self.is_return) else item.deferred_expense_account)
|
||||||
|
|
||||||
if not item.is_fixed_asset:
|
if not item.is_fixed_asset:
|
||||||
amount = flt(item.base_net_amount, item.precision("base_net_amount"))
|
dummy, amount = self.get_amount_and_base_amount(item, enable_discount_accounting)
|
||||||
else:
|
else:
|
||||||
amount = flt(item.base_net_amount + item.item_tax_amount, item.precision("base_net_amount"))
|
amount = flt(item.base_net_amount + item.item_tax_amount, item.precision("base_net_amount"))
|
||||||
|
|
||||||
@@ -854,8 +857,11 @@ class PurchaseInvoice(BuyingController):
|
|||||||
def make_tax_gl_entries(self, gl_entries):
|
def make_tax_gl_entries(self, gl_entries):
|
||||||
# tax table gl entries
|
# tax table gl entries
|
||||||
valuation_tax = {}
|
valuation_tax = {}
|
||||||
|
enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
|
||||||
|
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
if tax.category in ("Total", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount):
|
amount, base_amount = self.get_tax_amounts(tax, enable_discount_accounting)
|
||||||
|
if tax.category in ("Total", "Valuation and Total") and flt(base_amount):
|
||||||
account_currency = get_account_currency(tax.account_head)
|
account_currency = get_account_currency(tax.account_head)
|
||||||
|
|
||||||
dr_or_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
|
dr_or_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
|
||||||
@@ -864,21 +870,21 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": tax.account_head,
|
"account": tax.account_head,
|
||||||
"against": self.supplier,
|
"against": self.supplier,
|
||||||
dr_or_cr: tax.base_tax_amount_after_discount_amount,
|
dr_or_cr: base_amount,
|
||||||
dr_or_cr + "_in_account_currency": tax.base_tax_amount_after_discount_amount \
|
dr_or_cr + "_in_account_currency": base_amount
|
||||||
if account_currency==self.company_currency \
|
if account_currency==self.company_currency
|
||||||
else tax.tax_amount_after_discount_amount,
|
else amount,
|
||||||
"cost_center": tax.cost_center
|
"cost_center": tax.cost_center
|
||||||
}, account_currency, item=tax)
|
}, account_currency, item=tax)
|
||||||
)
|
)
|
||||||
# accumulate valuation tax
|
# accumulate valuation tax
|
||||||
if self.is_opening == "No" and tax.category in ("Valuation", "Valuation and Total") and flt(tax.base_tax_amount_after_discount_amount) \
|
if self.is_opening == "No" and tax.category in ("Valuation", "Valuation and Total") and flt(base_amount) \
|
||||||
and not self.is_internal_transfer():
|
and not self.is_internal_transfer():
|
||||||
if self.auto_accounting_for_stock and not tax.cost_center:
|
if self.auto_accounting_for_stock and not tax.cost_center:
|
||||||
frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
|
frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
|
||||||
valuation_tax.setdefault(tax.name, 0)
|
valuation_tax.setdefault(tax.name, 0)
|
||||||
valuation_tax[tax.name] += \
|
valuation_tax[tax.name] += \
|
||||||
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.base_tax_amount_after_discount_amount)
|
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(base_amount)
|
||||||
|
|
||||||
if self.is_opening == "No" and self.negative_expense_to_be_booked and valuation_tax:
|
if self.is_opening == "No" and self.negative_expense_to_be_booked and valuation_tax:
|
||||||
# credit valuation tax amount in "Expenses Included In Valuation"
|
# credit valuation tax amount in "Expenses Included In Valuation"
|
||||||
@@ -919,6 +925,13 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"remarks": self.remarks or "Accounting Entry for Stock"
|
"remarks": self.remarks or "Accounting Entry for Stock"
|
||||||
}, item=tax))
|
}, item=tax))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def enable_discount_accounting(self):
|
||||||
|
if not hasattr(self, "_enable_discount_accounting"):
|
||||||
|
self._enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
|
||||||
|
|
||||||
|
return self._enable_discount_accounting
|
||||||
|
|
||||||
def make_internal_transfer_gl_entries(self, gl_entries):
|
def make_internal_transfer_gl_entries(self, gl_entries):
|
||||||
if self.is_internal_transfer() and flt(self.base_total_taxes_and_charges):
|
if self.is_internal_transfer() and flt(self.base_total_taxes_and_charges):
|
||||||
account_currency = get_account_currency(self.unrealized_profit_loss_account)
|
account_currency = get_account_currency(self.unrealized_profit_loss_account)
|
||||||
|
|||||||
@@ -72,4 +72,3 @@ QUnit.test("test purchase invoice", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,50 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(discrepancy_caused_by_exchange_rate_diff, amount)
|
self.assertEqual(discrepancy_caused_by_exchange_rate_diff, amount)
|
||||||
|
|
||||||
|
def test_purchase_invoice_with_discount_accounting_enabled(self):
|
||||||
|
enable_discount_accounting()
|
||||||
|
|
||||||
|
discount_account = create_account(account_name="Discount Account",
|
||||||
|
parent_account="Indirect Expenses - _TC", company="_Test Company")
|
||||||
|
pi = make_purchase_invoice(discount_account=discount_account, rate=45)
|
||||||
|
|
||||||
|
expected_gle = [
|
||||||
|
["_Test Account Cost for Goods Sold - _TC", 250.0, 0.0, nowdate()],
|
||||||
|
["Creditors - _TC", 0.0, 225.0, nowdate()],
|
||||||
|
["Discount Account - _TC", 0.0, 25.0, nowdate()]
|
||||||
|
]
|
||||||
|
|
||||||
|
check_gl_entries(self, pi.name, expected_gle, nowdate())
|
||||||
|
enable_discount_accounting(enable=0)
|
||||||
|
|
||||||
|
def test_additional_discount_for_purchase_invoice_with_discount_accounting_enabled(self):
|
||||||
|
enable_discount_accounting()
|
||||||
|
additional_discount_account = create_account(account_name="Discount Account",
|
||||||
|
parent_account="Indirect Expenses - _TC", company="_Test Company")
|
||||||
|
|
||||||
|
pi = make_purchase_invoice(do_not_save=1, parent_cost_center="Main - _TC")
|
||||||
|
pi.apply_discount_on = "Grand Total"
|
||||||
|
pi.additional_discount_account = additional_discount_account
|
||||||
|
pi.additional_discount_percentage = 10
|
||||||
|
pi.disable_rounded_total = 1
|
||||||
|
pi.append("taxes", {
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"account_head": "_Test Account VAT - _TC",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"description": "Test",
|
||||||
|
"rate": 10
|
||||||
|
})
|
||||||
|
pi.submit()
|
||||||
|
|
||||||
|
expected_gle = [
|
||||||
|
["_Test Account Cost for Goods Sold - _TC", 250.0, 0.0, nowdate()],
|
||||||
|
["_Test Account VAT - _TC", 25.0, 0.0, nowdate()],
|
||||||
|
["Creditors - _TC", 0.0, 247.5, nowdate()],
|
||||||
|
["Discount Account - _TC", 0.0, 27.5, nowdate()]
|
||||||
|
]
|
||||||
|
|
||||||
|
check_gl_entries(self, pi.name, expected_gle, nowdate())
|
||||||
|
|
||||||
def test_purchase_invoice_change_naming_series(self):
|
def test_purchase_invoice_change_naming_series(self):
|
||||||
pi = frappe.copy_doc(test_records[1])
|
pi = frappe.copy_doc(test_records[1])
|
||||||
pi.insert()
|
pi.insert()
|
||||||
@@ -1161,6 +1205,18 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
self.assertEqual(expected_gle[i][0], gle.account)
|
self.assertEqual(expected_gle[i][0], gle.account)
|
||||||
self.assertEqual(expected_gle[i][1], gle.amount)
|
self.assertEqual(expected_gle[i][1], gle.amount)
|
||||||
|
|
||||||
|
def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
||||||
|
gl_entries = frappe.db.sql("""select account, debit, credit, posting_date
|
||||||
|
from `tabGL Entry`
|
||||||
|
where voucher_type='Purchase Invoice' and voucher_no=%s and posting_date >= %s
|
||||||
|
order by posting_date asc, account asc""", (voucher_no, posting_date), as_dict=1)
|
||||||
|
|
||||||
|
for i, gle in enumerate(gl_entries):
|
||||||
|
doc.assertEqual(expected_gle[i][0], gle.account)
|
||||||
|
doc.assertEqual(expected_gle[i][1], gle.debit)
|
||||||
|
doc.assertEqual(expected_gle[i][2], gle.credit)
|
||||||
|
doc.assertEqual(getdate(expected_gle[i][3]), gle.posting_date)
|
||||||
|
|
||||||
def update_tax_witholding_category(company, account, date):
|
def update_tax_witholding_category(company, account, date):
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
|
|
||||||
@@ -1191,6 +1247,11 @@ def unlink_payment_on_cancel_of_invoice(enable=1):
|
|||||||
accounts_settings.unlink_payment_on_cancellation_of_invoice = enable
|
accounts_settings.unlink_payment_on_cancellation_of_invoice = enable
|
||||||
accounts_settings.save()
|
accounts_settings.save()
|
||||||
|
|
||||||
|
def enable_discount_accounting(enable=1):
|
||||||
|
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||||
|
accounts_settings.enable_discount_accounting = enable
|
||||||
|
accounts_settings.save()
|
||||||
|
|
||||||
def make_purchase_invoice(**args):
|
def make_purchase_invoice(**args):
|
||||||
pi = frappe.new_doc("Purchase Invoice")
|
pi = frappe.new_doc("Purchase Invoice")
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
@@ -1213,6 +1274,7 @@ def make_purchase_invoice(**args):
|
|||||||
pi.return_against = args.return_against
|
pi.return_against = args.return_against
|
||||||
pi.is_subcontracted = args.is_subcontracted or "No"
|
pi.is_subcontracted = args.is_subcontracted or "No"
|
||||||
pi.supplier_warehouse = args.supplier_warehouse or "_Test Warehouse 1 - _TC"
|
pi.supplier_warehouse = args.supplier_warehouse or "_Test Warehouse 1 - _TC"
|
||||||
|
pi.cost_center = args.parent_cost_center
|
||||||
|
|
||||||
pi.append("items", {
|
pi.append("items", {
|
||||||
"item_code": args.item or args.item_code or "_Test Item",
|
"item_code": args.item or args.item_code or "_Test Item",
|
||||||
@@ -1221,7 +1283,10 @@ def make_purchase_invoice(**args):
|
|||||||
"received_qty": args.received_qty or 0,
|
"received_qty": args.received_qty or 0,
|
||||||
"rejected_qty": args.rejected_qty or 0,
|
"rejected_qty": args.rejected_qty or 0,
|
||||||
"rate": args.rate or 50,
|
"rate": args.rate or 50,
|
||||||
'expense_account': args.expense_account or '_Test Account Cost for Goods Sold - _TC',
|
"price_list_rate": args.price_list_rate or 50,
|
||||||
|
"expense_account": args.expense_account or '_Test Account Cost for Goods Sold - _TC',
|
||||||
|
"discount_account": args.discount_account or None,
|
||||||
|
"discount_amount": args.discount_amount or 0,
|
||||||
"conversion_factor": 1.0,
|
"conversion_factor": 1.0,
|
||||||
"serial_no": args.serial_no,
|
"serial_no": args.serial_no,
|
||||||
"stock_uom": args.uom or "_Test UOM",
|
"stock_uom": args.uom or "_Test UOM",
|
||||||
|
|||||||
@@ -73,6 +73,7 @@
|
|||||||
"manufacturer_part_no",
|
"manufacturer_part_no",
|
||||||
"accounting",
|
"accounting",
|
||||||
"expense_account",
|
"expense_account",
|
||||||
|
"discount_account",
|
||||||
"col_break5",
|
"col_break5",
|
||||||
"is_fixed_asset",
|
"is_fixed_asset",
|
||||||
"asset_location",
|
"asset_location",
|
||||||
@@ -501,6 +502,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"collapsible": 1,
|
"collapsible": 1,
|
||||||
|
"collapsible_depends_on": "enable_deferred_expense",
|
||||||
"fieldname": "deferred_expense_section",
|
"fieldname": "deferred_expense_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Deferred Expense"
|
"label": "Deferred Expense"
|
||||||
@@ -849,12 +851,18 @@
|
|||||||
"options": "Company:company:default_currency",
|
"options": "Company:company:default_currency",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "discount_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Discount Account",
|
||||||
|
"options": "Account"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-16 19:43:51.099386",
|
"modified": "2021-08-12 20:14:48.506639",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice Item",
|
"name": "Purchase Invoice Item",
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
"cost_center",
|
"cost_center",
|
||||||
"dimension_col_break",
|
"dimension_col_break",
|
||||||
"section_break_9",
|
"section_break_9",
|
||||||
"currency",
|
"account_currency",
|
||||||
"tax_amount",
|
"tax_amount",
|
||||||
"tax_amount_after_discount_amount",
|
"tax_amount_after_discount_amount",
|
||||||
"total",
|
"total",
|
||||||
@@ -208,14 +208,6 @@
|
|||||||
"fieldname": "dimension_col_break",
|
"fieldname": "dimension_col_break",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fetch_from": "account_head.account_currency",
|
|
||||||
"fieldname": "currency",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Account Currency",
|
|
||||||
"options": "Currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"depends_on": "eval:['Purchase Taxes and Charges Template', 'Payment Entry'].includes(parent.doctype)",
|
"depends_on": "eval:['Purchase Taxes and Charges Template', 'Payment Entry'].includes(parent.doctype)",
|
||||||
@@ -223,12 +215,20 @@
|
|||||||
"fieldname": "included_in_paid_amount",
|
"fieldname": "included_in_paid_amount",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Considered In Paid Amount"
|
"label": "Considered In Paid Amount"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "account_head.account_currency",
|
||||||
|
"fieldname": "account_currency",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Account Currency",
|
||||||
|
"options": "Currency",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-14 01:43:50.750455",
|
"modified": "2021-08-05 20:04:36.618240",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Taxes and Charges",
|
"name": "Purchase Taxes and Charges",
|
||||||
|
|||||||
@@ -26,4 +26,3 @@ QUnit.test("test sales taxes and charges template", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
{% include "erpnext/regional/india/taxes.js" %}
|
{% include "erpnext/regional/india/taxes.js" %}
|
||||||
{% include "erpnext/regional/india/e_invoice/einvoice.js" %}
|
|
||||||
|
|
||||||
erpnext.setup_auto_gst_taxation('Sales Invoice');
|
erpnext.setup_auto_gst_taxation('Sales Invoice');
|
||||||
erpnext.setup_einvoice_actions('Sales Invoice')
|
|
||||||
|
|
||||||
frappe.ui.form.on("Sales Invoice", {
|
frappe.ui.form.on("Sales Invoice", {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
|
|||||||
@@ -36,139 +36,4 @@ frappe.listview_settings['Sales Invoice'].onload = function (list_view) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
list_view.page.add_actions_menu_item(__('Generate E-Way Bill JSON'), action, false);
|
list_view.page.add_actions_menu_item(__('Generate E-Way Bill JSON'), action, false);
|
||||||
|
|
||||||
const generate_irns = () => {
|
|
||||||
const docnames = list_view.get_checked_items(true);
|
|
||||||
if (docnames && docnames.length) {
|
|
||||||
frappe.call({
|
|
||||||
method: 'erpnext.regional.india.e_invoice.utils.generate_einvoices',
|
|
||||||
args: { docnames },
|
|
||||||
freeze: true,
|
|
||||||
freeze_message: __('Generating E-Invoices...')
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
frappe.msgprint({
|
|
||||||
message: __('Please select at least one sales invoice to generate IRN'),
|
|
||||||
title: __('No Invoice Selected'),
|
|
||||||
indicator: 'red'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const cancel_irns = () => {
|
|
||||||
const docnames = list_view.get_checked_items(true);
|
|
||||||
|
|
||||||
const fields = [
|
|
||||||
{
|
|
||||||
"label": "Reason",
|
|
||||||
"fieldname": "reason",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"reqd": 1,
|
|
||||||
"default": "1-Duplicate",
|
|
||||||
"options": ["1-Duplicate", "2-Data Entry Error", "3-Order Cancelled", "4-Other"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Remark",
|
|
||||||
"fieldname": "remark",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"reqd": 1
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const d = new frappe.ui.Dialog({
|
|
||||||
title: __("Cancel IRN"),
|
|
||||||
fields: fields,
|
|
||||||
primary_action: function() {
|
|
||||||
const data = d.get_values();
|
|
||||||
frappe.call({
|
|
||||||
method: 'erpnext.regional.india.e_invoice.utils.cancel_irns',
|
|
||||||
args: {
|
|
||||||
doctype: list_view.doctype,
|
|
||||||
docnames,
|
|
||||||
reason: data.reason.split('-')[0],
|
|
||||||
remark: data.remark
|
|
||||||
},
|
|
||||||
freeze: true,
|
|
||||||
freeze_message: __('Cancelling E-Invoices...'),
|
|
||||||
});
|
|
||||||
d.hide();
|
|
||||||
},
|
|
||||||
primary_action_label: __('Submit')
|
|
||||||
});
|
|
||||||
d.show();
|
|
||||||
};
|
|
||||||
|
|
||||||
let einvoicing_enabled = false;
|
|
||||||
frappe.db.get_single_value("E Invoice Settings", "enable").then(enabled => {
|
|
||||||
einvoicing_enabled = enabled;
|
|
||||||
});
|
|
||||||
|
|
||||||
list_view.$result.on("change", "input[type=checkbox]", () => {
|
|
||||||
if (einvoicing_enabled) {
|
|
||||||
const docnames = list_view.get_checked_items(true);
|
|
||||||
// show/hide e-invoicing actions when no sales invoices are checked
|
|
||||||
if (docnames && docnames.length) {
|
|
||||||
// prevent adding actions twice if e-invoicing action group already exists
|
|
||||||
if (list_view.page.get_inner_group_button(__('E-Invoicing')).length == 0) {
|
|
||||||
list_view.page.add_inner_button(__('Generate IRNs'), generate_irns, __('E-Invoicing'));
|
|
||||||
list_view.page.add_inner_button(__('Cancel IRNs'), cancel_irns, __('E-Invoicing'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
list_view.page.remove_inner_button(__('Generate IRNs'), __('E-Invoicing'));
|
|
||||||
list_view.page.remove_inner_button(__('Cancel IRNs'), __('E-Invoicing'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frappe.realtime.on("bulk_einvoice_generation_complete", (data) => {
|
|
||||||
const { failures, user, invoices } = data;
|
|
||||||
|
|
||||||
if (invoices.length != failures.length) {
|
|
||||||
frappe.msgprint({
|
|
||||||
message: __('{0} e-invoices generated successfully', [invoices.length]),
|
|
||||||
title: __('Bulk E-Invoice Generation Complete'),
|
|
||||||
indicator: 'orange'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failures && failures.length && user == frappe.session.user) {
|
|
||||||
let message = `
|
|
||||||
Failed to generate IRNs for following ${failures.length} sales invoices:
|
|
||||||
<ul style="padding-left: 20px; padding-top: 5px;">
|
|
||||||
${failures.map(d => `<li>${d.docname}</li>`).join('')}
|
|
||||||
</ul>
|
|
||||||
`;
|
|
||||||
frappe.msgprint({
|
|
||||||
message: message,
|
|
||||||
title: __('Bulk E-Invoice Generation Complete'),
|
|
||||||
indicator: 'orange'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
frappe.realtime.on("bulk_einvoice_cancellation_complete", (data) => {
|
|
||||||
const { failures, user, invoices } = data;
|
|
||||||
|
|
||||||
if (invoices.length != failures.length) {
|
|
||||||
frappe.msgprint({
|
|
||||||
message: __('{0} e-invoices cancelled successfully', [invoices.length]),
|
|
||||||
title: __('Bulk E-Invoice Cancellation Complete'),
|
|
||||||
indicator: 'orange'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failures && failures.length && user == frappe.session.user) {
|
|
||||||
let message = `
|
|
||||||
Failed to cancel IRNs for following ${failures.length} sales invoices:
|
|
||||||
<ul style="padding-left: 20px; padding-top: 5px;">
|
|
||||||
${failures.map(d => `<li>${d.docname}</li>`).join('')}
|
|
||||||
</ul>
|
|
||||||
`;
|
|
||||||
frappe.msgprint({
|
|
||||||
message: message,
|
|
||||||
title: __('Bulk E-Invoice Cancellation Complete'),
|
|
||||||
indicator: 'orange'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
@@ -347,7 +347,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
|||||||
|
|
||||||
items_add(doc, cdt, cdn) {
|
items_add(doc, cdt, cdn) {
|
||||||
var row = frappe.get_doc(cdt, cdn);
|
var row = frappe.get_doc(cdt, cdn);
|
||||||
this.frm.script_manager.copy_from_first_row("items", row, ["income_account", "cost_center"]);
|
this.frm.script_manager.copy_from_first_row("items", row, ["income_account", "discount_account", "cost_center"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_dynamic_labels() {
|
set_dynamic_labels() {
|
||||||
@@ -448,6 +448,15 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
|||||||
this.frm.refresh_field("paid_amount");
|
this.frm.refresh_field("paid_amount");
|
||||||
this.frm.refresh_field("base_paid_amount");
|
this.frm.refresh_field("base_paid_amount");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currency() {
|
||||||
|
super.currency();
|
||||||
|
$.each(cur_frm.doc.timesheets, function(i, d) {
|
||||||
|
let row = frappe.get_doc(d.doctype, d.name)
|
||||||
|
set_timesheet_detail_rate(row.doctype, row.name, cur_frm.doc.currency, row.timesheet_detail)
|
||||||
|
});
|
||||||
|
calculate_total_billing_amount(cur_frm)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// for backward compatibility: combine new and previous states
|
// for backward compatibility: combine new and previous states
|
||||||
@@ -510,7 +519,6 @@ cur_frm.set_query("income_account", "items", function(doc) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Cost Center in Details Table
|
// Cost Center in Details Table
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(doc) {
|
cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(doc) {
|
||||||
@@ -592,6 +600,16 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("additional_discount_account", function() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: frm.doc.company,
|
||||||
|
is_group: 0,
|
||||||
|
report_type: "Profit and Loss",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
frm.custom_make_buttons = {
|
frm.custom_make_buttons = {
|
||||||
'Delivery Note': 'Delivery',
|
'Delivery Note': 'Delivery',
|
||||||
'Sales Invoice': 'Return / Credit Note',
|
'Sales Invoice': 'Return / Credit Note',
|
||||||
@@ -618,6 +636,17 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// discount account
|
||||||
|
frm.fields_dict['items'].grid.get_field('discount_account').get_query = function(doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'report_type': 'Profit and Loss',
|
||||||
|
'company': doc.company,
|
||||||
|
"is_group": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
frm.fields_dict['items'].grid.get_field('deferred_revenue_account').get_query = function(doc) {
|
frm.fields_dict['items'].grid.get_field('deferred_revenue_account').get_query = function(doc) {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
@@ -826,7 +855,8 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
'time_sheet': row.parent,
|
'time_sheet': row.parent,
|
||||||
'billing_hours': row.billing_hours,
|
'billing_hours': row.billing_hours,
|
||||||
'billing_amount': flt(row.billing_amount) * flt(exchange_rate),
|
'billing_amount': flt(row.billing_amount) * flt(exchange_rate),
|
||||||
'timesheet_detail': row.name
|
'timesheet_detail': row.name,
|
||||||
|
'project_name': row.project_name
|
||||||
});
|
});
|
||||||
frm.refresh_field('timesheets');
|
frm.refresh_field('timesheets');
|
||||||
calculate_total_billing_amount(frm);
|
calculate_total_billing_amount(frm);
|
||||||
@@ -945,43 +975,34 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
frappe.ui.form.on('Sales Invoice Timesheet', {
|
|
||||||
time_sheet: function(frm, cdt, cdn){
|
|
||||||
var d = locals[cdt][cdn];
|
|
||||||
if(d.time_sheet) {
|
|
||||||
frappe.call({
|
|
||||||
method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_data",
|
|
||||||
args: {
|
|
||||||
'name': d.time_sheet,
|
|
||||||
'project': frm.doc.project || null
|
|
||||||
},
|
|
||||||
callback: function(r, rt) {
|
|
||||||
if(r.message){
|
|
||||||
let data = r.message;
|
|
||||||
frappe.model.set_value(cdt, cdn, "billing_hours", data.billing_hours);
|
|
||||||
frappe.model.set_value(cdt, cdn, "billing_amount", data.billing_amount);
|
|
||||||
frappe.model.set_value(cdt, cdn, "timesheet_detail", data.timesheet_detail);
|
|
||||||
calculate_total_billing_amount(frm)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
var calculate_total_billing_amount = function(frm) {
|
var calculate_total_billing_amount = function(frm) {
|
||||||
var doc = frm.doc;
|
var doc = frm.doc;
|
||||||
|
|
||||||
doc.total_billing_amount = 0.0
|
doc.total_billing_amount = 0.0
|
||||||
if(doc.timesheets) {
|
if (doc.timesheets) {
|
||||||
$.each(doc.timesheets, function(index, data){
|
$.each(doc.timesheets, function(index, data){
|
||||||
doc.total_billing_amount += data.billing_amount
|
doc.total_billing_amount += flt(data.billing_amount)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh_field('total_billing_amount')
|
refresh_field('total_billing_amount')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var set_timesheet_detail_rate = function(cdt, cdn, currency, timelog) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_detail_rate",
|
||||||
|
args: {
|
||||||
|
timelog: timelog,
|
||||||
|
currency: currency
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if (!r.exc && r.message) {
|
||||||
|
frappe.model.set_value(cdt, cdn, 'billing_amount', r.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var select_loyalty_program = function(frm, loyalty_programs) {
|
var select_loyalty_program = function(frm, loyalty_programs) {
|
||||||
var dialog = new frappe.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
title: __("Select Loyalty Program"),
|
title: __("Select Loyalty Program"),
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
"section_break_49",
|
"section_break_49",
|
||||||
"apply_discount_on",
|
"apply_discount_on",
|
||||||
"base_discount_amount",
|
"base_discount_amount",
|
||||||
|
"additional_discount_account",
|
||||||
"column_break_51",
|
"column_break_51",
|
||||||
"additional_discount_percentage",
|
"additional_discount_percentage",
|
||||||
"discount_amount",
|
"discount_amount",
|
||||||
@@ -127,6 +128,7 @@
|
|||||||
"get_advances",
|
"get_advances",
|
||||||
"advances",
|
"advances",
|
||||||
"payment_schedule_section",
|
"payment_schedule_section",
|
||||||
|
"ignore_default_payment_terms_template",
|
||||||
"payment_terms_template",
|
"payment_terms_template",
|
||||||
"payment_schedule",
|
"payment_schedule",
|
||||||
"payments_section",
|
"payments_section",
|
||||||
@@ -690,6 +692,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "scan_barcode",
|
"fieldname": "scan_barcode",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
|
"options": "Barcode",
|
||||||
"hide_days": 1,
|
"hide_days": 1,
|
||||||
"hide_seconds": 1,
|
"hide_seconds": 1,
|
||||||
"label": "Scan Barcode"
|
"label": "Scan Barcode"
|
||||||
@@ -1932,6 +1935,7 @@
|
|||||||
"description": "Unrealized Profit / Loss account for intra-company transfers",
|
"description": "Unrealized Profit / Loss account for intra-company transfers",
|
||||||
"fieldname": "unrealized_profit_loss_account",
|
"fieldname": "unrealized_profit_loss_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_user_permissions": 1,
|
||||||
"label": "Unrealized Profit / Loss Account",
|
"label": "Unrealized Profit / Loss Account",
|
||||||
"options": "Account"
|
"options": "Account"
|
||||||
},
|
},
|
||||||
@@ -1953,6 +1957,7 @@
|
|||||||
"depends_on": "eval: doc.is_internal_customer && doc.update_stock",
|
"depends_on": "eval: doc.is_internal_customer && doc.update_stock",
|
||||||
"fieldname": "set_target_warehouse",
|
"fieldname": "set_target_warehouse",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"ignore_user_permissions": 1,
|
||||||
"label": "Set Target Warehouse",
|
"label": "Set Target Warehouse",
|
||||||
"options": "Warehouse"
|
"options": "Warehouse"
|
||||||
},
|
},
|
||||||
@@ -1969,6 +1974,12 @@
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Disable Rounded Total"
|
"label": "Disable Rounded Total"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "additional_discount_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Additional Discount Account",
|
||||||
|
"options": "Account"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"fieldname": "dispatch_address_name",
|
"fieldname": "dispatch_address_name",
|
||||||
@@ -1983,6 +1994,14 @@
|
|||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
"label": "Dispatch Address",
|
"label": "Dispatch Address",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "ignore_default_payment_terms_template",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Ignore Default Payment Terms Template",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-file-text",
|
"icon": "fa fa-file-text",
|
||||||
@@ -1995,7 +2014,7 @@
|
|||||||
"link_fieldname": "consolidated_invoice"
|
"link_fieldname": "consolidated_invoice"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-07-08 14:03:55.502522",
|
"modified": "2021-08-17 20:16:12.737743",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice",
|
"name": "Sales Invoice",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, erpnext
|
import frappe, erpnext
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe.utils import cint, flt, getdate, add_days, cstr, nowdate, get_link_to_form, formatdate
|
from frappe.utils import cint, flt, getdate, add_days, add_months, cstr, nowdate, get_link_to_form, formatdate
|
||||||
from frappe import _, msgprint, throw
|
from frappe import _, msgprint, throw
|
||||||
from erpnext.accounts.party import get_party_account, get_due_date, get_party_details
|
from erpnext.accounts.party import get_party_account, get_due_date, get_party_details
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
@@ -13,7 +13,7 @@ from erpnext.accounts.utils import get_account_currency
|
|||||||
from erpnext.stock.doctype.delivery_note.delivery_note import update_billed_amount_based_on_so
|
from erpnext.stock.doctype.delivery_note.delivery_note import update_billed_amount_based_on_so
|
||||||
from erpnext.projects.doctype.timesheet.timesheet import get_projectwise_timesheet_data
|
from erpnext.projects.doctype.timesheet.timesheet import get_projectwise_timesheet_data
|
||||||
from erpnext.assets.doctype.asset.depreciation \
|
from erpnext.assets.doctype.asset.depreciation \
|
||||||
import get_disposal_account_and_cost_center, get_gl_entries_on_asset_disposal, get_gl_entries_on_asset_regain
|
import get_disposal_account_and_cost_center, get_gl_entries_on_asset_disposal, get_gl_entries_on_asset_regain, post_depreciation_entries
|
||||||
from erpnext.stock.doctype.batch.batch import set_batch_nos
|
from erpnext.stock.doctype.batch.batch import set_batch_nos
|
||||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos, get_delivery_note_serial_no
|
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos, get_delivery_note_serial_no
|
||||||
from erpnext.setup.doctype.company.company import update_company_current_month_sales
|
from erpnext.setup.doctype.company.company import update_company_current_month_sales
|
||||||
@@ -285,8 +285,6 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
def before_cancel(self):
|
def before_cancel(self):
|
||||||
self.check_if_consolidated_invoice()
|
self.check_if_consolidated_invoice()
|
||||||
|
|
||||||
super(SalesInvoice, self).before_cancel()
|
|
||||||
self.update_time_sheet(None)
|
self.update_time_sheet(None)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
@@ -478,6 +476,9 @@ class SalesInvoice(SellingController):
|
|||||||
if cint(self.is_pos) != 1:
|
if cint(self.is_pos) != 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not self.account_for_change_amount:
|
||||||
|
self.account_for_change_amount = frappe.get_cached_value('Company', self.company, 'default_cash_account')
|
||||||
|
|
||||||
from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile
|
from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile
|
||||||
if not self.pos_profile:
|
if not self.pos_profile:
|
||||||
pos_profile = get_pos_profile(self.company) or {}
|
pos_profile = get_pos_profile(self.company) or {}
|
||||||
@@ -492,9 +493,6 @@ class SalesInvoice(SellingController):
|
|||||||
if not self.get('payments') and not for_validate:
|
if not self.get('payments') and not for_validate:
|
||||||
update_multi_mode_option(self, pos)
|
update_multi_mode_option(self, pos)
|
||||||
|
|
||||||
if not self.account_for_change_amount:
|
|
||||||
self.account_for_change_amount = frappe.get_cached_value('Company', self.company, 'default_cash_account')
|
|
||||||
|
|
||||||
if pos:
|
if pos:
|
||||||
if not for_validate:
|
if not for_validate:
|
||||||
self.tax_category = pos.get("tax_category")
|
self.tax_category = pos.get("tax_category")
|
||||||
@@ -848,6 +846,7 @@ class SalesInvoice(SellingController):
|
|||||||
self.allocate_advance_taxes(gl_entries)
|
self.allocate_advance_taxes(gl_entries)
|
||||||
|
|
||||||
self.make_item_gl_entries(gl_entries)
|
self.make_item_gl_entries(gl_entries)
|
||||||
|
self.make_discount_gl_entries(gl_entries)
|
||||||
|
|
||||||
# merge gl entries before adding pos entries
|
# merge gl entries before adding pos entries
|
||||||
gl_entries = merge_similar_entries(gl_entries)
|
gl_entries = merge_similar_entries(gl_entries)
|
||||||
@@ -887,18 +886,22 @@ class SalesInvoice(SellingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def make_tax_gl_entries(self, gl_entries):
|
def make_tax_gl_entries(self, gl_entries):
|
||||||
|
enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
|
||||||
|
|
||||||
for tax in self.get("taxes"):
|
for tax in self.get("taxes"):
|
||||||
|
amount, base_amount = self.get_tax_amounts(tax, enable_discount_accounting)
|
||||||
|
|
||||||
if flt(tax.base_tax_amount_after_discount_amount):
|
if flt(tax.base_tax_amount_after_discount_amount):
|
||||||
account_currency = get_account_currency(tax.account_head)
|
account_currency = get_account_currency(tax.account_head)
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": tax.account_head,
|
"account": tax.account_head,
|
||||||
"against": self.customer,
|
"against": self.customer,
|
||||||
"credit": flt(tax.base_tax_amount_after_discount_amount,
|
"credit": flt(base_amount,
|
||||||
tax.precision("tax_amount_after_discount_amount")),
|
tax.precision("tax_amount_after_discount_amount")),
|
||||||
"credit_in_account_currency": (flt(tax.base_tax_amount_after_discount_amount,
|
"credit_in_account_currency": (flt(base_amount,
|
||||||
tax.precision("base_tax_amount_after_discount_amount")) if account_currency==self.company_currency else
|
tax.precision("base_tax_amount_after_discount_amount")) if account_currency==self.company_currency else
|
||||||
flt(tax.tax_amount_after_discount_amount, tax.precision("tax_amount_after_discount_amount"))),
|
flt(amount, tax.precision("tax_amount_after_discount_amount"))),
|
||||||
"cost_center": tax.cost_center
|
"cost_center": tax.cost_center
|
||||||
}, account_currency, item=tax)
|
}, account_currency, item=tax)
|
||||||
)
|
)
|
||||||
@@ -917,30 +920,29 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
def make_item_gl_entries(self, gl_entries):
|
def make_item_gl_entries(self, gl_entries):
|
||||||
# income account gl entries
|
# income account gl entries
|
||||||
|
enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
|
||||||
|
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if flt(item.base_net_amount, item.precision("base_net_amount")):
|
if flt(item.base_net_amount, item.precision("base_net_amount")):
|
||||||
if item.is_fixed_asset:
|
if item.is_fixed_asset:
|
||||||
if item.get('asset'):
|
asset = self.get_asset(item)
|
||||||
asset = frappe.get_doc("Asset", item.asset)
|
|
||||||
else:
|
|
||||||
frappe.throw(_(
|
|
||||||
"Row #{0}: You must select an Asset for Item {1}.").format(item.idx, item.item_name),
|
|
||||||
title=_("Missing Asset")
|
|
||||||
)
|
|
||||||
if (len(asset.finance_books) > 1 and not item.finance_book
|
|
||||||
and asset.finance_books[0].finance_book):
|
|
||||||
frappe.throw(_("Select finance book for the item {0} at row {1}")
|
|
||||||
.format(item.item_code, item.idx))
|
|
||||||
|
|
||||||
if self.is_return:
|
if self.is_return:
|
||||||
fixed_asset_gl_entries = get_gl_entries_on_asset_regain(asset,
|
fixed_asset_gl_entries = get_gl_entries_on_asset_regain(asset,
|
||||||
item.base_net_amount, item.finance_book)
|
item.base_net_amount, item.finance_book)
|
||||||
asset.db_set("disposal_date", None)
|
asset.db_set("disposal_date", None)
|
||||||
|
|
||||||
|
if asset.calculate_depreciation:
|
||||||
|
self.reset_depreciation_schedule(asset)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(asset,
|
fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(asset,
|
||||||
item.base_net_amount, item.finance_book)
|
item.base_net_amount, item.finance_book)
|
||||||
asset.db_set("disposal_date", self.posting_date)
|
asset.db_set("disposal_date", self.posting_date)
|
||||||
|
|
||||||
|
if asset.calculate_depreciation:
|
||||||
|
self.depreciate_asset(asset)
|
||||||
|
|
||||||
for gle in fixed_asset_gl_entries:
|
for gle in fixed_asset_gl_entries:
|
||||||
gle["against"] = self.customer
|
gle["against"] = self.customer
|
||||||
gl_entries.append(self.get_gl_dict(gle, item=item))
|
gl_entries.append(self.get_gl_dict(gle, item=item))
|
||||||
@@ -953,15 +955,17 @@ class SalesInvoice(SellingController):
|
|||||||
income_account = (item.income_account
|
income_account = (item.income_account
|
||||||
if (not item.enable_deferred_revenue or self.is_return) else item.deferred_revenue_account)
|
if (not item.enable_deferred_revenue or self.is_return) else item.deferred_revenue_account)
|
||||||
|
|
||||||
|
amount, base_amount = self.get_amount_and_base_amount(item, enable_discount_accounting)
|
||||||
|
|
||||||
account_currency = get_account_currency(income_account)
|
account_currency = get_account_currency(income_account)
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": income_account,
|
"account": income_account,
|
||||||
"against": self.customer,
|
"against": self.customer,
|
||||||
"credit": flt(item.base_net_amount, item.precision("base_net_amount")),
|
"credit": flt(base_amount, item.precision("base_net_amount")),
|
||||||
"credit_in_account_currency": (flt(item.base_net_amount, item.precision("base_net_amount"))
|
"credit_in_account_currency": (flt(base_amount, item.precision("base_net_amount"))
|
||||||
if account_currency==self.company_currency
|
if account_currency==self.company_currency
|
||||||
else flt(item.net_amount, item.precision("net_amount"))),
|
else flt(amount, item.precision("net_amount"))),
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
"project": item.project or self.project
|
"project": item.project or self.project
|
||||||
}, account_currency, item=item)
|
}, account_currency, item=item)
|
||||||
@@ -972,6 +976,96 @@ class SalesInvoice(SellingController):
|
|||||||
erpnext.is_perpetual_inventory_enabled(self.company):
|
erpnext.is_perpetual_inventory_enabled(self.company):
|
||||||
gl_entries += super(SalesInvoice, self).get_gl_entries()
|
gl_entries += super(SalesInvoice, self).get_gl_entries()
|
||||||
|
|
||||||
|
def get_asset(self, item):
|
||||||
|
if item.get('asset'):
|
||||||
|
asset = frappe.get_doc("Asset", item.asset)
|
||||||
|
else:
|
||||||
|
frappe.throw(_(
|
||||||
|
"Row #{0}: You must select an Asset for Item {1}.").format(item.idx, item.item_name),
|
||||||
|
title=_("Missing Asset")
|
||||||
|
)
|
||||||
|
|
||||||
|
self.check_finance_books(item, asset)
|
||||||
|
return asset
|
||||||
|
|
||||||
|
def check_finance_books(self, item, asset):
|
||||||
|
if (len(asset.finance_books) > 1 and not item.finance_book
|
||||||
|
and asset.finance_books[0].finance_book):
|
||||||
|
frappe.throw(_("Select finance book for the item {0} at row {1}")
|
||||||
|
.format(item.item_code, item.idx))
|
||||||
|
|
||||||
|
def depreciate_asset(self, asset):
|
||||||
|
asset.flags.ignore_validate_update_after_submit = True
|
||||||
|
asset.prepare_depreciation_data(self.posting_date)
|
||||||
|
asset.save()
|
||||||
|
|
||||||
|
post_depreciation_entries(self.posting_date)
|
||||||
|
|
||||||
|
def reset_depreciation_schedule(self, asset):
|
||||||
|
asset.flags.ignore_validate_update_after_submit = True
|
||||||
|
|
||||||
|
# recreate original depreciation schedule of the asset
|
||||||
|
asset.prepare_depreciation_data()
|
||||||
|
|
||||||
|
self.modify_depreciation_schedule_for_asset_repairs(asset)
|
||||||
|
asset.save()
|
||||||
|
|
||||||
|
self.delete_depreciation_entry_made_after_sale(asset)
|
||||||
|
|
||||||
|
def modify_depreciation_schedule_for_asset_repairs(self, asset):
|
||||||
|
asset_repairs = frappe.get_all(
|
||||||
|
'Asset Repair',
|
||||||
|
filters = {'asset': asset.name},
|
||||||
|
fields = ['name', 'increase_in_asset_life']
|
||||||
|
)
|
||||||
|
|
||||||
|
for repair in asset_repairs:
|
||||||
|
if repair.increase_in_asset_life:
|
||||||
|
asset_repair = frappe.get_doc('Asset Repair', repair.name)
|
||||||
|
asset_repair.modify_depreciation_schedule()
|
||||||
|
asset.prepare_depreciation_data()
|
||||||
|
|
||||||
|
def delete_depreciation_entry_made_after_sale(self, asset):
|
||||||
|
from erpnext.accounts.doctype.journal_entry.journal_entry import make_reverse_journal_entry
|
||||||
|
|
||||||
|
posting_date_of_original_invoice = self.get_posting_date_of_sales_invoice()
|
||||||
|
|
||||||
|
row = -1
|
||||||
|
finance_book = asset.get('schedules')[0].get('finance_book')
|
||||||
|
for schedule in asset.get('schedules'):
|
||||||
|
if schedule.finance_book != finance_book:
|
||||||
|
row = 0
|
||||||
|
finance_book = schedule.finance_book
|
||||||
|
else:
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
if schedule.schedule_date == posting_date_of_original_invoice:
|
||||||
|
if not self.sale_was_made_on_original_schedule_date(asset, schedule, row, posting_date_of_original_invoice):
|
||||||
|
reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry)
|
||||||
|
reverse_journal_entry.posting_date = nowdate()
|
||||||
|
reverse_journal_entry.submit()
|
||||||
|
|
||||||
|
def get_posting_date_of_sales_invoice(self):
|
||||||
|
return frappe.db.get_value('Sales Invoice', self.return_against, 'posting_date')
|
||||||
|
|
||||||
|
# if the invoice had been posted on the date the depreciation was initially supposed to happen, the depreciation shouldn't be undone
|
||||||
|
def sale_was_made_on_original_schedule_date(self, asset, schedule, row, posting_date_of_original_invoice):
|
||||||
|
for finance_book in asset.get('finance_books'):
|
||||||
|
if schedule.finance_book == finance_book.finance_book:
|
||||||
|
orginal_schedule_date = add_months(finance_book.depreciation_start_date,
|
||||||
|
row * cint(finance_book.frequency_of_depreciation))
|
||||||
|
|
||||||
|
if orginal_schedule_date == posting_date_of_original_invoice:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def enable_discount_accounting(self):
|
||||||
|
if not hasattr(self, "_enable_discount_accounting"):
|
||||||
|
self._enable_discount_accounting = cint(frappe.db.get_single_value('Accounts Settings', 'enable_discount_accounting'))
|
||||||
|
|
||||||
|
return self._enable_discount_accounting
|
||||||
|
|
||||||
def set_asset_status(self, asset):
|
def set_asset_status(self, asset):
|
||||||
if self.is_return:
|
if self.is_return:
|
||||||
asset.set_status()
|
asset.set_status()
|
||||||
@@ -1367,7 +1461,7 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
discounting_status = None
|
discounting_status = None
|
||||||
if self.is_discounted:
|
if self.is_discounted:
|
||||||
discountng_status = get_discounting_status(self.name)
|
discounting_status = get_discounting_status(self.name)
|
||||||
|
|
||||||
if not status:
|
if not status:
|
||||||
if self.docstatus == 2:
|
if self.docstatus == 2:
|
||||||
@@ -1375,11 +1469,11 @@ class SalesInvoice(SellingController):
|
|||||||
elif self.docstatus == 1:
|
elif self.docstatus == 1:
|
||||||
if self.is_internal_transfer():
|
if self.is_internal_transfer():
|
||||||
self.status = 'Internal Transfer'
|
self.status = 'Internal Transfer'
|
||||||
elif outstanding_amount > 0 and due_date < nowdate and self.is_discounted and discountng_status=='Disbursed':
|
elif outstanding_amount > 0 and due_date < nowdate and self.is_discounted and discounting_status=='Disbursed':
|
||||||
self.status = "Overdue and Discounted"
|
self.status = "Overdue and Discounted"
|
||||||
elif outstanding_amount > 0 and due_date < nowdate:
|
elif outstanding_amount > 0 and due_date < nowdate:
|
||||||
self.status = "Overdue"
|
self.status = "Overdue"
|
||||||
elif outstanding_amount > 0 and due_date >= nowdate and self.is_discounted and discountng_status=='Disbursed':
|
elif outstanding_amount > 0 and due_date >= nowdate and self.is_discounted and discounting_status=='Disbursed':
|
||||||
self.status = "Unpaid and Discounted"
|
self.status = "Unpaid and Discounted"
|
||||||
elif outstanding_amount > 0 and due_date >= nowdate:
|
elif outstanding_amount > 0 and due_date >= nowdate:
|
||||||
self.status = "Unpaid"
|
self.status = "Unpaid"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import unli
|
|||||||
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import WarehouseMissingError
|
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import WarehouseMissingError
|
||||||
from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
|
from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
|
||||||
from erpnext.assets.doctype.asset.test_asset import create_asset, create_asset_data
|
from erpnext.assets.doctype.asset.test_asset import create_asset, create_asset_data
|
||||||
|
from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries
|
||||||
from erpnext.exceptions import InvalidAccountCurrency, InvalidCurrency
|
from erpnext.exceptions import InvalidAccountCurrency, InvalidCurrency
|
||||||
from erpnext.stock.doctype.serial_no.serial_no import SerialNoWarehouseError
|
from erpnext.stock.doctype.serial_no.serial_no import SerialNoWarehouseError
|
||||||
from frappe.model.naming import make_autoname
|
from frappe.model.naming import make_autoname
|
||||||
@@ -2063,54 +2064,6 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEqual(data['billLists'][0]['actualFromStateCode'],7)
|
self.assertEqual(data['billLists'][0]['actualFromStateCode'],7)
|
||||||
self.assertEqual(data['billLists'][0]['fromStateCode'],27)
|
self.assertEqual(data['billLists'][0]['fromStateCode'],27)
|
||||||
|
|
||||||
def test_einvoice_submission_without_irn(self):
|
|
||||||
# init
|
|
||||||
einvoice_settings = frappe.get_doc('E Invoice Settings')
|
|
||||||
einvoice_settings.enable = 1
|
|
||||||
einvoice_settings.applicable_from = nowdate()
|
|
||||||
einvoice_settings.append('credentials', {
|
|
||||||
'company': '_Test Company',
|
|
||||||
'gstin': '27AAECE4835E1ZR',
|
|
||||||
'username': 'test',
|
|
||||||
'password': 'test'
|
|
||||||
})
|
|
||||||
einvoice_settings.save()
|
|
||||||
|
|
||||||
country = frappe.flags.country
|
|
||||||
frappe.flags.country = 'India'
|
|
||||||
|
|
||||||
si = make_sales_invoice_for_ewaybill()
|
|
||||||
self.assertRaises(frappe.ValidationError, si.submit)
|
|
||||||
|
|
||||||
si.irn = 'test_irn'
|
|
||||||
si.submit()
|
|
||||||
|
|
||||||
# reset
|
|
||||||
einvoice_settings = frappe.get_doc('E Invoice Settings')
|
|
||||||
einvoice_settings.enable = 0
|
|
||||||
frappe.flags.country = country
|
|
||||||
|
|
||||||
def test_einvoice_json(self):
|
|
||||||
from erpnext.regional.india.e_invoice.utils import make_einvoice, validate_totals
|
|
||||||
|
|
||||||
si = get_sales_invoice_for_e_invoice()
|
|
||||||
si.discount_amount = 100
|
|
||||||
si.save()
|
|
||||||
|
|
||||||
einvoice = make_einvoice(si)
|
|
||||||
self.assertTrue(einvoice['EwbDtls'])
|
|
||||||
validate_totals(einvoice)
|
|
||||||
|
|
||||||
si.apply_discount_on = 'Net Total'
|
|
||||||
si.save()
|
|
||||||
einvoice = make_einvoice(si)
|
|
||||||
validate_totals(einvoice)
|
|
||||||
|
|
||||||
[d.set('included_in_print_rate', 1) for d in si.taxes]
|
|
||||||
si.save()
|
|
||||||
einvoice = make_einvoice(si)
|
|
||||||
validate_totals(einvoice)
|
|
||||||
|
|
||||||
def test_item_tax_net_range(self):
|
def test_item_tax_net_range(self):
|
||||||
item = create_item("T Shirt")
|
item = create_item("T Shirt")
|
||||||
|
|
||||||
@@ -2138,6 +2091,78 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
sales_invoice.save()
|
sales_invoice.save()
|
||||||
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")
|
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")
|
||||||
|
|
||||||
|
def test_sales_invoice_with_discount_accounting_enabled(self):
|
||||||
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import enable_discount_accounting
|
||||||
|
|
||||||
|
enable_discount_accounting()
|
||||||
|
|
||||||
|
discount_account = create_account(account_name="Discount Account",
|
||||||
|
parent_account="Indirect Expenses - _TC", company="_Test Company")
|
||||||
|
si = create_sales_invoice(discount_account=discount_account, discount_percentage=10, rate=90)
|
||||||
|
|
||||||
|
expected_gle = [
|
||||||
|
["Debtors - _TC", 90.0, 0.0, nowdate()],
|
||||||
|
["Discount Account - _TC", 10.0, 0.0, nowdate()],
|
||||||
|
["Sales - _TC", 0.0, 100.0, nowdate()]
|
||||||
|
]
|
||||||
|
|
||||||
|
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
|
||||||
|
enable_discount_accounting(enable=0)
|
||||||
|
|
||||||
|
def test_additional_discount_for_sales_invoice_with_discount_accounting_enabled(self):
|
||||||
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import enable_discount_accounting
|
||||||
|
|
||||||
|
enable_discount_accounting()
|
||||||
|
additional_discount_account = create_account(account_name="Discount Account",
|
||||||
|
parent_account="Indirect Expenses - _TC", company="_Test Company")
|
||||||
|
|
||||||
|
si = create_sales_invoice(parent_cost_center='Main - _TC', do_not_save=1)
|
||||||
|
si.apply_discount_on = "Grand Total"
|
||||||
|
si.additional_discount_account = additional_discount_account
|
||||||
|
si.additional_discount_percentage = 20
|
||||||
|
si.append("taxes", {
|
||||||
|
"charge_type": "On Net Total",
|
||||||
|
"account_head": "_Test Account VAT - _TC",
|
||||||
|
"cost_center": "Main - _TC",
|
||||||
|
"description": "Test",
|
||||||
|
"rate": 10
|
||||||
|
})
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
expected_gle = [
|
||||||
|
["_Test Account VAT - _TC", 0.0, 10.0, nowdate()],
|
||||||
|
["Debtors - _TC", 88, 0.0, nowdate()],
|
||||||
|
["Discount Account - _TC", 22.0, 0.0, nowdate()],
|
||||||
|
["Sales - _TC", 0.0, 100.0, nowdate()]
|
||||||
|
]
|
||||||
|
|
||||||
|
check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1))
|
||||||
|
enable_discount_accounting(enable=0)
|
||||||
|
|
||||||
|
def test_asset_depreciation_on_sale(self):
|
||||||
|
"""
|
||||||
|
Tests if an Asset set to depreciate yearly on June 30, that gets sold on Sept 30, creates an additional depreciation entry on Sept 30.
|
||||||
|
"""
|
||||||
|
|
||||||
|
create_asset_data()
|
||||||
|
asset = create_asset(item_code="Macbook Pro", calculate_depreciation=1, submit=1)
|
||||||
|
post_depreciation_entries(getdate("2021-09-30"))
|
||||||
|
|
||||||
|
create_sales_invoice(item_code="Macbook Pro", asset=asset.name, qty=1, rate=90000, posting_date=getdate("2021-09-30"))
|
||||||
|
asset.load_from_db()
|
||||||
|
|
||||||
|
expected_values = [
|
||||||
|
["2020-06-30", 1311.48, 1311.48],
|
||||||
|
["2021-06-30", 20000.0, 21311.48],
|
||||||
|
["2021-09-30", 3966.76, 25278.24]
|
||||||
|
]
|
||||||
|
|
||||||
|
for i, schedule in enumerate(asset.schedules):
|
||||||
|
self.assertEqual(getdate(expected_values[i][0]), schedule.schedule_date)
|
||||||
|
self.assertEqual(expected_values[i][1], schedule.depreciation_amount)
|
||||||
|
self.assertEqual(expected_values[i][2], schedule.accumulated_depreciation_amount)
|
||||||
|
self.assertTrue(schedule.journal_entry)
|
||||||
|
|
||||||
def get_sales_invoice_for_e_invoice():
|
def get_sales_invoice_for_e_invoice():
|
||||||
si = make_sales_invoice_for_ewaybill()
|
si = make_sales_invoice_for_ewaybill()
|
||||||
si.naming_series = 'INV-2020-.#####'
|
si.naming_series = 'INV-2020-.#####'
|
||||||
@@ -2330,6 +2355,7 @@ def create_sales_invoice(**args):
|
|||||||
si.currency=args.currency or "INR"
|
si.currency=args.currency or "INR"
|
||||||
si.conversion_rate = args.conversion_rate or 1
|
si.conversion_rate = args.conversion_rate or 1
|
||||||
si.naming_series = args.naming_series or "T-SINV-"
|
si.naming_series = args.naming_series or "T-SINV-"
|
||||||
|
si.cost_center = args.parent_cost_center
|
||||||
|
|
||||||
si.append("items", {
|
si.append("items", {
|
||||||
"item_code": args.item or args.item_code or "_Test Item",
|
"item_code": args.item or args.item_code or "_Test Item",
|
||||||
@@ -2341,8 +2367,11 @@ def create_sales_invoice(**args):
|
|||||||
"uom": args.uom or "Nos",
|
"uom": args.uom or "Nos",
|
||||||
"stock_uom": args.uom or "Nos",
|
"stock_uom": args.uom or "Nos",
|
||||||
"rate": args.rate if args.get("rate") is not None else 100,
|
"rate": args.rate if args.get("rate") is not None else 100,
|
||||||
|
"price_list_rate": args.price_list_rate if args.get("price_list_rate") is not None else 100,
|
||||||
"income_account": args.income_account or "Sales - _TC",
|
"income_account": args.income_account or "Sales - _TC",
|
||||||
"expense_account": args.expense_account or "Cost of Goods Sold - _TC",
|
"expense_account": args.expense_account or "Cost of Goods Sold - _TC",
|
||||||
|
"discount_account": args.discount_account or None,
|
||||||
|
"discount_amount": args.discount_amount or 0,
|
||||||
"asset": args.asset or None,
|
"asset": args.asset or None,
|
||||||
"cost_center": args.cost_center or "_Test Cost Center - _TC",
|
"cost_center": args.cost_center or "_Test Cost Center - _TC",
|
||||||
"serial_no": args.serial_no,
|
"serial_no": args.serial_no,
|
||||||
|
|||||||
@@ -40,4 +40,3 @@ QUnit.test("test sales Invoice", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -33,4 +33,3 @@ QUnit.test("test sales invoice with margin", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -54,4 +54,3 @@ QUnit.test("test sales Invoice with payment", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,4 +49,3 @@ QUnit.test("test sales Invoice with payment request", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -42,4 +42,3 @@ QUnit.test("test sales Invoice with serialize item", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@
|
|||||||
"finance_book",
|
"finance_book",
|
||||||
"col_break4",
|
"col_break4",
|
||||||
"expense_account",
|
"expense_account",
|
||||||
|
"discount_account",
|
||||||
"deferred_revenue",
|
"deferred_revenue",
|
||||||
"deferred_revenue_account",
|
"deferred_revenue_account",
|
||||||
"service_stop_date",
|
"service_stop_date",
|
||||||
@@ -473,6 +474,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"collapsible": 1,
|
"collapsible": 1,
|
||||||
|
"collapsible_depends_on": "enable_deferred_revenue",
|
||||||
"fieldname": "deferred_revenue",
|
"fieldname": "deferred_revenue",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Deferred Revenue"
|
"label": "Deferred Revenue"
|
||||||
@@ -820,12 +822,18 @@
|
|||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "currency",
|
"options": "currency",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "discount_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Discount Account",
|
||||||
|
"options": "Account"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-21 23:03:11.599901",
|
"modified": "2021-08-12 20:15:47.668399",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice Item",
|
"name": "Sales Invoice Item",
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
"description",
|
"description",
|
||||||
"billing_hours",
|
"billing_hours",
|
||||||
"billing_amount",
|
"billing_amount",
|
||||||
|
"column_break_5",
|
||||||
"time_sheet",
|
"time_sheet",
|
||||||
|
"project_name",
|
||||||
"timesheet_detail"
|
"timesheet_detail"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
@@ -61,11 +63,21 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Description",
|
"label": "Description",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_5",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "project_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Project Name",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-20 22:33:57.234846",
|
"modified": "2021-06-08 14:43:02.748981",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice Timesheet",
|
"name": "Sales Invoice Timesheet",
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-06 16:17:44.329943",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"sales_partner"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "sales_partner",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Sales Partner ",
|
||||||
|
"options": "Sales Partner"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-07 10:43:37.532095",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Sales Partner Item",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class SalesPartnerItem(Document):
|
||||||
|
pass
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
"section_break_8",
|
"section_break_8",
|
||||||
"rate",
|
"rate",
|
||||||
"section_break_9",
|
"section_break_9",
|
||||||
"currency",
|
"account_currency",
|
||||||
"tax_amount",
|
"tax_amount",
|
||||||
"total",
|
"total",
|
||||||
"tax_amount_after_discount_amount",
|
"tax_amount_after_discount_amount",
|
||||||
@@ -186,14 +186,6 @@
|
|||||||
"fieldname": "dimension_col_break",
|
"fieldname": "dimension_col_break",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fetch_from": "account_head.account_currency",
|
|
||||||
"fieldname": "currency",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Account Currency",
|
|
||||||
"options": "Currency",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"depends_on": "eval:['Sales Taxes and Charges Template', 'Payment Entry'].includes(parent.doctype)",
|
"depends_on": "eval:['Sales Taxes and Charges Template', 'Payment Entry'].includes(parent.doctype)",
|
||||||
@@ -210,13 +202,21 @@
|
|||||||
"label": "Dont Recompute tax",
|
"label": "Dont Recompute tax",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "account_head.account_currency",
|
||||||
|
"fieldname": "account_currency",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Account Currency",
|
||||||
|
"options": "Currency",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-07-27 12:40:59.051803",
|
"modified": "2021-08-05 20:04:01.726867",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Taxes and Charges",
|
"name": "Sales Taxes and Charges",
|
||||||
|
|||||||
@@ -26,4 +26,3 @@ QUnit.test("test sales taxes and charges template", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -34,4 +34,3 @@ QUnit.test("test Shipping Rule", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -34,4 +34,3 @@ QUnit.test("test Shipping Rule", function(assert) {
|
|||||||
() => done()
|
() => done()
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -630,5 +630,3 @@ class TestSubscription(unittest.TestCase):
|
|||||||
|
|
||||||
subscription.process()
|
subscription.process()
|
||||||
self.assertEqual(len(subscription.invoices), 1)
|
self.assertEqual(len(subscription.invoices), 1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-06 16:19:22.040795",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"supplier_group"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "supplier_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Supplier Group",
|
||||||
|
"options": "Supplier Group"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-07 10:43:59.877938",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Supplier Group Item",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class SupplierGroupItem(Document):
|
||||||
|
pass
|
||||||
31
erpnext/accounts/doctype/supplier_item/supplier_item.json
Normal file
31
erpnext/accounts/doctype/supplier_item/supplier_item.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-06 16:18:54.758468",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"supplier"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "supplier",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Supplier",
|
||||||
|
"options": "Supplier"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-07 10:44:09.707778",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Supplier Item",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
8
erpnext/accounts/doctype/supplier_item/supplier_item.py
Normal file
8
erpnext/accounts/doctype/supplier_item/supplier_item.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class SupplierItem(Document):
|
||||||
|
pass
|
||||||
0
erpnext/accounts/doctype/territory_item/__init__.py
Normal file
0
erpnext/accounts/doctype/territory_item/__init__.py
Normal file
31
erpnext/accounts/doctype/territory_item/territory_item.json
Normal file
31
erpnext/accounts/doctype/territory_item/territory_item.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-06 16:16:51.885441",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"territory"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "territory",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Territory",
|
||||||
|
"options": "Territory"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-07 10:43:26.641030",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Accounts",
|
||||||
|
"name": "Territory Item",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class TerritoryItem(Document):
|
||||||
|
pass
|
||||||
@@ -8,7 +8,7 @@ from frappe import _, msgprint, scrub
|
|||||||
from frappe.core.doctype.user_permission.user_permission import get_permitted_documents
|
from frappe.core.doctype.user_permission.user_permission import get_permitted_documents
|
||||||
from frappe.model.utils import get_fetch_values
|
from frappe.model.utils import get_fetch_values
|
||||||
from frappe.utils import (add_days, getdate, formatdate, date_diff,
|
from frappe.utils import (add_days, getdate, formatdate, date_diff,
|
||||||
add_years, get_timestamp, nowdate, flt, cstr, add_months, get_last_day)
|
add_years, get_timestamp, nowdate, flt, cstr, add_months, get_last_day, cint)
|
||||||
from frappe.contacts.doctype.address.address import (get_address_display,
|
from frappe.contacts.doctype.address.address import (get_address_display,
|
||||||
get_default_address, get_company_address)
|
get_default_address, get_company_address)
|
||||||
from frappe.contacts.doctype.contact.contact import get_contact_details
|
from frappe.contacts.doctype.contact.contact import get_contact_details
|
||||||
@@ -58,7 +58,7 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=
|
|||||||
customer_group=party_details.customer_group, supplier_group=party_details.supplier_group, tax_category=party_details.tax_category,
|
customer_group=party_details.customer_group, supplier_group=party_details.supplier_group, tax_category=party_details.tax_category,
|
||||||
billing_address=party_address, shipping_address=shipping_address)
|
billing_address=party_address, shipping_address=shipping_address)
|
||||||
|
|
||||||
if fetch_payment_terms_template:
|
if cint(fetch_payment_terms_template):
|
||||||
party_details["payment_terms_template"] = get_payment_terms_template(party.name, party_type, company)
|
party_details["payment_terms_template"] = get_payment_terms_template(party.name, party_type, company)
|
||||||
|
|
||||||
if not party_details.get("currency"):
|
if not party_details.get("currency"):
|
||||||
@@ -286,6 +286,7 @@ def validate_party_gle_currency(party_type, party, company, party_account_curren
|
|||||||
.format(frappe.bold(party_type), frappe.bold(party), frappe.bold(existing_gle_currency), frappe.bold(company)), InvalidAccountCurrency)
|
.format(frappe.bold(party_type), frappe.bold(party), frappe.bold(existing_gle_currency), frappe.bold(company)), InvalidAccountCurrency)
|
||||||
|
|
||||||
def validate_party_accounts(doc):
|
def validate_party_accounts(doc):
|
||||||
|
|
||||||
companies = []
|
companies = []
|
||||||
|
|
||||||
for account in doc.get("accounts"):
|
for account in doc.get("accounts"):
|
||||||
@@ -446,6 +447,10 @@ def get_payment_terms_template(party_name, party_type, company=None):
|
|||||||
return template
|
return template
|
||||||
|
|
||||||
def validate_party_frozen_disabled(party_type, party_name):
|
def validate_party_frozen_disabled(party_type, party_name):
|
||||||
|
|
||||||
|
if frappe.flags.ignore_party_validation:
|
||||||
|
return
|
||||||
|
|
||||||
if party_type and party_name:
|
if party_type and party_name:
|
||||||
if party_type in ("Customer", "Supplier"):
|
if party_type in ("Customer", "Supplier"):
|
||||||
party = frappe.get_cached_value(party_type, party_name, ["is_frozen", "disabled"], as_dict=True)
|
party = frappe.get_cached_value(party_type, party_name, ["is_frozen", "disabled"], as_dict=True)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"name": "Bank and Cash Payment Voucher",
|
"name": "Bank and Cash Payment Voucher",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"print_format_builder": 0,
|
"print_format_builder": 0,
|
||||||
"print_format_type": "Server",
|
"print_format_type": "Jinja",
|
||||||
"show_section_headings": 0,
|
"show_section_headings": 0,
|
||||||
"standard": "Yes"
|
"standard": "Yes"
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,6 @@
|
|||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"name": "Cheque Printing Format",
|
"name": "Cheque Printing Format",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"print_format_type": "Server",
|
"print_format_type": "Jinja",
|
||||||
"standard": "Yes"
|
"standard": "Yes"
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"parentfield": "__print_formats",
|
"parentfield": "__print_formats",
|
||||||
"print_format_builder": 0,
|
"print_format_builder": 0,
|
||||||
"print_format_type": "Server",
|
"print_format_type": "Jinja",
|
||||||
"show_section_headings": 0,
|
"show_section_headings": 0,
|
||||||
"standard": "Yes"
|
"standard": "Yes"
|
||||||
}
|
}
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
{%- from "templates/print_formats/standard_macros.html" import add_header, render_field, print_value -%}
|
|
||||||
{%- set einvoice = json.loads(doc.signed_einvoice) -%}
|
|
||||||
|
|
||||||
<div class="page-break">
|
|
||||||
<div {% if print_settings.repeat_header_footer %} id="header-html" class="hidden-pdf" {% endif %}>
|
|
||||||
{% if letter_head and not no_letterhead %}
|
|
||||||
<div class="letter-head">{{ letter_head }}</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="print-heading">
|
|
||||||
<h2>E Invoice<br><small>{{ doc.name }}</small></h2>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if print_settings.repeat_header_footer %}
|
|
||||||
<div id="footer-html" class="visible-pdf">
|
|
||||||
{% if not no_letterhead and footer %}
|
|
||||||
<div class="letter-head-footer">
|
|
||||||
{{ footer }}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<p class="text-center small page-number visible-pdf">
|
|
||||||
{{ _("Page {0} of {1}").format('<span class="page"></span>', '<span class="topage"></span>') }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<h5 class="font-bold" style="margin-top: 0px;">1. Transaction Details</h5>
|
|
||||||
<div class="row section-break" style="border-bottom: 1px solid #d1d8dd; padding-bottom: 10px;">
|
|
||||||
<div class="col-xs-8 column-break">
|
|
||||||
<div class="row data-field">
|
|
||||||
<div class="col-xs-4"><label>IRN</label></div>
|
|
||||||
<div class="col-xs-8 value">{{ einvoice.Irn }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="row data-field">
|
|
||||||
<div class="col-xs-4"><label>Ack. No</label></div>
|
|
||||||
<div class="col-xs-8 value">{{ einvoice.AckNo }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="row data-field">
|
|
||||||
<div class="col-xs-4"><label>Ack. Date</label></div>
|
|
||||||
<div class="col-xs-8 value">{{ frappe.utils.format_datetime(einvoice.AckDt, "dd/MM/yyyy hh:mm:ss") }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="row data-field">
|
|
||||||
<div class="col-xs-4"><label>Category</label></div>
|
|
||||||
<div class="col-xs-8 value">{{ einvoice.TranDtls.SupTyp }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="row data-field">
|
|
||||||
<div class="col-xs-4"><label>Document Type</label></div>
|
|
||||||
<div class="col-xs-8 value">{{ einvoice.DocDtls.Typ }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="row data-field">
|
|
||||||
<div class="col-xs-4"><label>Document No</label></div>
|
|
||||||
<div class="col-xs-8 value">{{ einvoice.DocDtls.No }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xs-4 column-break">
|
|
||||||
<img src="{{ doc.qrcode_image }}" width="175px" style="float: right;">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h5 class="font-bold" style="margin-top: 15px; margin-bottom: 10px;">2. Party Details</h5>
|
|
||||||
<div class="row section-break" style="border-bottom: 1px solid #d1d8dd; padding-bottom: 10px;">
|
|
||||||
{%- set seller = einvoice.SellerDtls -%}
|
|
||||||
<div class="col-xs-6 column-break">
|
|
||||||
<h5 style="margin-bottom: 5px;">Seller</h5>
|
|
||||||
<p>{{ seller.Gstin }}</p>
|
|
||||||
<p>{{ seller.LglNm }}</p>
|
|
||||||
<p>{{ seller.Addr1 }}</p>
|
|
||||||
{%- if seller.Addr2 -%} <p>{{ seller.Addr2 }}</p> {% endif %}
|
|
||||||
<p>{{ seller.Loc }}</p>
|
|
||||||
<p>{{ frappe.db.get_value("Address", doc.company_address, "gst_state") }} - {{ seller.Pin }}</p>
|
|
||||||
|
|
||||||
{%- if einvoice.ShipDtls -%}
|
|
||||||
{%- set shipping = einvoice.ShipDtls -%}
|
|
||||||
<h5 style="margin-bottom: 5px;">Shipping</h5>
|
|
||||||
<p>{{ shipping.Gstin }}</p>
|
|
||||||
<p>{{ shipping.LglNm }}</p>
|
|
||||||
<p>{{ shipping.Addr1 }}</p>
|
|
||||||
{%- if shipping.Addr2 -%} <p>{{ shipping.Addr2 }}</p> {% endif %}
|
|
||||||
<p>{{ shipping.Loc }}</p>
|
|
||||||
<p>{{ frappe.db.get_value("Address", doc.shipping_address_name, "gst_state") }} - {{ shipping.Pin }}</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{%- set buyer = einvoice.BuyerDtls -%}
|
|
||||||
<div class="col-xs-6 column-break">
|
|
||||||
<h5 style="margin-bottom: 5px;">Buyer</h5>
|
|
||||||
<p>{{ buyer.Gstin }}</p>
|
|
||||||
<p>{{ buyer.LglNm }}</p>
|
|
||||||
<p>{{ buyer.Addr1 }}</p>
|
|
||||||
{%- if buyer.Addr2 -%} <p>{{ buyer.Addr2 }}</p> {% endif %}
|
|
||||||
<p>{{ buyer.Loc }}</p>
|
|
||||||
<p>{{ frappe.db.get_value("Address", doc.customer_address, "gst_state") }} - {{ buyer.Pin }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="overflow-x: auto;">
|
|
||||||
<h5 class="font-bold" style="margin-top: 15px; margin-bottom: 10px;">3. Item Details</h5>
|
|
||||||
<table class="table table-bordered">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="text-left" style="width: 3%;">Sr. No.</th>
|
|
||||||
<th class="text-left">Item</th>
|
|
||||||
<th class="text-left" style="width: 10%;">HSN Code</th>
|
|
||||||
<th class="text-left" style="width: 5%;">Qty</th>
|
|
||||||
<th class="text-left" style="width: 5%;">UOM</th>
|
|
||||||
<th class="text-left">Rate</th>
|
|
||||||
<th class="text-left" style="width: 5%;">Discount</th>
|
|
||||||
<th class="text-left">Taxable Amount</th>
|
|
||||||
<th class="text-left" style="width: 7%;">Tax Rate</th>
|
|
||||||
<th class="text-left" style="width: 5%;">Other Charges</th>
|
|
||||||
<th class="text-left">Total</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for item in einvoice.ItemList %}
|
|
||||||
<tr>
|
|
||||||
<td class="text-left" style="width: 3%;">{{ item.SlNo }}</td>
|
|
||||||
<td class="text-left">{{ item.PrdDesc }}</td>
|
|
||||||
<td class="text-left" style="width: 10%;">{{ item.HsnCd }}</td>
|
|
||||||
<td class="text-right" style="width: 5%;">{{ item.Qty }}</td>
|
|
||||||
<td class="text-left" style="width: 5%;">{{ item.Unit }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(item.UnitPrice, None, "INR") }}</td>
|
|
||||||
<td class="text-right" style="width: 5%;">{{ frappe.utils.fmt_money(item.Discount, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(item.AssAmt, None, "INR") }}</td>
|
|
||||||
<td class="text-right" style="width: 7%;">{{ item.GstRt + item.CesRt }} %</td>
|
|
||||||
<td class="text-right" style="width: 5%;">{{ frappe.utils.fmt_money(0, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(item.TotItemVal, None, "INR") }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div style="overflow-x: auto;">
|
|
||||||
<h5 class="font-bold" style="margin-bottom: 0px;">4. Value Details</h5>
|
|
||||||
<table class="table table-bordered">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="text-left">Taxable Amount</th>
|
|
||||||
<th class="text-left">CGST</th>
|
|
||||||
<th class="text-left"">SGST</th>
|
|
||||||
<th class="text-left">IGST</th>
|
|
||||||
<th class="text-left">CESS</th>
|
|
||||||
<th class="text-left" style="width: 10%;">State CESS</th>
|
|
||||||
<th class="text-left">Discount</th>
|
|
||||||
<th class="text-left" style="width: 10%;">Other Charges</th>
|
|
||||||
<th class="text-left" style="width: 10%;">Round Off</th>
|
|
||||||
<th class="text-left">Total Value</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{%- set value_details = einvoice.ValDtls -%}
|
|
||||||
<tr>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.AssVal, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.CgstVal, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.SgstVal, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.IgstVal, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.CesVal, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(0, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.Discount, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.OthChrg, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.RndOffAmt, None, "INR") }}</td>
|
|
||||||
<td class="text-right">{{ frappe.utils.fmt_money(value_details.TotInvVal, None, "INR") }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"align_labels_right": 1,
|
|
||||||
"creation": "2020-10-10 18:01:21.032914",
|
|
||||||
"custom_format": 0,
|
|
||||||
"default_print_language": "en-US",
|
|
||||||
"disabled": 1,
|
|
||||||
"doc_type": "Sales Invoice",
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "Print Format",
|
|
||||||
"font": "Default",
|
|
||||||
"html": "",
|
|
||||||
"idx": 0,
|
|
||||||
"line_breaks": 1,
|
|
||||||
"modified": "2020-10-23 19:54:40.634936",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"module": "Accounts",
|
|
||||||
"name": "GST E-Invoice",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"print_format_builder": 0,
|
|
||||||
"print_format_type": "Jinja",
|
|
||||||
"raw_printing": 0,
|
|
||||||
"show_section_headings": 1,
|
|
||||||
"standard": "Yes"
|
|
||||||
}
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"name": "GST Purchase Invoice",
|
"name": "GST Purchase Invoice",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"print_format_builder": 1,
|
"print_format_builder": 1,
|
||||||
"print_format_type": "Server",
|
"print_format_type": "Jinja",
|
||||||
"show_section_headings": 0,
|
"show_section_headings": 0,
|
||||||
"standard": "Yes"
|
"standard": "Yes"
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"name": "Journal Auditing Voucher",
|
"name": "Journal Auditing Voucher",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"print_format_builder": 0,
|
"print_format_builder": 0,
|
||||||
"print_format_type": "Server",
|
"print_format_type": "Jinja",
|
||||||
"show_section_headings": 0,
|
"show_section_headings": 0,
|
||||||
"standard": "Yes"
|
"standard": "Yes"
|
||||||
}
|
}
|
||||||
@@ -27,4 +27,3 @@
|
|||||||
{{ _("Authorized Signatory") }}
|
{{ _("Authorized Signatory") }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,6 @@
|
|||||||
"name": "Payment Receipt Voucher",
|
"name": "Payment Receipt Voucher",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"print_format_builder": 0,
|
"print_format_builder": 0,
|
||||||
"print_format_type": "Server",
|
"print_format_type": "Jinja",
|
||||||
"standard": "Yes"
|
"standard": "Yes"
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"name": "Purchase Auditing Voucher",
|
"name": "Purchase Auditing Voucher",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"print_format_builder": 0,
|
"print_format_builder": 0,
|
||||||
"print_format_type": "Server",
|
"print_format_type": "Jinja",
|
||||||
"show_section_headings": 0,
|
"show_section_headings": 0,
|
||||||
"standard": "Yes"
|
"standard": "Yes"
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"name": "Sales Auditing Voucher",
|
"name": "Sales Auditing Voucher",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"print_format_builder": 0,
|
"print_format_builder": 0,
|
||||||
"print_format_type": "Server",
|
"print_format_type": "Jinja",
|
||||||
"show_section_headings": 0,
|
"show_section_headings": 0,
|
||||||
"standard": "Yes"
|
"standard": "Yes"
|
||||||
}
|
}
|
||||||
@@ -62,8 +62,3 @@ def make_sales_invoice():
|
|||||||
income_account = 'Sales - _TC2',
|
income_account = 'Sales - _TC2',
|
||||||
expense_account = 'Cost of Goods Sold - _TC2',
|
expense_account = 'Cost of Goods Sold - _TC2',
|
||||||
cost_center = 'Main - _TC2')
|
cost_center = 'Main - _TC2')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -136,4 +136,3 @@ frappe.query_reports["Accounts Payable"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.add_dimensions('Accounts Payable', 9);
|
erpnext.utils.add_dimensions('Accounts Payable', 9);
|
||||||
|
|
||||||
|
|||||||
@@ -105,4 +105,3 @@ frappe.query_reports["Accounts Payable Summary"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.add_dimensions('Accounts Payable Summary', 9);
|
erpnext.utils.add_dimensions('Accounts Payable Summary', 9);
|
||||||
|
|
||||||
|
|||||||
@@ -12,4 +12,3 @@ def execute(filters=None):
|
|||||||
"naming_by": ["Buying Settings", "supp_master_name"],
|
"naming_by": ["Buying Settings", "supp_master_name"],
|
||||||
}
|
}
|
||||||
return AccountsReceivableSummary(filters).run(args)
|
return AccountsReceivableSummary(filters).run(args)
|
||||||
|
|
||||||
|
|||||||
@@ -200,4 +200,3 @@ frappe.query_reports["Accounts Receivable"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.add_dimensions('Accounts Receivable', 9);
|
erpnext.utils.add_dimensions('Accounts Receivable', 9);
|
||||||
|
|
||||||
|
|||||||
@@ -535,6 +535,8 @@ class ReceivablePayableReport(object):
|
|||||||
if getdate(entry_date) > getdate(self.filters.report_date):
|
if getdate(entry_date) > getdate(self.filters.report_date):
|
||||||
row.range1 = row.range2 = row.range3 = row.range4 = row.range5 = 0.0
|
row.range1 = row.range2 = row.range3 = row.range4 = row.range5 = 0.0
|
||||||
|
|
||||||
|
row.total_due = row.range1 + row.range2 + row.range3 + row.range4 + row.range5
|
||||||
|
|
||||||
def get_ageing_data(self, entry_date, row):
|
def get_ageing_data(self, entry_date, row):
|
||||||
# [0-30, 30-60, 60-90, 90-120, 120-above]
|
# [0-30, 30-60, 60-90, 90-120, 120-above]
|
||||||
row.range1 = row.range2 = row.range3 = row.range4 = row.range5 = 0.0
|
row.range1 = row.range2 = row.range3 = row.range4 = row.range5 = 0.0
|
||||||
|
|||||||
@@ -93,4 +93,3 @@ def make_credit_note(docname):
|
|||||||
cost_center = 'Main - _TC2',
|
cost_center = 'Main - _TC2',
|
||||||
is_return = 1,
|
is_return = 1,
|
||||||
return_against = docname)
|
return_against = docname)
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class AccountsReceivableSummary(ReceivablePayableReport):
|
|||||||
"range3": 0.0,
|
"range3": 0.0,
|
||||||
"range4": 0.0,
|
"range4": 0.0,
|
||||||
"range5": 0.0,
|
"range5": 0.0,
|
||||||
|
"total_due": 0.0,
|
||||||
"sales_person": []
|
"sales_person": []
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -135,3 +136,6 @@ class AccountsReceivableSummary(ReceivablePayableReport):
|
|||||||
"{range3}-{range4}".format(range3=cint(self.filters["range3"])+ 1, range4=self.filters["range4"]),
|
"{range3}-{range4}".format(range3=cint(self.filters["range3"])+ 1, range4=self.filters["range4"]),
|
||||||
"{range4}-{above}".format(range4=cint(self.filters["range4"])+ 1, above=_("Above"))]):
|
"{range4}-{above}".format(range4=cint(self.filters["range4"])+ 1, above=_("Above"))]):
|
||||||
self.add_column(label=label, fieldname='range' + str(i+1))
|
self.add_column(label=label, fieldname='range' + str(i+1))
|
||||||
|
|
||||||
|
# Add column for total due amount
|
||||||
|
self.add_column(label="Total Amount Due", fieldname='total_due')
|
||||||
|
|||||||
@@ -92,4 +92,3 @@ frappe.query_reports["Budget Variance Report"] = {
|
|||||||
erpnext.dimension_filters.forEach((dimension) => {
|
erpnext.dimension_filters.forEach((dimension) => {
|
||||||
frappe.query_reports["Budget Variance Report"].filters[4].options.push(dimension["document_type"]);
|
frappe.query_reports["Budget Variance Report"].filters[4].options.push(dimension["document_type"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ def execute(filters=None):
|
|||||||
GROUP BY parent''',{'dimension':[dimension]})
|
GROUP BY parent''',{'dimension':[dimension]})
|
||||||
if DCC_allocation:
|
if DCC_allocation:
|
||||||
filters['budget_against_filter'] = [DCC_allocation[0][0]]
|
filters['budget_against_filter'] = [DCC_allocation[0][0]]
|
||||||
cam_map = get_dimension_account_month_map(filters)
|
ddc_cam_map = get_dimension_account_month_map(filters)
|
||||||
dimension_items = cam_map.get(DCC_allocation[0][0])
|
dimension_items = ddc_cam_map.get(DCC_allocation[0][0])
|
||||||
if dimension_items:
|
if dimension_items:
|
||||||
data = get_final_data(dimension, dimension_items, filters, period_month_ranges, data, DCC_allocation[0][1])
|
data = get_final_data(dimension, dimension_items, filters, period_month_ranges, data, DCC_allocation[0][1])
|
||||||
|
|
||||||
@@ -48,7 +48,6 @@ def execute(filters=None):
|
|||||||
return columns, data, None, chart
|
return columns, data, None, chart
|
||||||
|
|
||||||
def get_final_data(dimension, dimension_items, filters, period_month_ranges, data, DCC_allocation):
|
def get_final_data(dimension, dimension_items, filters, period_month_ranges, data, DCC_allocation):
|
||||||
|
|
||||||
for account, monthwise_data in iteritems(dimension_items):
|
for account, monthwise_data in iteritems(dimension_items):
|
||||||
row = [dimension, account]
|
row = [dimension, account]
|
||||||
totals = [0, 0, 0]
|
totals = [0, 0, 0]
|
||||||
@@ -400,4 +399,3 @@ def get_chart_data(filters, columns, data):
|
|||||||
},
|
},
|
||||||
'type' : 'bar'
|
'type' : 'bar'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -210,10 +210,10 @@ def get_data(companies, root_type, balance_must_be, fiscal_year, filters=None, i
|
|||||||
company_currency = get_company_currency(filters)
|
company_currency = get_company_currency(filters)
|
||||||
|
|
||||||
if filters.filter_based_on == 'Fiscal Year':
|
if filters.filter_based_on == 'Fiscal Year':
|
||||||
start_date = fiscal_year.year_start_date
|
start_date = fiscal_year.year_start_date if filters.report != 'Balance Sheet' else None
|
||||||
end_date = fiscal_year.year_end_date
|
end_date = fiscal_year.year_end_date
|
||||||
else:
|
else:
|
||||||
start_date = filters.period_start_date
|
start_date = filters.period_start_date if filters.report != 'Balance Sheet' else None
|
||||||
end_date = filters.period_end_date
|
end_date = filters.period_end_date
|
||||||
|
|
||||||
gl_entries_by_account = {}
|
gl_entries_by_account = {}
|
||||||
|
|||||||
@@ -176,4 +176,3 @@ frappe.query_reports["General Ledger"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.add_dimensions('General Ledger', 15)
|
erpnext.utils.add_dimensions('General Ledger', 15)
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user