Compare commits

..

220 Commits

Author SHA1 Message Date
Nabin Hait
c1d31baece Merge branch 'hotfix' 2016-12-23 16:45:08 +05:30
Nabin Hait
11c5da1d8c bumped to version 7.1.29 2016-12-23 17:15:07 +06:00
Nabin Hait
0e9f16f59d Merge pull request #7289 from rohitwaghchaure/enhancement_timesheet_v7_2
[Enhancement] Setting to maintain the work hours and bill hours same on the timesheet
2016-12-23 15:18:28 +05:30
Nabin Hait
6104fdc579 Update repost_stock_for_deleted_bins_for_merging_items.py 2016-12-22 17:49:46 +05:30
Rohit Waghchaure
1af1a43616 [Enhancement] Setting to maintain the work hours and bill hours same on the timesheet 2016-12-21 19:19:16 +05:30
Nabin Hait
a216f50114 Merge pull request #7287 from rohitwaghchaure/pos_issue_for_serialized_item
[Fix] POS issue for serialized items
2016-12-21 18:05:18 +05:30
Rohit Waghchaure
dd58d537d5 [Fix] POS issue for serialized items 2016-12-21 17:55:40 +05:30
Nabin Hait
ffcf0ca3a6 Merge pull request #7285 from rohitwaghchaure/packed_items_issue
[Fix] Warehouse is mandatory for packing materials on the sales invoice
2016-12-21 14:12:00 +05:30
Rohit Waghchaure
9df946e96c [Fix] Warehouse is mandatory for packing materials on the sales invoice 2016-12-21 13:27:54 +05:30
Nabin Hait
8650855926 Merge branch 'hotfix' 2016-12-21 12:18:37 +05:30
Nabin Hait
399e414909 bumped to version 7.1.28 2016-12-21 12:48:37 +06:00
Nabin Hait
b3943cb53a Update repost_stock_for_deleted_bins_for_merging_items.py 2016-12-21 12:04:39 +05:30
Nabin Hait
0c10e3b210 Merge branch 'hotfix' 2016-12-20 11:39:46 +05:30
Nabin Hait
1cc2d7403b bumped to version 7.1.27 2016-12-20 12:09:46 +06:00
Nabin Hait
778c1a022d Merge pull request #7236 from rohitwaghchaure/item_variant_issue
[Fix] Timeout error in item attribute validation
2016-12-20 11:31:50 +05:30
Nabin Hait
6c433a3012 Merge pull request #7264 from rmehta/sms-fix
[fix] https for SMS gateway, now using requests fixes #5404
2016-12-20 11:31:17 +05:30
Rushabh Mehta
4c210527b2 [fix] https for SMS gateway, now using requests fixes #5404 2016-12-19 16:22:34 +05:30
Rohit Waghchaure
6500ef404d [Fix] Timeout error in item attribute validation 2016-12-16 13:35:50 +05:30
Nabin Hait
76d1ec8ca7 Merge pull request #7245 from rohitwaghchaure/salary_test_case
[Fix] Test case
2016-12-16 12:41:19 +05:30
Rohit Waghchaure
61fb496be6 [Fix] Test case 2016-12-16 12:19:56 +05:30
Nabin Hait
b628971a80 Merge branch 'hotfix' 2016-12-15 16:35:32 +05:30
Nabin Hait
8a321406b2 bumped to version 7.1.26 2016-12-15 17:05:32 +06:00
Nabin Hait
e3edfe2b12 Removed quick entry for tax rule 2016-12-14 18:44:27 +05:30
Nabin Hait
7ac0d294e1 Merge branch 'hotfix' 2016-12-14 14:33:06 +05:30
Nabin Hait
673d43cc8e bumped to version 7.1.25 2016-12-14 15:03:06 +06:00
Nabin Hait
450a94c6b4 Merge pull request #7214 from rohitwaghchaure/pricing_rule_issue_latest
[Fix] Pricing rule issue
2016-12-14 14:31:34 +05:30
Rohit Waghchaure
39712b5e1d [Fix] Pricing rule issue 2016-12-14 14:12:20 +05:30
Nabin Hait
4b5ab6a0d0 Merge pull request #7205 from nabinhait/hotfix
Address naming if multiple address for same type
2016-12-14 12:50:01 +05:30
Nabin Hait
80cea9795e Address naming if multiple address for same type 2016-12-13 14:50:35 +05:30
Nabin Hait
3bfe01d1e0 Merge branch 'hotfix' 2016-12-13 14:22:15 +05:30
Nabin Hait
9d56d598bf bumped to version 7.1.24 2016-12-13 14:52:15 +06:00
Nabin Hait
23165ce0b4 Merge pull request #7185 from KanchanChauhan/salary-test-cases
[Fix] Salary Slip test cases fix
2016-12-13 12:40:19 +05:30
Kanchan Chauhan
d917b66a31 [Fix] Salary Slip test cases fix 2016-12-13 12:12:49 +05:30
Nabin Hait
c5869a00df Merge pull request #7194 from rohitwaghchaure/pricing_rule_issue_v7_1
[Fix] Ignore pricing rule not removed the discount percentage
2016-12-13 11:22:49 +05:30
Nabin Hait
c7b32e84d0 Merge pull request #7200 from nabinhait/hotfix
Fixed test cases for item / warehouse renaming
2016-12-13 11:07:09 +05:30
Nabin Hait
9a1a4cd0ac Fixed test cases for item / warehouse renaming 2016-12-13 10:46:50 +05:30
Rohit Waghchaure
2976e56d23 [Fix] Ignore pricing rule not removed the discount percentage 2016-12-13 10:28:27 +05:30
Nabin Hait
da3a9e255d Changed fieldtype of opening stock from Int to Float 2016-12-12 18:22:15 +05:30
Nabin Hait
f67799197d Merge pull request #7189 from nabinhait/fix_10111
Rename and merging of Item and Warehouse
2016-12-12 17:27:38 +05:30
Nabin Hait
37104b6bb1 Merge pull request #7184 from rohitwaghchaure/dropship_po_issue
[Fix] Unable to purchase item in the company warehouse if dropship has enabled
2016-12-12 17:24:48 +05:30
Nabin Hait
f93cbe9a51 Merge pull request #7180 from rohitwaghchaure/pos_profile_issue
[Fix] Item group missing in the POS profile
2016-12-12 17:23:15 +05:30
Nabin Hait
fb1fb83b8c [tests] Test cases for Item and Warehouse renaming and merging 2016-12-12 17:01:24 +05:30
Nabin Hait
3ef63bef02 Rename and merging of Item and Warehouse and patch to fix deleted bins 2016-12-12 15:37:52 +05:30
Nabin Hait
142aab79bf Fieldtype of payment url should be Small Text 2016-12-12 15:37:52 +05:30
Rohit Waghchaure
c858d52ce7 [Fix] Unable to purchase item in the company warehouse if dropship has enabled 2016-12-12 13:06:06 +05:30
Rohit Waghchaure
5664f8553e [Fix] Item group missing in the POS profile 2016-12-12 12:28:07 +05:30
Nabin Hait
a188af9f62 Merge pull request #7174 from saurabh6790/tax_rate_field_fix
[minor][fix] show tax rate if account type is tax
2016-12-09 18:09:28 +05:30
Saurabh
940084ed59 [minor][fix] show tax rate if account type is tax 2016-12-09 17:38:36 +05:30
Nabin Hait
67b6e2fbba Merge branch 'hotfix' 2016-12-09 15:45:45 +05:30
Nabin Hait
10de98c0be bumped to version 7.1.23 2016-12-09 16:15:45 +06:00
Nabin Hait
00ae31bd1c Merge pull request #7172 from nabinhait/hotfix
Issue fixed in Quality Inspection, P&L period and purchase register
2016-12-09 15:44:05 +05:30
Nabin Hait
6bfdd63ec8 Merge pull request #7171 from rohitwaghchaure/payment_entry_issue
[Fix] Payment entry showing wrong invoice amount
2016-12-09 15:11:38 +05:30
Nabin Hait
b00df641e0 Fixed period end date if year starts in the middle of the month 2016-12-09 15:09:11 +05:30
Nabin Hait
76a8508d2b Unlink Quality Inspection from PR while cancelling QI 2016-12-09 15:09:11 +05:30
Nabin Hait
43df804176 Fixed renamed fieldname 2016-12-09 15:09:11 +05:30
Rohit Waghchaure
e505067887 [Fix] Payment entry showing wrong invoice amount 2016-12-09 12:55:29 +05:30
Nabin Hait
a0fc404eb8 Merge pull request #7164 from KanchanChauhan/quoted-item-comparison-report-fix
[Fix] Quoted Item Comparison
2016-12-09 12:18:06 +05:30
Nabin Hait
8e885163a3 Update quoted_item_comparison.py 2016-12-09 12:17:45 +05:30
Nabin Hait
e70a284f8e Merge pull request #7167 from webonyx/fix_v7_1_20_patch
Fix patch update_status_of_po_so.py
2016-12-09 11:51:30 +05:30
Viet Pham
ddb856377c Fix patch update_status_of_po_so.py caused error: Column 'per_billed' cannot be null 2016-12-08 20:02:39 +07:00
Kanchan Chauhan
5c031a3512 [Fix] Quoted Item Comparison 2016-12-08 17:29:04 +05:30
Nabin Hait
7b91181fa0 Merge branch 'hotfix' 2016-12-08 12:33:53 +05:30
Nabin Hait
7b513891e3 bumped to version 7.1.22 2016-12-08 13:03:53 +06:00
Nabin Hait
cfe6182798 Merge pull request #7158 from rohitwaghchaure/timesheet_issue_po
minor issue
2016-12-08 12:15:44 +05:30
Rohit Waghchaure
86ed030b5c minor issue 2016-12-07 19:17:01 +05:30
Nabin Hait
07e4fd17af Merge pull request #7157 from rohitwaghchaure/timesheet_po_issue
[fix] Timesheet datetime issue
2016-12-07 18:37:02 +05:30
Rohit Waghchaure
0327b35b5e [fix] timesheet datetime issue 2016-12-07 18:32:36 +05:30
Nabin Hait
5c3564143b Merge branch 'hotfix' 2016-12-06 16:14:44 +05:30
Nabin Hait
bc2deafcf9 bumped to version 7.1.21 2016-12-06 16:44:44 +06:00
Nabin Hait
45fda8a257 Merge pull request #7149 from KanchanChauhan/salary-slip-validation-in-leave
[Minor] Validation fixes in Leave Application and Monthly Salary Register Fix for other laguages
2016-12-06 16:01:38 +05:30
Nabin Hait
67d226f491 Merge pull request #7127 from KanchanChauhan/salary-slip-fix
[Fix] lwp issue fixed for salary slip without salary structure
2016-12-06 15:48:47 +05:30
Nabin Hait
cb3f44716a Merge pull request #7139 from rohitwaghchaure/customer_billing_amount_issue
[Fix] Currecny symbol for customer's total annual billing, total unpaid amount
2016-12-06 15:42:37 +05:30
Nabin Hait
9313a7408c Merge pull request #7144 from rohitwaghchaure/report_builder_total_row_issue
[Enhancement] Total row added for report builder
2016-12-06 15:42:19 +05:30
Nabin Hait
e644ca8992 Merge pull request #7146 from RobertSchouten/digest_cache_dev
[fix] email digest cache by frequency
2016-12-06 15:41:33 +05:30
Nabin Hait
cacfb6839f Merge pull request #7138 from rohitwaghchaure/so_po_status_issue
[Fix] Status of sales order and purchase order
2016-12-06 15:40:57 +05:30
Kanchan Chauhan
dc80b35104 [Minor] Apply Salary Slip validation only if it is submitted 2016-12-06 15:37:24 +05:30
Nabin Hait
b9ebbf18f2 Merge pull request #7143 from rohitwaghchaure/customer_credit_issue
[fix] test cases for customer credit
2016-12-06 15:36:18 +05:30
robert schouten
7f72cd0f97 [fix] email digest cache by frequency 2016-12-06 08:51:40 +08:00
Rohit Waghchaure
6f6a533d66 [fix] salary slip working days 2016-12-05 23:33:02 +05:30
Rohit Waghchaure
36a01d3464 [Enhancement] Total row added for report builder 2016-12-05 18:59:59 +05:30
Rohit Waghchaure
bcc6ea450a [fix] test cases for customer credit 2016-12-05 18:32:57 +05:30
Rohit Waghchaure
c857f37f3a [fix] currecny symbol for customer's total annual billing, total unpaid amount 2016-12-05 17:44:06 +05:30
Rohit Waghchaure
82fa27c36f [Fix] Status of sales order and purchase order 2016-12-05 16:32:23 +05:30
Nabin Hait
12a396ef25 Merge pull request #7107 from RobertSchouten/timesheetdates
calc timesheet dates on validate not just submit
2016-12-05 14:23:21 +05:30
Kanchan Chauhan
4a888b4c91 [Fix] lwp issue fixed for salary slip without salary structure 2016-12-04 13:42:30 +05:30
Nabin Hait
d97ec828b5 Merge pull request #7113 from rohitwaghchaure/edit_serial_no
Allow user to edit serial no for credit note, debit note
2016-12-01 18:06:58 +05:30
Nabin Hait
1f1ffd79e2 Merge pull request #7109 from RobertSchouten/project_wise
[fix] Project wise Stock Tracking is script report
2016-12-01 16:12:46 +05:30
Nabin Hait
c92e2f9044 Update project_wise_stock_tracking.json 2016-12-01 16:12:35 +05:30
Rohit Waghchaure
2e8a94458d allow user to edit serial no for credit note, debit note 2016-12-01 16:04:41 +05:30
Nabin Hait
79f0a97431 Merge pull request #7112 from KanchanChauhan/salary-slip-issue
[Fix] Fixed condition and formula issue in Salary Slip
2016-12-01 15:56:52 +05:30
Kanchan Chauhan
faa525e4f1 [Fix] Fixed condition and formula issue in Salary Slip 2016-12-01 15:31:38 +05:30
robert schouten
81a5467c8f [fix] Project wise Stock Tracking is script report 2016-12-01 09:02:17 +08:00
robert schouten
0beb5bdea6 calc timesheet dates on validate not just submit 2016-12-01 08:51:03 +08:00
Nabin Hait
de932911b5 Merge branch 'hotfix' 2016-11-28 14:22:54 +05:30
Nabin Hait
edfca16931 bumped to version 7.1.20 2016-11-28 14:52:54 +06:00
Nabin Hait
50a240e758 Merge pull request #7061 from rohitwaghchaure/cost_center_issue
[Fix] Cost center group not showing data in the P&L report
2016-11-28 12:42:48 +05:30
Nabin Hait
96be3dd4f4 Merge pull request #7082 from rohitwaghchaure/pos_qty_issues
[Fix] Wrong actual qty showing in POS
2016-11-28 12:39:09 +05:30
Nabin Hait
1880fc46d3 Merge pull request #7084 from nabinhait/hotfix
Multiple minor fixes
2016-11-28 12:38:48 +05:30
Nabin Hait
a78c463e97 Multiple minor fixes 2016-11-27 16:32:41 +05:30
Rohit Waghchaure
80f5bb6a6c [Fix] Wrong actual qty showing in POS 2016-11-27 12:04:12 +05:30
Nabin Hait
d0839799c1 Update workstation.py 2016-11-26 09:54:00 +05:30
Rohit Waghchaure
bca0d73e1c [Fix] Cost center group not showing data in the P&L report 2016-11-25 14:54:34 +05:30
Nabin Hait
14823d0d0f Merge pull request #7066 from rohitwaghchaure/pos_barcode_search_issue
[fix] Barcode and special character issue in the search box of the POS
2016-11-25 11:20:55 +05:30
Rohit Waghchaure
9a36083095 [fix] Barcode and special character issue in the search box of the POS 2016-11-25 11:17:48 +05:30
Nabin Hait
1e3d14fda7 Merge pull request #7051 from rohitwaghchaure/v7_timesheet_cleanup
cleanup timesheet and fix sales invoice total timesheet billing amount
2016-11-24 13:06:04 +05:30
Rohit Waghchaure
8c4e45ab3d cleanup timesheet 2016-11-23 17:54:47 +05:30
Nabin Hait
6fc850d071 Merge branch 'hotfix' 2016-11-23 16:00:22 +05:30
Nabin Hait
580534a22a bumped to version 7.1.19 2016-11-23 16:30:22 +06:00
Nabin Hait
297d74a997 Unlink payment entries on cancellation of invoice 2016-11-23 15:59:00 +05:30
Nabin Hait
b8a7926464 Merge branch 'hotfix' 2016-11-23 14:53:42 +05:30
Nabin Hait
7f540af7a6 bumped to version 7.1.18 2016-11-23 15:23:42 +06:00
Nabin Hait
b18ad55e2b minor fixes 2016-11-23 14:51:30 +05:30
Nabin Hait
b439afb5e5 Merge pull request #7045 from saurabh6790/root_type_fix_and_other
[fix] Root type fix
2016-11-23 14:46:05 +05:30
Nabin Hait
cf895c220c Update account_tree.js 2016-11-23 14:44:07 +05:30
Saurabh
9342f650e0 [fix] remove root type selection while created new node and hooks call to initialize payment gateway 2016-11-23 14:06:14 +05:30
Nabin Hait
b91aed807a Merge pull request #7042 from RobertSchouten/naming_series
[fix] naming series only show non disabled role doctypes
2016-11-23 13:26:19 +05:30
robert schouten
085706bcbf [fix] naming series only show non disabled role doctypes 2016-11-23 13:57:21 +08:00
Rushabh Mehta
8685225644 Merge branch 'hotfix' 2016-11-22 23:18:28 +05:30
Rushabh Mehta
6557e37d5c bumped to version 7.1.17 2016-11-22 23:48:28 +06:00
Rushabh Mehta
698c040d21 [hot] fix quotation (#7039) 2016-11-22 23:16:40 +05:30
Nabin Hait
c381327e6e Merge pull request #7032 from rohitwaghchaure/patch_issue
fix patch
2016-11-22 13:51:51 +05:30
Rohit Waghchaure
334f032780 fix patch 2016-11-22 13:30:13 +05:30
Nabin Hait
ee874a2a36 Update student_admission.py 2016-11-22 12:42:24 +05:30
Nabin Hait
8132be288f Merge branch 'hotfix' 2016-11-21 19:10:05 +05:30
Nabin Hait
d75d3a927d bumped to version 7.1.16 2016-11-21 19:40:05 +06:00
Nabin Hait
651d8e996b Merge pull request #7020 from nabinhait/balance_sheet_fix
Provisional Loss related fix in Balance Sheet. Fixed #6918
2016-11-21 19:06:42 +05:30
Nabin Hait
d01d74cafd Merge pull request #7019 from nabinhait/fix_10014
Default warehouse is mandatory only for stock item in POS. Fixed #6893
2016-11-21 19:06:30 +05:30
Nabin Hait
9789b50ae5 Merge pull request #7018 from nabinhait/fix_10013
Set project from Sales Order while creating Material Request from PPT, fixed #6731
2016-11-21 19:06:14 +05:30
Nabin Hait
5224a04628 Merge pull request #7016 from nabinhait/fix_10012
Set WIP warehouse in Pro Order based on Manufacturing Settings. Fixed #6636
2016-11-21 19:05:50 +05:30
Nabin Hait
bdab3103e3 Merge pull request #7015 from nabinhait/fix_10011
Multiple fixes
2016-11-21 19:05:34 +05:30
Nabin Hait
376e8945f7 Merge pull request #7014 from rohitwaghchaure/rename_autoname_field
patch for rename autoname field
2016-11-21 19:04:44 +05:30
Nabin Hait
3d5ef804b2 Provisional Loss related fix in Balance Sheet. Fixed #6918 2016-11-21 18:53:05 +05:30
Nabin Hait
977eff911f Default warehouse is mandatory only for stock item in POS. Fixed #6893 2016-11-21 18:29:16 +05:30
Nabin Hait
9b797974b5 Set project from Sales Order while creating Material Request from PPT, fixed #6731 2016-11-21 18:15:50 +05:30
Nabin Hait
075e33245e Set WIP warehouse in Pro Order based on Manufacturing Settings. Fixed #6636 2016-11-21 18:09:55 +05:30
Nabin Hait
fd23fa7c0b Prifitability report link added to accounts module page 2016-11-21 16:59:03 +05:30
Nabin Hait
542bf8f7d4 Party filter and total row for opening and closing in trial balance for party report 2016-11-21 16:58:50 +05:30
Rohit Waghchaure
4810d1fa2d patch for rename autoname field 2016-11-21 16:52:50 +05:30
Nabin Hait
8d161ef2e1 Merge pull request #6899 from shreyasp/docs-update
Updated Docs for Purchase Order and Supplier Quotation
2016-11-21 15:28:27 +05:30
Nabin Hait
e60d51b74c Merge pull request #6969 from rohitwaghchaure/pos_syncing_issue_and_enhancement
User can able to add multiple item group, customer group in the POS profile.
2016-11-21 15:27:41 +05:30
Nabin Hait
b30e184f6b Merge pull request #7003 from KanchanChauhan/workstation-fix
[Fix]Workstation holiday list
2016-11-21 14:51:24 +05:30
Nabin Hait
0900407c18 Merge pull request #7010 from rmehta/duplicate-icon-patch-fix
[patch] reload desktop icon #6826
2016-11-21 14:50:36 +05:30
Nabin Hait
c16b373969 Merge pull request #6994 from nabinhait/manual_depreciation
Manual Depreciation Schedule for Asset
2016-11-21 14:49:58 +05:30
Rushabh Mehta
e9fc31168d [patch] reload desktop icon #6826 2016-11-21 14:29:31 +05:30
Kanchan Chauhan
d33c44e3a5 [Fix]Workstation holiday list 2016-11-21 11:23:01 +05:30
Rohit Waghchaure
a27c417e48 fix master data sync performance issue 2016-11-20 23:41:13 +05:30
Nabin Hait
cbd26e3b2c Manual Depreciation Schedule for Asset 2016-11-18 17:19:45 +05:30
Rohit Waghchaure
2a81960e0b test cases 2016-11-18 15:33:11 +05:30
Rohit Waghchaure
801029e055 Added item groups, customer groups in the POS profile. 2016-11-18 15:32:48 +05:30
Nabin Hait
c29c5210f9 Merge pull request #6972 from RobertSchouten/bankstatement
[fix] update bank recon statement printing for payment entries
2016-11-18 12:50:40 +05:30
Nabin Hait
a3a59ea895 Merge pull request #6973 from RobertSchouten/bankrecon
[fix] layout for bank reconciliation
2016-11-18 12:49:16 +05:30
Nabin Hait
684d44385f Merge pull request #6991 from rohitwaghchaure/delivery_note_issue
[Fix] Delivery note, show paking items in order, show serial no of the respective item in the dropdown of packing item
2016-11-18 12:45:31 +05:30
Nabin Hait
eae077e05d Merge pull request #6989 from RobertSchouten/financialprint
[fix] financial printing and add to profitability
2016-11-18 12:44:50 +05:30
Rohit Waghchaure
e887e92dd4 Minor fix in delivery note, show paking items in order, show serial no of the respective item in the dropdown of packing item 2016-11-18 12:16:22 +05:30
robert schouten
0a1f3e4058 [fix] financial printing and add to profitability 2016-11-18 10:54:01 +08:00
Nabin Hait
05d0cd9574 Merge pull request #6982 from rohitwaghchaure/pos_is_pos_default_issue
[Fix] Onload pull pos profile data for IS POS invoice
2016-11-17 18:29:22 +05:30
Rohit Waghchaure
2ef7c7ae5c [Fix] Onload pull pos profile data for IS POS invoice 2016-11-17 17:29:10 +05:30
Nabin Hait
d79cca3ba7 Merge branch 'hotfix' 2016-11-17 16:41:51 +05:30
Nabin Hait
f83302836c bumped to version 7.1.15 2016-11-17 17:11:51 +06:00
Nabin Hait
bd99a7cb5d Merge pull request #6980 from shreyasp/setup-wizard-domain
[Fix] Updated 'FR' translation to prevent setup wizard failure
2016-11-17 16:07:43 +05:30
Nabin Hait
29570d1ecb Merge branch 'hotfix' 2016-11-17 15:54:07 +05:30
Nabin Hait
f2b7ec919a bumped to version 7.1.14 2016-11-17 16:24:07 +06:00
Nabin Hait
f76aab6021 Merge pull request #6976 from saurabh6790/advance_payment_entry_cancellation_fix
[fix] on advance payment entry cancellation delink invoice and pyamen…
2016-11-17 15:41:31 +05:30
robert schouten
2b63e14089 dh drop guest from student attendance so disabling acedemic user disables all school doctypes (#6974) 2016-11-17 15:23:38 +05:30
Saurabh
1d210968de [fix] on advance payment entry cancellation delink invoice and pyament entry references 2016-11-17 15:21:46 +05:30
shreyas
0c93445be0 [Fix] Updated 'FR' translation to prevent setup wizard failure 2016-11-17 14:31:32 +05:30
Nabin Hait
7fc05d6432 Update update_missing_salary_component_type.py 2016-11-17 12:16:52 +05:30
robert schouten
a943535520 [fix] update bank recon statement printing for payment entries 2016-11-17 14:33:28 +08:00
robert schouten
60fb1b8643 [fix] layout for bank reconciliation 2016-11-17 14:30:47 +08:00
Nabin Hait
aa68058910 Updated modified_datetime in production planning tool 2016-11-16 17:41:08 +05:30
Nabin Hait
8dd859920f Merge pull request #6960 from KanchanChauhan/thumbnail-in-shoppingcart
[Fix]Product thumbnail in Shopping Cart
2016-11-16 17:34:17 +05:30
Nabin Hait
7f6b99aca4 Merge pull request #6962 from KanchanChauhan/payroll-fixes
[Fix] Filters to get employee in Payroll
2016-11-16 17:34:00 +05:30
Nabin Hait
01dc2e412d Merge pull request #6964 from mbauskar/hotfix
[minor] fixes in validate selling price
2016-11-16 17:32:11 +05:30
mbauskar
e9747a8a6e [minor] fixes in validate selling price 2016-11-16 17:19:47 +05:30
Kanchan Chauhan
7652b857c8 [Fix] Filters to get employee in Payroll 2016-11-16 15:29:01 +05:30
Kanchan Chauhan
98f499a43e [Fix]Product thumbnail in Shopping Cart 2016-11-16 15:17:55 +05:30
Nabin Hait
535462fc20 Merge pull request #6947 from saurabh6790/delink_jv_from_advance
[fix] delink jv from advance table
2016-11-16 14:22:03 +05:30
Nabin Hait
e346a499c7 Merge pull request #6956 from rohitwaghchaure/payment_entry_issue
[Fix] Payment entry, exchange rate is not set properly
2016-11-16 14:15:52 +05:30
Saurabh
8adbfa8a09 [test-case] test cases for delinking advance payments 2016-11-16 13:43:01 +05:30
Saurabh
866c295989 [fix] on jv cancel remove linkings from advance table of Sales/Purchase Invoice 2016-11-16 13:43:01 +05:30
Nabin Hait
67bceef1cb Merge branch 'hotfix' 2016-11-16 12:55:59 +05:30
Nabin Hait
38bfcaa203 bumped to version 7.1.13 2016-11-16 13:25:59 +06:00
Nabin Hait
00e841d744 update missing salary component abbr 2016-11-16 12:55:17 +05:30
Rohit Waghchaure
9b18ed4ffe [Fix] Payment entry, exchange rate is not set properly 2016-11-16 12:24:40 +05:30
Rushabh Mehta
d65d67e0a7 Merge branch 'hotfix' 2016-11-16 11:26:42 +05:30
Rushabh Mehta
a78bac61cc bumped to version 7.1.12 2016-11-16 11:56:42 +06:00
rohitwaghchaure
48cb3d89b6 [Fix] Opening balance calculation issue for balance sheet (#6945) 2016-11-16 11:18:49 +05:30
Rushabh Mehta
8dfbe7c748 [fix] patch missing salary component type based on existing salary slips (#6955) 2016-11-16 11:18:20 +05:30
Shreyas Patil
99a3593a0d [Fix] Make from_date and to_date for stock balance query report as mandatory fields (#6948) 2016-11-16 11:16:44 +05:30
rohitwaghchaure
7be942db54 [Fix] Status updater for sales order in purchase order (#6944) 2016-11-16 11:14:32 +05:30
Rushabh Mehta
24f658d633 [fix] [minor] accounts receivable not translated (#6943) 2016-11-16 11:13:46 +05:30
Rushabh Mehta
d51e1587d5 [fix] contact us page should create a opportunity by default (#6939) 2016-11-16 11:13:31 +05:30
rohitwaghchaure
b3ba7f01ef [Fix] PO status not changed as material return created against them (#6869) 2016-11-16 11:10:10 +05:30
Rushabh Mehta
e0ab64d6cc [minor] reload user for patch 2016-11-15 16:43:37 +05:30
Nabin Hait
952b1cb9a7 Merge pull request #6933 from rohitwaghchaure/remove_no_copy
disable no copy for po number, po date on sales order
2016-11-14 17:47:57 +05:30
Rohit Waghchaure
6f27f580e1 disable no copy for po number, po date on sales order 2016-11-14 16:08:18 +05:30
Rushabh Mehta
440650d4a2 [fix] view shopping cart dropdown (#6928) 2016-11-14 13:13:53 +05:30
Nabin Hait
6261745366 Merge branch 'hotfix' 2016-11-14 12:42:26 +05:30
Nabin Hait
d209f21e76 bumped to version 7.1.11 2016-11-14 13:12:25 +06:00
Nabin Hait
da4689461a Merge pull request #6926 from nabinhait/hotfix
Multiple fixes
2016-11-14 12:37:11 +05:30
Nabin Hait
a5a733630f [fix] Opportunity loading issue 2016-11-14 12:32:16 +05:30
Nabin Hait
0075c7e659 Purchase Order and Receipt links in Purchase Invoice dashboard 2016-11-14 12:32:16 +05:30
Nabin Hait
7017dc029a Editable grid columns for payment entry 2016-11-14 12:32:16 +05:30
Nabin Hait
f98835036b Merge pull request #6900 from rohitwaghchaure/account_receivable_summary_report_issue
[Report] Company not found in the filter for making auto email report
2016-11-14 12:00:48 +05:30
Nabin Hait
47c8d5fd56 Merge pull request #6924 from nabinhait/hotfix
Fixed multiple minor issues
2016-11-14 11:59:46 +05:30
Nabin Hait
6209f2f75b Merge pull request #6925 from rmehta/setup-wizard-fix
[fix] ignore duplicate names for program, academic term, academic year, course, instructor
2016-11-14 11:59:26 +05:30
Rushabh Mehta
463808ef9e [fix] ignore duplicate names for program, academic term, academic year, course, instructor 2016-11-14 11:21:11 +05:30
Nabin Hait
256a3fef95 Fixed multiple minor issues 2016-11-14 11:10:50 +05:30
Rohit Waghchaure
387c2846aa [Report] Company not found in the filter for making auto email report 2016-11-10 19:13:20 +05:30
shreyas
2cb294c8b4 [Docs] Updated docs for supplier quotation and purchase order 2016-11-10 18:14:33 +05:30
Nabin Hait
598a0c918d [fix] fixed student dashboard issue (#6897) 2016-11-10 17:25:37 +05:30
Nabin Hait
176577b549 Merge branch 'hotfix' 2016-11-10 11:25:33 +05:30
Nabin Hait
27c1f85836 bumped to version 7.1.10 2016-11-10 11:55:33 +06:00
Nabin Hait
84ecaac27d Update set_base_amount_in_invoice_payment_table.py 2016-11-10 11:24:22 +05:30
Nabin Hait
0f2e3a4e95 Merge branch 'hotfix' 2016-11-09 14:55:29 +05:30
Nabin Hait
549de70fa2 bumped to version 7.1.9 2016-11-09 15:25:29 +06:00
Nabin Hait
9e83b70ea8 Merge pull request #6860 from rohitwaghchaure/status_for_sales_invoice
Added status field in sales invoice and purchase invoice
2016-11-09 14:53:03 +05:30
Rohit Waghchaure
2285f90b64 added debit and credit note status 2016-11-09 14:47:24 +05:30
Rohit Waghchaure
2f1db57fe1 Added status field in sales invoice and purchase invoice 2016-11-08 18:49:58 +05:30
Nabin Hait
31f6436f75 [patch] Set base amount in Sales Invoice Payment table 2016-11-08 17:41:14 +05:30
154 changed files with 2600 additions and 779 deletions

View File

@@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe
__version__ = '7.1.8'
__version__ = '7.1.29'
def get_default_company(user=None):
'''Get default company for user'''

View File

@@ -27,13 +27,14 @@ frappe.treeview_settings["Account"] = {
{fieldtype:'Check', fieldname:'is_group', label:__('Is Group'),
description: __('Further accounts can be made under Groups, but entries can be made against non-Groups')},
{fieldtype:'Select', fieldname:'root_type', label:__('Root Type'),
options: ['Asset', 'Liability', 'Equity', 'Income', 'Expense'].join('\n')},
options: ['Asset', 'Liability', 'Equity', 'Income', 'Expense'].join('\n'),
depends_on: 'eval:doc.is_group && !doc.parent_account'},
{fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),
options: ['', 'Bank', 'Cash', 'Stock', 'Tax', 'Chargeable', 'Fixed Asset'].join('\n'),
description: __("Optional. This setting will be used to filter in various transactions.")
},
{fieldtype:'Float', fieldname:'tax_rate', label:__('Tax Rate'),
depends_on: 'eval:doc.is_group==1&&doc.account_type=="Tax"'},
depends_on: 'eval:doc.is_group==0&&doc.account_type=="Tax"'},
{fieldtype:'Link', fieldname:'warehouse', label:__('Warehouse'), options:"Warehouse",
depends_on: 'eval:(!doc.is_group&&doc.account_type=="Stock")',
get_query: function() {
@@ -79,4 +80,4 @@ frappe.treeview_settings["Account"] = {
}
],
extend_toolbar: true
}
}

View File

@@ -28,6 +28,7 @@ frappe.ui.form.on('Asset', {
refresh: function(frm) {
frappe.ui.form.trigger("Asset", "is_existing_asset");
frm.toggle_display("next_depreciation_date", frm.doc.docstatus < 1);
frm.events.make_schedules_editable(frm);
if (frm.doc.docstatus==1) {
if (frm.doc.status=='Submitted' && !frm.doc.is_existing_asset && !frm.doc.purchase_invoice) {
@@ -141,6 +142,22 @@ frappe.ui.form.on('Asset', {
frm.toggle_enable("supplier", frm.doc.is_existing_asset);
frm.toggle_reqd("next_depreciation_date", !frm.doc.is_existing_asset);
},
opening_accumulated_depreciation: function(frm) {
erpnext.asset.set_accululated_depreciation(frm);
},
depreciation_method: function(frm) {
frm.events.make_schedules_editable(frm);
},
make_schedules_editable: function(frm) {
var is_editable = frm.doc.depreciation_method==="Manual" ? true : false;
frm.toggle_enable("schedules", is_editable);
frm.fields_dict["schedules"].grid.toggle_enable("schedule_date", is_editable);
frm.fields_dict["schedules"].grid.toggle_enable("depreciation_amount", is_editable);
}
});
frappe.ui.form.on('Depreciation Schedule', {
@@ -159,9 +176,25 @@ frappe.ui.form.on('Depreciation Schedule', {
}
})
}
},
depreciation_amount: function(frm, cdt, cdn) {
erpnext.asset.set_accululated_depreciation(frm);
}
})
erpnext.asset.set_accululated_depreciation = function(frm) {
if(frm.doc.depreciation_method != "Manual") return;
accumulated_depreciation = flt(frm.doc.opening_accumulated_depreciation);
$.each(frm.doc.schedules || [], function(i, row) {
accumulated_depreciation += flt(row.depreciation_amount);
frappe.model.set_value(row.doctype, row.name,
"accumulated_depreciation_amount", accumulated_depreciation);
})
}
erpnext.asset.make_purchase_invoice = function(frm) {
frappe.call({
args: {

View File

@@ -516,7 +516,7 @@
"columns": 0,
"fieldname": "value_after_depreciation",
"fieldtype": "Currency",
"hidden": 0,
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
@@ -580,7 +580,7 @@
"label": "Depreciation Method",
"length": 0,
"no_copy": 0,
"options": "\nStraight Line\nDouble Declining Balance",
"options": "\nStraight Line\nDouble Declining Balance\nManual",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -750,7 +750,7 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@@ -797,7 +797,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-11-03 14:58:53.710357",
"modified": "2016-11-18 15:59:19.774500",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Asset",

View File

@@ -18,6 +18,7 @@ class Asset(Document):
self.set_missing_values()
self.validate_asset_values()
self.make_depreciation_schedule()
self.set_accumulated_depreciation()
self.validate_expected_value_after_useful_life()
# Validate depreciation related accounts
get_depreciation_accounts(self)
@@ -48,7 +49,7 @@ class Asset(Document):
for field, value in item_details.items():
if not self.get(field):
self.set(field, value)
self.value_after_depreciation = (flt(self.gross_purchase_amount) -
flt(self.opening_accumulated_depreciation))
@@ -87,9 +88,10 @@ class Asset(Document):
frappe.throw(_("Please set Next Depreciation Date"))
def make_depreciation_schedule(self):
self.schedules = []
if self.depreciation_method != 'Manual':
self.schedules = []
if not self.get("schedules") and self.next_depreciation_date:
accumulated_depreciation = flt(self.opening_accumulated_depreciation)
value_after_depreciation = flt(self.value_after_depreciation)
number_of_pending_depreciations = cint(self.total_number_of_depreciations) - \
@@ -100,18 +102,21 @@ class Asset(Document):
n * cint(self.frequency_of_depreciation))
depreciation_amount = self.get_depreciation_amount(value_after_depreciation)
accumulated_depreciation += flt(depreciation_amount)
value_after_depreciation -= flt(depreciation_amount)
self.append("schedules", {
"schedule_date": schedule_date,
"depreciation_amount": depreciation_amount,
"accumulated_depreciation_amount": accumulated_depreciation
"depreciation_amount": depreciation_amount
})
def set_accumulated_depreciation(self):
accumulated_depreciation = flt(self.opening_accumulated_depreciation)
for d in self.get("schedules"):
accumulated_depreciation += flt(d.depreciation_amount)
d.accumulated_depreciation_amount = accumulated_depreciation
def get_depreciation_amount(self, depreciable_value):
if self.depreciation_method == "Straight Line":
if self.depreciation_method in ("Straight Line", "Manual"):
depreciation_amount = (flt(self.value_after_depreciation) -
flt(self.expected_value_after_useful_life)) / (cint(self.total_number_of_depreciations) -
cint(self.number_of_depreciations_booked))
@@ -126,16 +131,15 @@ class Asset(Document):
return depreciation_amount
def validate_expected_value_after_useful_life(self):
if self.depreciation_method == "Double Declining Balance":
accumulated_depreciation_after_full_schedule = \
max([d.accumulated_depreciation_amount for d in self.get("schedules")])
asset_value_after_full_schedule = (flt(self.gross_purchase_amount) -
flt(accumulated_depreciation_after_full_schedule))
if self.expected_value_after_useful_life < asset_value_after_full_schedule:
frappe.throw(_("Expected value after useful life must be greater than or equal to {0}")
.format(asset_value_after_full_schedule))
accumulated_depreciation_after_full_schedule = \
max([d.accumulated_depreciation_amount for d in self.get("schedules")])
asset_value_after_full_schedule = (flt(self.gross_purchase_amount) -
flt(accumulated_depreciation_after_full_schedule))
if self.expected_value_after_useful_life < asset_value_after_full_schedule:
frappe.throw(_("Expected value after useful life must be greater than or equal to {0}")
.format(asset_value_after_full_schedule))
def validate_cancellation(self):
if self.status not in ("Submitted", "Partially Depreciated", "Fully Depreciated"):

View File

@@ -119,6 +119,30 @@ class TestAsset(unittest.TestCase):
for d in asset.get("schedules")]
self.assertEqual(schedules, expected_schedules)
def test_schedule_for_manual_method(self):
asset = frappe.get_doc("Asset", "Macbook Pro 1")
asset.depreciation_method = "Manual"
asset.schedules = []
for schedule_date, amount in [["2020-12-31", 40000], ["2021-06-30", 30000], ["2021-10-31", 20000]]:
asset.append("schedules", {
"schedule_date": schedule_date,
"depreciation_amount": amount
})
asset.save()
self.assertEqual(asset.status, "Draft")
expected_schedules = [
["2020-12-31", 40000, 40000],
["2021-06-30", 30000, 70000],
["2021-10-31", 20000, 90000]
]
schedules = [[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount]
for d in asset.get("schedules")]
self.assertEqual(schedules, expected_schedules)
def test_depreciation(self):
asset = frappe.get_doc("Asset", "Macbook Pro 1")

View File

@@ -46,6 +46,12 @@ frappe.ui.form.on("Bank Reconciliation", {
callback: function(r, rt) {
frm.refresh_field("payment_entries");
frm.refresh_fields();
$(frm.fields_dict.payment_entries.wrapper).find("[data-fieldname=amount]").each(function(i,v){
if (i !=0){
$(v).addClass("text-right")
}
})
}
});
}

View File

@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import flt, getdate, nowdate
from frappe.utils import flt, getdate, nowdate, fmt_money
from frappe import msgprint, _
from frappe.model.document import Document
@@ -26,8 +26,8 @@ class BankReconciliation(Document):
select
"Journal Entry" as payment_document, t1.name as payment_entry,
t1.cheque_no as cheque_number, t1.cheque_date,
abs(t2.debit_in_account_currency - t2.credit_in_account_currency) as amount,
t1.posting_date, t2.against_account, t1.clearance_date
t2.debit_in_account_currency as debit, t2.credit_in_account_currency as credit,
t1.posting_date, t2.against_account, t1.clearance_date, t2.account_currency
from
`tabJournal Entry` t1, `tabJournal Entry Account` t2
where
@@ -36,21 +36,23 @@ class BankReconciliation(Document):
and ifnull(t1.is_opening, 'No') = 'No' {0}
order by t1.posting_date ASC, t1.name DESC
""".format(condition), (self.bank_account, self.from_date, self.to_date), as_dict=1)
payment_entries = frappe.db.sql("""
select
"Payment Entry" as payment_document, name as payment_entry,
reference_no as cheque_number, reference_date as cheque_date,
if(paid_from=%s, paid_amount, received_amount) as amount,
posting_date, party as against_account, clearance_date
if(paid_from=%(account)s, paid_amount, "") as credit,
if(paid_from=%(account)s, "", received_amount) as debit,
posting_date, ifnull(party,if(paid_from=%(account)s,paid_to,paid_from)) as against_account, clearance_date,
if(paid_to=%(account)s, paid_to_account_currency, paid_from_account_currency) as account_currency
from `tabPayment Entry`
where
(paid_from=%s or paid_to=%s) and docstatus=1
and posting_date >= %s and posting_date <= %s {0}
(paid_from=%(account)s or paid_to=%(account)s) and docstatus=1
and posting_date >= %(from)s and posting_date <= %(to)s {0}
order by
posting_date ASC, name DESC
""".format(condition),
(self.bank_account, self.bank_account, self.bank_account, self.from_date, self.to_date), as_dict=1)
{"account":self.bank_account, "from":self.from_date, "to":self.to_date}, as_dict=1)
entries = sorted(list(payment_entries)+list(journal_entries),
key=lambda k: k['posting_date'] or getdate(nowdate()))
@@ -60,6 +62,11 @@ class BankReconciliation(Document):
for d in entries:
row = self.append('payment_entries', {})
d.amount = fmt_money(d.debit if d.debit else d.credit, 2, d.account_currency) + " " + (_("Dr") if d.debit else _("Cr"))
d.pop("credit")
d.pop("debit")
d.pop("account_currency")
row.update(d)
self.total_amount += flt(d.amount)

View File

@@ -40,14 +40,14 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"columns": 1,
"fieldname": "payment_entry",
"fieldtype": "Dynamic Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_list_view": 1,
"label": "Payment Entry",
"length": 0,
"no_copy": 0,
@@ -69,7 +69,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 3,
"columns": 2,
"fieldname": "against_account",
"fieldtype": "Data",
"hidden": 0,
@@ -99,7 +99,7 @@
"collapsible": 0,
"columns": 2,
"fieldname": "amount",
"fieldtype": "Currency",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -110,7 +110,7 @@
"no_copy": 0,
"oldfieldname": "debit",
"oldfieldtype": "Currency",
"options": "account_currency",
"options": "",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -151,7 +151,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"columns": 2,
"fieldname": "posting_date",
"fieldtype": "Date",
"hidden": 0,
@@ -178,7 +178,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 3,
"columns": 1,
"fieldname": "cheque_number",
"fieldtype": "Data",
"hidden": 0,
@@ -267,7 +267,7 @@
"istable": 1,
"max_attachments": 0,
"menu_index": 0,
"modified": "2016-08-26 01:51:36.123941",
"modified": "2016-11-17 11:39:00.308624",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Bank Reconciliation Detail",

View File

@@ -10,11 +10,13 @@
"doctype": "DocType",
"document_type": "Document",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "schedule_date",
"fieldtype": "Date",
"hidden": 0,
@@ -29,7 +31,8 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -40,6 +43,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "depreciation_amount",
"fieldtype": "Currency",
"hidden": 0,
@@ -55,7 +59,8 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -66,6 +71,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
@@ -80,6 +86,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -90,6 +97,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "accumulated_depreciation_amount",
"fieldtype": "Currency",
"hidden": 0,
@@ -106,8 +114,9 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@@ -116,6 +125,8 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.docstatus==1",
"fieldname": "journal_entry",
"fieldtype": "Link",
"hidden": 0,
@@ -132,6 +143,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -142,7 +154,8 @@
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"depends_on": "eval:(!doc.journal_entry && doc.schedule_date <= get_today())",
"columns": 0,
"depends_on": "eval:(doc.docstatus==1 && !doc.journal_entry && doc.schedule_date <= get_today())",
"fieldname": "make_depreciation_entry",
"fieldtype": "Button",
"hidden": 0,
@@ -158,6 +171,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -175,7 +189,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-07-11 03:27:59.603924",
"modified": "2016-11-18 16:42:19.543657",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Depreciation Schedule",

View File

@@ -195,6 +195,7 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
if against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
ref_doc = frappe.get_doc(against_voucher_type, against_voucher)
ref_doc.db_set('outstanding_amount', bal)
ref_doc.set_status(update=True)
def validate_frozen_account(account, adv_adj=None):
frozen_account = frappe.db.get_value("Account", account, "freeze_account")

View File

@@ -63,12 +63,21 @@ class JournalEntry(AccountsController):
def on_cancel(self):
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
from erpnext.hr.doctype.salary_slip.salary_slip import unlink_ref_doc_from_salary_slip
unlink_ref_doc_from_payment_entries(self.doctype, self.name)
unlink_ref_doc_from_salary_slip(self.name)
unlink_ref_doc_from_payment_entries(self)
unlink_ref_doc_from_salary_slip(self.name)
self.make_gl_entries(1)
self.update_advance_paid()
self.update_expense_claim()
self.unlink_advance_entry_reference()
def unlink_advance_entry_reference(self):
for d in self.get("accounts"):
if d.is_advance and d.reference_type in ("Sales Invoice", "Purchase Invoice"):
doc = frappe.get_doc(d.reference_type, d.reference_name)
doc.delink_advance_entries(self.name)
d.reference_type = ''
d.reference_name = ''
d.db_update()
def validate_party(self):
for d in self.get("accounts"):

View File

@@ -9,11 +9,14 @@
"description": "**Monthly Distribution** helps you distribute the Budget/Target across months if you have seasonality in your business.",
"docstatus": 0,
"doctype": "DocType",
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Name of the Monthly Distribution",
"fieldname": "distribution_id",
"fieldtype": "Data",
@@ -31,6 +34,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -41,6 +45,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "fiscal_year",
"fieldtype": "Link",
"hidden": 0,
@@ -58,6 +63,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 1,
@@ -68,6 +74,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "percentages",
"fieldtype": "Table",
"hidden": 0,
@@ -85,6 +92,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -96,13 +104,14 @@
"hide_toolbar": 0,
"icon": "icon-bar-chart",
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-05-16 16:35:20.349194",
"modified": "2016-11-21 14:54:35.998761",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Monthly Distribution",
@@ -119,6 +128,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
@@ -139,6 +149,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 2,
"print": 0,
"read": 1,
@@ -150,7 +161,7 @@
"write": 0
}
],
"quick_entry": 1,
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",

View File

@@ -406,7 +406,10 @@ frappe.ui.form.on('Payment Entry', {
if(!frm.doc.paid_amount && frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency) {
frm.set_value("paid_amount", frm.doc.received_amount);
frm.set_value("source_exchange_rate", frm.doc.target_exchange_rate);
if(frm.doc.target_exchange_rate) {
frm.set_value("source_exchange_rate", frm.doc.target_exchange_rate);
}
frm.set_value("base_paid_amount", frm.doc.base_received_amount);
}
@@ -426,7 +429,10 @@ frappe.ui.form.on('Payment Entry', {
(frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency)) {
frm.set_value("received_amount", frm.doc.paid_amount);
frm.set_value("target_exchange_rate", frm.doc.source_exchange_rate);
if(frm.doc.source_exchange_rate) {
frm.set_value("target_exchange_rate", frm.doc.source_exchange_rate);
}
frm.set_value("base_received_amount", frm.doc.base_paid_amount);
}

View File

@@ -60,7 +60,14 @@ class PaymentEntry(AccountsController):
self.setup_party_account_field()
self.make_gl_entries(cancel=1)
self.update_advance_paid()
self.delink_advance_entry_references()
def delink_advance_entry_references(self):
for reference in self.references:
if reference.reference_doctype in ("Sales Invoice", "Purchase Invoice"):
doc = frappe.get_doc(reference.reference_doctype, reference.reference_name)
doc.delink_advance_entries(self.name)
def set_missing_values(self):
if self.payment_type == "Internal Transfer":
for field in ("party", "party_balance", "total_allocated_amount",
@@ -632,7 +639,7 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
if party_amount:
grand_total = outstanding_amount = party_amount
elif dt in ("Sales Invoice", "Purchase Invoice"):
grand_total = doc.grand_total
grand_total = doc.base_grand_total if party_account_currency == doc.company_currency else doc.grand_total
outstanding_amount = doc.outstanding_amount
else:
total_field = "base_grand_total" if party_account_currency == doc.company_currency else "grand_total"

View File

@@ -31,6 +31,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -58,6 +59,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -84,6 +86,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -109,6 +112,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -119,7 +123,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"columns": 2,
"fieldname": "total_amount",
"fieldtype": "Float",
"hidden": 0,
@@ -135,6 +139,7 @@
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -145,7 +150,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 3,
"columns": 2,
"fieldname": "outstanding_amount",
"fieldtype": "Float",
"hidden": 0,
@@ -161,6 +166,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -171,7 +177,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 3,
"columns": 2,
"fieldname": "allocated_amount",
"fieldtype": "Float",
"hidden": 0,
@@ -187,6 +193,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -213,6 +220,7 @@
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -230,7 +238,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-08-26 01:59:04.697274",
"modified": "2016-11-14 12:28:51.822341",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Entry Reference",

View File

@@ -32,6 +32,7 @@
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -58,6 +59,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -86,6 +88,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -112,6 +115,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -138,6 +142,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -163,6 +168,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -190,6 +196,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -217,6 +224,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -245,6 +253,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -273,6 +282,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -300,6 +310,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -325,6 +336,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -351,6 +363,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -378,6 +391,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -404,6 +418,7 @@
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
@@ -416,7 +431,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "payment_url",
"fieldtype": "Data",
"fieldtype": "Small Text",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -430,6 +445,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -457,6 +473,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -484,6 +501,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -511,6 +529,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -537,6 +556,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -564,6 +584,7 @@
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
@@ -591,6 +612,7 @@
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 1,
"reqd": 0,
"search_index": 0,
@@ -617,6 +639,7 @@
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -634,7 +657,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-09-02 04:07:15.279949",
"modified": "2016-12-12 13:30:42.858205",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Request",
@@ -651,6 +674,7 @@
"export": 1,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
@@ -671,6 +695,7 @@
"export": 1,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,

View File

@@ -0,0 +1,66 @@
{
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2016-11-16 15:27:16.413449",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "customer_group",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Customer Group",
"length": 0,
"no_copy": 0,
"options": "Customer Group",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-11-16 15:27:25.730507",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Customer Group",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_seen": 0
}

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class POSCustomerGroup(Document):
pass

View File

@@ -0,0 +1,66 @@
{
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2016-11-16 15:26:47.706713",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "item_group",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Item Group",
"length": 0,
"no_copy": 0,
"options": "Item Group",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-11-16 15:27:32.263630",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Item Group",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_seen": 0
}

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class POSItemGroup(Document):
pass

View File

@@ -375,6 +375,114 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_14",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "item_groups",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Item Groups",
"length": 0,
"no_copy": 0,
"options": "POS Item Group",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_16",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "customer_groups",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Customer Groups",
"length": 0,
"no_copy": 0,
"options": "POS Customer Group",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@@ -543,34 +651,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "customer_group",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Customer Group",
"length": 0,
"no_copy": 0,
"options": "Customer Group",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@@ -951,8 +1031,8 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-11-03 15:53:33.820428",
"modified_by": "Administrator",
"modified": "2016-11-17 00:20:51.377850",
"modified_by": "rohit@erpnext.com",
"module": "Accounts",
"name": "POS Profile",
"owner": "Administrator",

View File

@@ -13,6 +13,7 @@ class POSProfile(Document):
def validate(self):
self.check_for_duplicate()
self.validate_all_link_fields()
self.validate_duplicate_groups()
def check_for_duplicate(self):
res = frappe.db.sql("""select name, user from `tabPOS Profile`
@@ -37,6 +38,16 @@ class POSProfile(Document):
"company": self.company, "name": link_dn}):
frappe.throw(_("{0} does not belong to Company {1}").format(link_dn, self.company))
def validate_duplicate_groups(self):
item_groups = [d.item_group for d in self.item_groups]
customer_groups = [d.customer_group for d in self.customer_groups]
if len(item_groups) != len(set(item_groups)):
frappe.throw(_("Duplicate item group found in the item group table"), title = "Duplicate Item Group")
if len(customer_groups) != len(set(customer_groups)):
frappe.throw(_("Duplicate customer group found in the cutomer group table"), title = "Duplicate Customer Group")
def before_save(self):
set_account_for_mode_of_payment(self)

View File

@@ -5,8 +5,47 @@ from __future__ import unicode_literals
import frappe
import unittest
# test_records = frappe.get_test_records('POS Profile')
from erpnext.stock.get_item_details import get_pos_profile
from erpnext.accounts.doctype.sales_invoice.pos import get_items_list, get_customers_list
class TestPOSProfile(unittest.TestCase):
pass
def test_pos_profile(self):
make_pos_profile()
pos_profile = get_pos_profile("_Test Company") or {}
if pos_profile:
doc = frappe.get_doc("POS Profile", pos_profile.get("name"))
doc.append('item_groups', {'item_group': '_Test Item Group'})
doc.append('customer_groups', {'customer_group': '_Test Customer Group'})
doc.save()
items = get_items_list(doc)
customers = get_customers_list(doc)
products_count = frappe.db.sql(""" select count(name) from tabItem where item_group = '_Test Item Group'""", as_list=1)
customers_count = frappe.db.sql(""" select count(name) from tabCustomer where customer_group = '_Test Customer Group'""")
self.assertEquals(len(items), products_count[0][0])
self.assertEquals(len(customers), customers_count[0][0])
frappe.db.sql("delete from `tabPOS Profile`")
def make_pos_profile():
pos_profile = frappe.get_doc({
"company": "_Test Company",
"cost_center": "_Test Cost Center - _TC",
"currency": "INR",
"doctype": "POS Profile",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"income_account": "Sales - _TC",
"name": "_Test POS Profile",
"naming_series": "_T-POS Profile-",
"selling_price_list": "_Test Price List",
"territory": "_Test Territory",
"warehouse": "_Test Warehouse - _TC",
"write_off_account": "_Test Write Off - _TC",
"write_off_cost_center": "_Test Write Off Cost Center - _TC"
})
if not frappe.db.exists("POS Profile", "_Test POS Profile"):
pos_profile.insert()

View File

@@ -126,6 +126,8 @@ def get_pricing_rule_for_item(args):
})
if args.ignore_pricing_rule or not args.item_code:
if frappe.db.exists(args.doctype, args.name) and args.get("pricing_rule"):
item_details = remove_pricing_rule(args, item_details)
return item_details
if not (args.item_group and args.brand):
@@ -166,9 +168,16 @@ def get_pricing_rule_for_item(args):
else:
item_details.discount_percentage = pricing_rule.discount_percentage
elif args.get('pricing_rule'):
if frappe.db.get_value('Pricing Rule', args.get('pricing_rule'), 'price_or_discount') == 'Discount Percentage':
item_details.discount_percentage = 0.0
item_details = remove_pricing_rule(args, item_details)
return item_details
def remove_pricing_rule(args, item_details):
pricing_rule = frappe.db.get_value('Pricing Rule', args.get('pricing_rule'), ['price_or_discount', 'margin_type'], as_dict=1)
if pricing_rule and pricing_rule.price_or_discount == 'Discount Percentage':
item_details.discount_percentage = 0.0
if pricing_rule and pricing_rule.margin_type in ['Percentage', 'Amount']:
item_details.margin_rate_or_amount = 0.0
item_details.margin_type = None

View File

@@ -198,7 +198,7 @@ function hide_fields(doc) {
item_fields_stock = ['warehouse_section', 'received_qty', 'rejected_qty'];
cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock,
(cint(doc.update_stock)==1 ? true : false));
(cint(doc.update_stock)==1 || cint(doc.is_return)==1 ? true : false));
cur_frm.refresh_fields();
}

View File

@@ -2771,6 +2771,35 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Draft",
"fieldname": "status",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Status",
"length": 0,
"no_copy": 0,
"options": "\nDraft\nReturn\nDebit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@@ -3264,7 +3293,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2016-11-03 15:54:34.750548",
"modified": "2016-11-09 14:18:47.094777",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",

View File

@@ -65,6 +65,7 @@ class PurchaseInvoice(BuyingController):
self.validate_fixed_asset()
self.validate_fixed_asset_account()
self.create_remarks()
self.set_status()
def validate_cash(self):
if not self.cash_bank_account and flt(self.paid_amount):
@@ -582,7 +583,7 @@ class PurchaseInvoice(BuyingController):
if not self.is_return:
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
if frappe.db.get_single_value('Accounts Settings', 'unlink_payment_on_cancellation_of_invoice'):
unlink_ref_doc_from_payment_entries(self.doctype, self.name)
unlink_ref_doc_from_payment_entries(self)
self.update_prevdoc_status()
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
@@ -596,6 +597,7 @@ class PurchaseInvoice(BuyingController):
self.make_gl_entries_on_cancel()
self.update_project()
self.update_fixed_asset()
frappe.db.set(self, 'status', 'Cancelled')
def update_project(self):
project_list = []

View File

@@ -4,7 +4,6 @@ def get_data():
return {
'fieldname': 'purchase_invoice',
'non_standard_fieldnames': {
'Delivery Note': 'against_sales_invoice',
'Journal Entry': 'reference_name',
'Payment Entry': 'reference_name',
'Payment Request': 'reference_name',
@@ -12,8 +11,8 @@ def get_data():
'Purchase Invoice': 'return_against'
},
'internal_links': {
'Purchase Order': ['items', 'sales_order'],
'Purchase Receipt': ['items', 'delivery_note'],
'Purchase Order': ['items', 'purchase_order'],
'Purchase Receipt': ['items', 'purchase_receipt'],
},
'transactions': [
{

View File

@@ -14,7 +14,9 @@ frappe.listview_settings['Purchase Invoice'] = {
} else {
return [__("Unpaid"), "orange", "outstanding_amount,>,0|due,>=,Today"];
}
} else if(flt(doc.outstanding_amount)==0 && doc.docstatus==1) {
} else if(flt(doc.outstanding_amount) < 0 && doc.docstatus == 1) {
return [__("Debit Note Issued"), "darkgrey", "outstanding_amount,<,0"]
}else if(flt(doc.outstanding_amount)==0 && doc.docstatus==1) {
return [__("Paid"), "green", "outstanding_amount,=,0"];
}
}

View File

@@ -437,6 +437,85 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEquals(frappe.db.get_value("Serial No", pi.get("items")[0].rejected_serial_no,
"warehouse"), pi.get("items")[0].rejected_warehouse)
def test_outstanding_amount_after_advance_jv_cancelation(self):
from erpnext.accounts.doctype.journal_entry.test_journal_entry \
import test_records as jv_test_records
jv = frappe.copy_doc(jv_test_records[1])
jv.insert()
jv.submit()
pi = frappe.copy_doc(test_records[0])
pi.append("advances", {
"reference_type": "Journal Entry",
"reference_name": jv.name,
"reference_row": jv.get("accounts")[0].name,
"advance_amount": 400,
"allocated_amount": 300,
"remarks": jv.remark
})
pi.insert()
pi.submit()
pi.load_from_db()
#check outstanding after advance allocation
self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total - pi.total_advance))
#added to avoid Document has been modified exception
jv = frappe.get_doc("Journal Entry", jv.name)
jv.cancel()
pi.load_from_db()
#check outstanding after advance cancellation
self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total + pi.total_advance))
def test_outstanding_amount_after_advance_payment_entry_cancelation(self):
pe = frappe.get_doc({
"doctype": "Payment Entry",
"payment_type": "Pay",
"party_type": "Supplier",
"party": "_Test Supplier",
"company": "_Test Company",
"paid_from_account_currency": "INR",
"paid_to_account_currency": "INR",
"source_exchange_rate": 1,
"target_exchange_rate": 1,
"reference_no": "1",
"reference_date": nowdate(),
"received_amount": 300,
"paid_amount": 300,
"paid_from": "_Test Cash - _TC",
"paid_to": "_Test Payable - _TC"
})
pe.insert()
pe.submit()
pi = frappe.copy_doc(test_records[0])
pi.is_pos = 0
pi.append("advances", {
"doctype": "Purchase Invoice Advance",
"reference_type": "Payment Entry",
"reference_name": pe.name,
"advance_amount": 300,
"allocated_amount": 300,
"remarks": pe.remarks
})
pi.insert()
pi.submit()
pi.load_from_db()
#check outstanding after advance allocation
self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total - pi.total_advance))
#added to avoid Document has been modified exception
pe = frappe.get_doc("Payment Entry", pe.name)
pe.cancel()
pi.load_from_db()
#check outstanding after advance cancellation
self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total + pi.total_advance))
def unlink_payment_on_cancel_of_invoice(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings")

View File

@@ -30,10 +30,16 @@ def get_pos_data():
return {
'doc': doc,
'default_customer': pos_profile.get('customer'),
'items': get_items(doc, pos_profile),
'customers': get_customers(pos_profile, doc, company_data.default_currency),
'pricing_rules': get_pricing_rules(doc),
'items': get_items_list(pos_profile),
'customers': get_customers_list(pos_profile),
'serial_no_data': get_serial_no_data(pos_profile, doc.company),
'batch_no_data': get_batch_no_data(),
'tax_data': get_item_tax_data(),
'price_list_data': get_price_list_data(doc.selling_price_list),
'bin_data': get_bin_data(pos_profile),
'pricing_rules': get_pricing_rule_data(doc),
'print_template': print_template,
'pos_profile': pos_profile,
'meta': {
'invoice': frappe.get_meta('Sales Invoice'),
'items': frappe.get_meta('Sales Invoice Item'),
@@ -104,63 +110,122 @@ def update_tax_table(doc):
for tax in taxes:
doc.append('taxes', tax)
def get_items(doc, pos_profile):
item_list = []
for item in frappe.get_all("Item", fields=["*"], filters={'disabled': 0, 'has_variants': 0, 'is_sales_item': 1}):
item_doc = frappe.get_doc('Item', item.name)
if item_doc.taxes:
item.taxes = json.dumps(dict(([d.tax_type, d.tax_rate] for d in
item_doc.get("taxes"))))
def get_items_list(pos_profile):
cond = "1=1"
item_groups = []
if pos_profile.get('item_groups'):
# Get items based on the item groups defined in the POS profile
for d in pos_profile.get('item_groups'):
item_groups.extend(get_child_nodes('Item Group', d.item_group))
cond = "item_group in (%s)"%(', '.join(['%s']*len(item_groups)))
item.price_list_rate = frappe.db.get_value('Item Price', {'item_code': item.name,
'price_list': doc.selling_price_list}, 'price_list_rate') or 0
item.default_warehouse = pos_profile.get('warehouse') or \
get_item_warehouse_for_company(doc.company, item.default_warehouse) or None
item.expense_account = pos_profile.get('expense_account') or item.expense_account
item.income_account = pos_profile.get('income_account') or item_doc.income_account
item.cost_center = pos_profile.get('cost_center') or item_doc.selling_cost_center
item.actual_qty = frappe.db.get_value('Bin', {'item_code': item.name,
'warehouse': item.default_warehouse}, 'actual_qty') or 0
item.serial_nos = get_serial_nos(item, pos_profile, doc.company)
item.batch_nos = frappe.db.sql_list("""select name from `tabBatch` where ifnull(expiry_date, '4000-10-10') > curdate()
and item = %(item_code)s""", {'item_code': item.item_code})
return frappe.db.sql("""
select
name, item_code, item_name, description, item_group, expense_account, has_batch_no,
has_serial_no, expense_account, selling_cost_center, stock_uom, image,
default_warehouse, is_stock_item, barcode
from
tabItem
where
disabled = 0 and has_variants = 0 and is_sales_item = 1 and {cond}
""".format(cond=cond), tuple(item_groups), as_dict=1)
item_list.append(item)
def get_customers_list(pos_profile):
cond = "1=1"
customer_groups = []
if pos_profile.get('customer_groups'):
# Get customers based on the customer groups defined in the POS profile
for d in pos_profile.get('customer_groups'):
customer_groups.extend(get_child_nodes('Customer Group', d.customer_group))
cond = "customer_group in (%s)"%(', '.join(['%s']*len(customer_groups)))
return item_list
return frappe.db.sql(""" select name, customer_name, customer_group,
territory from tabCustomer where disabled = 0
and {cond}""".format(cond=cond), tuple(customer_groups), as_dict=1) or {}
def get_item_warehouse_for_company(company, warehouse):
if frappe.db.get_value('Warehouse', warehouse, 'company') != company:
warehouse = None
return warehouse
def get_child_nodes(group_type, root):
lft, rgt = frappe.db.get_value(group_type, root, ["lft", "rgt"])
return frappe.db.sql_list(""" Select name from `tab{tab}` where
lft >= {lft} and rgt <= {rgt}""".format(tab=group_type, lft=lft, rgt=rgt))
def get_serial_no_data(pos_profile, company):
# get itemwise serial no data
# example {'Nokia Lumia 1020': {'SN0001': 'Pune'}}
# where Nokia Lumia 1020 is item code, SN0001 is serial no and Pune is warehouse
def get_serial_nos(item, pos_profile, company):
cond = "1=1"
if pos_profile.get('update_stock') and pos_profile.get('warehouse'):
cond = "warehouse = '{0}'".format(pos_profile.get('warehouse'))
serial_nos = frappe.db.sql("""select name, warehouse from `tabSerial No` where {0}
and item_code = %(item_code)s and company = %(company)s
""".format(cond), {'item_code': item.item_code, 'company': company}, as_dict=1)
serial_nos = frappe.db.sql("""select name, warehouse, item_code from `tabSerial No` where {0}
and company = %(company)s """.format(cond), {'company': company}, as_dict=1)
serial_no_list = {}
for serial_no in serial_nos:
serial_no_list[serial_no.name] = serial_no.warehouse
itemwise_serial_no = {}
for sn in serial_nos:
if sn.item_code not in itemwise_serial_no:
itemwise_serial_no.setdefault(sn.item_code, {})
itemwise_serial_no[sn.item_code][sn.name] = sn.warehouse
return serial_no_list
return itemwise_serial_no
def get_customers(pos_profile, doc, company_currency):
filters = {'disabled': 0}
customer_list = []
customers = frappe.get_all("Customer", fields=["*"], filters = filters)
def get_batch_no_data():
# get itemwise batch no data
# exmaple: {'LED-GRE': [Batch001, Batch002]}
# where LED-GRE is item code, SN0001 is serial no and Pune is warehouse
for customer in customers:
customer_currency = get_party_account_currency('Customer', customer.name, doc.company) or doc.currency
if customer_currency == doc.currency or customer_currency == company_currency:
customer_list.append(customer)
return customer_list
itemwise_batch = {}
batches = frappe.db.sql("""select name, item from `tabBatch`
where ifnull(expiry_date, '4000-10-10') >= curdate()""", as_dict=1)
def get_pricing_rules(doc):
for batch in batches:
if batch.item not in itemwise_batch:
itemwise_batch.setdefault(batch.item, [])
itemwise_batch[batch.item].append(batch.name)
return itemwise_batch
def get_item_tax_data():
# get default tax of an item
# example: {'Consulting Services': {'Excise 12 - TS': '12.000'}}
itemwise_tax = {}
taxes = frappe.db.sql(""" select parent, tax_type, tax_rate from `tabItem Tax`""", as_dict=1)
for tax in taxes:
if tax.parent not in itemwise_tax:
itemwise_tax.setdefault(tax.parent, {})
itemwise_tax[tax.parent][tax.tax_type] = tax.tax_rate
return itemwise_tax
def get_price_list_data(selling_price_list):
itemwise_price_list = {}
price_lists = frappe.db.sql("""Select ifnull(price_list_rate, 0) as price_list_rate,
item_code from `tabItem Price` ip where price_list = %(price_list)s""",
{'price_list': selling_price_list}, as_dict=1)
for item in price_lists:
itemwise_price_list[item.item_code] = item.price_list_rate
return itemwise_price_list
def get_bin_data(pos_profile):
itemwise_bin_data = {}
cond = "1=1"
if pos_profile.get('warehouse'):
cond = "warehouse = '{0}'".format(pos_profile.get('warehouse'))
bin_data = frappe.db.sql(""" select item_code, warehouse, actual_qty from `tabBin`
where actual_qty > 0 and {cond}""".format(cond=cond), as_dict=1)
for bins in bin_data:
if bins.item_code not in itemwise_bin_data:
itemwise_bin_data.setdefault(bins.item_code, {})
itemwise_bin_data[bins.item_code][bins.warehouse] = bins.actual_qty
return itemwise_bin_data
def get_pricing_rule_data(doc):
pricing_rules = ""
if doc.ignore_pricing_rule == 0:
pricing_rules = frappe.db.sql(""" Select * from `tabPricing Rule` where docstatus < 2
@@ -180,8 +245,7 @@ def make_invoice(doc_list):
for docs in doc_list:
for name, doc in docs.items():
if not frappe.db.exists('Sales Invoice',
{'offline_pos_name': name, 'docstatus': ("<", "2")}):
if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name}):
validate_records(doc)
si_doc = frappe.new_doc('Sales Invoice')
si_doc.offline_pos_name = name
@@ -226,6 +290,7 @@ def submit_invoice(si_doc, name):
try:
si_doc.insert()
si_doc.submit()
frappe.db.commit()
except Exception, e:
if frappe.message_log: frappe.message_log.pop()
frappe.db.rollback()
@@ -236,4 +301,3 @@ def save_invoice(e, si_doc, name):
si_doc.docstatus = 0
si_doc.flags.ignore_mandatory = True
si_doc.insert()
frappe.log_error(frappe.get_traceback())

View File

@@ -20,6 +20,13 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
erpnext.queries.setup_queries(this.frm, "Warehouse", function() {
return erpnext.queries.warehouse(me.frm.doc);
});
if(this.frm.doc.__islocal && this.frm.doc.is_pos) {
//Load pos profile data on the invoice if the default value of Is POS is 1
me.frm.script_manager.trigger("is_pos");
me.frm.refresh_fields();
}
},
refresh: function(doc, dt, dn) {
@@ -300,7 +307,7 @@ cur_frm.cscript.hide_fields = function(doc) {
item_fields_stock = ['serial_no', 'batch_no', 'actual_qty', 'expense_account', 'warehouse', 'expense_account', 'warehouse']
cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock,
(cint(doc.update_stock)==1 ? true : false));
(cint(doc.update_stock)==1 || cint(doc.is_return)==1 ? true : false));
// India related fields
if (frappe.boot.sysdefaults.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
@@ -496,9 +503,23 @@ frappe.ui.form.on('Sales Invoice Timesheet', {
frappe.model.set_value(cdt, cdn, "billing_hours", data.billing_hours);
frappe.model.set_value(cdt, cdn, "billing_amount", data.billing_amount);
frappe.model.set_value(cdt, cdn, "timesheet_detail", data.timesheet_detail);
calculate_total_billing_amount(frm)
}
}
})
}
}
})
var calculate_total_billing_amount = function(frm) {
var doc = frm.doc;
doc.total_billing_amount = 0.0
if(doc.timesheets) {
$.each(doc.timesheets, function(index, data){
doc.total_billing_amount += data.billing_amount
})
}
refresh_field('total_billing_amount')
}

View File

@@ -3065,6 +3065,35 @@
"unique": 0,
"width": "50%"
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Draft",
"fieldname": "status",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Status",
"length": 0,
"no_copy": 1,
"options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@@ -4010,7 +4039,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2016-11-03 15:55:41.249414",
"modified": "2016-11-09 14:18:24.760263",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",

View File

@@ -86,6 +86,7 @@ class SalesInvoice(SellingController):
self.update_packing_list()
self.set_billing_hours_and_amount()
self.update_timesheet_billing_for_project()
self.set_status()
def before_save(self):
set_account_for_mode_of_payment(self)
@@ -137,7 +138,7 @@ class SalesInvoice(SellingController):
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
if frappe.db.get_single_value('Accounts Settings', 'unlink_payment_on_cancellation_of_invoice'):
unlink_ref_doc_from_payment_entries(self.doctype, self.name)
unlink_ref_doc_from_payment_entries(self)
if self.is_return:
# NOTE status updating bypassed for is_return
@@ -158,6 +159,7 @@ class SalesInvoice(SellingController):
self.update_stock_ledger()
self.make_gl_entries_on_cancel()
frappe.db.set(self, 'status', 'Cancelled')
def update_status_updater_args(self):
if cint(self.update_stock):
@@ -401,9 +403,9 @@ class SalesInvoice(SellingController):
def validate_warehouse(self):
super(SalesInvoice, self).validate_warehouse()
for d in self.get('items'):
for d in self.get_item_list():
if not d.warehouse and frappe.db.get_value("Item", d.item_code, "is_stock_item"):
frappe.throw(_("Warehouse required at Row No {0}").format(d.idx))
frappe.throw(_("Warehouse required for stock Item {0}").format(d.item_code))
def validate_delivery_note(self):
for d in self.get("items"):

View File

@@ -10,9 +10,11 @@ frappe.listview_settings['Sales Invoice'] = {
return [__("Return"), "darkgrey", "is_return,=,Yes"];
} else if(flt(doc.outstanding_amount)==0) {
return [__("Paid"), "green", "outstanding_amount,=,0"]
} else if (flt(doc.outstanding_amount) > 0 && doc.due_date > frappe.datetime.get_today()) {
} else if(flt(doc.outstanding_amount) < 0) {
return [__("Credit Note Issued"), "darkgrey", "outstanding_amount,<,0"]
}else if (flt(doc.outstanding_amount) > 0 && doc.due_date >= frappe.datetime.get_today()) {
return [__("Unpaid"), "orange", "outstanding_amount,>,0|due_date,>,Today"]
} else if (flt(doc.outstanding_amount) > 0 && doc.due_date <= frappe.datetime.get_today()) {
} else if (flt(doc.outstanding_amount) > 0 && doc.due_date < frappe.datetime.get_today()) {
return [__("Overdue"), "red", "outstanding_amount,>,0|due_date,<=,Today"]
}
},

View File

@@ -7,6 +7,7 @@ import unittest, copy
from frappe.utils import nowdate, add_days, flt, nowdate
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry, get_qty_after_transaction
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import unlink_payment_on_cancel_of_invoice
from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
from erpnext.exceptions import InvalidAccountCurrency, InvalidCurrency
from erpnext.stock.doctype.serial_no.serial_no import SerialNoWarehouseError
@@ -467,7 +468,7 @@ class TestSalesInvoice(unittest.TestCase):
def test_pos_gl_entry_with_perpetual_inventory(self):
set_perpetual_inventory()
self.make_pos_profile()
make_pos_profile()
self._insert_purchase_receipt()
pos = copy.deepcopy(test_records[1])
@@ -486,7 +487,7 @@ class TestSalesInvoice(unittest.TestCase):
def test_pos_change_amount(self):
set_perpetual_inventory()
self.make_pos_profile()
make_pos_profile()
self._insert_purchase_receipt()
pos = copy.deepcopy(test_records[1])
@@ -508,7 +509,7 @@ class TestSalesInvoice(unittest.TestCase):
set_perpetual_inventory()
self.make_pos_profile()
make_pos_profile()
self._insert_purchase_receipt()
pos = copy.deepcopy(test_records[1])
@@ -572,26 +573,6 @@ class TestSalesInvoice(unittest.TestCase):
frappe.db.sql("delete from `tabPOS Profile`")
def make_pos_profile(self):
pos_profile = frappe.get_doc({
"company": "_Test Company",
"cost_center": "_Test Cost Center - _TC",
"currency": "INR",
"doctype": "POS Profile",
"expense_account": "_Test Account Cost for Goods Sold - _TC",
"income_account": "Sales - _TC",
"name": "_Test POS Profile",
"naming_series": "_T-POS Profile-",
"selling_price_list": "_Test Price List",
"territory": "_Test Territory",
"warehouse": "_Test Warehouse - _TC",
"write_off_account": "_Test Write Off - _TC",
"write_off_cost_center": "_Test Write Off Cost Center - _TC"
})
if not frappe.db.exists("POS Profile", "_Test POS Profile"):
pos_profile.insert()
def test_sales_invoice_gl_entry_with_perpetual_inventory_no_item_code(self):
set_perpetual_inventory()
@@ -980,6 +961,86 @@ class TestSalesInvoice(unittest.TestCase):
pe.submit()
self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Active')
def test_outstanding_amount_after_advance_jv_cancelation(self):
from erpnext.accounts.doctype.journal_entry.test_journal_entry \
import test_records as jv_test_records
jv = frappe.copy_doc(jv_test_records[0])
jv.insert()
jv.submit()
si = frappe.copy_doc(test_records[0])
si.append("advances", {
"doctype": "Sales Invoice Advance",
"reference_type": "Journal Entry",
"reference_name": jv.name,
"reference_row": jv.get("accounts")[0].name,
"advance_amount": 400,
"allocated_amount": 300,
"remarks": jv.remark
})
si.insert()
si.submit()
si.load_from_db()
#check outstanding after advance allocation
self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total - si.total_advance, si.precision("outstanding_amount")))
#added to avoid Document has been modified exception
jv = frappe.get_doc("Journal Entry", jv.name)
jv.cancel()
si.load_from_db()
#check outstanding after advance cancellation
self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total + si.total_advance, si.precision("outstanding_amount")))
def test_outstanding_amount_after_advance_payment_entry_cancelation(self):
pe = frappe.get_doc({
"doctype": "Payment Entry",
"payment_type": "Receive",
"party_type": "Customer",
"party": "_Test Customer",
"company": "_Test Company",
"paid_from_account_currency": "INR",
"paid_to_account_currency": "INR",
"source_exchange_rate": 1,
"target_exchange_rate": 1,
"reference_no": "1",
"reference_date": nowdate(),
"received_amount": 300,
"paid_amount": 300,
"paid_from": "_Test Receivable - _TC",
"paid_to": "_Test Cash - _TC"
})
pe.insert()
pe.submit()
si = frappe.copy_doc(test_records[0])
si.is_pos = 0
si.append("advances", {
"doctype": "Sales Invoice Advance",
"reference_type": "Payment Entry",
"reference_name": pe.name,
"advance_amount": 300,
"allocated_amount": 300,
"remarks": pe.remarks
})
si.insert()
si.submit()
si.load_from_db()
#check outstanding after advance allocation
self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total - si.total_advance, si.precision("outstanding_amount")))
#added to avoid Document has been modified exception
pe = frappe.get_doc("Payment Entry", pe.name)
pe.cancel()
si.load_from_db()
#check outstanding after advance cancellation
self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total + si.total_advance, si.precision("outstanding_amount")))
def create_sales_invoice(**args):
si = frappe.new_doc("Sales Invoice")

View File

@@ -764,7 +764,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-11-03 15:56:28.704122",
"modified": "2016-12-13 15:56:28.704122",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Tax Rule",
@@ -793,10 +793,10 @@
"write": 1
}
],
"quick_entry": 1,
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_seen": 0
}
}

View File

@@ -25,7 +25,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.set_indicator();
this.onload();
this.make_menu_list();
this.set_interval_for_si_sync();
this.si_docs = this.get_doc_from_localstorage();
},
@@ -73,8 +72,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.get_data_from_server(function(){
me.create_new();
});
this.check_internet_connection();
},
make_menu_list: function(){
@@ -204,13 +201,10 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
freeze: true,
freeze_message: __("Master data syncing, it might take some time"),
callback: function(r){
window.items = r.message.items;
window.customers = r.message.customers;
window.pricing_rules = r.message.pricing_rules;
window.meta = r.message.meta;
window.print_template = r.message.print_template;
me.default_customer = r.message.default_customer || null;
me.init_master_data(r)
localStorage.setItem('doc', JSON.stringify(r.message.doc));
me.set_interval_for_si_sync();
me.check_internet_connection();
if(callback){
callback();
}
@@ -218,6 +212,22 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
})
},
init_master_data: function(r){
var me = this;
this.meta = r.message.meta;
this.item_data = r.message.items;
this.customers = r.message.customers;
this.serial_no_data = r.message.serial_no_data;
this.batch_no_data = r.message.batch_no_data;
this.tax_data = r.message.tax_data;
this.price_list_data = r.message.price_list_data;
this.bin_data = r.message.bin_data;
this.pricing_rules = r.message.pricing_rules;
this.print_template = r.message.print_template;
this.pos_profile_data = r.message.pos_profile;
this.default_customer = r.message.default_customer || null;
},
save_previous_entry : function(){
if(this.frm.doc.items.length > 0){
this.create_invoice()
@@ -233,20 +243,21 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
},
load_data: function(load_doc){
this.items = window.items;
this.customers = window.customers;
this.pricing_rules = window.pricing_rules;
var me = this;
this.items = this.item_data;
this.actual_qty_dict = {};
if(load_doc) {
this.frm.doc = JSON.parse(localStorage.getItem('doc'));
}
$.each(window.meta, function(i, data){
$.each(this.meta, function(i, data){
frappe.meta.sync(data)
})
this.print_template = frappe.render_template("print_template",
{content: window.print_template, title:"POS",
{content: this.print_template, title:"POS",
base_url: frappe.urllib.get_base_url(), print_css: frappe.boot.print_css})
},
@@ -387,12 +398,12 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
var $wrap = me.wrapper.find(".item-list");
me.wrapper.find(".item-list").empty();
if (this.items) {
if (this.items.length > 0) {
$.each(this.items, function(index, obj) {
if(index < 30){
$(frappe.render_template("pos_item", {
item_code: obj.name,
item_price: format_currency(obj.price_list_rate, me.frm.doc.currency),
item_price: format_currency(me.price_list_data[obj.name], me.frm.doc.currency),
item_name: obj.name===obj.item_name ? "" : obj.item_name,
item_image: obj.image ? "url('" + obj.image + "')" : null,
color: frappe.get_palette(obj.item_name),
@@ -400,6 +411,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
})).tooltip().appendTo($wrap);
}
});
} else {
$("<h4>Searching record not found.</h4>").appendTo($wrap)
}
if(this.items.length == 1
@@ -426,27 +439,28 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.item_batch_no = {};
if(item_code){
return $.grep(window.items, function(item){
return $.grep(this.item_data, function(item){
if(item.item_code == item_code ){
return true
}
})
}
key = this.search.$input.val().toLowerCase();
key = this.search.$input.val().toLowerCase().replace(/[&\/\\#,+()\[\]$~.'":*?<>{}]/g,'\\$&');
var re = new RegExp('%', 'g');
var reg = new RegExp(key.replace(re, '[\\w*\\s*[a-zA-Z0-9]*]*'))
search_status = true
if(key){
return $.grep(window.items, function(item){
return $.grep(this.item_data, function(item){
if(search_status){
if(in_list(item.batch_nos, me.search.$input.val())){
if(in_list(me.batch_no_data[item.item_code], me.search.$input.val())){
search_status = false;
return me.item_batch_no[item.item_code] = me.search.$input.val()
} else if(in_list(Object.keys(item.serial_nos), me.search.$input.val())) {
} else if( me.serial_no_data[item.item_code]
&& in_list(Object.keys(me.serial_no_data[item.item_code]), me.search.$input.val())) {
search_status = false;
me.item_serial_no[item.item_code] = [me.search.$input.val(), item.serial_nos[me.search.$input.val()]]
me.item_serial_no[item.item_code] = [me.search.$input.val(), me.serial_no_data[item.item_code][me.search.$input.val()]]
return true
} else if(item.barcode == me.search.$input.val()) {
search_status = false;
@@ -458,30 +472,38 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
}
})
}else{
return window.items;
return this.item_data;
}
},
update_qty: function() {
bind_qty_event: function() {
var me = this;
$(this.wrapper).find(".pos-item-qty").on("change", function(){
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
me.update_qty_rate_against_item_code(item_code, "qty", $(this).val());
var qty = $(this).val();
me.update_qty(item_code, qty)
})
$(this.wrapper).find("[data-action='increase-qty']").on("click", function(){
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) + 1;
me.update_qty_rate_against_item_code(item_code, "qty", qty);
me.update_qty(item_code, qty)
})
$(this.wrapper).find("[data-action='decrease-qty']").on("click", function(){
var item_code = $(this).parents(".pos-bill-item").attr("data-item-code");
var qty = flt($(this).parents(".pos-bill-item").find('.pos-item-qty').val()) - 1;
me.update_qty_rate_against_item_code(item_code, "qty", qty);
me.update_qty(item_code, qty)
})
},
update_qty: function(item_code, qty) {
var me = this;
this.items = this.get_items(item_code);
this.validate_serial_no()
this.update_qty_rate_against_item_code(item_code, "qty", qty);
},
update_rate: function() {
var me = this;
@@ -611,18 +633,18 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.child.description = this.items[0].description;
this.child.qty = 1;
this.child.item_group = this.items[0].item_group;
this.child.cost_center = this.items[0].cost_center;
this.child.income_account = this.items[0].income_account;
this.child.cost_center = this.pos_profile_data['cost_center'] || this.items[0].cost_center;
this.child.income_account = this.pos_profile_data['income_account'] || this.items[0].income_account;
this.child.warehouse = (this.item_serial_no[this.child.item_code]
? this.item_serial_no[this.child.item_code][1] : this.items[0].default_warehouse);
this.child.price_list_rate = flt(this.items[0].price_list_rate, 9) / flt(this.frm.doc.conversion_rate, 9);
this.child.rate = flt(this.items[0].price_list_rate, 9) / flt(this.frm.doc.conversion_rate, 9);
this.child.actual_qty = this.items[0].actual_qty;
? this.item_serial_no[this.child.item_code][1] : (this.pos_profile_data['warehouse'] || this.items[0].default_warehouse) );
this.child.price_list_rate = flt(this.price_list_data[this.child.item_code], 9) / flt(this.frm.doc.conversion_rate, 9);
this.child.rate = flt(this.price_list_data[this.child.item_code], 9) / flt(this.frm.doc.conversion_rate, 9);
this.child.actual_qty = me.get_actual_qty(this.items[0]);
this.child.amount = flt(this.child.qty) * flt(this.child.rate);
this.child.batch_no = this.item_batch_no[this.child.item_code];
this.child.serial_no = (this.item_serial_no[this.child.item_code]
? this.item_serial_no[this.child.item_code][0] : '');
this.child.item_tax_rate = this.items[0].taxes;
this.child.item_tax_rate = JSON.stringify(this.tax_data[this.child.item_code]);
},
update_paid_amount_status: function(update_paid_amount){
@@ -636,7 +658,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
refresh: function(update_paid_amount) {
var me = this;
this.refresh_fields(update_paid_amount);
this.update_qty();
this.bind_qty_event();
this.update_rate();
this.set_primary_action();
},
@@ -668,7 +690,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
item_code: d.item_code,
item_name: (d.item_name===d.item_code || !d.item_name) ? "" : ("<br>" + d.item_name),
qty: d.qty,
actual_qty: d.actual_qty,
actual_qty: me.actual_qty_dict[d.item_code] || 0,
projected_qty: d.projected_qty,
rate: format_number(d.rate, me.frm.doc.currency),
amount: format_currency(d.amount, me.frm.doc.currency)
@@ -932,6 +954,13 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
serial_no = me.item_serial_no[key][0];
}
if(this.items[0].has_serial_no && serial_no == ""){
this.refresh();
frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
'item': this.items[0].item_code
})))
}
if(item_code && serial_no){
$.each(this.frm.doc.items, function(index, data){
if(data.item_code == item_code){
@@ -943,12 +972,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
}
})
}
if(this.items[0].has_serial_no && serial_no == ""){
frappe.throw(__(repl("Error: Serial no is mandatory for item %(item)s", {
'item': this.items[0].item_code
})))
}
},
validate_serial_no_qty: function(args, item_code, field, value){
@@ -960,11 +983,13 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
frappe.throw(__("Serial no item cannot be a fraction"))
}
if(args.serial_no && args.serial_no.split('\n').length != cint(value)){
if(args.item_code == item_code && args.serial_no && args.serial_no.split('\n').length != cint(value)){
args.qty = 0.0;
args.serial_no = ''
this.refresh();
frappe.throw(__("Total nos of serial no is not equal to quantity."))
frappe.throw(__(repl("Total nos of serial no is not equal to quantity for item %(item)s.", {
'item': item_code
})))
}
},
@@ -1064,8 +1089,20 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
},
validate_warehouse: function(){
if(!this.items[0].default_warehouse){
if(this.items[0].is_stock_item && !this.items[0].default_warehouse && !this.pos_profile_data['warehouse']){
frappe.throw(__("Default warehouse is required for selected item"))
}
},
get_actual_qty: function(item) {
this.actual_qty = 0.0;
var warehouse = this.pos_profile_data['warehouse'] || item.default_warehouse;
if(warehouse && this.bin_data[item.item_code]) {
this.actual_qty = this.bin_data[item.item_code][warehouse] || 0;
this.actual_qty_dict[item.item_code] = this.actual_qty
}
return this.actual_qty
}
})

View File

@@ -4,7 +4,7 @@
<h2 class="text-center">{%= __(report.report_name) %}</h2>
<h4 class="text-center">{%= filters.customer || filters.supplier %} </h4>
<h5 class="text-center">
{%= filters.ageing_based_on %}
{%= __(filters.ageing_based_on) %}
{%= __("Until") %}
{%= dateutil.str_to_user(filters.report_date) %}
</h5>
@@ -12,7 +12,7 @@
<table class="table table-bordered">
<thead>
<tr>
{% if(__(report.report_name) == "Accounts Receivable" || __(report.report_name) == "Accounts Payable") { %}
{% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %}
<th style="width: 15%">{%= __("Date") %}</th>
<th style="width: 15%">{%= __("Ref") %}</th>
<th style="width: 40%">{%= __("Party") %}</th>
@@ -30,7 +30,7 @@
<tbody>
{% for(var i=0, l=data.length; i<l; i++) { %}
<tr>
{% if(__(report.report_name) == "Accounts Receivable" || __(report.report_name) == "Accounts Payable") { %}
{% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %}
{% if(data[i][__("Customer")] || data[i][__("Supplier")]) { %}
<td>{%= dateutil.str_to_user(data[i][__("Posting Date")]) %}</td>
<td>{%= data[i][__("Voucher Type")] %}
@@ -38,21 +38,21 @@
<td>{%= data[i][__("Customer Name")] || data[i][__("Customer")] || data[i][__("Supplier Name")] || data[i][__("Supplier")] %}
<br>{%= __("Remarks") %}: {%= data[i][__("Remarks")] %}</td>
<td style="text-align: right">
{%= format_currency(data[i][__("Invoiced Amount")], data[i]["currency"]) %}</td>
{%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"]) %}</td>
<td style="text-align: right">
{%= format_currency(data[i][__("Paid Amount")], data[i]["currency"]) %}</td>
{%= format_currency(data[i]["Paid Amount"], data[i]["currency"]) %}</td>
<td style="text-align: right">
{%= format_currency(data[i][__("Outstanding Amount")], data[i]["currency"]) %}</td>
{%= format_currency(data[i]["Outstanding Amount"], data[i]["currency"]) %}</td>
{% } else { %}
<td></td>
<td></td>
<td><b>{%= __("Total") %}</b></td>
<td style="text-align: right">
{%= format_currency(data[i][__("Invoiced Amount")]) %}</td>
{%= format_currency(data[i]["Invoiced Amount"]) %}</td>
<td style="text-align: right">
{%= format_currency(data[i][__("Paid Amount")]) %}</td>
{%= format_currency(data[i]["Paid Amount"]) %}</td>
<td style="text-align: right">
{%= format_currency(data[i][__("Outstanding Amount")]) %}</td>
{%= format_currency(data[i]["Outstanding Amount"]) %}</td>
{% } %}
{% } else { %}
{% if(data[i][__("Customer")] || data[i][__("Supplier")]|| "&nbsp;") { %}
@@ -71,4 +71,4 @@
{% } %}
</tbody>
</table>
<p class="text-right text-muted">Printed On {%= dateutil.str_to_user(dateutil.get_datetime_as_string()) %}</p>
<p class="text-right text-muted">{{ __("Printed On") }}{%= dateutil.str_to_user(dateutil.get_datetime_as_string()) %}</p>

View File

@@ -88,6 +88,9 @@ class ReceivablePayableReport(object):
future_vouchers = self.get_entries_after(self.filters.report_date, args.get("party_type"))
if not self.filters.get("company"):
self.filters["company"] = frappe.db.get_single_value('Global Defaults', 'default_company')
company_currency = frappe.db.get_value("Company", self.filters.get("company"), "default_currency")
data = []

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import flt
from frappe.utils import flt, cint
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
def execute(filters=None):
@@ -14,10 +14,10 @@ def execute(filters=None):
liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False)
equity = get_data(filters.company, "Equity", "Credit", period_list, only_current_fiscal_year=False)
provisional_profit_loss,total_credit = get_provisional_profit_loss(asset, liability, equity,
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
period_list, filters.company)
message,opening_balance = check_opening_balance(asset, liability, equity)
message, opening_balance = check_opening_balance(asset, liability, equity)
data = []
data.extend(asset or [])
@@ -32,7 +32,9 @@ def execute(filters=None):
}
for period in period_list:
unclosed[period.key] = opening_balance
provisional_profit_loss[period.key] = provisional_profit_loss[period.key] - opening_balance
if provisional_profit_loss:
provisional_profit_loss[period.key] = provisional_profit_loss[period.key] - opening_balance
unclosed["total"]=opening_balance
data.append(unclosed)
@@ -48,15 +50,11 @@ def execute(filters=None):
return columns, data, message, chart
def get_provisional_profit_loss(asset, liability, equity, period_list, company):
provisional_profit_loss = {}
total_row = {}
if asset and (liability or equity):
total = total_row_total=0
currency = frappe.db.get_value("Company", company, "default_currency")
provisional_profit_loss = {
"account_name": "'" + _("Provisional Profit / Loss (Credit)") + "'",
"account": None,
"warn_if_negative": True,
"currency": currency
}
total_row = {
"account_name": "'" + _("Total (Credit)") + "'",
"account": None,
@@ -85,19 +83,25 @@ def get_provisional_profit_loss(asset, liability, equity, period_list, company):
total_row["total"] = total_row_total
if has_value:
return provisional_profit_loss, total_row
return None,total_row
return None, None
provisional_profit_loss.update({
"account_name": "'" + _("Provisional Profit / Loss (Credit)") + "'",
"account": None,
"warn_if_negative": True,
"currency": currency
})
return provisional_profit_loss, total_row
def check_opening_balance(asset, liability, equity):
# Check if previous year balance sheet closed
opening_balance = 0
float_precision = cint(frappe.db.get_default("float_precision")) or 2
if asset:
opening_balance = flt(asset[0].get("opening_balance", 0))
opening_balance = flt(asset[0].get("opening_balance", 0), float_precision)
if liability:
opening_balance -= flt(liability[0].get("opening_balance", 0))
opening_balance -= flt(liability[0].get("opening_balance", 0), float_precision)
if equity:
opening_balance -= flt(equity[0].get("opening_balance", 0))
opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision)
if opening_balance:
return _("Previous Financial Year is not closed"),opening_balance

View File

@@ -8,7 +8,7 @@
<thead>
<tr>
<th style="width: 15%">{%= __("Posting Date") %}</th>
<th style="width: 15%">{%= __("Journal Entry") %}</th>
<th style="width: 15%">{%= __("Payment Entry") %}</th>
<th style="width: 40%">{%= __("Reference") %}</th>
<th style="width: 15%; text-align: right;">{%= __("Debit") %}</th>
<th style="width: 15%; text-align: right;">{%= __("Credit") %}</th>
@@ -19,10 +19,10 @@
{% if (data[i]["posting_date"]) { %}
<tr>
<td>{%= dateutil.str_to_user(data[i]["posting_date"]) %}</td>
<td>{%= data[i]["journal_entry"] %}</td>
<td>{%= data[i]["payment_entry"] %}</td>
<td>{%= __("Against") %}: {%= data[i]["against_account"] %}
{% if (data[i]["reference"]) { %}
<br>{%= __("Reference") %}: {%= data[i]["reference"] %}
{% if (data[i]["reference_no"]) { %}
<br>{%= __("Reference") %}: {%= data[i]["reference_no"] %}
{% if (data[i]["ref_date"]) { %}
<br>{%= __("Reference Date") %}: {%= dateutil.str_to_user(data[i]["ref_date"]) %}
{% } %}
@@ -38,7 +38,7 @@
<tr>
<td></td>
<td></td>
<td>{%= data[i]["journal_entry"] %}</td>
<td>{%= data[i]["payment_entry"] %}</td>
<td style="text-align: right">{%= format_currency(data[i]["debit"]) %}</td>
<td style="text-align: right">{%= format_currency(data[i]["credit"]) %}</td>
</tr>

View File

@@ -129,7 +129,7 @@ def get_entries(filters):
reference_no, reference_date as ref_date,
if(paid_to=%(account)s, received_amount, 0) as debit,
if(paid_from=%(account)s, paid_amount, 0) as credit,
posting_date, party as against_account, clearance_date,
posting_date, ifnull(party,if(paid_from=%(account)s,paid_to,paid_from)) as against_account, clearance_date,
if(paid_to=%(account)s, paid_to_account_currency, paid_from_account_currency) as account_currency
from `tabPayment Entry`
where

View File

@@ -0,0 +1 @@
{% include "accounts/report/financial_statements.html" %}

View File

@@ -42,9 +42,6 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity):
if to_date == get_first_day(to_date):
# if to_date is the first day, get the last day of previous month
to_date = add_days(to_date, -1)
else:
# to_date should be the last day of the new to_date's month
to_date = get_last_day(to_date)
if to_date <= year_end_date:
# the normal case
@@ -324,12 +321,17 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
additional_conditions.append("posting_date >= %(from_date)s")
if filters:
for key in ['cost_center', 'project']:
if filters.get(key):
additional_conditions.append("%s = '%s'"%(key, filters.get(key)))
if filters.get("project"):
additional_conditions.append("project = '%s'"%(frappe.db.escape(filters.get("project"))))
if filters.get("cost_center"):
additional_conditions.append(get_cost_center_cond(filters.get("cost_center")))
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
def get_cost_center_cond(cost_center):
lft, rgt = frappe.db.get_value("Cost Center", cost_center, ["lft", "rgt"])
return (""" cost_center in (select name from `tabCost Center` where lft >=%s and rgt <=%s)"""%(lft, rgt))
def get_columns(periodicity, period_list, accumulated_values=1, company=None):
columns = [{
"fieldname": "account",

View File

@@ -31,7 +31,7 @@ def execute(filters=None):
purchase_receipt = d.purchase_receipt
elif d.po_detail:
purchase_receipt = ", ".join(frappe.db.sql_list("""select distinct parent
from `tabPurchase Receipt Item` where docstatus=1 and prevdoc_detail_docname=%s""", d.po_detail))
from `tabPurchase Receipt Item` where docstatus=1 and purchase_order_item=%s""", d.po_detail))
expense_account = d.expense_account or aii_account_map.get(d.company)
row = [d.item_code, d.item_name, d.item_group, d.parent, d.posting_date, d.supplier,

View File

@@ -0,0 +1 @@
{% include "accounts/report/financial_statements.html" %}

View File

@@ -185,7 +185,7 @@ def get_invoice_po_pr_map(invoice_list):
pr_list = [d.purchase_receipt]
elif d.po_detail:
pr_list = frappe.db.sql_list("""select distinct parent from `tabPurchase Receipt Item`
where docstatus=1 and prevdoc_detail_docname=%s""", d.po_detail)
where docstatus=1 and purchase_order_item=%s""", d.po_detail)
if pr_list:
invoice_po_pr_map.setdefault(d.parent, frappe._dict()).setdefault("purchase_receipt", pr_list)

View File

@@ -50,6 +50,19 @@ frappe.query_reports["Trial Balance for Party"] = {
"options": ["Customer", "Supplier"],
"default": "Customer"
},
{
"fieldname":"party",
"label": __("Party"),
"fieldtype": "Dynamic Link",
"get_options": function() {
var party_type = frappe.query_report_filters_by_name.party_type.get_value();
var party = frappe.query_report_filters_by_name.party.get_value();
if(party && !party_type) {
frappe.throw(__("Please select Party Type first"));
}
return party_type;
}
},
{
"fieldname": "show_zero_values",
"label": __("Show zero values"),

View File

@@ -20,13 +20,23 @@ def execute(filters=None):
def get_data(filters, show_party_name):
party_name_field = "customer_name" if filters.get("party_type")=="Customer" else "supplier_name"
parties = frappe.get_all(filters.get("party_type"), fields = ["name", party_name_field], order_by="name")
party_filters = {"name": filters.get("party")} if filters.get("party") else {}
parties = frappe.get_all(filters.get("party_type"), fields = ["name", party_name_field],
filters = party_filters, order_by="name")
company_currency = frappe.db.get_value("Company", filters.company, "default_currency")
opening_balances = get_opening_balances(filters)
balances_within_period = get_balances_within_period(filters)
data = []
total_debit, total_credit = 0, 0
# total_debit, total_credit = 0, 0
total_row = frappe._dict({
"opening_debit": 0,
"opening_credit": 0,
"debit": 0,
"credit": 0,
"closing_debit": 0,
"closing_credit": 0
})
for party in parties:
row = { "party": party.name }
if show_party_name:
@@ -45,11 +55,7 @@ def get_data(filters, show_party_name):
"debit": debit,
"credit": credit
})
# totals
total_debit += debit
total_credit += credit
# closing
closing_debit, closing_credit = toggle_debit_credit(opening_debit + debit, opening_credit + credit)
row.update({
@@ -57,6 +63,10 @@ def get_data(filters, show_party_name):
"closing_credit": closing_credit
})
# totals
for col in total_row:
total_row[col] += row.get(col)
row.update({
"currency": company_currency
})
@@ -69,13 +79,12 @@ def get_data(filters, show_party_name):
data.append(row)
# Add total row
if total_debit or total_credit:
data.append({
"party": "'" + _("Totals") + "'",
"debit": total_debit,
"credit": total_credit,
"currency": company_currency
})
total_row.update({
"party": "'" + _("Totals") + "'",
"currency": company_currency
})
data.append(total_row)
return data

View File

@@ -401,16 +401,22 @@ def update_reference_in_payment_entry(d, payment_entry):
payment_entry.set_amounts()
payment_entry.save(ignore_permissions=True)
def unlink_ref_doc_from_payment_entries(ref_type, ref_no):
remove_ref_doc_link_from_jv(ref_type, ref_no)
remove_ref_doc_link_from_pe(ref_type, ref_no)
def unlink_ref_doc_from_payment_entries(ref_doc):
remove_ref_doc_link_from_jv(ref_doc.doctype, ref_doc.name)
remove_ref_doc_link_from_pe(ref_doc.doctype, ref_doc.name)
frappe.db.sql("""update `tabGL Entry`
set against_voucher_type=null, against_voucher=null,
modified=%s, modified_by=%s
where against_voucher_type=%s and against_voucher=%s
and voucher_no != ifnull(against_voucher, '')""",
(now(), frappe.session.user, ref_type, ref_no))
(now(), frappe.session.user, ref_doc.doctype, ref_doc.name))
if ref_doc.doctype in ("Sales Invoice", "Purchase Invoice"):
ref_doc.set("advances", [])
frappe.db.sql("""delete from `tab{0} Advance` where parent = %s"""
.format(ref_doc.doctype), ref_doc.name)
def remove_ref_doc_link_from_jv(ref_type, ref_no):
linked_jv = frappe.db.sql_list("""select parent from `tabJournal Entry Account`

View File

@@ -231,6 +231,7 @@ class PurchaseOrder(BuyingController):
"target_parent_dt": "Sales Order",
"target_dt": "Sales Order Item",
'target_field': 'ordered_qty',
"join_field": "sales_order_item",
"target_parent_field": ''
})

View File

@@ -28,15 +28,12 @@ class QualityInspection(Document):
frappe.db.sql("""update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2
set t1.qa_no = %s, t2.modified = %s
where t1.parent = %s and t1.item_code = %s and t1.parent = t2.name""",
(self.name, self.modified, self.purchase_receipt_no,
self.item_code))
(self.name, self.modified, self.purchase_receipt_no, self.item_code))
def on_cancel(self):
if self.purchase_receipt_no:
frappe.db.sql("""update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2
set t1.qa_no = '', t2.modified = %s
where t1.parent = %s and t1.item_code = %s and t1.parent = t2.name""",
(self.modified, self.purchase_receipt_no, self.item_code))
frappe.db.sql("""update `tabPurchase Receipt Item` set qa_no = '', modified=%s
where qa_no = %s""", (self.modified, self.name))
def item_query(doctype, txt, searchfield, start, page_len, filters):
if filters.get("from"):

