mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
Merge branch 'frappe:develop' into balancesheet-report-summary
This commit is contained in:
130
.github/workflows/run-indinvidual-tests.yml
vendored
Normal file
130
.github/workflows/run-indinvidual-tests.yml
vendored
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
name: Individual
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: server-individual-tests-develop-${{ github.event_name }}-${{ github.event.number || github.event_name == 'workflow_dispatch' && github.run_id || '' }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
discover:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
- name: Clone
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- id: set-matrix
|
||||||
|
run: |
|
||||||
|
# Use grep and find to get the list of test files
|
||||||
|
matrix=$(find . -path '*/doctype/*/test_*.py' | xargs grep -l 'def test_' | awk '{
|
||||||
|
# Remove ./ prefix, file extension, and replace / with .
|
||||||
|
gsub(/^\.\//, "", $0)
|
||||||
|
gsub(/\.py$/, "", $0)
|
||||||
|
gsub(/\//, ".", $0)
|
||||||
|
# Add to array
|
||||||
|
tests[NR] = $0
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
# Start JSON array
|
||||||
|
printf "{\n \"include\": [\n"
|
||||||
|
# Loop through array and create JSON objects
|
||||||
|
for (i=1; i<=NR; i++) {
|
||||||
|
printf " {\"test\": \"%s\"}", tests[i]
|
||||||
|
if (i < NR) printf ","
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
# Close JSON array
|
||||||
|
printf " ]\n}"
|
||||||
|
}')
|
||||||
|
|
||||||
|
# Output the matrix
|
||||||
|
echo "matrix=$(echo "$matrix" | jq -c)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# For debugging (optional)
|
||||||
|
echo "Generated matrix:"
|
||||||
|
echo "$matrix"
|
||||||
|
test:
|
||||||
|
needs: discover
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 60
|
||||||
|
env:
|
||||||
|
NODE_ENV: "production"
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix: ${{fromJson(needs.discover.outputs.matrix)}}
|
||||||
|
|
||||||
|
name: Test
|
||||||
|
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mariadb:10.6
|
||||||
|
env:
|
||||||
|
MARIADB_ROOT_PASSWORD: 'root'
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.12'
|
||||||
|
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
|
- name: Add to Hosts
|
||||||
|
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
|
||||||
|
|
||||||
|
- name: Cache pip
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
|
${{ runner.os }}-
|
||||||
|
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v4
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||||
|
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
id: yarn-cache
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
|
||||||
|
env:
|
||||||
|
DB: mariadb
|
||||||
|
TYPE: server
|
||||||
|
FRAPPE_USER: ${{ github.event.inputs.user }}
|
||||||
|
FRAPPE_BRANCH: ${{ github.event.inputs.branch }}
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: 'cd ~/frappe-bench/ && bench --site test_site run-tests --app erpnext --module ${{ matrix.test }}'
|
||||||
2
.github/workflows/server-tests-mariadb.yml
vendored
2
.github/workflows/server-tests-mariadb.yml
vendored
@@ -120,7 +120,7 @@ jobs:
|
|||||||
FRAPPE_BRANCH: ${{ github.event.inputs.branch }}
|
FRAPPE_BRANCH: ${{ github.event.inputs.branch }}
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: 'cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --total-builds 4 --build-number ${{ matrix.container }}'
|
run: 'cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --total-builds ${{ strategy.job-total }} --build-number ${{ matrix.container }}'
|
||||||
env:
|
env:
|
||||||
TYPE: server
|
TYPE: server
|
||||||
CAPTURE_COVERAGE: ${{ github.event_name != 'pull_request' }}
|
CAPTURE_COVERAGE: ${{ github.event_name != 'pull_request' }}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.test_runner import make_test_records
|
from frappe.tests import IntegrationTestCase
|
||||||
|
from frappe.tests.utils import make_test_records
|
||||||
from frappe.utils import nowdate
|
from frappe.utils import nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.account import (
|
from erpnext.accounts.doctype.account.account import (
|
||||||
@@ -15,10 +14,10 @@ from erpnext.accounts.doctype.account.account import (
|
|||||||
)
|
)
|
||||||
from erpnext.stock import get_company_default_inventory_account, get_warehouse_account
|
from erpnext.stock import get_company_default_inventory_account, get_warehouse_account
|
||||||
|
|
||||||
test_dependencies = ["Company"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Company"]
|
||||||
|
|
||||||
|
|
||||||
class TestAccount(unittest.TestCase):
|
class TestAccount(IntegrationTestCase):
|
||||||
def test_rename_account(self):
|
def test_rename_account(self):
|
||||||
if not frappe.db.exists("Account", "1210 - Debtors - _TC"):
|
if not frappe.db.exists("Account", "1210 - Debtors - _TC"):
|
||||||
acc = frappe.new_doc("Account")
|
acc = frappe.new_doc("Account")
|
||||||
@@ -328,7 +327,7 @@ class TestAccount(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def _make_test_records(verbose=None):
|
def _make_test_records(verbose=None):
|
||||||
from frappe.test_runner import make_test_objects
|
from frappe.tests.utils import make_test_objects
|
||||||
|
|
||||||
accounts = [
|
accounts = [
|
||||||
# [account_name, parent_account, is_group]
|
# [account_name, parent_account, is_group]
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype": "Account",
|
|
||||||
"name": "_Test Account 1"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
3
erpnext/accounts/doctype/account/test_records.toml
Normal file
3
erpnext/accounts/doctype/account/test_records.toml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[[Account]]
|
||||||
|
name = "_Test Account 1"
|
||||||
|
|
||||||
@@ -2,8 +2,17 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestAccountClosingBalance(FrappeTestCase):
|
class UnitTestAccountClosingBalance(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for AccountClosingBalance.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestAccountClosingBalance(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
|
|
||||||
test_dependencies = ["Cost Center", "Location", "Warehouse", "Department"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Cost Center", "Location", "Warehouse", "Department"]
|
||||||
|
|
||||||
|
|
||||||
class TestAccountingDimension(unittest.TestCase):
|
class TestAccountingDimension(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
create_dimension()
|
create_dimension()
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension imp
|
|||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError
|
from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError
|
||||||
|
|
||||||
test_dependencies = ["Location", "Cost Center", "Department"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Location", "Cost Center", "Department"]
|
||||||
|
|
||||||
|
|
||||||
class TestAccountingDimensionFilter(unittest.TestCase):
|
class TestAccountingDimensionFilter(unittest.TestCase):
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import add_months, nowdate
|
from frappe.utils import add_months, nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.accounting_period.accounting_period import (
|
from erpnext.accounts.doctype.accounting_period.accounting_period import (
|
||||||
@@ -12,10 +12,10 @@ from erpnext.accounts.doctype.accounting_period.accounting_period import (
|
|||||||
)
|
)
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
|
|
||||||
test_dependencies = ["Item"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]
|
||||||
|
|
||||||
|
|
||||||
class TestAccountingPeriod(unittest.TestCase):
|
class TestAccountingPeriod(IntegrationTestCase):
|
||||||
def test_overlap(self):
|
def test_overlap(self):
|
||||||
ap1 = create_accounting_period(
|
ap1 = create_accounting_period(
|
||||||
start_date="2018-04-01", end_date="2018-06-30", company="Wind Power LLC"
|
start_date="2018-04-01", end_date="2018-06-30", company="Wind Power LLC"
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestAccountsSettings(unittest.TestCase):
|
class TestAccountsSettings(IntegrationTestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# Just in case `save` method succeeds, we need to take things back to default so that other tests
|
# Just in case `save` method succeeds, we need to take things back to default so that other tests
|
||||||
# don't break
|
# don't break
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestBank(unittest.TestCase):
|
|
||||||
|
class TestBank(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -208,8 +208,54 @@
|
|||||||
"label": "Disabled"
|
"label": "Disabled"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [],
|
"links": [
|
||||||
"modified": "2024-03-27 13:06:37.049542",
|
{
|
||||||
|
"group": "Transactions",
|
||||||
|
"link_doctype": "Payment Request",
|
||||||
|
"link_fieldname": "bank_account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Transactions",
|
||||||
|
"link_doctype": "Payment Order",
|
||||||
|
"link_fieldname": "bank_account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Transactions",
|
||||||
|
"link_doctype": "Bank Guarantee",
|
||||||
|
"link_fieldname": "bank_account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Transactions",
|
||||||
|
"link_doctype": "Payroll Entry",
|
||||||
|
"link_fieldname": "bank_account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Transactions",
|
||||||
|
"link_doctype": "Bank Transaction",
|
||||||
|
"link_fieldname": "bank_account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Accounting",
|
||||||
|
"link_doctype": "Payment Entry",
|
||||||
|
"link_fieldname": "bank_account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Accounting",
|
||||||
|
"link_doctype": "Journal Entry",
|
||||||
|
"link_fieldname": "bank_account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Party",
|
||||||
|
"link_doctype": "Customer",
|
||||||
|
"link_fieldname": "default_bank_account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Party",
|
||||||
|
"link_doctype": "Supplier",
|
||||||
|
"link_fieldname": "default_bank_account"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"modified": "2024-09-24 06:57:41.292970",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Bank Account",
|
"name": "Bank Account",
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
from frappe import _
|
|
||||||
|
|
||||||
|
|
||||||
def get_data():
|
|
||||||
return {
|
|
||||||
"fieldname": "bank_account",
|
|
||||||
"non_standard_fieldnames": {
|
|
||||||
"Customer": "default_bank_account",
|
|
||||||
"Supplier": "default_bank_account",
|
|
||||||
},
|
|
||||||
"transactions": [
|
|
||||||
{
|
|
||||||
"label": _("Payments"),
|
|
||||||
"items": ["Payment Entry", "Payment Request", "Payment Order", "Payroll Entry"],
|
|
||||||
},
|
|
||||||
{"label": _("Party"), "items": ["Customer", "Supplier"]},
|
|
||||||
{"items": ["Bank Guarantee"]},
|
|
||||||
{"items": ["Journal Entry"]},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import ValidationError
|
from frappe import ValidationError
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
# test_records = frappe.get_test_records('Bank Account')
|
|
||||||
|
|
||||||
|
|
||||||
class TestBankAccount(unittest.TestCase):
|
class TestBankAccount(IntegrationTestCase):
|
||||||
def test_validate_iban(self):
|
def test_validate_iban(self):
|
||||||
valid_ibans = [
|
valid_ibans = [
|
||||||
"GB82 WEST 1234 5698 7654 32",
|
"GB82 WEST 1234 5698 7654 32",
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestBankAccountSubtype(unittest.TestCase):
|
|
||||||
|
class TestBankAccountSubtype(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestBankAccountType(unittest.TestCase):
|
|
||||||
|
class TestBankAccountType(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -108,8 +108,18 @@ class BankClearance(Document):
|
|||||||
if not d.clearance_date:
|
if not d.clearance_date:
|
||||||
d.clearance_date = None
|
d.clearance_date = None
|
||||||
|
|
||||||
payment_entry = frappe.get_doc(d.payment_document, d.payment_entry)
|
if d.payment_document == "Sales Invoice":
|
||||||
payment_entry.db_set("clearance_date", d.clearance_date)
|
frappe.db.set_value(
|
||||||
|
"Sales Invoice Payment",
|
||||||
|
{"parent": d.payment_entry, "account": self.get("account"), "amount": [">", 0]},
|
||||||
|
"clearance_date",
|
||||||
|
d.clearance_date,
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
frappe.db.set_value(
|
||||||
|
d.payment_document, d.payment_entry, "clearance_date", d.clearance_date
|
||||||
|
)
|
||||||
|
|
||||||
clearance_date_updated = True
|
clearance_date_updated = True
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,34 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import add_months, getdate
|
from frappe.utils import add_months, getdate
|
||||||
|
|
||||||
|
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
||||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
||||||
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
|
from erpnext.stock.doctype.item.test_item import create_item
|
||||||
|
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
|
||||||
from erpnext.tests.utils import if_lending_app_installed, if_lending_app_not_installed
|
from erpnext.tests.utils import if_lending_app_installed, if_lending_app_not_installed
|
||||||
|
|
||||||
|
|
||||||
class TestBankClearance(unittest.TestCase):
|
class TestBankClearance(IntegrationTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
create_warehouse(
|
||||||
|
warehouse_name="_Test Warehouse",
|
||||||
|
properties={"parent_warehouse": "All Warehouses - _TC"},
|
||||||
|
company="_Test Company",
|
||||||
|
)
|
||||||
|
create_item("_Test Item")
|
||||||
|
create_cost_center(cost_center_name="_Test Cost Center", company="_Test Company")
|
||||||
|
|
||||||
clear_payment_entries()
|
clear_payment_entries()
|
||||||
clear_loan_transactions()
|
clear_loan_transactions()
|
||||||
|
clear_pos_sales_invoices()
|
||||||
make_bank_account()
|
make_bank_account()
|
||||||
add_transactions()
|
add_transactions()
|
||||||
|
|
||||||
@@ -83,11 +96,41 @@ class TestBankClearance(unittest.TestCase):
|
|||||||
bank_clearance.get_payment_entries()
|
bank_clearance.get_payment_entries()
|
||||||
self.assertEqual(len(bank_clearance.payment_entries), 3)
|
self.assertEqual(len(bank_clearance.payment_entries), 3)
|
||||||
|
|
||||||
|
def test_update_clearance_date_on_si(self):
|
||||||
|
sales_invoice = make_pos_sales_invoice()
|
||||||
|
|
||||||
|
date = getdate()
|
||||||
|
bank_clearance = frappe.get_doc("Bank Clearance")
|
||||||
|
bank_clearance.account = "_Test Bank Clearance - _TC"
|
||||||
|
bank_clearance.from_date = add_months(date, -1)
|
||||||
|
bank_clearance.to_date = date
|
||||||
|
bank_clearance.include_pos_transactions = 1
|
||||||
|
bank_clearance.get_payment_entries()
|
||||||
|
|
||||||
|
self.assertNotEqual(len(bank_clearance.payment_entries), 0)
|
||||||
|
for payment in bank_clearance.payment_entries:
|
||||||
|
if payment.payment_entry == sales_invoice.name:
|
||||||
|
payment.clearance_date = date
|
||||||
|
|
||||||
|
bank_clearance.update_clearance_date()
|
||||||
|
|
||||||
|
si_clearance_date = frappe.db.get_value(
|
||||||
|
"Sales Invoice Payment",
|
||||||
|
{"parent": sales_invoice.name, "account": bank_clearance.account},
|
||||||
|
"clearance_date",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(si_clearance_date, date)
|
||||||
|
|
||||||
|
|
||||||
def clear_payment_entries():
|
def clear_payment_entries():
|
||||||
frappe.db.delete("Payment Entry")
|
frappe.db.delete("Payment Entry")
|
||||||
|
|
||||||
|
|
||||||
|
def clear_pos_sales_invoices():
|
||||||
|
frappe.db.delete("Sales Invoice", {"is_pos": 1})
|
||||||
|
|
||||||
|
|
||||||
@if_lending_app_installed
|
@if_lending_app_installed
|
||||||
def clear_loan_transactions():
|
def clear_loan_transactions():
|
||||||
for dt in [
|
for dt in [
|
||||||
@@ -115,9 +158,45 @@ def add_transactions():
|
|||||||
|
|
||||||
|
|
||||||
def make_payment_entry():
|
def make_payment_entry():
|
||||||
pi = make_purchase_invoice(supplier="_Test Supplier", qty=1, rate=690)
|
from erpnext.buying.doctype.supplier.test_supplier import create_supplier
|
||||||
|
|
||||||
|
supplier = create_supplier(supplier_name="_Test Supplier")
|
||||||
|
pi = make_purchase_invoice(
|
||||||
|
supplier=supplier,
|
||||||
|
supplier_warehouse="_Test Warehouse - _TC",
|
||||||
|
expense_account="Cost of Goods Sold - _TC",
|
||||||
|
uom="Nos",
|
||||||
|
qty=1,
|
||||||
|
rate=690,
|
||||||
|
)
|
||||||
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank Clearance - _TC")
|
pe = get_payment_entry("Purchase Invoice", pi.name, bank_account="_Test Bank Clearance - _TC")
|
||||||
pe.reference_no = "Conrad Oct 18"
|
pe.reference_no = "Conrad Oct 18"
|
||||||
pe.reference_date = "2018-10-24"
|
pe.reference_date = "2018-10-24"
|
||||||
pe.insert()
|
pe.insert()
|
||||||
pe.submit()
|
pe.submit()
|
||||||
|
|
||||||
|
|
||||||
|
def make_pos_sales_invoice():
|
||||||
|
from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import (
|
||||||
|
make_customer,
|
||||||
|
)
|
||||||
|
|
||||||
|
mode_of_payment = frappe.get_doc({"doctype": "Mode of Payment", "name": "Cash"})
|
||||||
|
|
||||||
|
if not frappe.db.get_value("Mode of Payment Account", {"company": "_Test Company", "parent": "Cash"}):
|
||||||
|
mode_of_payment.append(
|
||||||
|
"accounts", {"company": "_Test Company", "default_account": "_Test Bank Clearance - _TC"}
|
||||||
|
)
|
||||||
|
mode_of_payment.save()
|
||||||
|
|
||||||
|
customer = make_customer(customer="_Test Customer")
|
||||||
|
|
||||||
|
si = create_sales_invoice(customer=customer, item="_Test Item", is_pos=1, qty=1, rate=1000, do_not_save=1)
|
||||||
|
si.set("payments", [])
|
||||||
|
si.append(
|
||||||
|
"payments", {"mode_of_payment": "Cash", "account": "_Test Bank Clearance - _TC", "amount": 1000}
|
||||||
|
)
|
||||||
|
si.insert()
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
return si
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestBankGuarantee(unittest.TestCase):
|
|
||||||
|
class TestBankGuarantee(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import qb
|
from frappe import qb
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import add_days, today
|
from frappe.utils import add_days, today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import (
|
from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import (
|
||||||
@@ -15,7 +15,7 @@ from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_pay
|
|||||||
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
||||||
|
|
||||||
|
|
||||||
class TestBankReconciliationTool(AccountsTestMixin, FrappeTestCase):
|
class TestBankReconciliationTool(AccountsTestMixin, IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.create_company()
|
self.create_company()
|
||||||
self.create_customer()
|
self.create_customer()
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies and Contributors
|
# Copyright (c) 2020, Frappe Technologies and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestBankStatementImport(unittest.TestCase):
|
|
||||||
|
class TestBankStatementImport(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -2,13 +2,22 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
from frappe.utils import nowdate
|
from frappe.utils import nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import create_bank_account
|
from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import create_bank_account
|
||||||
|
|
||||||
|
|
||||||
class TestAutoMatchParty(FrappeTestCase):
|
class UnitTestBankTransaction(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for BankTransaction.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestAutoMatchParty(IntegrationTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
create_bank_account()
|
create_bank_account()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import json
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import utils
|
from frappe import utils
|
||||||
from frappe.model.docstatus import DocStatus
|
from frappe.model.docstatus import DocStatus
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import (
|
from erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool import (
|
||||||
get_linked_payments,
|
get_linked_payments,
|
||||||
@@ -18,10 +18,19 @@ from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make
|
|||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
from erpnext.tests.utils import if_lending_app_installed
|
from erpnext.tests.utils import if_lending_app_installed
|
||||||
|
|
||||||
test_dependencies = ["Item", "Cost Center"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "Cost Center"]
|
||||||
|
|
||||||
|
|
||||||
class TestBankTransaction(FrappeTestCase):
|
class UnitTestBankTransaction(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for BankTransaction.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestBankTransaction(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
for dt in [
|
for dt in [
|
||||||
"Bank Transaction",
|
"Bank Transaction",
|
||||||
|
|||||||
@@ -2,8 +2,17 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestBisectAccountingStatements(FrappeTestCase):
|
class UnitTestBisectAccountingStatements(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for BisectAccountingStatements.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestBisectAccountingStatements(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -2,8 +2,17 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestBisectNodes(FrappeTestCase):
|
class UnitTestBisectNodes(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for BisectNodes.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestBisectNodes(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import now_datetime, nowdate
|
from frappe.utils import now_datetime, nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.budget.budget import BudgetError, get_actual_expense
|
from erpnext.accounts.doctype.budget.budget import BudgetError, get_actual_expense
|
||||||
@@ -11,10 +11,10 @@ from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journ
|
|||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
||||||
|
|
||||||
test_dependencies = ["Monthly Distribution"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Monthly Distribution"]
|
||||||
|
|
||||||
|
|
||||||
class TestBudget(unittest.TestCase):
|
class TestBudget(IntegrationTestCase):
|
||||||
def test_monthly_budget_crossed_ignore(self):
|
def test_monthly_budget_crossed_ignore(self):
|
||||||
set_total_expense_zero(nowdate(), "cost_center")
|
set_total_expense_zero(nowdate(), "cost_center")
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestCashierClosing(unittest.TestCase):
|
|
||||||
|
class TestCashierClosing(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestChartofAccountsImporter(unittest.TestCase):
|
|
||||||
|
class TestChartofAccountsImporter(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
# test_records = frappe.get_test_records('Cheque Print Template')
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestChequePrintTemplate(unittest.TestCase):
|
class TestChequePrintTemplate(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
test_records = frappe.get_test_records("Cost Center")
|
|
||||||
|
|
||||||
|
|
||||||
class TestCostCenter(unittest.TestCase):
|
class TestCostCenter(IntegrationTestCase):
|
||||||
def test_cost_center_creation_against_child_node(self):
|
def test_cost_center_creation_against_child_node(self):
|
||||||
if not frappe.db.get_value("Cost Center", {"name": "_Test Cost Center 2 - _TC"}):
|
|
||||||
frappe.get_doc(test_records[1]).insert()
|
|
||||||
|
|
||||||
cost_center = frappe.get_doc(
|
cost_center = frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Cost Center",
|
"doctype": "Cost Center",
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"cost_center_name": "_Test Cost Center",
|
|
||||||
"doctype": "Cost Center",
|
|
||||||
"is_group": 0,
|
|
||||||
"parent_cost_center": "_Test Company - _TC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"cost_center_name": "_Test Cost Center 2",
|
|
||||||
"doctype": "Cost Center",
|
|
||||||
"is_group": 0,
|
|
||||||
"parent_cost_center": "_Test Company - _TC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"cost_center_name": "_Test Write Off Cost Center",
|
|
||||||
"doctype": "Cost Center",
|
|
||||||
"is_group": 0,
|
|
||||||
"parent_cost_center": "_Test Company - _TC"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
18
erpnext/accounts/doctype/cost_center/test_records.toml
Normal file
18
erpnext/accounts/doctype/cost_center/test_records.toml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[["Cost Center"]]
|
||||||
|
company = "_Test Company"
|
||||||
|
cost_center_name = "_Test Cost Center"
|
||||||
|
is_group = 0
|
||||||
|
parent_cost_center = "_Test Company - _TC"
|
||||||
|
|
||||||
|
[["Cost Center"]]
|
||||||
|
company = "_Test Company"
|
||||||
|
cost_center_name = "_Test Cost Center 2"
|
||||||
|
is_group = 0
|
||||||
|
parent_cost_center = "_Test Company - _TC"
|
||||||
|
|
||||||
|
[["Cost Center"]]
|
||||||
|
company = "_Test Company"
|
||||||
|
cost_center_name = "_Test Write Off Cost Center"
|
||||||
|
is_group = 0
|
||||||
|
parent_cost_center = "_Test Company - _TC"
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import add_days, today
|
from frappe.utils import add_days, today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center
|
||||||
@@ -17,7 +17,7 @@ from erpnext.accounts.doctype.cost_center_allocation.cost_center_allocation impo
|
|||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
|
|
||||||
|
|
||||||
class TestCostCenterAllocation(unittest.TestCase):
|
class TestCostCenterAllocation(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
cost_centers = [
|
cost_centers = [
|
||||||
"Main Cost Center 1",
|
"Main Cost Center 1",
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
|
|
||||||
test_dependencies = ["Item"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]
|
||||||
|
|
||||||
|
|
||||||
def test_create_test_data():
|
def test_create_test_data():
|
||||||
@@ -110,7 +110,7 @@ def test_create_test_data():
|
|||||||
coupon_code.insert()
|
coupon_code.insert()
|
||||||
|
|
||||||
|
|
||||||
class TestCouponCode(unittest.TestCase):
|
class TestCouponCode(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
test_create_test_data()
|
test_create_test_data()
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ def get_api_endpoint(service_provider: str | None = None, use_http: bool = False
|
|||||||
if service_provider == "exchangerate.host":
|
if service_provider == "exchangerate.host":
|
||||||
api = "api.exchangerate.host/convert"
|
api = "api.exchangerate.host/convert"
|
||||||
elif service_provider == "frankfurter.app":
|
elif service_provider == "frankfurter.app":
|
||||||
api = "frankfurter.app/{transaction_date}"
|
api = "api.frankfurter.app/{transaction_date}"
|
||||||
|
|
||||||
protocol = "https://"
|
protocol = "https://"
|
||||||
if use_http:
|
if use_http:
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# Copyright (c) 2021, Wahni Green Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2021, Wahni Green Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestCurrencyExchangeSettings(unittest.TestCase):
|
|
||||||
|
class TestCurrencyExchangeSettings(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -220,19 +220,31 @@ def get_linked_dunnings_as_per_state(sales_invoice, state):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_dunning_letter_text(dunning_type, doc, language=None):
|
def get_dunning_letter_text(dunning_type: str, doc: str | dict, language: str | None = None) -> dict:
|
||||||
|
DOCTYPE = "Dunning Letter Text"
|
||||||
|
FIELDS = ["body_text", "closing_text", "language"]
|
||||||
|
|
||||||
if isinstance(doc, str):
|
if isinstance(doc, str):
|
||||||
doc = json.loads(doc)
|
doc = json.loads(doc)
|
||||||
|
|
||||||
|
if not language:
|
||||||
|
language = doc.get("language")
|
||||||
|
|
||||||
if language:
|
if language:
|
||||||
filters = {"parent": dunning_type, "language": language}
|
letter_text = frappe.db.get_value(
|
||||||
else:
|
DOCTYPE, {"parent": dunning_type, "language": language}, FIELDS, as_dict=1
|
||||||
filters = {"parent": dunning_type, "is_default_language": 1}
|
)
|
||||||
letter_text = frappe.db.get_value(
|
|
||||||
"Dunning Letter Text", filters, ["body_text", "closing_text", "language"], as_dict=1
|
if not letter_text:
|
||||||
)
|
letter_text = frappe.db.get_value(
|
||||||
if letter_text:
|
DOCTYPE, {"parent": dunning_type, "is_default_language": 1}, FIELDS, as_dict=1
|
||||||
return {
|
)
|
||||||
"body_text": frappe.render_template(letter_text.body_text, doc),
|
|
||||||
"closing_text": frappe.render_template(letter_text.closing_text, doc),
|
if not letter_text:
|
||||||
"language": letter_text.language,
|
return {}
|
||||||
}
|
|
||||||
|
return {
|
||||||
|
"body_text": frappe.render_template(letter_text.body_text, doc),
|
||||||
|
"closing_text": frappe.render_template(letter_text.closing_text, doc),
|
||||||
|
"language": letter_text.language,
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
from frappe.utils import add_days, nowdate, today
|
from frappe.utils import add_days, nowdate, today
|
||||||
|
|
||||||
from erpnext import get_default_cost_center
|
from erpnext import get_default_cost_center
|
||||||
@@ -16,10 +16,19 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import (
|
|||||||
create_sales_invoice_against_cost_center,
|
create_sales_invoice_against_cost_center,
|
||||||
)
|
)
|
||||||
|
|
||||||
test_dependencies = ["Company", "Cost Center"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Company", "Cost Center"]
|
||||||
|
|
||||||
|
|
||||||
class TestDunning(FrappeTestCase):
|
class UnitTestDunning(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for Dunning.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestDunning(IntegrationTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestDunningType(unittest.TestCase):
|
|
||||||
|
class TestDunningType(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype": "Dunning Type",
|
|
||||||
"dunning_type": "_Test First Notice",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"is_default": 1,
|
|
||||||
"dunning_fee": 0.0,
|
|
||||||
"rate_of_interest": 0.0,
|
|
||||||
"dunning_letter_text": [
|
|
||||||
{
|
|
||||||
"language": "en",
|
|
||||||
"body_text": "We have still not received payment for our invoice",
|
|
||||||
"closing_text": "We kindly request that you pay the outstanding amount immediately, including interest and late fees."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"income_account": "Sales - _TC",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Dunning Type",
|
|
||||||
"dunning_type": "_Test Second Notice",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"is_default": 0,
|
|
||||||
"dunning_fee": 10.0,
|
|
||||||
"rate_of_interest": 10.0,
|
|
||||||
"dunning_letter_text": [
|
|
||||||
{
|
|
||||||
"language": "en",
|
|
||||||
"body_text": "We have still not received payment for our invoice",
|
|
||||||
"closing_text": "We kindly request that you pay the outstanding amount immediately, including interest and late fees."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"income_account": "Sales - _TC",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
28
erpnext/accounts/doctype/dunning_type/test_records.toml
Normal file
28
erpnext/accounts/doctype/dunning_type/test_records.toml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
[["Dunning Type"]]
|
||||||
|
dunning_type = "_Test First Notice"
|
||||||
|
company = "_Test Company"
|
||||||
|
is_default = 1
|
||||||
|
dunning_fee = 0.0
|
||||||
|
rate_of_interest = 0.0
|
||||||
|
income_account = "Sales - _TC"
|
||||||
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
[["Dunning Type".dunning_letter_text]]
|
||||||
|
language = "en"
|
||||||
|
body_text = "We have still not received payment for our invoice"
|
||||||
|
closing_text = "We kindly request that you pay the outstanding amount immediately, including interest and late fees."
|
||||||
|
|
||||||
|
|
||||||
|
[["Dunning Type"]]
|
||||||
|
dunning_type = "_Test Second Notice"
|
||||||
|
company = "_Test Company"
|
||||||
|
is_default = 0
|
||||||
|
dunning_fee = 10.0
|
||||||
|
rate_of_interest = 10.0
|
||||||
|
income_account = "Sales - _TC"
|
||||||
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
[["Dunning Type".dunning_letter_text]]
|
||||||
|
language = "en"
|
||||||
|
body_text = "We have still not received payment for our invoice"
|
||||||
|
closing_text = "We kindly request that you pay the outstanding amount immediately, including interest and late fees."
|
||||||
|
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import add_days, flt, today
|
from frappe.utils import add_days, flt, today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
|
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
|
||||||
@@ -11,7 +11,7 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal
|
|||||||
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
||||||
|
|
||||||
|
|
||||||
class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase):
|
class TestExchangeRateRevaluation(AccountsTestMixin, IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.create_company()
|
self.create_company()
|
||||||
self.create_usd_receivable_account()
|
self.create_usd_receivable_account()
|
||||||
@@ -35,7 +35,7 @@ class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase):
|
|||||||
company_doc.unrealized_exchange_gain_loss_account = company_doc.exchange_gain_loss_account
|
company_doc.unrealized_exchange_gain_loss_account = company_doc.exchange_gain_loss_account
|
||||||
company_doc.save()
|
company_doc.save()
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0},
|
{"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0},
|
||||||
)
|
)
|
||||||
@@ -88,7 +88,7 @@ class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase):
|
|||||||
)[0]
|
)[0]
|
||||||
self.assertEqual(acc_balance.balance, 8500.0)
|
self.assertEqual(acc_balance.balance, 8500.0)
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0},
|
{"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0},
|
||||||
)
|
)
|
||||||
@@ -158,7 +158,7 @@ class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase):
|
|||||||
self.assertEqual(acc_balance.balance, 0.0)
|
self.assertEqual(acc_balance.balance, 0.0)
|
||||||
self.assertEqual(acc_balance.balance_in_account_currency, 0.0)
|
self.assertEqual(acc_balance.balance_in_account_currency, 0.0)
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0},
|
{"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0},
|
||||||
)
|
)
|
||||||
@@ -247,7 +247,7 @@ class TestExchangeRateRevaluation(AccountsTestMixin, FrappeTestCase):
|
|||||||
self.assertEqual(flt(acc_balance.balance, precision), 0.0)
|
self.assertEqual(flt(acc_balance.balance, precision), 0.0)
|
||||||
self.assertEqual(flt(acc_balance.balance_in_account_currency, precision), 0.0)
|
self.assertEqual(flt(acc_balance.balance_in_account_currency, precision), 0.0)
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0},
|
{"allow_multi_currency_invoices_against_single_party_account": 1, "allow_stale": 0},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
|
|
||||||
|
|
||||||
class TestFinanceBook(unittest.TestCase):
|
class TestFinanceBook(IntegrationTestCase):
|
||||||
def test_finance_book(self):
|
def test_finance_book(self):
|
||||||
finance_book = create_finance_book()
|
finance_book = create_finance_book()
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import now_datetime
|
from frappe.utils import now_datetime
|
||||||
|
|
||||||
test_ignore = ["Company"]
|
IGNORE_TEST_RECORD_DEPENDENCIES = ["Company"]
|
||||||
|
|
||||||
|
|
||||||
class TestFiscalYear(unittest.TestCase):
|
class TestFiscalYear(IntegrationTestCase):
|
||||||
def test_extra_year(self):
|
def test_extra_year(self):
|
||||||
if frappe.db.exists("Fiscal Year", "_Test Fiscal Year 2000"):
|
if frappe.db.exists("Fiscal Year", "_Test Fiscal Year 2000"):
|
||||||
frappe.delete_doc("Fiscal Year", "_Test Fiscal Year 2000")
|
frappe.delete_doc("Fiscal Year", "_Test Fiscal Year 2000")
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.naming import parse_naming_series
|
from frappe.model.naming import parse_naming_series
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.gl_entry.gl_entry import rename_gle_sle_docs
|
from erpnext.accounts.doctype.gl_entry.gl_entry import rename_gle_sle_docs
|
||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
|
|
||||||
|
|
||||||
class TestGLEntry(unittest.TestCase):
|
class TestGLEntry(IntegrationTestCase):
|
||||||
def test_round_off_entry(self):
|
def test_round_off_entry(self):
|
||||||
frappe.db.set_value("Company", "_Test Company", "round_off_account", "_Test Write Off - _TC")
|
frappe.db.set_value("Company", "_Test Company", "round_off_account", "_Test Write Off - _TC")
|
||||||
frappe.db.set_value("Company", "_Test Company", "round_off_cost_center", "_Test Cost Center - _TC")
|
frappe.db.set_value("Company", "_Test Company", "round_off_cost_center", "_Test Cost Center - _TC")
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import add_days, flt, nowdate
|
from frappe.utils import add_days, flt, nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.test_account import create_account
|
from erpnext.accounts.doctype.account.test_account import create_account
|
||||||
@@ -12,7 +12,7 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal
|
|||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_entries
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_entries
|
||||||
|
|
||||||
|
|
||||||
class TestInvoiceDiscounting(unittest.TestCase):
|
class TestInvoiceDiscounting(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.ar_credit = create_account(
|
self.ar_credit = create_account(
|
||||||
account_name="_Test Accounts Receivable Credit",
|
account_name="_Test Accounts Receivable Credit",
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestItemTaxTemplate(unittest.TestCase):
|
|
||||||
|
class TestItemTaxTemplate(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template",
|
|
||||||
"title": "_Test Account Excise Duty @ 10",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"taxes": [
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template Detail",
|
|
||||||
"parentfield": "taxes",
|
|
||||||
"tax_rate": 10,
|
|
||||||
"tax_type": "_Test Account Excise Duty - _TC"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template",
|
|
||||||
"title": "_Test Account Excise Duty @ 12",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"taxes": [
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template Detail",
|
|
||||||
"parentfield": "taxes",
|
|
||||||
"tax_rate": 12,
|
|
||||||
"tax_type": "_Test Account Excise Duty - _TC"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template",
|
|
||||||
"title": "_Test Account Excise Duty @ 15",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"taxes": [
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template Detail",
|
|
||||||
"parentfield": "taxes",
|
|
||||||
"tax_rate": 15,
|
|
||||||
"tax_type": "_Test Account Excise Duty - _TC"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template",
|
|
||||||
"title": "_Test Account Excise Duty @ 20",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"taxes": [
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template Detail",
|
|
||||||
"parentfield": "taxes",
|
|
||||||
"tax_rate": 20,
|
|
||||||
"tax_type": "_Test Account Excise Duty - _TC"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template",
|
|
||||||
"title": "_Test Item Tax Template 1",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"taxes": [
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template Detail",
|
|
||||||
"parentfield": "taxes",
|
|
||||||
"tax_rate": 5,
|
|
||||||
"tax_type": "_Test Account Excise Duty - _TC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template Detail",
|
|
||||||
"parentfield": "taxes",
|
|
||||||
"tax_rate": 10,
|
|
||||||
"tax_type": "_Test Account Education Cess - _TC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Item Tax Template Detail",
|
|
||||||
"parentfield": "taxes",
|
|
||||||
"tax_rate": 15,
|
|
||||||
"tax_type": "_Test Account S&H Education Cess - _TC"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
62
erpnext/accounts/doctype/item_tax_template/test_records.toml
Normal file
62
erpnext/accounts/doctype/item_tax_template/test_records.toml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
[["Item Tax Template"]]
|
||||||
|
title = "_Test Account Excise Duty @ 10"
|
||||||
|
company = "_Test Company"
|
||||||
|
[["Item Tax Template".taxes]]
|
||||||
|
doctype = "Item Tax Template Detail"
|
||||||
|
parentfield = "taxes"
|
||||||
|
tax_rate = 10
|
||||||
|
tax_type = "_Test Account Excise Duty - _TC"
|
||||||
|
|
||||||
|
|
||||||
|
[["Item Tax Template"]]
|
||||||
|
title = "_Test Account Excise Duty @ 12"
|
||||||
|
company = "_Test Company"
|
||||||
|
[["Item Tax Template".taxes]]
|
||||||
|
doctype = "Item Tax Template Detail"
|
||||||
|
parentfield = "taxes"
|
||||||
|
tax_rate = 12
|
||||||
|
tax_type = "_Test Account Excise Duty - _TC"
|
||||||
|
|
||||||
|
|
||||||
|
[["Item Tax Template"]]
|
||||||
|
title = "_Test Account Excise Duty @ 15"
|
||||||
|
company = "_Test Company"
|
||||||
|
[["Item Tax Template".taxes]]
|
||||||
|
doctype = "Item Tax Template Detail"
|
||||||
|
parentfield = "taxes"
|
||||||
|
tax_rate = 15
|
||||||
|
tax_type = "_Test Account Excise Duty - _TC"
|
||||||
|
|
||||||
|
|
||||||
|
[["Item Tax Template"]]
|
||||||
|
title = "_Test Account Excise Duty @ 20"
|
||||||
|
company = "_Test Company"
|
||||||
|
[["Item Tax Template".taxes]]
|
||||||
|
doctype = "Item Tax Template Detail"
|
||||||
|
parentfield = "taxes"
|
||||||
|
tax_rate = 20
|
||||||
|
tax_type = "_Test Account Excise Duty - _TC"
|
||||||
|
|
||||||
|
|
||||||
|
[["Item Tax Template"]]
|
||||||
|
title = "_Test Item Tax Template 1"
|
||||||
|
company = "_Test Company"
|
||||||
|
[["Item Tax Template".taxes]]
|
||||||
|
doctype = "Item Tax Template Detail"
|
||||||
|
parentfield = "taxes"
|
||||||
|
tax_rate = 5
|
||||||
|
tax_type = "_Test Account Excise Duty - _TC"
|
||||||
|
|
||||||
|
[["Item Tax Template".taxes]]
|
||||||
|
doctype = "Item Tax Template Detail"
|
||||||
|
parentfield = "taxes"
|
||||||
|
tax_rate = 10
|
||||||
|
tax_type = "_Test Account Education Cess - _TC"
|
||||||
|
|
||||||
|
[["Item Tax Template".taxes]]
|
||||||
|
doctype = "Item Tax Template Detail"
|
||||||
|
parentfield = "taxes"
|
||||||
|
tax_rate = 15
|
||||||
|
tax_type = "_Test Account S&H Education Cess - _TC"
|
||||||
|
|
||||||
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import change_settings
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
from frappe.utils import flt, nowdate
|
from frappe.utils import flt, nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
||||||
@@ -13,25 +10,36 @@ from erpnext.accounts.doctype.journal_entry.journal_entry import StockAccountInv
|
|||||||
from erpnext.exceptions import InvalidAccountCurrency
|
from erpnext.exceptions import InvalidAccountCurrency
|
||||||
|
|
||||||
|
|
||||||
class TestJournalEntry(unittest.TestCase):
|
class UnitTestJournalEntry(UnitTestCase):
|
||||||
@change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1})
|
"""
|
||||||
|
Unit tests for JournalEntry.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestJournalEntry(IntegrationTestCase):
|
||||||
|
@IntegrationTestCase.change_settings(
|
||||||
|
"Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}
|
||||||
|
)
|
||||||
def test_journal_entry_with_against_jv(self):
|
def test_journal_entry_with_against_jv(self):
|
||||||
jv_invoice = frappe.copy_doc(test_records[2])
|
jv_invoice = frappe.copy_doc(self.globalTestRecords["Journal Entry"][2])
|
||||||
base_jv = frappe.copy_doc(test_records[0])
|
base_jv = frappe.copy_doc(self.globalTestRecords["Journal Entry"][0])
|
||||||
self.jv_against_voucher_testcase(base_jv, jv_invoice)
|
self.jv_against_voucher_testcase(base_jv, jv_invoice)
|
||||||
|
|
||||||
def test_jv_against_sales_order(self):
|
def test_jv_against_sales_order(self):
|
||||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
|
|
||||||
sales_order = make_sales_order(do_not_save=True)
|
sales_order = make_sales_order(do_not_save=True)
|
||||||
base_jv = frappe.copy_doc(test_records[0])
|
base_jv = frappe.copy_doc(self.globalTestRecords["Journal Entry"][0])
|
||||||
self.jv_against_voucher_testcase(base_jv, sales_order)
|
self.jv_against_voucher_testcase(base_jv, sales_order)
|
||||||
|
|
||||||
def test_jv_against_purchase_order(self):
|
def test_jv_against_purchase_order(self):
|
||||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
||||||
|
|
||||||
purchase_order = create_purchase_order(do_not_save=True)
|
purchase_order = create_purchase_order(do_not_save=True)
|
||||||
base_jv = frappe.copy_doc(test_records[1])
|
base_jv = frappe.copy_doc(self.globalTestRecords["Journal Entry"][1])
|
||||||
self.jv_against_voucher_testcase(base_jv, purchase_order)
|
self.jv_against_voucher_testcase(base_jv, purchase_order)
|
||||||
|
|
||||||
def jv_against_voucher_testcase(self, base_jv, test_voucher):
|
def jv_against_voucher_testcase(self, base_jv, test_voucher):
|
||||||
@@ -515,6 +523,23 @@ class TestJournalEntry(unittest.TestCase):
|
|||||||
self.assertEqual(row.debit_in_account_currency, 100)
|
self.assertEqual(row.debit_in_account_currency, 100)
|
||||||
self.assertEqual(row.credit_in_account_currency, 100)
|
self.assertEqual(row.credit_in_account_currency, 100)
|
||||||
|
|
||||||
|
def test_transaction_exchange_rate_on_journals(self):
|
||||||
|
jv = make_journal_entry("_Test Bank - _TC", "_Test Receivable USD - _TC", 100, save=False)
|
||||||
|
jv.accounts[0].update({"debit_in_account_currency": 8500, "exchange_rate": 1})
|
||||||
|
jv.accounts[1].update({"party_type": "Customer", "party": "_Test Customer USD", "exchange_rate": 85})
|
||||||
|
jv.submit()
|
||||||
|
actual = frappe.db.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"voucher_no": jv.name, "is_cancelled": 0},
|
||||||
|
fields=["account", "transaction_exchange_rate"],
|
||||||
|
order_by="account",
|
||||||
|
)
|
||||||
|
expected = [
|
||||||
|
{"account": "_Test Bank - _TC", "transaction_exchange_rate": 1.0},
|
||||||
|
{"account": "_Test Receivable USD - _TC", "transaction_exchange_rate": 85.0},
|
||||||
|
]
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
|
||||||
def make_journal_entry(
|
def make_journal_entry(
|
||||||
account1,
|
account1,
|
||||||
@@ -563,6 +588,3 @@ def make_journal_entry(
|
|||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
return jv
|
return jv
|
||||||
|
|
||||||
|
|
||||||
test_records = frappe.get_test_records("Journal Entry")
|
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"cheque_date": "2013-03-14",
|
|
||||||
"cheque_no": "33",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"doctype": "Journal Entry",
|
|
||||||
"accounts": [
|
|
||||||
{
|
|
||||||
"account": "Debtors - _TC",
|
|
||||||
"party_type": "Customer",
|
|
||||||
"party": "_Test Customer",
|
|
||||||
"credit_in_account_currency": 400.0,
|
|
||||||
"debit_in_account_currency": 0.0,
|
|
||||||
"doctype": "Journal Entry Account",
|
|
||||||
"parentfield": "accounts",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "_Test Bank - _TC",
|
|
||||||
"credit_in_account_currency": 0.0,
|
|
||||||
"debit_in_account_currency": 400.0,
|
|
||||||
"doctype": "Journal Entry Account",
|
|
||||||
"parentfield": "accounts",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"naming_series": "_T-Journal Entry-",
|
|
||||||
"posting_date": "2013-02-14",
|
|
||||||
"user_remark": "test",
|
|
||||||
"voucher_type": "Bank Entry"
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"cheque_date": "2013-02-14",
|
|
||||||
"cheque_no": "33",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"doctype": "Journal Entry",
|
|
||||||
"accounts": [
|
|
||||||
{
|
|
||||||
"account": "_Test Payable - _TC",
|
|
||||||
"party_type": "Supplier",
|
|
||||||
"party": "_Test Supplier",
|
|
||||||
"credit_in_account_currency": 0.0,
|
|
||||||
"debit_in_account_currency": 400.0,
|
|
||||||
"doctype": "Journal Entry Account",
|
|
||||||
"parentfield": "accounts",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "_Test Bank - _TC",
|
|
||||||
"credit_in_account_currency": 400.0,
|
|
||||||
"debit_in_account_currency": 0.0,
|
|
||||||
"doctype": "Journal Entry Account",
|
|
||||||
"parentfield": "accounts",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"naming_series": "_T-Journal Entry-",
|
|
||||||
"posting_date": "2013-02-14",
|
|
||||||
"user_remark": "test",
|
|
||||||
"voucher_type": "Bank Entry"
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"cheque_date": "2013-02-14",
|
|
||||||
"cheque_no": "33",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"doctype": "Journal Entry",
|
|
||||||
"accounts": [
|
|
||||||
{
|
|
||||||
"account": "Debtors - _TC",
|
|
||||||
"party_type": "Customer",
|
|
||||||
"party": "_Test Customer",
|
|
||||||
"credit_in_account_currency": 0.0,
|
|
||||||
"debit_in_account_currency": 400.0,
|
|
||||||
"doctype": "Journal Entry Account",
|
|
||||||
"parentfield": "accounts",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "Sales - _TC",
|
|
||||||
"credit_in_account_currency": 400.0,
|
|
||||||
"debit_in_account_currency": 0.0,
|
|
||||||
"doctype": "Journal Entry Account",
|
|
||||||
"parentfield": "accounts",
|
|
||||||
"cost_center": "_Test Cost Center - _TC"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"naming_series": "_T-Journal Entry-",
|
|
||||||
"posting_date": "2013-02-14",
|
|
||||||
"user_remark": "test",
|
|
||||||
"voucher_type": "Bank Entry"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
81
erpnext/accounts/doctype/journal_entry/test_records.toml
Normal file
81
erpnext/accounts/doctype/journal_entry/test_records.toml
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
[["Journal Entry"]]
|
||||||
|
cheque_date = "2013-03-14"
|
||||||
|
cheque_no = "33"
|
||||||
|
company = "_Test Company"
|
||||||
|
naming_series = "_T-Journal Entry-"
|
||||||
|
posting_date = "2013-02-14"
|
||||||
|
user_remark = "test"
|
||||||
|
voucher_type = "Bank Entry"
|
||||||
|
[["Journal Entry".accounts]]
|
||||||
|
account = "Debtors - _TC"
|
||||||
|
party_type = "Customer"
|
||||||
|
party = "_Test Customer"
|
||||||
|
credit_in_account_currency = 400.0
|
||||||
|
debit_in_account_currency = 0.0
|
||||||
|
doctype = "Journal Entry Account"
|
||||||
|
parentfield = "accounts"
|
||||||
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
|
||||||
|
[["Journal Entry".accounts]]
|
||||||
|
account = "_Test Bank - _TC"
|
||||||
|
credit_in_account_currency = 0.0
|
||||||
|
debit_in_account_currency = 400.0
|
||||||
|
doctype = "Journal Entry Account"
|
||||||
|
parentfield = "accounts"
|
||||||
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
|
||||||
|
|
||||||
|
[["Journal Entry"]]
|
||||||
|
cheque_date = "2013-02-14"
|
||||||
|
cheque_no = "33"
|
||||||
|
company = "_Test Company"
|
||||||
|
naming_series = "_T-Journal Entry-"
|
||||||
|
posting_date = "2013-02-14"
|
||||||
|
user_remark = "test"
|
||||||
|
voucher_type = "Bank Entry"
|
||||||
|
[["Journal Entry".accounts]]
|
||||||
|
account = "_Test Payable - _TC"
|
||||||
|
party_type = "Supplier"
|
||||||
|
party = "_Test Supplier"
|
||||||
|
credit_in_account_currency = 0.0
|
||||||
|
debit_in_account_currency = 400.0
|
||||||
|
doctype = "Journal Entry Account"
|
||||||
|
parentfield = "accounts"
|
||||||
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
|
||||||
|
[["Journal Entry".accounts]]
|
||||||
|
account = "_Test Bank - _TC"
|
||||||
|
credit_in_account_currency = 400.0
|
||||||
|
debit_in_account_currency = 0.0
|
||||||
|
doctype = "Journal Entry Account"
|
||||||
|
parentfield = "accounts"
|
||||||
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
|
||||||
|
|
||||||
|
[["Journal Entry"]]
|
||||||
|
cheque_date = "2013-02-14"
|
||||||
|
cheque_no = "33"
|
||||||
|
company = "_Test Company"
|
||||||
|
naming_series = "_T-Journal Entry-"
|
||||||
|
posting_date = "2013-02-14"
|
||||||
|
user_remark = "test"
|
||||||
|
voucher_type = "Bank Entry"
|
||||||
|
[["Journal Entry".accounts]]
|
||||||
|
account = "Debtors - _TC"
|
||||||
|
party_type = "Customer"
|
||||||
|
party = "_Test Customer"
|
||||||
|
credit_in_account_currency = 0.0
|
||||||
|
debit_in_account_currency = 400.0
|
||||||
|
doctype = "Journal Entry Account"
|
||||||
|
parentfield = "accounts"
|
||||||
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
|
||||||
|
[["Journal Entry".accounts]]
|
||||||
|
account = "Sales - _TC"
|
||||||
|
credit_in_account_currency = 400.0
|
||||||
|
debit_in_account_currency = 0.0
|
||||||
|
doctype = "Journal Entry Account"
|
||||||
|
parentfield = "accounts"
|
||||||
|
cost_center = "_Test Cost Center - _TC"
|
||||||
|
|
||||||
|
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestJournalEntryTemplate(unittest.TestCase):
|
|
||||||
|
class TestJournalEntryTemplate(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import qb
|
from frappe import qb
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import nowdate
|
from frappe.utils import nowdate
|
||||||
|
|
||||||
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
||||||
from erpnext.accounts.utils import run_ledger_health_checks
|
from erpnext.accounts.utils import run_ledger_health_checks
|
||||||
|
|
||||||
|
|
||||||
class TestLedgerHealth(AccountsTestMixin, FrappeTestCase):
|
class TestLedgerHealth(AccountsTestMixin, IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.create_company()
|
self.create_company()
|
||||||
self.create_customer()
|
self.create_customer()
|
||||||
|
|||||||
@@ -2,8 +2,17 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestLedgerHealthMonitor(FrappeTestCase):
|
class UnitTestLedgerHealthMonitor(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for LedgerHealthMonitor.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestLedgerHealthMonitor(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
# Copyright (c) 2021, Wahni Green Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2021, Wahni Green Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.ledger_merge.ledger_merge import start_merge
|
from erpnext.accounts.doctype.ledger_merge.ledger_merge import start_merge
|
||||||
|
|
||||||
|
|
||||||
class TestLedgerMerge(unittest.TestCase):
|
class TestLedgerMerge(IntegrationTestCase):
|
||||||
def test_merge_success(self):
|
def test_merge_success(self):
|
||||||
if not frappe.db.exists("Account", "Indirect Expenses - _TC"):
|
if not frappe.db.exists("Account", "Indirect Expenses - _TC"):
|
||||||
acc = frappe.new_doc("Account")
|
acc = frappe.new_doc("Account")
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import today
|
from frappe.utils import today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.loyalty_program.test_loyalty_program import create_records
|
from erpnext.accounts.doctype.loyalty_program.test_loyalty_program import create_records
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
|
|
||||||
|
|
||||||
class TestLoyaltyPointEntry(unittest.TestCase):
|
class TestLoyaltyPointEntry(IntegrationTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
# Create test records
|
# Create test records
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import cint, flt, getdate, today
|
from frappe.utils import cint, flt, getdate, today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.loyalty_program.loyalty_program import (
|
from erpnext.accounts.doctype.loyalty_program.loyalty_program import (
|
||||||
@@ -13,7 +13,7 @@ from erpnext.accounts.doctype.loyalty_program.loyalty_program import (
|
|||||||
from erpnext.accounts.party import get_dashboard_info
|
from erpnext.accounts.party import get_dashboard_info
|
||||||
|
|
||||||
|
|
||||||
class TestLoyaltyProgram(unittest.TestCase):
|
class TestLoyaltyProgram(IntegrationTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
# create relevant item, customer, loyalty program, etc
|
# create relevant item, customer, loyalty program, etc
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
# test_records = frappe.get_test_records('Mode of Payment')
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestModeofPayment(unittest.TestCase):
|
class TestModeofPayment(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
test_records = frappe.get_test_records("Monthly Distribution")
|
|
||||||
|
|
||||||
|
|
||||||
class TestMonthlyDistribution(unittest.TestCase):
|
class TestMonthlyDistribution(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
[{
|
|
||||||
"doctype": "Monthly Distribution",
|
|
||||||
"distribution_id": "_Test Distribution",
|
|
||||||
"fiscal_year": "_Test Fiscal Year 2013",
|
|
||||||
"percentages": [
|
|
||||||
{
|
|
||||||
"month": "January",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "February",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "March",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "April",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "May",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "June",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "July",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "August",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "September",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "October",
|
|
||||||
"percentage_allocation": "8"
|
|
||||||
}, {
|
|
||||||
"month": "November",
|
|
||||||
"percentage_allocation": "10"
|
|
||||||
}, {
|
|
||||||
"month": "December",
|
|
||||||
"percentage_allocation": "10"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}]
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
[["Monthly Distribution"]]
|
||||||
|
distribution_id = "_Test Distribution"
|
||||||
|
fiscal_year = "_Test Fiscal Year 2013"
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "January"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "February"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "March"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "April"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "May"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "June"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "July"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "August"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "September"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "October"
|
||||||
|
percentage_allocation = "8"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "November"
|
||||||
|
percentage_allocation = "10"
|
||||||
|
|
||||||
|
[["Monthly Distribution".percentages]]
|
||||||
|
month = "December"
|
||||||
|
percentage_allocation = "10"
|
||||||
|
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import (
|
from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import (
|
||||||
create_dimension,
|
create_dimension,
|
||||||
@@ -12,10 +12,19 @@ from erpnext.accounts.doctype.opening_invoice_creation_tool.opening_invoice_crea
|
|||||||
get_temporary_opening_account,
|
get_temporary_opening_account,
|
||||||
)
|
)
|
||||||
|
|
||||||
test_dependencies = ["Customer", "Supplier", "Accounting Dimension"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Customer", "Supplier", "Accounting Dimension"]
|
||||||
|
|
||||||
|
|
||||||
class TestOpeningInvoiceCreationTool(FrappeTestCase):
|
class UnitTestOpeningInvoiceCreationTool(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for OpeningInvoiceCreationTool.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestOpeningInvoiceCreationTool(IntegrationTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
if not frappe.db.exists("Company", "_Test Opening Invoice Company"):
|
if not frappe.db.exists("Company", "_Test Opening Invoice Company"):
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestPartyLink(unittest.TestCase):
|
|
||||||
|
class TestPartyLink(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -233,9 +233,21 @@ class PaymentEntry(AccountsController):
|
|||||||
self.is_opening = "No"
|
self.is_opening = "No"
|
||||||
return
|
return
|
||||||
|
|
||||||
liability_account = get_party_account(
|
accounts = get_party_account(self.party_type, self.party, self.company, include_advance=True)
|
||||||
self.party_type, self.party, self.company, include_advance=True
|
|
||||||
)[1]
|
liability_account = accounts[1] if len(accounts) > 1 else None
|
||||||
|
fieldname = (
|
||||||
|
"default_advance_received_account"
|
||||||
|
if self.party_type == "Customer"
|
||||||
|
else "default_advance_paid_account"
|
||||||
|
)
|
||||||
|
|
||||||
|
if not liability_account:
|
||||||
|
throw(
|
||||||
|
_("Please set default {0} in Company {1}").format(
|
||||||
|
frappe.bold(frappe.get_meta("Company").get_label(fieldname)), frappe.bold(self.company)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.set(self.party_account_field, liability_account)
|
self.set(self.party_account_field, liability_account)
|
||||||
|
|
||||||
@@ -1251,6 +1263,10 @@ class PaymentEntry(AccountsController):
|
|||||||
if not self.party_account:
|
if not self.party_account:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
advance_payment_doctypes = frappe.get_hooks("advance_payment_receivable_doctypes") + frappe.get_hooks(
|
||||||
|
"advance_payment_payable_doctypes"
|
||||||
|
)
|
||||||
|
|
||||||
if self.payment_type == "Receive":
|
if self.payment_type == "Receive":
|
||||||
against_account = self.paid_to
|
against_account = self.paid_to
|
||||||
else:
|
else:
|
||||||
@@ -1296,11 +1312,30 @@ class PaymentEntry(AccountsController):
|
|||||||
{
|
{
|
||||||
dr_or_cr: allocated_amount_in_company_currency,
|
dr_or_cr: allocated_amount_in_company_currency,
|
||||||
dr_or_cr + "_in_account_currency": d.allocated_amount,
|
dr_or_cr + "_in_account_currency": d.allocated_amount,
|
||||||
"against_voucher_type": d.reference_doctype,
|
|
||||||
"against_voucher": d.reference_name,
|
|
||||||
"cost_center": cost_center,
|
"cost_center": cost_center,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.book_advance_payments_in_separate_party_account:
|
||||||
|
if d.reference_doctype in advance_payment_doctypes:
|
||||||
|
# Upon reconciliation, whole ledger will be reposted. So, reference to SO/PO is fine
|
||||||
|
gle.update(
|
||||||
|
{
|
||||||
|
"against_voucher_type": d.reference_doctype,
|
||||||
|
"against_voucher": d.reference_name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# Do not reference Invoices while Advance is in separate party account
|
||||||
|
gle.update({"against_voucher_type": self.doctype, "against_voucher": self.name})
|
||||||
|
else:
|
||||||
|
gle.update(
|
||||||
|
{
|
||||||
|
"against_voucher_type": d.reference_doctype,
|
||||||
|
"against_voucher": d.reference_name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
gl_entries.append(gle)
|
gl_entries.append(gle)
|
||||||
|
|
||||||
if self.unallocated_amount:
|
if self.unallocated_amount:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import qb
|
from frappe import qb
|
||||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
from frappe.utils import add_days, flt, nowdate
|
from frappe.utils import add_days, flt, nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.test_account import create_account
|
from erpnext.accounts.doctype.account.test_account import create_account
|
||||||
@@ -25,10 +25,19 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import (
|
|||||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
from erpnext.setup.doctype.employee.test_employee import make_employee
|
from erpnext.setup.doctype.employee.test_employee import make_employee
|
||||||
|
|
||||||
test_dependencies = ["Item"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "Currency Exchange"]
|
||||||
|
|
||||||
|
|
||||||
class TestPaymentEntry(FrappeTestCase):
|
class UnitTestPaymentEntry(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for PaymentEntry.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestPaymentEntry(IntegrationTestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
frappe.db.rollback()
|
frappe.db.rollback()
|
||||||
|
|
||||||
@@ -383,7 +392,7 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
self.assertEqual(si.payment_schedule[0].outstanding, 0)
|
self.assertEqual(si.payment_schedule[0].outstanding, 0)
|
||||||
self.assertEqual(si.payment_schedule[0].discounted_amount, 50)
|
self.assertEqual(si.payment_schedule[0].discounted_amount, 50)
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{
|
{
|
||||||
"allow_multi_currency_invoices_against_single_party_account": 1,
|
"allow_multi_currency_invoices_against_single_party_account": 1,
|
||||||
@@ -610,12 +619,9 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
self.assertEqual(flt(pe.references[0].exchange_gain_loss, 2), -94.74)
|
self.assertEqual(flt(pe.references[0].exchange_gain_loss, 2), -94.74)
|
||||||
|
|
||||||
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 (
|
from erpnext.setup.doctype.currency_exchange.test_currency_exchange import save_new_records
|
||||||
save_new_records,
|
|
||||||
test_records,
|
|
||||||
)
|
|
||||||
|
|
||||||
save_new_records(test_records)
|
save_new_records(self.globalTestRecords["Currency Exchange"])
|
||||||
|
|
||||||
pe = frappe.new_doc("Payment Entry")
|
pe = frappe.new_doc("Payment Entry")
|
||||||
pe.payment_type = "Pay"
|
pe.payment_type = "Pay"
|
||||||
@@ -1090,7 +1096,7 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
}
|
}
|
||||||
self.assertDictEqual(ref_details, expected_response)
|
self.assertDictEqual(ref_details, expected_response)
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{
|
{
|
||||||
"unlink_payment_on_cancellation_of_invoice": 1,
|
"unlink_payment_on_cancellation_of_invoice": 1,
|
||||||
@@ -1185,7 +1191,7 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
si3.cancel()
|
si3.cancel()
|
||||||
si3.delete()
|
si3.delete()
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{
|
{
|
||||||
"unlink_payment_on_cancellation_of_invoice": 1,
|
"unlink_payment_on_cancellation_of_invoice": 1,
|
||||||
@@ -1791,7 +1797,7 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
# 'Is Opening' should always be 'No' for normal advance payments
|
# 'Is Opening' should always be 'No' for normal advance payments
|
||||||
self.assertEqual(gl_with_opening_set, [])
|
self.assertEqual(gl_with_opening_set, [])
|
||||||
|
|
||||||
@change_settings("Accounts Settings", {"delete_linked_ledger_entries": 1})
|
@IntegrationTestCase.change_settings("Accounts Settings", {"delete_linked_ledger_entries": 1})
|
||||||
def test_delete_linked_exchange_gain_loss_journal(self):
|
def test_delete_linked_exchange_gain_loss_journal(self):
|
||||||
from erpnext.accounts.doctype.account.test_account import create_account
|
from erpnext.accounts.doctype.account.test_account import create_account
|
||||||
from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import (
|
from erpnext.accounts.doctype.opening_invoice_creation_tool.test_opening_invoice_creation_tool import (
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
# test_records = frappe.get_test_records('Payment Gateway Account')
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
test_ignore = ["Payment Gateway"]
|
IGNORE_TEST_RECORD_DEPENDENCIES = ["Payment Gateway"]
|
||||||
|
|
||||||
|
|
||||||
class TestPaymentGatewayAccount(unittest.TestCase):
|
class TestPaymentGatewayAccount(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import qb
|
from frappe import qb
|
||||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
from frappe.utils import nowdate
|
from frappe.utils import nowdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
|
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
|
||||||
@@ -13,7 +13,16 @@ from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_orde
|
|||||||
from erpnext.stock.doctype.item.test_item import create_item
|
from erpnext.stock.doctype.item.test_item import create_item
|
||||||
|
|
||||||
|
|
||||||
class TestPaymentLedgerEntry(FrappeTestCase):
|
class UnitTestPaymentLedgerEntry(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for PaymentLedgerEntry.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestPaymentLedgerEntry(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.ple = qb.DocType("Payment Ledger Entry")
|
self.ple = qb.DocType("Payment Ledger Entry")
|
||||||
self.create_company()
|
self.create_company()
|
||||||
@@ -445,7 +454,7 @@ class TestPaymentLedgerEntry(FrappeTestCase):
|
|||||||
self.assertEqual(pl_entries_for_crnote[0], expected_values[0])
|
self.assertEqual(pl_entries_for_crnote[0], expected_values[0])
|
||||||
self.assertEqual(pl_entries_for_crnote[1], expected_values[1])
|
self.assertEqual(pl_entries_for_crnote[1], expected_values[1])
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{"unlink_payment_on_cancellation_of_invoice": 1, "delete_linked_ledger_entries": 1},
|
{"unlink_payment_on_cancellation_of_invoice": 1, "delete_linked_ledger_entries": 1},
|
||||||
)
|
)
|
||||||
@@ -474,7 +483,7 @@ class TestPaymentLedgerEntry(FrappeTestCase):
|
|||||||
si.delete()
|
si.delete()
|
||||||
self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, si.doctype, si.name)
|
self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, si.doctype, si.name)
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{"unlink_payment_on_cancellation_of_invoice": 1, "delete_linked_ledger_entries": 1},
|
{"unlink_payment_on_cancellation_of_invoice": 1, "delete_linked_ledger_entries": 1},
|
||||||
)
|
)
|
||||||
@@ -507,7 +516,7 @@ class TestPaymentLedgerEntry(FrappeTestCase):
|
|||||||
si.delete()
|
si.delete()
|
||||||
self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, si.doctype, si.name)
|
self.assertRaises(frappe.DoesNotExistError, frappe.get_doc, si.doctype, si.name)
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{
|
{
|
||||||
"unlink_payment_on_cancellation_of_invoice": 1,
|
"unlink_payment_on_cancellation_of_invoice": 1,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import (
|
from erpnext.accounts.doctype.bank_transaction.test_bank_transaction import (
|
||||||
@@ -17,7 +17,16 @@ from erpnext.accounts.doctype.payment_entry.payment_entry import (
|
|||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
||||||
|
|
||||||
|
|
||||||
class TestPaymentOrder(FrappeTestCase):
|
class UnitTestPaymentOrder(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for PaymentOrder.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestPaymentOrder(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# generate and use a uniq hash identifier for 'Bank Account' and it's linked GL 'Account' to avoid validation error
|
# generate and use a uniq hash identifier for 'Bank Account' and it's linked GL 'Account' to avoid validation error
|
||||||
uniq_identifier = frappe.generate_hash(length=10)
|
uniq_identifier = frappe.generate_hash(length=10)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import qb
|
from frappe import qb
|
||||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
from frappe.utils import add_days, add_years, flt, getdate, nowdate, today
|
from frappe.utils import add_days, add_years, flt, getdate, nowdate, today
|
||||||
|
|
||||||
from erpnext import get_default_cost_center
|
from erpnext import get_default_cost_center
|
||||||
@@ -17,10 +17,19 @@ from erpnext.accounts.utils import get_fiscal_year
|
|||||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
||||||
from erpnext.stock.doctype.item.test_item import create_item
|
from erpnext.stock.doctype.item.test_item import create_item
|
||||||
|
|
||||||
test_dependencies = ["Item"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]
|
||||||
|
|
||||||
|
|
||||||
class TestPaymentReconciliation(FrappeTestCase):
|
class UnitTestPaymentReconciliation(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for PaymentReconciliation.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestPaymentReconciliation(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.create_company()
|
self.create_company()
|
||||||
self.create_item()
|
self.create_item()
|
||||||
@@ -1104,7 +1113,7 @@ class TestPaymentReconciliation(FrappeTestCase):
|
|||||||
payment_vouchers = [x.get("reference_name") for x in pr.get("payments")]
|
payment_vouchers = [x.get("reference_name") for x in pr.get("payments")]
|
||||||
self.assertCountEqual(payment_vouchers, [je2.name, pe2.name])
|
self.assertCountEqual(payment_vouchers, [je2.name, pe2.name])
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"Accounts Settings",
|
"Accounts Settings",
|
||||||
{
|
{
|
||||||
"allow_multi_currency_invoices_against_single_party_account": 1,
|
"allow_multi_currency_invoices_against_single_party_account": 1,
|
||||||
|
|||||||
@@ -482,4 +482,4 @@
|
|||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": []
|
"states": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ def make_payment_request(**args):
|
|||||||
)
|
)
|
||||||
|
|
||||||
party_type = args.get("party_type") or "Customer"
|
party_type = args.get("party_type") or "Customer"
|
||||||
party_account_currency = ref_doc.party_account_currency
|
party_account_currency = ref_doc.get("party_account_currency")
|
||||||
|
|
||||||
if not party_account_currency:
|
if not party_account_currency:
|
||||||
party_account = get_party_account(party_type, ref_doc.get(party_type.lower()), ref_doc.company)
|
party_account = get_party_account(party_type, ref_doc.get(party_type.lower()), ref_doc.company)
|
||||||
@@ -883,33 +883,6 @@ def validate_payment(doc, method=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_paid_amount_against_order(dt, dn):
|
|
||||||
pe_ref = frappe.qb.DocType("Payment Entry Reference")
|
|
||||||
if dt == "Sales Order":
|
|
||||||
inv_dt, inv_field = "Sales Invoice Item", "sales_order"
|
|
||||||
else:
|
|
||||||
inv_dt, inv_field = "Purchase Invoice Item", "purchase_order"
|
|
||||||
inv_item = frappe.qb.DocType(inv_dt)
|
|
||||||
return (
|
|
||||||
frappe.qb.from_(pe_ref)
|
|
||||||
.select(
|
|
||||||
Sum(pe_ref.allocated_amount),
|
|
||||||
)
|
|
||||||
.where(
|
|
||||||
(pe_ref.docstatus == 1)
|
|
||||||
& (
|
|
||||||
(pe_ref.reference_name == dn)
|
|
||||||
| pe_ref.reference_name.isin(
|
|
||||||
frappe.qb.from_(inv_item)
|
|
||||||
.select(inv_item.parent)
|
|
||||||
.where(inv_item[inv_field] == dn)
|
|
||||||
.distinct()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).run()[0][0] or 0
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_open_payment_requests_query(doctype, txt, searchfield, start, page_len, filters):
|
def get_open_payment_requests_query(doctype, txt, searchfield, start, page_len, filters):
|
||||||
# permission checks in `get_list()`
|
# permission checks in `get_list()`
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import unittest
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_terms_template
|
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_terms_template
|
||||||
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
|
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
|
||||||
@@ -16,7 +16,7 @@ from erpnext.buying.doctype.purchase_order.test_purchase_order import create_pur
|
|||||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
from erpnext.setup.utils import get_exchange_rate
|
from erpnext.setup.utils import get_exchange_rate
|
||||||
|
|
||||||
test_dependencies = ["Currency Exchange", "Journal Entry", "Contact", "Address"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Currency Exchange", "Journal Entry", "Contact", "Address"]
|
||||||
|
|
||||||
PAYMENT_URL = "https://example.com/payment"
|
PAYMENT_URL = "https://example.com/payment"
|
||||||
|
|
||||||
@@ -57,7 +57,16 @@ payment_method = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class TestPaymentRequest(FrappeTestCase):
|
class UnitTestPaymentRequest(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for PaymentRequest.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestPaymentRequest(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
for payment_gateway in payment_gateways:
|
for payment_gateway in payment_gateways:
|
||||||
if not frappe.db.get_value("Payment Gateway", payment_gateway["gateway"], "name"):
|
if not frappe.db.get_value("Payment Gateway", payment_gateway["gateway"], "name"):
|
||||||
@@ -218,7 +227,7 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
|
|
||||||
def test_payment_entry_against_purchase_invoice(self):
|
def test_payment_entry_against_purchase_invoice(self):
|
||||||
si_usd = make_purchase_invoice(
|
si_usd = make_purchase_invoice(
|
||||||
customer="_Test Supplier USD",
|
supplier="_Test Supplier USD",
|
||||||
debit_to="_Test Payable USD - _TC",
|
debit_to="_Test Payable USD - _TC",
|
||||||
currency="USD",
|
currency="USD",
|
||||||
conversion_rate=50,
|
conversion_rate=50,
|
||||||
@@ -243,7 +252,7 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
|
|
||||||
def test_multiple_payment_entry_against_purchase_invoice(self):
|
def test_multiple_payment_entry_against_purchase_invoice(self):
|
||||||
purchase_invoice = make_purchase_invoice(
|
purchase_invoice = make_purchase_invoice(
|
||||||
customer="_Test Supplier USD",
|
supplier="_Test Supplier USD",
|
||||||
debit_to="_Test Payable USD - _TC",
|
debit_to="_Test Payable USD - _TC",
|
||||||
currency="USD",
|
currency="USD",
|
||||||
conversion_rate=50,
|
conversion_rate=50,
|
||||||
@@ -483,8 +492,13 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
return_doc=1,
|
return_doc=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@IntegrationTestCase.change_settings(
|
||||||
|
"Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1}
|
||||||
|
)
|
||||||
def test_multiple_payment_if_partially_paid_for_multi_currency(self):
|
def test_multiple_payment_if_partially_paid_for_multi_currency(self):
|
||||||
pi = make_purchase_invoice(currency="USD", conversion_rate=50, qty=1, rate=100)
|
pi = make_purchase_invoice(currency="USD", conversion_rate=50, qty=1, rate=100, do_not_save=1)
|
||||||
|
pi.credit_to = "Creditors - _TC"
|
||||||
|
pi.submit()
|
||||||
|
|
||||||
pr = make_payment_request(
|
pr = make_payment_request(
|
||||||
dt="Purchase Invoice",
|
dt="Purchase Invoice",
|
||||||
@@ -585,10 +599,15 @@ class TestPaymentRequest(FrappeTestCase):
|
|||||||
self.assertEqual(pr.outstanding_amount, 0)
|
self.assertEqual(pr.outstanding_amount, 0)
|
||||||
self.assertEqual(pr.grand_total, 20000)
|
self.assertEqual(pr.grand_total, 20000)
|
||||||
|
|
||||||
|
@IntegrationTestCase.change_settings(
|
||||||
|
"Accounts Settings", {"allow_multi_currency_invoices_against_single_party_account": 1}
|
||||||
|
)
|
||||||
def test_single_payment_with_payment_term_for_multi_currency(self):
|
def test_single_payment_with_payment_term_for_multi_currency(self):
|
||||||
create_payment_terms_template()
|
create_payment_terms_template()
|
||||||
|
|
||||||
si = create_sales_invoice(do_not_save=1, currency="USD", qty=1, rate=200, conversion_rate=50)
|
si = create_sales_invoice(
|
||||||
|
do_not_save=1, currency="USD", debit_to="Debtors - _TC", qty=1, rate=200, conversion_rate=50
|
||||||
|
)
|
||||||
si.payment_terms_template = "Test Receivable Template" # 84.746 and 15.254
|
si.payment_terms_template = "Test Receivable Template" # 84.746 and 15.254
|
||||||
si.save()
|
si.save()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestPaymentTerm(unittest.TestCase):
|
|
||||||
|
class TestPaymentTerm(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype":"Payment Term",
|
|
||||||
"due_date_based_on":"Day(s) after invoice date",
|
|
||||||
"payment_term_name":"_Test N30",
|
|
||||||
"description":"_Test Net 30 Days",
|
|
||||||
"invoice_portion":50,
|
|
||||||
"credit_days":30
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype":"Payment Term",
|
|
||||||
"due_date_based_on":"Day(s) after invoice date",
|
|
||||||
"payment_term_name":"_Test COD",
|
|
||||||
"description":"_Test Cash on Delivery",
|
|
||||||
"invoice_portion":50,
|
|
||||||
"credit_days":0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype":"Payment Term",
|
|
||||||
"due_date_based_on":"Month(s) after the end of the invoice month",
|
|
||||||
"payment_term_name":"_Test EONM",
|
|
||||||
"description":"_Test End of Next Month",
|
|
||||||
"invoice_portion":100,
|
|
||||||
"credit_months":1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype":"Payment Term",
|
|
||||||
"due_date_based_on":"Day(s) after invoice date",
|
|
||||||
"payment_term_name":"_Test N30 1",
|
|
||||||
"description":"_Test Net 30 Days",
|
|
||||||
"invoice_portion":100,
|
|
||||||
"credit_days":30
|
|
||||||
}
|
|
||||||
]
|
|
||||||
28
erpnext/accounts/doctype/payment_term/test_records.toml
Normal file
28
erpnext/accounts/doctype/payment_term/test_records.toml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
[["Payment Term"]]
|
||||||
|
due_date_based_on = "Day(s) after invoice date"
|
||||||
|
payment_term_name = "_Test N30"
|
||||||
|
description = "_Test Net 30 Days"
|
||||||
|
invoice_portion = 50
|
||||||
|
credit_days = 30
|
||||||
|
|
||||||
|
[["Payment Term"]]
|
||||||
|
due_date_based_on = "Day(s) after invoice date"
|
||||||
|
payment_term_name = "_Test COD"
|
||||||
|
description = "_Test Cash on Delivery"
|
||||||
|
invoice_portion = 50
|
||||||
|
credit_days = 0
|
||||||
|
|
||||||
|
[["Payment Term"]]
|
||||||
|
due_date_based_on = "Month(s) after the end of the invoice month"
|
||||||
|
payment_term_name = "_Test EONM"
|
||||||
|
description = "_Test End of Next Month"
|
||||||
|
invoice_portion = 100
|
||||||
|
credit_months = 1
|
||||||
|
|
||||||
|
[["Payment Term"]]
|
||||||
|
due_date_based_on = "Day(s) after invoice date"
|
||||||
|
payment_term_name = "_Test N30 1"
|
||||||
|
description = "_Test Net 30 Days"
|
||||||
|
invoice_portion = 100
|
||||||
|
credit_days = 30
|
||||||
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestPaymentTermsTemplate(unittest.TestCase):
|
class TestPaymentTermsTemplate(IntegrationTestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
frappe.delete_doc("Payment Terms Template", "_Test Payment Terms Template For Test", force=1)
|
frappe.delete_doc("Payment Terms Template", "_Test Payment Terms Template For Test", force=1)
|
||||||
|
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype":"Payment Terms Template",
|
|
||||||
"terms":[
|
|
||||||
{
|
|
||||||
"doctype":"Payment Terms Template Detail",
|
|
||||||
"due_date_based_on":"Day(s) after invoice date",
|
|
||||||
"idx":1,
|
|
||||||
"description":"Cash on Delivery",
|
|
||||||
"invoice_portion":50,
|
|
||||||
"credit_days":0,
|
|
||||||
"credit_months":0,
|
|
||||||
"payment_term":"_Test COD"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype":"Payment Terms Template Detail",
|
|
||||||
"due_date_based_on":"Day(s) after invoice date",
|
|
||||||
"idx":2,
|
|
||||||
"description":"Net 30 Days ",
|
|
||||||
"invoice_portion":50,
|
|
||||||
"credit_days":30,
|
|
||||||
"credit_months":0,
|
|
||||||
"payment_term":"_Test N30"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"template_name":"_Test Payment Term Template"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype":"Payment Terms Template",
|
|
||||||
"terms":[
|
|
||||||
{
|
|
||||||
"doctype":"Payment Terms Template Detail",
|
|
||||||
"due_date_based_on":"Month(s) after the end of the invoice month",
|
|
||||||
"idx":1,
|
|
||||||
"description":"_Test End of Next Months",
|
|
||||||
"invoice_portion":100,
|
|
||||||
"credit_days":0,
|
|
||||||
"credit_months":1,
|
|
||||||
"payment_term":"_Test EONM"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"template_name":"_Test Payment Term Template 1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype":"Payment Terms Template",
|
|
||||||
"terms":[
|
|
||||||
{
|
|
||||||
"doctype":"Payment Terms Template Detail",
|
|
||||||
"due_date_based_on":"Day(s) after invoice date",
|
|
||||||
"idx":1,
|
|
||||||
"description":"_Test Net Within 30 days",
|
|
||||||
"invoice_portion":100,
|
|
||||||
"credit_days":30,
|
|
||||||
"credit_months":0,
|
|
||||||
"payment_term":"_Test N30 1"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"template_name":"_Test Payment Term Template 3"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
[["Payment Terms Template"]]
|
||||||
|
template_name = "_Test Payment Term Template"
|
||||||
|
[["Payment Terms Template".terms]]
|
||||||
|
doctype = "Payment Terms Template Detail"
|
||||||
|
due_date_based_on = "Day(s) after invoice date"
|
||||||
|
idx = 1
|
||||||
|
description = "Cash on Delivery"
|
||||||
|
invoice_portion = 50
|
||||||
|
credit_days = 0
|
||||||
|
credit_months = 0
|
||||||
|
payment_term = "_Test COD"
|
||||||
|
|
||||||
|
[["Payment Terms Template".terms]]
|
||||||
|
doctype = "Payment Terms Template Detail"
|
||||||
|
due_date_based_on = "Day(s) after invoice date"
|
||||||
|
idx = 2
|
||||||
|
description = "Net 30 Days "
|
||||||
|
invoice_portion = 50
|
||||||
|
credit_days = 30
|
||||||
|
credit_months = 0
|
||||||
|
payment_term = "_Test N30"
|
||||||
|
|
||||||
|
|
||||||
|
[["Payment Terms Template"]]
|
||||||
|
template_name = "_Test Payment Term Template 1"
|
||||||
|
[["Payment Terms Template".terms]]
|
||||||
|
doctype = "Payment Terms Template Detail"
|
||||||
|
due_date_based_on = "Month(s) after the end of the invoice month"
|
||||||
|
idx = 1
|
||||||
|
description = "_Test End of Next Months"
|
||||||
|
invoice_portion = 100
|
||||||
|
credit_days = 0
|
||||||
|
credit_months = 1
|
||||||
|
payment_term = "_Test EONM"
|
||||||
|
|
||||||
|
|
||||||
|
[["Payment Terms Template"]]
|
||||||
|
template_name = "_Test Payment Term Template 3"
|
||||||
|
[["Payment Terms Template".terms]]
|
||||||
|
doctype = "Payment Terms Template Detail"
|
||||||
|
due_date_based_on = "Day(s) after invoice date"
|
||||||
|
idx = 1
|
||||||
|
description = "_Test Net Within 30 days"
|
||||||
|
invoice_portion = 100
|
||||||
|
credit_days = 30
|
||||||
|
credit_months = 0
|
||||||
|
payment_term = "_Test N30 1"
|
||||||
|
|
||||||
|
|
||||||
@@ -392,8 +392,7 @@ def process_closing_entries(gl_entries, closing_entries, voucher_name, company,
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if gl_entries + closing_entries:
|
make_closing_entries(gl_entries + closing_entries, voucher_name, company, closing_date)
|
||||||
make_closing_entries(gl_entries + closing_entries, voucher_name, company, closing_date)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
frappe.db.rollback()
|
frappe.db.rollback()
|
||||||
frappe.log_error(e)
|
frappe.log_error(e)
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import today
|
from frappe.utils import today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.finance_book.test_finance_book import create_finance_book
|
from erpnext.accounts.doctype.finance_book.test_finance_book import create_finance_book
|
||||||
@@ -13,7 +12,7 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal
|
|||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
|
|
||||||
|
|
||||||
class TestPeriodClosingVoucher(unittest.TestCase):
|
class TestPeriodClosingVoucher(IntegrationTestCase):
|
||||||
def test_closing_entry(self):
|
def test_closing_entry(self):
|
||||||
frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'")
|
frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'")
|
||||||
frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'")
|
frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'")
|
||||||
@@ -381,5 +380,4 @@ def create_cost_center(cc_name):
|
|||||||
return costcenter.name
|
return costcenter.name
|
||||||
|
|
||||||
|
|
||||||
test_dependencies = ["Customer", "Cost Center"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Customer", "Cost Center"]
|
||||||
test_records = frappe.get_test_records("Period Closing Voucher")
|
|
||||||
|
|||||||
@@ -194,7 +194,9 @@ function refresh_payments(d, frm) {
|
|||||||
}
|
}
|
||||||
if (payment) {
|
if (payment) {
|
||||||
payment.expected_amount += flt(p.amount);
|
payment.expected_amount += flt(p.amount);
|
||||||
payment.closing_amount = payment.expected_amount;
|
if (payment.closing_amount === 0) {
|
||||||
|
payment.closing_amount = payment.expected_amount;
|
||||||
|
}
|
||||||
payment.difference = payment.closing_amount - payment.expected_amount;
|
payment.difference = payment.closing_amount - payment.expected_amount;
|
||||||
} else {
|
} else {
|
||||||
frm.add_child("payment_reconciliation", {
|
frm.add_child("payment_reconciliation", {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import (
|
from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import (
|
||||||
create_dimension,
|
create_dimension,
|
||||||
@@ -24,7 +24,7 @@ from erpnext.stock.doctype.serial_and_batch_bundle.test_serial_and_batch_bundle
|
|||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||||
|
|
||||||
|
|
||||||
class TestPOSClosingEntry(unittest.TestCase):
|
class TestPOSClosingEntry(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Make stock available for POS Sales
|
# Make stock available for POS Sales
|
||||||
make_stock_entry(target="_Test Warehouse - _TC", qty=2, basic_rate=100)
|
make_stock_entry(target="_Test Warehouse - _TC", qty=2, basic_rate=100)
|
||||||
|
|||||||
@@ -40,6 +40,19 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.frm.set_query("item_code", "items", function (doc) {
|
||||||
|
return {
|
||||||
|
query: "erpnext.accounts.doctype.pos_invoice.pos_invoice.item_query",
|
||||||
|
filters: {
|
||||||
|
has_variants: ["=", 0],
|
||||||
|
is_sales_item: ["=", 1],
|
||||||
|
disabled: ["=", 0],
|
||||||
|
is_fixed_asset: ["=", 0],
|
||||||
|
pos_profile: ["=", doc.pos_profile],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype);
|
erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import frappe
|
|||||||
from frappe import _, bold
|
from frappe import _, bold
|
||||||
from frappe.query_builder.functions import IfNull, Sum
|
from frappe.query_builder.functions import IfNull, Sum
|
||||||
from frappe.utils import cint, flt, get_link_to_form, getdate, nowdate
|
from frappe.utils import cint, flt, get_link_to_form, getdate, nowdate
|
||||||
|
from frappe.utils.nestedset import get_descendants_of
|
||||||
|
|
||||||
from erpnext.accounts.doctype.loyalty_program.loyalty_program import validate_loyalty_points
|
from erpnext.accounts.doctype.loyalty_program.loyalty_program import validate_loyalty_points
|
||||||
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
|
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
|
||||||
@@ -15,6 +16,7 @@ from erpnext.accounts.doctype.sales_invoice.sales_invoice import (
|
|||||||
update_multi_mode_option,
|
update_multi_mode_option,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.party import get_due_date, get_party_account
|
from erpnext.accounts.party import get_due_date, get_party_account
|
||||||
|
from erpnext.controllers.queries import item_query as _item_query
|
||||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
||||||
|
|
||||||
|
|
||||||
@@ -450,7 +452,7 @@ class POSInvoice(SalesInvoice):
|
|||||||
if self.is_return and entry.amount > 0:
|
if self.is_return and entry.amount > 0:
|
||||||
frappe.throw(_("Row #{0} (Payment Table): Amount must be negative").format(entry.idx))
|
frappe.throw(_("Row #{0} (Payment Table): Amount must be negative").format(entry.idx))
|
||||||
|
|
||||||
if self.is_return:
|
if self.is_return and self.docstatus != 0:
|
||||||
invoice_total = self.rounded_total or self.grand_total
|
invoice_total = self.rounded_total or self.grand_total
|
||||||
total_amount_in_payments = flt(total_amount_in_payments, self.precision("grand_total"))
|
total_amount_in_payments = flt(total_amount_in_payments, self.precision("grand_total"))
|
||||||
if total_amount_in_payments and total_amount_in_payments < invoice_total:
|
if total_amount_in_payments and total_amount_in_payments < invoice_total:
|
||||||
@@ -840,3 +842,30 @@ def add_return_modes(doc, pos_profile):
|
|||||||
]:
|
]:
|
||||||
payment_mode = get_mode_of_payment_info(mode_of_payment, doc.company)
|
payment_mode = get_mode_of_payment_info(mode_of_payment, doc.company)
|
||||||
append_payment(payment_mode[0])
|
append_payment(payment_mode[0])
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
@frappe.validate_and_sanitize_search_inputs
|
||||||
|
def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
|
||||||
|
if pos_profile := filters.get("pos_profile")[1]:
|
||||||
|
pos_profile = frappe.get_cached_doc("POS Profile", pos_profile)
|
||||||
|
if item_groups := get_item_group(pos_profile):
|
||||||
|
filters["item_group"] = ["in", tuple(item_groups)]
|
||||||
|
|
||||||
|
del filters["pos_profile"]
|
||||||
|
|
||||||
|
else:
|
||||||
|
filters.pop("pos_profile", None)
|
||||||
|
|
||||||
|
return _item_query(doctype, txt, searchfield, start, page_len, filters, as_dict)
|
||||||
|
|
||||||
|
|
||||||
|
def get_item_group(pos_profile):
|
||||||
|
item_groups = []
|
||||||
|
if pos_profile.get("item_groups"):
|
||||||
|
# Get items based on the item groups defined in the POS profile
|
||||||
|
for row in pos_profile.get("item_groups"):
|
||||||
|
item_groups.append(row.item_group)
|
||||||
|
item_groups.extend(get_descendants_of("Item Group", row.item_group))
|
||||||
|
|
||||||
|
return list(set(item_groups))
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return
|
from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return
|
||||||
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
|
||||||
@@ -20,9 +20,11 @@ from erpnext.stock.doctype.serial_and_batch_bundle.test_serial_and_batch_bundle
|
|||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
|
|
||||||
|
|
||||||
class TestPOSInvoice(unittest.TestCase):
|
class TestPOSInvoice(IntegrationTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0))
|
||||||
make_stock_entry(target="_Test Warehouse - _TC", item_code="_Test Item", qty=800, basic_rate=100)
|
make_stock_entry(target="_Test Warehouse - _TC", item_code="_Test Item", qty=800, basic_rate=100)
|
||||||
frappe.db.sql("delete from `tabTax Rule`")
|
frappe.db.sql("delete from `tabTax Rule`")
|
||||||
|
|
||||||
@@ -248,6 +250,7 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||||
|
|
||||||
se = make_serialized_item(
|
se = make_serialized_item(
|
||||||
|
self,
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
target_warehouse="Stores - _TC",
|
target_warehouse="Stores - _TC",
|
||||||
cost_center="Main - _TC",
|
cost_center="Main - _TC",
|
||||||
@@ -289,6 +292,7 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||||
|
|
||||||
se = make_serialized_item(
|
se = make_serialized_item(
|
||||||
|
self,
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
target_warehouse="Stores - _TC",
|
target_warehouse="Stores - _TC",
|
||||||
cost_center="Main - _TC",
|
cost_center="Main - _TC",
|
||||||
@@ -377,6 +381,7 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||||
|
|
||||||
se = make_serialized_item(
|
se = make_serialized_item(
|
||||||
|
self,
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
target_warehouse="Stores - _TC",
|
target_warehouse="Stores - _TC",
|
||||||
cost_center="Main - _TC",
|
cost_center="Main - _TC",
|
||||||
@@ -431,6 +436,7 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||||
|
|
||||||
se = make_serialized_item(
|
se = make_serialized_item(
|
||||||
|
self,
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
target_warehouse="Stores - _TC",
|
target_warehouse="Stores - _TC",
|
||||||
cost_center="Main - _TC",
|
cost_center="Main - _TC",
|
||||||
@@ -482,6 +488,7 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||||
|
|
||||||
se = make_serialized_item(
|
se = make_serialized_item(
|
||||||
|
self,
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
target_warehouse="Stores - _TC",
|
target_warehouse="Stores - _TC",
|
||||||
cost_center="Main - _TC",
|
cost_center="Main - _TC",
|
||||||
@@ -512,6 +519,7 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||||
|
|
||||||
se = make_serialized_item(
|
se = make_serialized_item(
|
||||||
|
self,
|
||||||
company="_Test Company",
|
company="_Test Company",
|
||||||
target_warehouse="Stores - _TC",
|
target_warehouse="Stores - _TC",
|
||||||
cost_center="Main - _TC",
|
cost_center="Main - _TC",
|
||||||
@@ -901,7 +909,7 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.db.savepoint("before_test_delivered_serial_no_case")
|
frappe.db.savepoint("before_test_delivered_serial_no_case")
|
||||||
try:
|
try:
|
||||||
se = make_serialized_item()
|
se = make_serialized_item(self)
|
||||||
serial_no = get_serial_nos_from_bundle(se.get("items")[0].serial_and_batch_bundle)[0]
|
serial_no = get_serial_nos_from_bundle(se.get("items")[0].serial_and_batch_bundle)[0]
|
||||||
|
|
||||||
dn = create_delivery_note(item_code="_Test Serialized Item With Series", serial_no=[serial_no])
|
dn = create_delivery_note(item_code="_Test Serialized Item With Series", serial_no=[serial_no])
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import unittest
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import change_settings
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile
|
from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile
|
||||||
from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return
|
from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return
|
||||||
@@ -19,7 +17,21 @@ from erpnext.stock.doctype.serial_and_batch_bundle.test_serial_and_batch_bundle
|
|||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
|
|
||||||
|
|
||||||
class TestPOSInvoiceMergeLog(unittest.TestCase):
|
class UnitTestPosInvoiceMergeLog(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for PosInvoiceMergeLog.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestPOSInvoiceMergeLog(IntegrationTestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0))
|
||||||
|
|
||||||
def test_consolidated_invoice_creation(self):
|
def test_consolidated_invoice_creation(self):
|
||||||
frappe.db.sql("delete from `tabPOS Invoice`")
|
frappe.db.sql("delete from `tabPOS Invoice`")
|
||||||
|
|
||||||
@@ -288,7 +300,7 @@ class TestPOSInvoiceMergeLog(unittest.TestCase):
|
|||||||
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`")
|
||||||
|
|
||||||
@change_settings(
|
@IntegrationTestCase.change_settings(
|
||||||
"System Settings", {"number_format": "#,###.###", "currency_precision": 3, "float_precision": 3}
|
"System Settings", {"number_format": "#,###.###", "currency_precision": 3, "float_precision": 3}
|
||||||
)
|
)
|
||||||
def test_consolidation_round_off_error_3(self):
|
def test_consolidation_round_off_error_3(self):
|
||||||
@@ -403,7 +415,7 @@ class TestPOSInvoiceMergeLog(unittest.TestCase):
|
|||||||
frappe.db.sql("delete from `tabPOS Invoice`")
|
frappe.db.sql("delete from `tabPOS Invoice`")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
se = make_serialized_item()
|
se = make_serialized_item(self)
|
||||||
serial_no = get_serial_nos_from_bundle(se.get("items")[0].serial_and_batch_bundle)[0]
|
serial_no = get_serial_nos_from_bundle(se.get("items")[0].serial_and_batch_bundle)[0]
|
||||||
|
|
||||||
init_user_and_profile()
|
init_user_and_profile()
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestPOSOpeningEntry(unittest.TestCase):
|
class TestPOSOpeningEntry(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.pos_profile.pos_profile import (
|
from erpnext.accounts.doctype.pos_profile.pos_profile import (
|
||||||
get_child_nodes,
|
get_child_nodes,
|
||||||
)
|
)
|
||||||
from erpnext.stock.get_item_details import get_pos_profile
|
from erpnext.stock.get_item_details import get_pos_profile
|
||||||
|
|
||||||
test_dependencies = ["Item"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item"]
|
||||||
|
|
||||||
|
|
||||||
class TestPOSProfile(unittest.TestCase):
|
class TestPOSProfile(IntegrationTestCase):
|
||||||
def test_pos_profile(self):
|
def test_pos_profile(self):
|
||||||
make_pos_profile()
|
make_pos_profile()
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ def get_customers_list(pos_profile=None):
|
|||||||
customer_groups.extend(
|
customer_groups.extend(
|
||||||
[d.get("name") for d in get_child_nodes("Customer Group", d.get("customer_group"))]
|
[d.get("name") for d in get_child_nodes("Customer Group", d.get("customer_group"))]
|
||||||
)
|
)
|
||||||
cond = "customer_group in (%s)" % (", ".join(["%s"] * len(customer_groups)))
|
cond = "customer_group in ({})".format(", ".join(["%s"] * len(customer_groups)))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
frappe.db.sql(
|
frappe.db.sql(
|
||||||
@@ -72,7 +72,7 @@ def get_items_list(pos_profile, company):
|
|||||||
for d in pos_profile.get("item_groups"):
|
for d in pos_profile.get("item_groups"):
|
||||||
args_list.extend([d.name for d in get_child_nodes("Item Group", d.item_group)])
|
args_list.extend([d.name for d in get_child_nodes("Item Group", d.item_group)])
|
||||||
if args_list:
|
if args_list:
|
||||||
cond = "and i.item_group in (%s)" % (", ".join(["%s"] * len(args_list)))
|
cond = "and i.item_group in ({})".format(", ".join(["%s"] * len(args_list)))
|
||||||
|
|
||||||
return frappe.db.sql(
|
return frappe.db.sql(
|
||||||
f"""
|
f"""
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestPOSProfileUser(unittest.TestCase):
|
|
||||||
|
class TestPOSProfileUser(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
class TestPOSSettings(unittest.TestCase):
|
|
||||||
|
class TestPOSSettings(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
@@ -15,10 +15,20 @@ from erpnext.stock.doctype.item.test_item import make_item
|
|||||||
from erpnext.stock.get_item_details import get_item_details
|
from erpnext.stock.get_item_details import get_item_details
|
||||||
|
|
||||||
|
|
||||||
class TestPricingRule(FrappeTestCase):
|
class UnitTestPricingRule(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for PricingRule.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestPricingRule(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
delete_existing_pricing_rules()
|
delete_existing_pricing_rules()
|
||||||
setup_pricing_rule_data()
|
setup_pricing_rule_data()
|
||||||
|
self.enterClassContext(self.change_settings("Selling Settings", validate_selling_price=0))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
delete_existing_pricing_rules()
|
delete_existing_pricing_rules()
|
||||||
@@ -1131,6 +1141,12 @@ class TestPricingRule(FrappeTestCase):
|
|||||||
self.assertEqual(so.items[1].item_code, "_Test Item")
|
self.assertEqual(so.items[1].item_code, "_Test Item")
|
||||||
self.assertEqual(so.items[1].qty, 3)
|
self.assertEqual(so.items[1].qty, 3)
|
||||||
|
|
||||||
|
so = make_sales_order(item_code="_Test Item", qty=5, do_not_submit=1)
|
||||||
|
so.items[0].qty = 1
|
||||||
|
del so.items[-1]
|
||||||
|
so.save()
|
||||||
|
self.assertEqual(len(so.items), 1)
|
||||||
|
|
||||||
def test_apply_multiple_pricing_rules_for_discount_percentage_and_amount(self):
|
def test_apply_multiple_pricing_rules_for_discount_percentage_and_amount(self):
|
||||||
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 1")
|
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 1")
|
||||||
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")
|
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")
|
||||||
@@ -1378,7 +1394,7 @@ class TestPricingRule(FrappeTestCase):
|
|||||||
pi.cancel()
|
pi.cancel()
|
||||||
|
|
||||||
|
|
||||||
test_dependencies = ["UTM Campaign"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["UTM Campaign"]
|
||||||
|
|
||||||
|
|
||||||
def make_pricing_rule(**args):
|
def make_pricing_rule(**args):
|
||||||
|
|||||||
@@ -657,6 +657,9 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
|
|||||||
if pricing_rule.round_free_qty:
|
if pricing_rule.round_free_qty:
|
||||||
qty = math.floor(qty)
|
qty = math.floor(qty)
|
||||||
|
|
||||||
|
if not qty:
|
||||||
|
return
|
||||||
|
|
||||||
free_item_data_args = {
|
free_item_data_args = {
|
||||||
"item_code": free_item,
|
"item_code": free_item,
|
||||||
"qty": qty,
|
"qty": qty,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.test_account import create_account
|
from erpnext.accounts.doctype.account.test_account import create_account
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import (
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import (
|
||||||
@@ -13,7 +13,7 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import (
|
|||||||
from erpnext.stock.doctype.item.test_item import create_item
|
from erpnext.stock.doctype.item.test_item import create_item
|
||||||
|
|
||||||
|
|
||||||
class TestProcessDeferredAccounting(unittest.TestCase):
|
class TestProcessDeferredAccounting(IntegrationTestCase):
|
||||||
def test_creation_of_ledger_entry_on_submit(self):
|
def test_creation_of_ledger_entry_on_submit(self):
|
||||||
"""test creation of gl entries on submission of document"""
|
"""test creation of gl entries on submission of document"""
|
||||||
change_acc_settings(acc_frozen_upto="2023-05-31", book_deferred_entries_based_on="Months")
|
change_acc_settings(acc_frozen_upto="2023-05-31", book_deferred_entries_based_on="Months")
|
||||||
|
|||||||
@@ -2,8 +2,17 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestProcessPaymentReconciliation(FrappeTestCase):
|
class UnitTestProcessPaymentReconciliation(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for ProcessPaymentReconciliation.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestProcessPaymentReconciliation(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -2,8 +2,17 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestProcessPaymentReconciliationLog(FrappeTestCase):
|
class UnitTestProcessPaymentReconciliationLog(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for ProcessPaymentReconciliationLog.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestProcessPaymentReconciliationLog(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase
|
||||||
from frappe.utils import add_days, getdate, today
|
from frappe.utils import add_days, getdate, today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts import (
|
from erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts import (
|
||||||
@@ -14,7 +14,12 @@ from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sal
|
|||||||
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
||||||
|
|
||||||
|
|
||||||
class TestProcessStatementOfAccounts(AccountsTestMixin, FrappeTestCase):
|
class TestProcessStatementOfAccounts(AccountsTestMixin, IntegrationTestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0))
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.create_company()
|
self.create_company()
|
||||||
self.create_customer()
|
self.create_customer()
|
||||||
|
|||||||
@@ -2,8 +2,17 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
# import frappe
|
# import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||||
|
|
||||||
|
|
||||||
class TestProcessSubscription(FrappeTestCase):
|
class UnitTestProcessSubscription(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for ProcessSubscription.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestProcessSubscription(IntegrationTestCase):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.accounts.doctype.promotional_scheme.promotional_scheme import TransactionExists
|
from erpnext.accounts.doctype.promotional_scheme.promotional_scheme import TransactionExists
|
||||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
|
|
||||||
|
|
||||||
class TestPromotionalScheme(unittest.TestCase):
|
class TestPromotionalScheme(IntegrationTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if frappe.db.exists("Promotional Scheme", "_Test Scheme"):
|
if frappe.db.exists("Promotional Scheme", "_Test Scheme"):
|
||||||
frappe.delete_doc("Promotional Scheme", "_Test Scheme")
|
frappe.delete_doc("Promotional Scheme", "_Test Scheme")
|
||||||
|
|||||||
@@ -565,11 +565,12 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
frm.custom_make_buttons = {
|
frm.custom_make_buttons = {
|
||||||
"Purchase Invoice": "Return / Debit Note",
|
"Purchase Invoice": "Return / Debit Note",
|
||||||
"Payment Entry": "Payment",
|
"Payment Entry": "Payment",
|
||||||
"Landed Cost Voucher": function () {
|
|
||||||
frm.trigger("create_landed_cost_voucher");
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (frm.doc.update_stock) {
|
||||||
|
frm.custom_make_buttons["Landed Cost Voucher"] = "Landed Cost Voucher";
|
||||||
|
}
|
||||||
|
|
||||||
frm.set_query("additional_discount_account", function () {
|
frm.set_query("additional_discount_account", function () {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
@@ -611,20 +612,6 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
create_landed_cost_voucher: function (frm) {
|
|
||||||
let lcv = frappe.model.get_new_doc("Landed Cost Voucher");
|
|
||||||
lcv.company = frm.doc.company;
|
|
||||||
|
|
||||||
let lcv_receipt = frappe.model.get_new_doc("Landed Cost Purchase Invoice");
|
|
||||||
lcv_receipt.receipt_document_type = "Purchase Invoice";
|
|
||||||
lcv_receipt.receipt_document = frm.doc.name;
|
|
||||||
lcv_receipt.supplier = frm.doc.supplier;
|
|
||||||
lcv_receipt.grand_total = frm.doc.grand_total;
|
|
||||||
lcv.purchase_receipts = [lcv_receipt];
|
|
||||||
|
|
||||||
frappe.set_route("Form", lcv.doctype, lcv.name);
|
|
||||||
},
|
|
||||||
|
|
||||||
add_custom_buttons: function (frm) {
|
add_custom_buttons: function (frm) {
|
||||||
if (frm.doc.docstatus == 1 && frm.doc.per_received < 100) {
|
if (frm.doc.docstatus == 1 && frm.doc.per_received < 100) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
@@ -649,6 +636,32 @@ frappe.ui.form.on("Purchase Invoice", {
|
|||||||
__("View")
|
__("View")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frm.doc.docstatus === 1 && frm.doc.update_stock) {
|
||||||
|
frm.add_custom_button(
|
||||||
|
__("Landed Cost Voucher"),
|
||||||
|
() => {
|
||||||
|
frm.events.make_lcv(frm);
|
||||||
|
},
|
||||||
|
__("Create")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
make_lcv(frm) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_lcv",
|
||||||
|
args: {
|
||||||
|
doctype: frm.doc.doctype,
|
||||||
|
docname: frm.doc.name,
|
||||||
|
},
|
||||||
|
callback: (r) => {
|
||||||
|
if (r.message) {
|
||||||
|
var doc = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route("Form", doc[0].doctype, doc[0].name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user