View File

@@ -3,11 +3,9 @@
from __future__ import unicode_literals
from erpnext.setup.utils import get_exchange_rate
import frappe
def execute(filters=None):
qty_list = get_quantity_list(filters.item)
data = get_quote_list(filters.item, qty_list)
@@ -15,12 +13,9 @@ def execute(filters=None):
columns = get_columns(qty_list)
return columns, data
def get_quote_list(item, qty_list):
out = []
if item:
price_data = []
suppliers = []
@@ -38,8 +33,11 @@ def get_quote_list(item, qty_list):
#Add a row for each supplier
for root in set(suppliers):
supplier_currency = frappe.db.get_value("Supplier",root,"default_currency")
exg = get_exchange_rate(supplier_currency,company_currency)
supplier_currency = frappe.db.get_value("Supplier", root, "default_currency")
if supplier_currency:
exchange_rate = get_exchange_rate(supplier_currency, company_currency)
else:
exchange_rate = 1
row = frappe._dict({
"supplier_name": root
@@ -48,7 +46,7 @@ def get_quote_list(item, qty_list):
# Get the quantity for this row
for item_price in price_data:
if str(item_price.qty) == col.key and item_price.supplier == root:
row[col.key] = item_price.rate * exg
row[col.key] = item_price.rate * exchange_rate
row[col.key + "QUOTE"] = item_price.parent
break
else:
@@ -56,15 +54,11 @@ def get_quote_list(item, qty_list):
row[col.key + "QUOTE"] = ""
out.append(row)
return out
def get_quantity_list(item):
out = []
if item:
qty_list = frappe.db.sql("""select distinct qty from `tabSupplier Quotation Item` where ifnull(item_code,'')=%s and docstatus < 2""", item, as_dict=1)
qty_list.sort(reverse=False)
@@ -102,5 +96,4 @@ def get_columns(qty_list):
"width": 90
})
return columns
return columns

View File

@@ -371,6 +371,12 @@ def get_data():
"doctype": "GL Entry",
"is_query_report": True,
},
{
"type": "report",
"name": "Profitability Analysis",
"doctype": "GL Entry",
"is_query_report": True,
},
{
"type": "report",
"name": "Payment Period Based On Invoice Date",

View File

@@ -560,6 +560,21 @@ class AccountsController(TransactionBase):
elif asset.status in ("Scrapped", "Cancelled", "Sold"):
frappe.throw(_("Row #{0}: Asset {1} cannot be submitted, it is already {2}")
.format(d.idx, d.asset, asset.status))
def delink_advance_entries(self, linked_doc_name):
total_allocated_amount = 0
for adv in self.advances:
consider_for_total_advance = True
if adv.reference_name == linked_doc_name:
frappe.db.sql("""delete from `tab{0} Advance`
where name = %s""".format(self.doctype), adv.name)
consider_for_total_advance = False
if consider_for_total_advance:
total_allocated_amount += flt(adv.allocated_amount, adv.precision("allocated_amount"))
frappe.db.set_value(self.doctype, self.name, "total_advance",
total_allocated_amount, update_modified=False)
@frappe.whitelist()
def get_tax_rate(account_head):
@@ -720,4 +735,13 @@ def get_advance_payment_entries(party_type, party, party_account,
and docstatus = 1 and unallocated_amount > 0
""".format(party_account_field), (party_account, party_type, party, payment_type), as_dict=1)
return list(payment_entries_against_order) + list(unallocated_payment_entries)
return list(payment_entries_against_order) + list(unallocated_payment_entries)
def update_invoice_status():
# Daily update the status of the invoices
frappe.db.sql(""" update `tabSales Invoice` set status = 'Overdue'
where due_date < CURDATE() and docstatus = 1 and outstanding_amount > 0""")
frappe.db.sql(""" update `tabPurchase Invoice` set status = 'Overdue'
where due_date < CURDATE() and docstatus = 1 and outstanding_amount > 0""")

View File

@@ -41,30 +41,37 @@ def validate_item_variant_attributes(item, args=None):
if attribute.lower() in numeric_values:
numeric_attribute = numeric_values[attribute.lower()]
validate_is_incremental(numeric_attribute, attribute, value, item.name)
from_range = numeric_attribute.from_range
to_range = numeric_attribute.to_range
increment = numeric_attribute.increment
else:
attributes_list = attribute_values.get(attribute.lower(), [])
validate_item_attribute_value(attributes_list, attribute, value, item.name)
if increment == 0:
# defensive validation to prevent ZeroDivisionError
frappe.throw(_("Increment for Attribute {0} cannot be 0").format(attribute))
def validate_is_incremental(numeric_attribute, attribute, value, item):
from_range = numeric_attribute.from_range
to_range = numeric_attribute.to_range
increment = numeric_attribute.increment
is_in_range = from_range <= flt(value) <= to_range
precision = max(len(cstr(v).split(".")[-1].rstrip("0")) for v in (value, increment))
#avoid precision error by rounding the remainder
remainder = flt((flt(value) - from_range) % increment, precision)
if increment == 0:
# defensive validation to prevent ZeroDivisionError
frappe.throw(_("Increment for Attribute {0} cannot be 0").format(attribute))
is_incremental = remainder==0 or remainder==increment
is_in_range = from_range <= flt(value) <= to_range
precision = max(len(cstr(v).split(".")[-1].rstrip("0")) for v in (value, increment))
#avoid precision error by rounding the remainder
remainder = flt((flt(value) - from_range) % increment, precision)
if not (is_in_range and is_incremental):
frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3} for Item {4}")\
.format(attribute, from_range, to_range, increment, item.name),
InvalidItemAttributeValueError, title=_('Invalid Attribute'))
is_incremental = remainder==0 or remainder==increment
elif value not in attribute_values.get(attribute.lower(), []):
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format(
value, attribute, item.name), InvalidItemAttributeValueError, title=_('Invalid Attribute'))
if not (is_in_range and is_incremental):
frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3} for Item {4}")\
.format(attribute, from_range, to_range, increment, item),
InvalidItemAttributeValueError, title=_('Invalid Attribute'))
def validate_item_attribute_value(attributes_list, attribute, attribute_value, item):
if attribute_value not in attributes_list:
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format(
attribute_value, attribute, item), InvalidItemAttributeValueError, title=_('Invalid Attribute'))
def get_attribute_values():
if not frappe.flags.attribute_values:

View File

@@ -32,12 +32,13 @@ def get_filters_cond(doctype, filters, conditions):
# searches for active employees
def employee_query(doctype, txt, searchfield, start, page_len, filters):
conditions = []
return frappe.db.sql("""select name, employee_name from `tabEmployee`
where status = 'Active'
and docstatus < 2
and ({key} like %(txt)s
or employee_name like %(txt)s)
{mcond}
{fcond} {mcond}
order by
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
if(locate(%(_txt)s, employee_name), locate(%(_txt)s, employee_name), 99999),
@@ -45,6 +46,7 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters):
name, employee_name
limit %(start)s, %(page_len)s""".format(**{
'key': searchfield,
'fcond': get_filters_cond(doctype, filters, conditions),
'mcond': get_match_cond(doctype)
}), {
'txt': "%%%s%%" % txt,

View File

@@ -207,6 +207,7 @@ def make_return_doc(doctype, source_name, target_doc=None):
target_doc.rejected_qty = -1* source_doc.rejected_qty
target_doc.qty = -1* source_doc.qty
target_doc.purchase_order = source_doc.purchase_order
target_doc.purchase_order_item = source_doc.purchase_order_item
target_doc.rejected_warehouse = source_doc.rejected_warehouse
elif doctype == "Purchase Invoice":
target_doc.received_qty = -1* source_doc.received_qty

View File

@@ -164,14 +164,18 @@ class SellingController(StockController):
frappe.throw(_("Maxiumm discount for Item {0} is {1}%").format(d.item_code, discount))
def validate_selling_price(self):
def throw_message(item_name, rate, ref_rate_field):
frappe.throw(_("""Selling price for item {0} is lower than its {1}. Selling price should be atleast {2}""")
.format(item_name, ref_rate_field, rate))
if not frappe.db.get_single_value("Selling Settings", "validate_selling_price"):
return
for it in self.get("items"):
last_purchase_rate, is_stock_item = frappe.db.get_value("Item", it.name, ["last_purchase_rate", "is_stock_item"])
last_purchase_rate, is_stock_item = frappe.db.get_value("Item", it.item_code, ["last_purchase_rate", "is_stock_item"])
if flt(it.base_rate) < flt(last_purchase_rate):
throw(it.name, last_purchase_rate, "last purchase rate")
throw_message(it.item_name, last_purchase_rate, "last purchase rate")
last_valuation_rate = frappe.db.sql("""
SELECT valuation_rate FROM `tabStock Ledger Entry` WHERE item_code = %s
@@ -182,9 +186,6 @@ class SellingController(StockController):
if is_stock_item and flt(it.base_rate) < flt(last_valuation_rate):
throw_message(it.name, last_valuation_rate, "valuation rate")
def throw_message(item_name, rate, ref_rate_field):
frappe.throw(_("""Selling price for item {0} is lower than its {1}. Selling price should be atleast {2}""")
.format(item_name, ref_rate_field, rate))
def get_item_list(self):
il = []

View File

@@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import flt, comma_or
from frappe.utils import flt, comma_or, nowdate, getdate
from frappe import _
from frappe.model.document import Document
from erpnext.accounts.party_status import notify_status
@@ -41,6 +41,26 @@ status_map = {
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed'"],
],
"Sales Invoice": [
["Draft", None],
["Submitted", "eval:self.docstatus==1"],
["Return", "eval:self.is_return==1 and self.docstatus==1"],
["Credit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1"],
["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1 and self.is_return==0"],
["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"],
["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"],
["Cancelled", "eval:self.docstatus==2"],
],
"Purchase Invoice": [
["Draft", None],
["Submitted", "eval:self.docstatus==1"],
["Return", "eval:self.is_return==1 and self.docstatus==1"],
["Debit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1"],
["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1 and self.is_return==0"],
["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"],
["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"],
["Cancelled", "eval:self.docstatus==2"],
],
"Purchase Order": [
["Draft", None],
["To Receive and Bill", "eval:self.per_received < 100 and self.per_billed < 100 and self.docstatus == 1"],
@@ -251,19 +271,19 @@ class StatusUpdater(Document):
%(update_modified)s
where name='%(name)s'""" % args)
# update field
if args.get('status_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(status_field)s = if(%(target_parent_field)s<0.001,
'Not %(keyword)s', if(%(target_parent_field)s>=99.99,
'Fully %(keyword)s', 'Partly %(keyword)s'))
where name='%(name)s'""" % args)
# update field
if args.get('status_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(status_field)s = if(%(target_parent_field)s<0.001,
'Not %(keyword)s', if(%(target_parent_field)s>=99.99,
'Fully %(keyword)s', 'Partly %(keyword)s'))
where name='%(name)s'""" % args)
if update_modified:
target = frappe.get_doc(args["target_parent_dt"], args["name"])
target.set_status(update=True)
target.notify_update()
notify_status(target)
if update_modified:
target = frappe.get_doc(args["target_parent_dt"], args["name"])
target.set_status(update=True)
target.notify_update()
notify_status(target)
def _update_modified(self, args, update_modified):
args['update_modified'] = ''

View File

@@ -23,20 +23,19 @@ frappe.ui.form.on("Opportunity", {
refresh: function(frm) {
var doc = frm.doc;
frm.events.enquiry_from(frm);
if(doc.status!=="Lost") {
if(doc.with_items){
frm.add_custom_button(__('Supplier Quotation'),
function() {
frm.trigger("make_supplier_quotation")
}, __("Make"));
frm.add_custom_button(__('Quotation'),
cur_frm.cscript.create_quotation, __("Make"));
frm.page.set_inner_btn_group_as_primary(__("Make"));
}
frm.add_custom_button(__('Quotation'),
cur_frm.cscript.create_quotation, __("Make"));
frm.page.set_inner_btn_group_as_primary(__("Make"));
if(doc.status!=="Quotation") {
frm.add_custom_button(__('Lost'),
cur_frm.cscript['Declare Opportunity Lost']);
@@ -61,9 +60,10 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
this.frm.doc.enquiry_from = "Lead";
if(!this.frm.doc.status)
set_multiple(cdt, cdn, { status:'Draft' });
set_multiple(this.frm.doc.doctype, this.frm.doc.name, { status:'Open' });
if(!this.frm.doc.company && frappe.defaults.get_user_default("Company"))
set_multiple(cdt, cdn, { company:frappe.defaults.get_user_default("Company") });
set_multiple(this.frm.doc.doctype, this.frm.doc.name,
{ company:frappe.defaults.get_user_default("Company") });
this.setup_queries();
},

View File

@@ -39,6 +39,9 @@ class Opportunity(TransactionBase):
if not self.title:
self.title = self.customer_name
if not self.with_items:
self.items = []
def make_new_lead_if_required(self):

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

View File

@@ -7,7 +7,7 @@ Supplier Quotation.
#### Purchase Order Flow Chart
![Purchase Order]({{docs_base_url}}/assets/old_images/erpnext/purchase-order-f.jpg)
![Purchase Order]({{docs_base_url}}/assets/img/buying/buying_flow.png)
In ERPNext, you can also make a Purchase Order directly by going to:
@@ -39,6 +39,12 @@ which you collect from your Customer. In many regions, what you pay to your
government is only the difference between what you collect from your Customer
and what you pay to your Supplier. This is called Value Added Tax (VAT).
#### Add Taxes in Purchase Order
<img class="screenshot" alt="Purchase Order" src="{{docs_base_url}}/assets/img/buying/add_taxes_to_doc.png">
#### Show Tax break-up
<img class="screenshot" alt="Purchase Order" src="{{docs_base_url}}/assets/img/buying/show_tax_breakup.png">
For example you buy Items worth X and sell them for 1.3X. So your Customer
pays 1.3 times the tax you pay your Supplier. Since you have already paid tax
to your Supplier for X, what you owe your government is only the tax on 0.3X.
@@ -49,7 +55,7 @@ Ideally you must create two Accounts for each type of VAT you pay and collect,
effect. Please contact your accountant if you need more help or post a query
on our forums!
#### Purchase UOM and Stock UOM Conversion
@@ -82,5 +88,5 @@ __Step 5:__ Notice that the stock quantity will be updated accordingly.
__Step 6:__ Save and Submit the Form.
{next}

View File

@@ -8,7 +8,7 @@ You can make a supplier quotation from a Material Request
#### Supplier Quotation Flow-Chart
![Supplier Quotation]({{docs_base_url}}/assets/old_images/erpnext/supplier-quotation-f.jpg)
![Supplier Quotation]({{docs_base_url}}/assets/img/buying/buying_flow.png)
You can also make a Supplier Quotation directly from:
@@ -23,11 +23,22 @@ usually send out a message (Request for Quote) to various Suppliers. In
many cases, especially if you have centralized buying, you may want to record
all the quotes so that
* You can easily compare prices in the future
* You can easily compare prices in the future
* Audit whether all Suppliers were given the opportunity to quote.
Supplier Quotations are not necessary for most small businesses. Always
evaluate the cost of collecting information to the value it really provides!
You could only do this for high value items.
#### Taxes
If your Supplier is going to charge you additional taxes or charge like a shipping or insurance charge, you can add it here. It will help you to accurately track your costs. Also, if some of these charges add to the value of the product you will have to mention them in the Taxes table. You can also use templates for your taxes. For more information on setting up your taxes see the Purchase Taxes and Charges Template.
You can select relevant tax by going to "Taxes and Charges" section and adding an entry to the table as shown below,
<img class="screenshot" alt="Supplier Quotation" src="{{docs_base_url}}/assets/img/buying/add_taxes_to_doc.png">
Besides, in case of multiple items you can keep track of taxes on each by clicking "Show tax break-up"
<img class="screenshot" alt="Supplier Quotation" src="{{docs_base_url}}/assets/img/buying/show_tax_breakup.png">
{next}

View File

@@ -189,6 +189,7 @@ scheduler_events = {
"erpnext.stock.reorder_item.reorder_item",
"erpnext.setup.doctype.email_digest.email_digest.send",
"erpnext.support.doctype.issue.issue.auto_close_tickets",
"erpnext.controllers.accounts_controller.update_invoice_status",
"erpnext.accounts.doctype.fiscal_year.fiscal_year.auto_create_fiscal_year",
"erpnext.hr.doctype.employee.employee.send_birthday_reminders",
"erpnext.projects.doctype.task.task.set_tasks_as_overdue",
@@ -211,3 +212,5 @@ bot_parsers = [
]
get_site_info = 'erpnext.utilities.get_site_info'
payment_gateway_enabled = "erpnext.accounts.utils.create_payment_gateway_and_account"

View File

@@ -1,7 +1,7 @@
{
"allow_copy": 0,
"allow_import": 1,
"allow_rename": 0,
"allow_rename": 1,
"autoname": "field:expense_type",
"beta": 0,
"creation": "2012-03-27 14:35:55",
@@ -10,11 +10,13 @@
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "expense_type",
"fieldtype": "Data",
"hidden": 0,
@@ -41,6 +43,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "description",
"fieldtype": "Small Text",
"hidden": 0,
@@ -68,6 +71,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "accounts",
"fieldtype": "Table",
"hidden": 0,
@@ -102,7 +106,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-07-18 12:36:10.096252",
"modified": "2016-11-07 11:54:10.936716",
"modified_by": "Administrator",
"module": "HR",
"name": "Expense Claim Type",
@@ -118,6 +122,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
@@ -138,6 +143,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 0,
"read": 1,

View File

@@ -14,6 +14,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "employee_settings",
"fieldtype": "Section Break",
"hidden": 0,
@@ -28,6 +29,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -38,6 +40,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "",
"description": "Enter retirement age in years",
"fieldname": "retirement_age",
@@ -55,6 +58,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -65,6 +69,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Naming Series",
"description": "Employee record is created using selected field. ",
"fieldname": "emp_created_by",
@@ -82,6 +87,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -92,6 +98,33 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_4",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Don't send Employee Birthday Reminders",
"fieldname": "stop_birthday_reminders",
"fieldtype": "Check",
@@ -107,6 +140,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -117,6 +151,34 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "maintain_bill_work_hours_same",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Maintain Billing Hours and Working Hours Same on Timesheet",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "payroll_settings",
"fieldtype": "Section Break",
"hidden": 0,
@@ -131,6 +193,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -141,6 +204,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "If checked, Total no. of Working Days will include holidays, and this will reduce the value of Salary Per Day",
"fieldname": "include_holidays_in_total_working_days",
"fieldtype": "Check",
@@ -156,6 +220,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -166,6 +231,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "1",
"description": "Emails salary slip to employee based on preferred email selected in Employee",
"fieldname": "email_salary_slip_to_employee",
@@ -183,6 +249,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -193,6 +260,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "max_working_hours_against_timesheet",
"fieldtype": "Float",
"hidden": 0,
@@ -208,6 +276,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -226,7 +295,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2016-09-21 11:28:50.687129",
"modified": "2016-12-21 18:52:03.633251",
"modified_by": "Administrator",
"module": "HR",
"name": "HR Settings",
@@ -242,6 +311,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,

View File

@@ -38,6 +38,7 @@ class LeaveApplication(Document):
self.validate_block_days()
self.validate_salary_processed_days()
self.validate_leave_approver()
self.validate_attendance()
def on_update(self):
if (not self.previous_doc and self.leave_approver) or (self.previous_doc and \
@@ -102,7 +103,7 @@ class LeaveApplication(Document):
last_processed_pay_slip = frappe.db.sql("""
select start_date, end_date from `tabSalary Slip`
where docstatus != 2 and employee = %s
where docstatus = 1 and employee = %s
and ((%s between start_date and end_date) or (%s between start_date and end_date))
order by modified desc limit 1
""",(self.employee, self.to_date, self.from_date))
@@ -212,6 +213,13 @@ class LeaveApplication(Document):
elif self.docstatus==1 and len(leave_approvers) and self.leave_approver != frappe.session.user:
frappe.throw(_("Only the selected Leave Approver can submit this Leave Application"),
LeaveApproverIdentityError)
def validate_attendance(self):
attendance = frappe.db.sql("""select name from `tabAttendance` where employee = %s and (att_date between %s and %s)
and docstatus = 1""",
(self.employee, self.from_date, self.to_date))
if attendance:
frappe.throw(_("Attendance for employee {0} is already marked for this day").format(self.employee))
def notify_employee(self, status):
employee = frappe.get_doc("Employee", self.employee)

View File

@@ -43,6 +43,16 @@ frappe.ui.form.on("Process Payroll", {
}
})
}
},
account: function(frm) {
var account_types = ["Bank", "Cash"];
return {
filters: {
"account_type": ["in", account_types],
"is_group": 0,
"company": frm.doc.company
}
}
}
})

View File

@@ -22,7 +22,7 @@ class ProcessPayroll(Document):
sal_struct = frappe.db.sql("""
select name from `tabSalary Structure`
where docstatus != 2 and company = %(company)s and
where docstatus != 2 and is_active = 'Yes' and company = %(company)s and
ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s""",
{"company": self.company, "salary_slip_based_on_timesheet":self.salary_slip_based_on_timesheet})
@@ -51,8 +51,8 @@ class ProcessPayroll(Document):
def get_joining_releiving_condition(self):
cond = """
and ifnull(t1.date_of_joining, '0000-00-00') <= '%(from_date)s'
and ifnull(t1.relieving_date, '2199-12-31') >= '%(to_date)s'
and ifnull(t1.date_of_joining, '0000-00-00') <= '%(to_date)s'
and ifnull(t1.relieving_date, '2199-12-31') >= '%(from_date)s'
""" % {"from_date": self.from_date, "to_date": self.to_date}
return cond

View File

@@ -31,6 +31,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -58,8 +59,9 @@
"print_hide_if_no_value": 0,
"print_width": "120px",
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0,
@@ -86,6 +88,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -112,6 +115,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -137,6 +141,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -164,6 +169,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -182,7 +188,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-08-31 08:08:47.359578",
"modified": "2016-11-16 12:44:37.733773",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Component",
@@ -199,6 +205,7 @@
"export": 1,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,

View File

@@ -10,7 +10,6 @@ from frappe import _
class SalaryComponent(Document):
def validate(self):
self.validate_abbr()
def validate_abbr(self):
if not self.salary_component_abbr:
@@ -21,8 +20,5 @@ class SalaryComponent(Document):
if self.get('__islocal') and len(self.salary_component_abbr) > 5:
frappe.throw(_("Abbreviation cannot have more than 5 characters"))
if not self.salary_component_abbr.strip():
frappe.throw(_("Abbreviation is mandatory"))
if frappe.db.sql("select salary_component_abbr from `tabSalary Component` where name!=%s and salary_component_abbr=%s", (self.name, self.salary_component_abbr)):
frappe.throw(_("Abbreviation already used for another salary component"))

View File

@@ -114,22 +114,15 @@ var calculate_all = function(doc, dt, dn) {
}
cur_frm.cscript.amount = function(doc,dt,dn){
calculate_earning_total(doc, dt, dn);
calculate_net_pay(doc, dt, dn);
var child = locals[dt][dn];
if(!doc.salary_structure){
frappe.model.set_value(dt,dn, "default_amount", child.amount)
}
calculate_all(doc, dt, dn);
}
cur_frm.cscript.depends_on_lwp = function(doc,dt,dn){
calculate_earning_total(doc, dt, dn, true);
calculate_net_pay(doc, dt, dn);
}
// Trigger on earning modified amount and depends on lwp
// ------------------------------------------------------------------------
cur_frm.cscript.amount = function(doc,dt,dn){
calculate_ded_total(doc, dt, dn);
calculate_net_pay(doc, dt, dn);
}
cur_frm.cscript.depends_on_lwp = function(doc, dt, dn) {
calculate_ded_total(doc, dt, dn, true);
calculate_net_pay(doc, dt, dn);
};

View File

@@ -10,7 +10,6 @@ from frappe.model.naming import make_autoname
from frappe import msgprint, _
from erpnext.accounts.utils import get_fiscal_year
from erpnext.setup.utils import get_company_currency
from erpnext.hr.utils import set_employee_name
from erpnext.hr.doctype.process_payroll.process_payroll import get_month_details
from erpnext.hr.doctype.employee.employee import get_holiday_list_for_employee
from erpnext.utilities.transaction_base import TransactionBase
@@ -84,6 +83,7 @@ class SalarySlip(TransactionBase):
if d.amount_based_on_formula:
if d.formula:
amount = eval(d.formula, None, data)
if amount:
data[d.abbr] = amount
return amount
@@ -223,17 +223,21 @@ class SalarySlip(TransactionBase):
["date_of_joining", "relieving_date"])
holidays = self.get_holidays_for_employee(self.start_date, self.end_date)
working_days = date_diff(self.end_date, self.start_date) + 1
if not cint(frappe.db.get_value("HR Settings", None, "include_holidays_in_total_working_days")):
working_days -= len(holidays)
if working_days < 0:
frappe.throw(_("There are more holidays than working days this month."))
actual_lwp = self.calculate_lwp(holidays, working_days)
if not lwp:
lwp = self.calculate_lwp(holidays, working_days)
lwp = actual_lwp
elif lwp != actual_lwp:
frappe.msgprint(_("Leave Without Pay does not match with approved Leave Application records"))
self.total_days_in_month = working_days
self.leave_without_pay = lwp
payment_days = flt(self.get_payment_days(joining_date, relieving_date)) - flt(lwp)
self.payment_days = payment_days > 0 and payment_days or 0
@@ -315,7 +319,7 @@ class SalarySlip(TransactionBase):
def sum_components(self, component_type, total_field):
for d in self.get(component_type):
if cint(d.depends_on_lwp) == 1 and not self.salary_slip_based_on_timesheet:
d.amount = rounded((flt(d.amount) * flt(self.payment_days)
d.amount = rounded((flt(d.default_amount) * flt(self.payment_days)
/ cint(self.total_days_in_month)), self.precision("amount", component_type))
elif not self.payment_days and not self.salary_slip_based_on_timesheet:
d.amount = 0

View File

@@ -1,45 +0,0 @@
[
{
"company": "_Test Company",
"doctype": "Salary Slip",
"deductions": [
{
"doctype": "Salary Detail",
"amount": 100,
"depends_on_lwp": 0,
"salary_component": "_Test Professional Tax",
"parentfield": "deductions"
},
{
"doctype": "Salary Detail",
"amount": 48.39,
"depends_on_lwp": 0,
"salary_component": "_Test TDS",
"parentfield": "deductions"
}
],
"earnings": [
{
"doctype": "Salary Detail",
"amount": 14516.13,
"depends_on_lwp": 0,
"salary_component": "_Test Basic Salary",
"parentfield": "earnings"
},
{
"doctype": "Salary Detail",
"amount": 500,
"depends_on_lwp": 0,
"salary_component": "_Test Allowance",
"parentfield": "earnings"
}
],
"employee": "_T-Employee-0001",
"employee_name": "_Test Employee",
"posting_date": "2013-02-01",
"fiscal_year": "_Test Fiscal Year 2013",
"month": "01",
"payment_days": 31,
"total_days_in_month": 31
}
]

View File

@@ -5,32 +5,31 @@ from __future__ import unicode_literals
import unittest
import frappe
import erpnext
from frappe.utils.make_random import get_random
from frappe.utils import today, now_datetime, getdate, cstr, add_years, nowdate
import calendar
from erpnext.accounts.utils import get_fiscal_year
from frappe.utils import getdate, nowdate, add_days
from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
from erpnext.hr.doctype.process_payroll.test_process_payroll import get_salary_component_account
class TestSalarySlip(unittest.TestCase):
def setUp(self):
make_salary_component(["Basic Salary", "Allowance", "HRA", "Professional Tax", "TDS"])
make_earning_salary_component(["Basic Salary", "Allowance", "HRA"])
make_deduction_salary_component(["Professional Tax", "TDS"])
for dt in ["Leave Application", "Leave Allocation", "Salary Slip"]:
frappe.db.sql("delete from `tab%s`" % dt)
self.make_holiday_list()
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List")
from erpnext.hr.doctype.leave_application.test_leave_application import _test_records as leave_applications
la = frappe.copy_doc(leave_applications[2])
la.insert()
la.status = "Approved"
la.submit()
def tearDown(self):
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
frappe.set_user("Administrator")
def test_salary_slip_with_holidays_included(self):
no_of_days = self.get_no_of_days()
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 1)
self.make_employee("test_employee@salary.com")
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
@@ -38,8 +37,8 @@ class TestSalarySlip(unittest.TestCase):
ss = frappe.get_doc("Salary Slip",
self.make_employee_salary_slip("test_employee@salary.com"))
self.assertEquals(ss.total_days_in_month, 31)
self.assertEquals(ss.payment_days, 31)
self.assertEquals(ss.total_days_in_month, no_of_days[0])
self.assertEquals(ss.payment_days, no_of_days[0])
self.assertEquals(ss.earnings[0].amount, 5000)
self.assertEquals(ss.earnings[1].amount, 3000)
self.assertEquals(ss.deductions[0].amount, 5000)
@@ -48,6 +47,7 @@ class TestSalarySlip(unittest.TestCase):
self.assertEquals(ss.net_pay, 3000)
def test_salary_slip_with_holidays_excluded(self):
no_of_days = self.get_no_of_days()
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
self.make_employee("test_employee@salary.com")
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
@@ -55,8 +55,8 @@ class TestSalarySlip(unittest.TestCase):
ss = frappe.get_doc("Salary Slip",
self.make_employee_salary_slip("test_employee@salary.com"))
self.assertEquals(ss.total_days_in_month, 27)
self.assertEquals(ss.payment_days, 27)
self.assertEquals(ss.total_days_in_month, no_of_days[0] - no_of_days[1])
self.assertEquals(ss.payment_days, no_of_days[0] - no_of_days[1])
self.assertEquals(ss.earnings[0].amount, 5000)
self.assertEquals(ss.earnings[0].default_amount, 5000)
self.assertEquals(ss.earnings[1].amount, 3000)
@@ -66,37 +66,46 @@ class TestSalarySlip(unittest.TestCase):
self.assertEquals(ss.net_pay, 3000)
def test_payment_days(self):
no_of_days = self.get_no_of_days()
# Holidays not included in working days
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 1)
# set joinng date in the same month
self.make_employee("test_employee@salary.com")
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "date_of_joining", "2013-01-11")
if getdate(nowdate()).day >= 15:
date_of_joining = getdate(add_days(nowdate(),-10))
relieving_date = getdate(add_days(nowdate(),-10))
elif getdate(nowdate()).day < 15 and getdate(nowdate()).day > 5:
date_of_joining = getdate(add_days(nowdate(),-3))
relieving_date = getdate(add_days(nowdate(),-3))
elif getdate(nowdate()).day < 5 and not getdate(nowdate()).day == 1:
date_of_joining = getdate(add_days(nowdate(),-1))
relieving_date = getdate(add_days(nowdate(),-1))
elif getdate(nowdate()).day == 1:
date_of_joining = getdate(nowdate())
relieving_date = getdate(nowdate())
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "date_of_joining", date_of_joining)
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
ss = frappe.get_doc("Salary Slip",
self.make_employee_salary_slip("test_employee@salary.com"))
self.assertEquals(ss.total_days_in_month, 27)
self.assertEquals(ss.payment_days, 27)
self.assertEquals(ss.total_days_in_month, no_of_days[0])
self.assertEquals(ss.payment_days, (no_of_days[0] - getdate(date_of_joining).day + 1))
# set relieving date in the same month
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", "12-12-2016")
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "date_of_joining", (add_days(nowdate(),-60)))
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", relieving_date)
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "status", "Left")
self.assertEquals(ss.total_days_in_month, 27)
self.assertEquals(ss.payment_days, 27)
ss.save()
self.assertEquals(ss.total_days_in_month, no_of_days[0])
self.assertEquals(ss.payment_days, getdate(relieving_date).day)
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "status", "Active")
# Holidays included in working days
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 1)
self.assertEquals(ss.total_days_in_month, 27)
self.assertEquals(ss.payment_days, 27)
ss.save()
#
# frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "date_of_joining", "2001-01-11")
# frappe.db.set_value("Employee", frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"), "relieving_date", None)
def test_employee_salary_slip_read_permission(self):
self.make_employee("test_employee@salary.com")
@@ -120,7 +129,6 @@ class TestSalarySlip(unittest.TestCase):
email_queue = frappe.db.sql("""select name from `tabEmail Queue`""")
self.assertTrue(email_queue)
def make_employee(self, user):
if not frappe.db.get_value("User", user):
frappe.get_doc({
@@ -148,29 +156,30 @@ class TestSalarySlip(unittest.TestCase):
"status": "Active",
"employment_type": "Intern"
}).insert()
def make_holiday_list(self):
fiscal_year = get_fiscal_year(nowdate())
if not frappe.db.get_value("Holiday List", "Salary Slip Test Holiday List"):
holiday_list = frappe.get_doc({
"doctype": "Holiday List",
"holiday_list_name": "Salary Slip Test Holiday List",
"from_date": nowdate(),
"to_date": add_years(nowdate(), 1),
"from_date": fiscal_year[1],
"to_date": fiscal_year[2],
"weekly_off": "Sunday"
}).insert()
holiday_list.get_weekly_off_dates()
holiday_list.save()
def make_employee_salary_slip(self, user):
employee = frappe.db.get_value("Employee", {"user_id": user})
salary_structure = make_salary_structure("Salary Structure Test for Salary Slip")
salary_structure = make_salary_structure("Salary Structure Test for Salary Slip", employee)
salary_slip = frappe.db.get_value("Salary Slip", {"employee": frappe.db.get_value("Employee", {"user_id": user})})
if not salary_slip:
salary_slip = make_salary_slip(salary_structure, employee = employee)
salary_slip.employee_name = frappe.get_value("Employee", {"name":frappe.db.get_value("Employee", {"user_id": user})}, "employee_name")
salary_slip.month = "12"
salary_slip.fiscal_year = "_Test Fiscal Year 2016"
salary_slip.month = getdate(nowdate()).month
salary_slip.posting_date = nowdate()
salary_slip.insert()
# salary_slip.submit()
@@ -185,38 +194,67 @@ class TestSalarySlip(unittest.TestCase):
activity_type.wage_rate = 25
activity_type.save()
def make_salary_component(salary_components):
def get_no_of_days(self):
no_of_days_in_month = calendar.monthrange(getdate(nowdate()).year,
getdate(nowdate()).month)
no_of_holidays_in_month = len([1 for i in calendar.monthcalendar(getdate(nowdate()).year,
getdate(nowdate()).month) if i[6] != 0])
return [no_of_days_in_month[1], no_of_holidays_in_month]
def make_earning_salary_component(salary_components):
for salary_component in salary_components:
if not frappe.db.exists('Salary Component', salary_component):
sal_comp = frappe.get_doc({
"doctype": "Salary Component",
"salary_component": salary_component
"salary_component": salary_component,
"type": "Earning"
})
sal_comp.insert()
get_salary_component_account(salary_component)
def make_salary_structure(sal_struct):
def make_deduction_salary_component(salary_components):
for salary_component in salary_components:
if not frappe.db.exists('Salary Component', salary_component):
sal_comp = frappe.get_doc({
"doctype": "Salary Component",
"salary_component": salary_component,
"type": "Deduction"
})
sal_comp.insert()
get_salary_component_account(salary_component)
def make_salary_structure(sal_struct, employee):
if not frappe.db.exists('Salary Structure', sal_struct):
frappe.get_doc({
"doctype": "Salary Structure",
"name": sal_struct,
"company": erpnext.get_default_company(),
"from_date": nowdate(),
"employees": get_employee_details(),
"employees": get_employee_details(employee),
"earnings": get_earnings_component(),
"deductions": get_deductions_component(),
"payment_account": frappe.get_value('Account', {'account_type': 'Cash', 'company': erpnext.get_default_company(),'is_group':0}, "name")
}).insert()
elif not frappe.db.get_value("Salary Structure Employee",{'parent':sal_struct, 'employee':employee},'name'):
sal_struct = frappe.get_doc("Salary Structure", sal_struct)
sal_struct.append("employees", {"employee": employee,
"employee_name": employee,
"base": 32000,
"variable": 3200
})
sal_struct.save()
sal_struct = sal_struct.name
return sal_struct
def get_employee_details():
return [{"employee": frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"),
def get_employee_details(employee):
return [{"employee": employee,
"base": 25000,
"variable": 5000
}
]
def get_earnings_component():
return [
{
@@ -270,7 +308,4 @@ def get_deductions_component():
"formula": 'base*.1',
"idx": 3
}
]
test_dependencies = ["Leave Application", "Holiday List"]
]

View File

@@ -28,7 +28,15 @@ frappe.ui.form.on('Salary Structure', {
type: "deduction"
}
}
})
});
frm.set_query("employee", "employees", function(doc) {
return {
query: "erpnext.controllers.queries.employee_query",
filters: {
company: doc.company
}
}
});
},
refresh: function(frm) {
@@ -182,11 +190,3 @@ frappe.ui.form.on('Salary Detail', {
calculate_totals(frm.doc);
}
})
frappe.ui.form.on('Salary Structure Employee', {
onload: function(frm) {
frm.set_query("employee","employees", function(doc,cdt,cdn) {
return{ query: "erpnext.controllers.queries.employee_query" }
})
}
});

View File

@@ -6,25 +6,19 @@ import frappe
import unittest
import erpnext
from frappe.utils.make_random import get_random
from frappe.utils import nowdate, add_days, add_years
from frappe.utils import nowdate, add_days, add_years, getdate
from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
from erpnext.hr.doctype.salary_slip.test_salary_slip import make_salary_component
from erpnext.hr.doctype.salary_slip.test_salary_slip import make_earning_salary_component, make_deduction_salary_component
# test_records = frappe.get_test_records('Salary Structure')
test_dependencies = ["Fiscal Year"]
class TestSalaryStructure(unittest.TestCase):
def test_setup(self):
if not frappe.db.exists("Fiscal Year", "_Test Fiscal Year 2016"):
fy = frappe.get_doc({
"doctype": "Fiscal Year",
"year": "_Test Fiscal Year 2016",
"year_end_date": "2016-12-31",
"year_start_date": "2016-01-01"
})
fy.insert()
def setUp(self):
self.make_holiday_list()
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Structure Test Holiday List")
make_salary_component(["Basic Salary", "Allowance", "HRA", "Professional Tax", "TDS"])
make_earning_salary_component(["Basic Salary", "Allowance", "HRA"])
make_deduction_salary_component(["Professional Tax", "TDS"])
employee1 = self.make_employee("test_employee@salary.com")
employee2 = self.make_employee("test_employee_2@salary.com")
@@ -87,8 +81,8 @@ def make_salary_slip_from_salary_structure(employee):
sal_struct = make_salary_structure('Salary Structure Sample')
sal_slip = make_salary_slip(sal_struct, employee = employee)
sal_slip.employee_name = frappe.get_value("Employee", {"name":employee}, "employee_name")
sal_slip.month = "11"
sal_slip.fiscal_year = "_Test Fiscal Year 2016"
sal_slip.month = getdate(nowdate()).month
sal_slip.posting_date = nowdate()
sal_slip.insert()
sal_slip.submit()

View File

@@ -1,12 +1,14 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2013-05-06 18:43:53",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"json": "{\"filters\":[],\"columns\":[[\"name\",\"Employee\"],[\"employee_number\",\"Employee\"],[\"date_of_joining\",\"Employee\"],[\"branch\",\"Employee\"],[\"department\",\"Employee\"],[\"designation\",\"Employee\"],[\"gender\",\"Employee\"],[\"status\",\"Employee\"],[\"company\",\"Employee\"],[\"employment_type\",\"Employee\"],[\"reports_to\",\"Employee\"],[\"company_email\",\"Employee\"]],\"sort_by\":\"Employee.bank_ac_no\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}",
"modified": "2015-03-02 07:42:02.352823",
"json": "{\"add_total_row\": 0, \"sort_by\": \"Employee.bank_ac_no\", \"sort_order\": \"desc\", \"sort_by_next\": \"\", \"filters\": [], \"sort_order_next\": \"desc\", \"columns\": [[\"name\", \"Employee\"], [\"employee_number\", \"Employee\"], [\"date_of_joining\", \"Employee\"], [\"branch\", \"Employee\"], [\"department\", \"Employee\"], [\"designation\", \"Employee\"], [\"gender\", \"Employee\"], [\"status\", \"Employee\"], [\"company\", \"Employee\"], [\"employment_type\", \"Employee\"], [\"reports_to\", \"Employee\"], [\"company_email\", \"Employee\"]]}",
"modified": "2016-12-05 18:49:34.782552",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Information",

View File

@@ -8,32 +8,32 @@ from frappe import msgprint, _
def execute(filters=None):
if not filters: filters = {}
salary_slips = get_salary_slips(filters)
columns, earning_types, ded_types = get_columns(salary_slips)
ss_earning_map = get_ss_earning_map(salary_slips)
ss_ded_map = get_ss_ded_map(salary_slips)
data = []
for ss in salary_slips:
row = [ss.name, ss.employee, ss.employee_name, ss.branch, ss.department, ss.designation,
ss.company, ss.month, ss.leave_withut_pay, ss.payment_days]
for e in earning_types:
row.append(ss_earning_map.get(ss.name, {}).get(e))
row += [ss.arrear_amount, ss.leave_encashment_amount, ss.gross_pay]
for d in ded_types:
row.append(ss_ded_map.get(ss.name, {}).get(d))
row += [ss.total_deduction, ss.net_pay]
data.append(row)
return columns, data
def get_columns(salary_slips):
columns = [
_("Salary Slip ID") + ":Link/Salary Slip:150",_("Employee") + ":Link/Employee:120", _("Employee Name") + "::140", _("Branch") + ":Link/Branch:120",
@@ -41,14 +41,14 @@ def get_columns(salary_slips):
_("Company") + ":Link/Company:120", _("Month") + "::80", _("Leave Without Pay") + ":Float:130",
_("Payment Days") + ":Float:120"
]
salary_components = {_("Earning"): [], _("Deduction"): []}
for component in frappe.db.sql("""select distinct sd.salary_component, sc.type
from `tabSalary Detail` sd, `tabSalary Component` sc
where sc.name=sd.salary_component and sd.amount != 0 and sd.parent in (%s)""" %
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1):
salary_components[component.type].append(component.salary_component)
salary_components[_(component.type)].append(component.salary_component)
columns = columns + [(e + ":Currency:120") for e in salary_components[_("Earning")]] + \
[ _("Arrear Amount") + ":Currency:120", _("Leave Encashment Amount") + ":Currency:150",
@@ -61,47 +61,47 @@ def get_salary_slips(filters):
conditions, filters = get_conditions(filters)
salary_slips = frappe.db.sql("""select * from `tabSalary Slip` where docstatus = 1 %s
order by employee, month""" % conditions, filters, as_dict=1)
if not salary_slips:
msgprint(_("No salary slip found for month: ") + cstr(filters.get("month")) +
_(" and year: ") + cstr(filters.get("fiscal_year")), raise_exception=1)
frappe.throw(_("No salary slip found for month {0} and year {1}").format(
filters.get("month"), filters.get("fiscal_year")))
return salary_slips
def get_conditions(filters):
conditions = ""
if filters.get("month"):
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
"Dec"].index(filters["month"]) + 1
filters["month"] = month
conditions += " and month = %(month)s"
if filters.get("fiscal_year"): conditions += " and fiscal_year = %(fiscal_year)s"
if filters.get("company"): conditions += " and company = %(company)s"
if filters.get("employee"): conditions += " and employee = %(employee)s"
return conditions, filters
def get_ss_earning_map(salary_slips):
ss_earnings = frappe.db.sql("""select parent, salary_component, amount
ss_earnings = frappe.db.sql("""select parent, salary_component, amount
from `tabSalary Detail` where parent in (%s)""" %
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1)
ss_earning_map = {}
for d in ss_earnings:
ss_earning_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, [])
ss_earning_map[d.parent][d.salary_component] = flt(d.amount)
return ss_earning_map
def get_ss_ded_map(salary_slips):
ss_deductions = frappe.db.sql("""select parent, salary_component, amount
ss_deductions = frappe.db.sql("""select parent, salary_component, amount
from `tabSalary Detail` where parent in (%s)""" %
(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]), as_dict=1)
ss_ded_map = {}
for d in ss_deductions:
ss_ded_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, [])
ss_ded_map[d.parent][d.salary_component] = flt(d.amount)
return ss_ded_map

View File

@@ -816,7 +816,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2016-08-17 05:35:34.331954",
"modified": "2016-11-16 05:35:34.331954",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Planning Tool",

View File

@@ -486,7 +486,9 @@ class ProductionPlanningTool(Document):
"qty": requested_qty,
"schedule_date": add_days(nowdate(), cint(item_wrapper.lead_time_days)),
"warehouse": self.purchase_request_for_warehouse,
"sales_order": sales_order if sales_order!="No Sales Order" else None
"sales_order": sales_order if sales_order!="No Sales Order" else None,
"project": frappe.db.get_value("Sales Order", sales_order, "project") \
if sales_order!="No Sales Order" else None
})
material_request.flags.ignore_permissions = 1

View File

@@ -1,17 +1,19 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
frappe.call({
type:"GET",
method:"erpnext.manufacturing.doctype.workstation.workstation.get_default_holiday_list",
callback: function(r) {
if(!r.exe && r.message){
cur_frm.set_value("holiday_list", r.message);
}
frappe.ui.form.on("Workstation", {
onload: function(frm) {
if(frm.is_new())
{
frappe.call({
type:"GET",
method:"erpnext.manufacturing.doctype.workstation.workstation.get_default_holiday_list",
callback: function(r) {
if(!r.exe && r.message){
cur_frm.set_value("holiday_list", r.message);
}
}
})
}
})
}
}
})

View File

@@ -60,9 +60,10 @@ def is_within_operating_hours(workstation, operation, from_datetime, to_datetime
workstation = frappe.get_doc("Workstation", workstation)
for working_hour in workstation.working_hours:
slot_length = (to_timedelta(working_hour.end_time or "") - to_timedelta(working_hour.start_time or "")).total_seconds()
if slot_length >= operation_length:
return
if working_hour.start_time and working_hour.end_time:
slot_length = (to_timedelta(working_hour.end_time or "") - to_timedelta(working_hour.start_time or "")).total_seconds()
if slot_length >= operation_length:
return
frappe.throw(_("Operation {0} longer than any available working hours in workstation {1}, break down the operation into multiple operations").format(operation, workstation.name), NotInWorkingHoursError)

View File

@@ -344,4 +344,11 @@ execute:frappe.reload_doc('accounts', 'doctype', 'accounts_settings')
execute:frappe.db.set_value("Accounts Settings", "Accounts Settings", "unlink_payment_on_cancellation_of_invoice", 0)
execute:frappe.db.sql("update `tabStock Entry` set total_amount = null where purpose in('Repack', 'Manufacture')")
erpnext.patches.v7_0.repost_gle_for_pi_with_update_stock #2016-11-01
erpnext.patches.v7_1.add_account_user_role_for_timesheet
erpnext.patches.v7_1.add_account_user_role_for_timesheet
erpnext.patches.v7_0.set_base_amount_in_invoice_payment_table
erpnext.patches.v7_1.update_invoice_status
erpnext.patches.v7_0.po_status_issue_for_pr_return
erpnext.patches.v7_1.update_missing_salary_component_type
erpnext.patches.v7_0.update_autoname_field
erpnext.patches.v7_0.update_status_of_po_so
erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items

View File

@@ -22,7 +22,7 @@ def execute():
# Update billed_amt in DN and PR which are not against any order
for d in frappe.db.sql("""select name from `tabPurchase Receipt Item` item
where (prevdoc_detail_docname is null or prevdoc_detail_docname = '') and docstatus=1""", as_dict=1):
where (purchase_order_item is null or purchase_order_item = '') and docstatus=1""", as_dict=1):
billed_amt = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
where pr_detail=%s and docstatus=1""", d.name)

View File

@@ -6,6 +6,8 @@ from erpnext.patches.v7_0.migrate_schools_to_erpnext import reload_doctypes_for_
def execute():
'''hide new style icons if old ones are set'''
frappe.reload_doc('desk', 'doctype', 'desktop_icon')
reload_doctypes_for_schools_icons()
sync_desktop_icons()

View File

@@ -0,0 +1,36 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
parent_list = []
count = 0
for data in frappe.db.sql("""
select
`tabPurchase Receipt Item`.purchase_order, `tabPurchase Receipt Item`.name,
`tabPurchase Receipt Item`.item_code, `tabPurchase Receipt Item`.idx,
`tabPurchase Receipt Item`.parent
from
`tabPurchase Receipt Item`, `tabPurchase Receipt`
where
`tabPurchase Receipt Item`.parent = `tabPurchase Receipt`.name and
`tabPurchase Receipt Item`.purchase_order_item is null and
`tabPurchase Receipt Item`.purchase_order is not null and
`tabPurchase Receipt`.is_return = 1""", as_dict=1):
name = frappe.db.get_value('Purchase Order Item',
{'item_code': data.item_code, 'parent': data.purchase_order, 'idx': data.idx}, 'name')
if name:
frappe.db.set_value('Purchase Receipt Item', data.name, 'purchase_order_item', name, update_modified=False)
parent_list.append(data.parent)
count +=1
if count % 200 == 0:
frappe.db.commit()
if len(parent_list) > 0:
for parent in set(parent_list):
doc = frappe.get_doc('Purchase Receipt', parent)
doc.update_qty(update_modified=False)

View File

@@ -9,6 +9,8 @@ def execute():
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
return
frappe.reload_doctype("Purchase Invoice")
for pi in frappe.db.sql("""select name from `tabPurchase Invoice`
where update_stock=1 and docstatus=1 order by posting_date asc""", as_dict=1):

View File

@@ -0,0 +1,24 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import flt
def execute():
si_list = frappe.db.sql("""
select distinct parent
from `tabSales Invoice Payment`
where docstatus!=2 and parenttype = 'Sales Invoice'
and amount != 0 and base_amount = 0
""")
count = 0
for d in si_list:
si = frappe.get_doc("Sales Invoice", d[0])
for p in si.get("payments"):
if p.amount and not p.base_amount:
base_amount = flt(p.amount*si.conversion_rate, si.precision("base_paid_amount"))
frappe.db.set_value("Sales Invoice Payment", p.name, "base_amount", base_amount, update_modified=False)
count +=1
if count % 200 == 0:
frappe.db.commit()

View File

@@ -0,0 +1,14 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
doctypes = frappe.db.sql(""" select name, autoname from `tabDocType`
where autoname like 'field:%' and allow_rename = 1""", as_dict=1)
for doctype in doctypes:
fieldname = doctype.autoname.split(":")[1]
if fieldname:
frappe.db.sql(""" update `tab%s` set %s = name """%(doctype.name, fieldname))

View File

@@ -0,0 +1,62 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.utils import cint, flt
def execute():
update_po_per_received_per_billed()
update_so_per_delivered_per_billed()
update_status()
def update_po_per_received_per_billed():
frappe.db.sql("""
update
`tabPurchase Order`
set
`tabPurchase Order`.per_received = round((select sum(if(qty > ifnull(received_qty, 0),
ifnull(received_qty, 0), qty)) / sum(qty) *100 from `tabPurchase Order Item`
where parent = `tabPurchase Order`.name), 2),
`tabPurchase Order`.per_billed = ifnull(round((select sum( if(amount > ifnull(billed_amt, 0),
ifnull(billed_amt, 0), amount)) / sum(amount) *100 from `tabPurchase Order Item`
where parent = `tabPurchase Order`.name), 2), 0)""")
def update_so_per_delivered_per_billed():
frappe.db.sql("""
update
`tabSales Order`
set
`tabSales Order`.per_delivered = round((select sum( if(qty > ifnull(delivered_qty, 0),
ifnull(delivered_qty, 0), qty)) / sum(qty) *100 from `tabSales Order Item`
where parent = `tabSales Order`.name), 2),
`tabSales Order`.per_billed = ifnull(round((select sum( if(amount > ifnull(billed_amt, 0),
ifnull(billed_amt, 0), amount)) / sum(amount) *100 from `tabSales Order Item`
where parent = `tabSales Order`.name), 2), 0)""")
def update_status():
frappe.db.sql("""
update
`tabSales Order`
set status = (Case when status = 'Closed' then 'Closed'
When per_delivered < 100 and per_billed < 100 and docstatus = 1 then 'To Deliver and Bill'
when per_delivered = 100 and per_billed < 100 and docstatus = 1 then 'To Bill'
when per_delivered < 100 and per_billed = 100 and docstatus = 1 then 'To Deliver'
when per_delivered = 100 and per_billed = 100 and docstatus = 1 then 'Completed'
when order_type = 'Maintenance' and per_billed = 100 and docstatus = 1 then 'Completed'
when docstatus = 2 then 'Cancelled'
else 'Draft'
End)""")
frappe.db.sql("""
update
`tabPurchase Order`
set status = (Case when status = 'Closed' then 'Closed'
when status = 'Delivered' then 'Delivered'
When per_received < 100 and per_billed < 100 and docstatus = 1 then 'To Receive and Bill'
when per_received = 100 and per_billed < 100 and docstatus = 1 then 'To Bill'
when per_received < 100 and per_billed = 100 and docstatus = 1 then 'To Receive'
when per_received = 100 and per_billed = 100 and docstatus = 1 then 'Completed'
when docstatus = 2 then 'Cancelled'
else 'Draft'
End)""")

View File

@@ -0,0 +1,44 @@
from __future__ import unicode_literals
import frappe
from erpnext.stock.stock_balance import repost_stock
def execute():
frappe.reload_doc('manufacturing', 'doctype', 'production_order_item')
frappe.reload_doc('manufacturing', 'doctype', 'production_order')
modified_items = frappe.db.sql_list("""
select name from `tabItem`
where is_stock_item=1 and modified >= '2016-10-31'
""")
if not modified_items:
return
item_warehouses_with_transactions = []
transactions = ("Sales Order Item", "Material Request Item", "Purchase Order Item",
"Stock Ledger Entry", "Packed Item")
for doctype in transactions:
item_warehouses_with_transactions += list(frappe.db.sql("""
select distinct item_code, warehouse
from `tab{0}` where docstatus=1 and item_code in ({1})"""
.format(doctype, ', '.join(['%s']*len(modified_items))), tuple(modified_items)))
item_warehouses_with_transactions += list(frappe.db.sql("""
select distinct production_item, fg_warehouse
from `tabProduction Order` where docstatus=1 and production_item in ({0})"""
.format(', '.join(['%s']*len(modified_items))), tuple(modified_items)))
item_warehouses_with_transactions += list(frappe.db.sql("""
select distinct pr_item.item_code, pr.source_warehouse
from `tabProduction Order` pr, `tabProduction Order Item` pr_item
where pr_item.parent and pr.name and pr.docstatus=1 and pr_item.item_code in ({0})"""
.format(', '.join(['%s']*len(modified_items))), tuple(modified_items)))
item_warehouses_with_bin = list(frappe.db.sql("select distinct item_code, warehouse from `tabBin`"))
item_warehouses_with_missing_bin = list(
set(item_warehouses_with_transactions) - set(item_warehouses_with_bin))
for item_code, warehouse in item_warehouses_with_missing_bin:
repost_stock(item_code, warehouse)

Some files were not shown because too many files have changed in this diff Show More