Compare commits
537 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b75f5fd5ab | ||
|
|
6f5815838e | ||
|
|
fe53651287 | ||
|
|
d8546c4316 | ||
|
|
17405d4130 | ||
|
|
2f443a5789 | ||
|
|
a5e11d7195 | ||
|
|
3832e1f9be | ||
|
|
67079d292c | ||
|
|
01a3a81f71 | ||
|
|
befa8d613f | ||
|
|
9e26bcfeeb | ||
|
|
f948fea3bf | ||
|
|
d851bd8d85 | ||
|
|
30672c6b55 | ||
|
|
e73941b9cc | ||
|
|
f33787a706 | ||
|
|
fcc4021e44 | ||
|
|
3b67c89e0b | ||
|
|
7364ebaff6 | ||
|
|
fd8f34018d | ||
|
|
799fa09a23 | ||
|
|
d1dc622914 | ||
|
|
8ce47862f9 | ||
|
|
b24d2efc4b | ||
|
|
a184fbfa66 | ||
|
|
763821d57d | ||
|
|
a132767126 | ||
|
|
453cc374d4 | ||
|
|
43e46a8506 | ||
|
|
2c95130451 | ||
|
|
d46fb5eb8c | ||
|
|
e95c18a42d | ||
|
|
18c2c54633 | ||
|
|
0edec9d25b | ||
|
|
15216fdd6f | ||
|
|
9117af3077 | ||
|
|
92b6f76612 | ||
|
|
8bf0b89595 | ||
|
|
746c162055 | ||
|
|
9eb9ccd785 | ||
|
|
1e046aa49a | ||
|
|
3ad26e4dd1 | ||
|
|
2f3b097d63 | ||
|
|
c505cbc988 | ||
|
|
1e8025b327 | ||
|
|
0e6f2474e8 | ||
|
|
e102332f08 | ||
|
|
145227e4ec | ||
|
|
18e033514e | ||
|
|
26052df76e | ||
|
|
b2f354a614 | ||
|
|
49a59c075f | ||
|
|
ff3b220c79 | ||
|
|
cc7cb2a70a | ||
|
|
79bf233734 | ||
|
|
3698b84d7c | ||
|
|
3fbbb71afc | ||
|
|
a2f18ba794 | ||
|
|
9088432f10 | ||
|
|
c80059e10e | ||
|
|
8e8e9c61ca | ||
|
|
424f0c7b84 | ||
|
|
aa5fb5e50e | ||
|
|
08a60653ba | ||
|
|
8b96fdac12 | ||
|
|
e319598c51 | ||
|
|
0c7fd6cd94 | ||
|
|
0b5260acf0 | ||
|
|
d4be82cf9b | ||
|
|
0166e9e47a | ||
|
|
b71471fcb5 | ||
|
|
7e8d7d05ef | ||
|
|
228ff87ea2 | ||
|
|
8d8655e1cd | ||
|
|
5c73bafeaa | ||
|
|
14859faf17 | ||
|
|
2b7eda8135 | ||
|
|
751d7ecd85 | ||
|
|
6a09b3f7ef | ||
|
|
21897e3c52 | ||
|
|
15b4f6310c | ||
|
|
196a0bc675 | ||
|
|
7c011985f0 | ||
|
|
3cf67a462b | ||
|
|
f061877b4f | ||
|
|
04d244a360 | ||
|
|
b74999da82 | ||
|
|
061f7079ed | ||
|
|
246ed3f122 | ||
|
|
6b25708b7a | ||
|
|
623ed57663 | ||
|
|
1d21842f68 | ||
|
|
ada485f096 | ||
|
|
8a9d41a92e | ||
|
|
f965c5d203 | ||
|
|
21647974c4 | ||
|
|
9c3dca63fa | ||
|
|
c40b99be26 | ||
|
|
982f4ae44d | ||
|
|
9257413b68 | ||
|
|
c723c8b5aa | ||
|
|
2771b7d828 | ||
|
|
75ebed815f | ||
|
|
975ef07c48 | ||
|
|
f666535223 | ||
|
|
08fb19ac8c | ||
|
|
db9762be3f | ||
|
|
03ae61afce | ||
|
|
1847b705fe | ||
|
|
4a573a7e8b | ||
|
|
f74b9b06f7 | ||
|
|
2820a8749f | ||
|
|
41b4864f0c | ||
|
|
13df8a40ef | ||
|
|
7cfa5f0508 | ||
|
|
bb274fce2e | ||
|
|
fec61fe33e | ||
|
|
d0387f41df | ||
|
|
05d8174696 | ||
|
|
ba02ce6adc | ||
|
|
886def0a69 | ||
|
|
7590aa2524 | ||
|
|
8b48ceab8c | ||
|
|
d900e12ae7 | ||
|
|
098760f0e2 | ||
|
|
cc431716ed | ||
|
|
f5ea801b69 | ||
|
|
e2b8ccf1bb | ||
|
|
f447c8258a | ||
|
|
f78ffd84b4 | ||
|
|
63d345c6ab | ||
|
|
d0d1af2072 | ||
|
|
83694fd180 | ||
|
|
fc353efeca | ||
|
|
16edf8b478 | ||
|
|
c9e4fbeda0 | ||
|
|
46ae789f2f | ||
|
|
a9a284a5ae | ||
|
|
823e88d5bd | ||
|
|
1be94efcfa | ||
|
|
a5e9c71397 | ||
|
|
285135da8e | ||
|
|
906c2babaa | ||
|
|
14a394cde1 | ||
|
|
3c821c89f2 | ||
|
|
a041297861 | ||
|
|
856ee10dc4 | ||
|
|
1401e3f679 | ||
|
|
dae29bf2d4 | ||
|
|
0a3be6da27 | ||
|
|
3631e9cbe0 | ||
|
|
1c9a7d2a1b | ||
|
|
972f2f9194 | ||
|
|
239296d16a | ||
|
|
3210db9056 | ||
|
|
feda4f9bc9 | ||
|
|
f6954fb798 | ||
|
|
c6656e68b8 | ||
|
|
a39387d352 | ||
|
|
f3791797d6 | ||
|
|
ea4d63cef3 | ||
|
|
5464ca8a73 | ||
|
|
6c6875f503 | ||
|
|
20523c45c7 | ||
|
|
0248811e53 | ||
|
|
93416ee72c | ||
|
|
51e7086a08 | ||
|
|
5e849ae53e | ||
|
|
de0db0d000 | ||
|
|
f3a67c4533 | ||
|
|
0847f9a074 | ||
|
|
9490c21b8a | ||
|
|
bdb71bca4e | ||
|
|
e8861e2871 | ||
|
|
b084b5e449 | ||
|
|
41d3e57702 | ||
|
|
9df2899f72 | ||
|
|
dacf127f1b | ||
|
|
2b49f9b30a | ||
|
|
533434e878 | ||
|
|
1956028ddc | ||
|
|
a87dc3b4e6 | ||
|
|
97b3f750c9 | ||
|
|
c41b63eff1 | ||
|
|
e6f7ac961f | ||
|
|
cf26964deb | ||
|
|
94157334a7 | ||
|
|
c530161de0 | ||
|
|
2212ae12d8 | ||
|
|
54ade0d26c | ||
|
|
f043760526 | ||
|
|
1cd049d824 | ||
|
|
0a45260ed9 | ||
|
|
1540ad12f9 | ||
|
|
76bd015b2c | ||
|
|
5054a3955b | ||
|
|
1a0713e4b9 | ||
|
|
e9604d8484 | ||
|
|
008d1a0334 | ||
|
|
fe2ffaeafa | ||
|
|
dcef448f1e | ||
|
|
6224cfc414 | ||
|
|
700434ff37 | ||
|
|
4089b3d376 | ||
|
|
6cfab43d5f | ||
|
|
09a66c4201 | ||
|
|
ed8cecbdd8 | ||
|
|
c70109d0c5 | ||
|
|
ccf8c337f7 | ||
|
|
6809b4d86c | ||
|
|
cc08c68153 | ||
|
|
7daa7900ea | ||
|
|
7641f3fe53 | ||
|
|
fe2f51bbbc | ||
|
|
4f33249e1c | ||
|
|
b95b606f25 | ||
|
|
e690f245f2 | ||
|
|
5da4d857c9 | ||
|
|
6e38e917eb | ||
|
|
f3b0b95b15 | ||
|
|
7b0f1ffb2d | ||
|
|
97bb6bbaf4 | ||
|
|
cb4b2ec52a | ||
|
|
f18bbcef86 | ||
|
|
27976382d8 | ||
|
|
93d3c82737 | ||
|
|
03bf529622 | ||
|
|
6c4085fc0c | ||
|
|
c37484c8da | ||
|
|
b4ec294463 | ||
|
|
58406a920c | ||
|
|
98311f4394 | ||
|
|
53829707ad | ||
|
|
fcc31028c6 | ||
|
|
fc3d87181a | ||
|
|
6336ff7323 | ||
|
|
fde13e666a | ||
|
|
f80c09290e | ||
|
|
b797963bd8 | ||
|
|
03b42a7934 | ||
|
|
7e9ff99a6c | ||
|
|
5cbe3441e8 | ||
|
|
0724449d0e | ||
|
|
5a6ff218e8 | ||
|
|
122e4e0a96 | ||
|
|
e233f0e2ff | ||
|
|
40e92b679b | ||
|
|
4770a1abb5 | ||
|
|
ccb9117ba5 | ||
|
|
db938762c7 | ||
|
|
0910fc3b25 | ||
|
|
f0737667c6 | ||
|
|
2d83122c6b | ||
|
|
e2b7f832cc | ||
|
|
6a6958db5c | ||
|
|
ab1acb460b | ||
|
|
48d71fa7f7 | ||
|
|
30960e6a06 | ||
|
|
736000c223 | ||
|
|
4017bfcd2e | ||
|
|
e594e5de49 | ||
|
|
1f1f14be39 | ||
|
|
ebb60f5dbc | ||
|
|
75b00e3958 | ||
|
|
5e3646ad6e | ||
|
|
4439d8264f | ||
|
|
00d79eb68d | ||
|
|
28a9e35de9 | ||
|
|
c450536a2c | ||
|
|
3b3c48c877 | ||
|
|
621d6eac3c | ||
|
|
f9b356992a | ||
|
|
c516e1871d | ||
|
|
9a38e669ef | ||
|
|
143f2c6faf | ||
|
|
9269813207 | ||
|
|
0e6f92efa8 | ||
|
|
1a0e86f11d | ||
|
|
73b7efd61d | ||
|
|
4c4a5b968c | ||
|
|
7b5ac6396a | ||
|
|
01771e8afc | ||
|
|
347c4affe9 | ||
|
|
526957505f | ||
|
|
faa3416852 | ||
|
|
56912791e2 | ||
|
|
38647c68b9 | ||
|
|
4d64acfafc | ||
|
|
d7441ec051 | ||
|
|
0f15273bd7 | ||
|
|
24efb3122a | ||
|
|
85e6f5d04e | ||
|
|
1faaf71dfc | ||
|
|
5a0fbff1a3 | ||
|
|
7278c0ae85 | ||
|
|
5688a6c31a | ||
|
|
71349d221b | ||
|
|
b7219dc698 | ||
|
|
37c6ce7b1e | ||
|
|
7028ba507e | ||
|
|
fcee17fd16 | ||
|
|
5906f02e3a | ||
|
|
721dcb1870 | ||
|
|
6385967ccd | ||
|
|
81a977cacf | ||
|
|
34058ded0e | ||
|
|
e98120b716 | ||
|
|
50e363b24e | ||
|
|
bc176b6bf8 | ||
|
|
784b49e54e | ||
|
|
04fb6e1a45 | ||
|
|
dffd7c3889 | ||
|
|
0c7594e5ed | ||
|
|
5105f909d6 | ||
|
|
2ab9d6e92c | ||
|
|
7580723ab3 | ||
|
|
52fef71c14 | ||
|
|
2cd02af80a | ||
|
|
0b0ec3536c | ||
|
|
6b35ea873b | ||
|
|
ecf220a721 | ||
|
|
04fb1c7fe4 | ||
|
|
53bd62eafc | ||
|
|
ff68bf2609 | ||
|
|
fdd0db3459 | ||
|
|
f92465981c | ||
|
|
885c70984d | ||
|
|
9c15ef903d | ||
|
|
bc799885d0 | ||
|
|
cb129264cb | ||
|
|
fe9cd1d875 | ||
|
|
64fbe955c7 | ||
|
|
0988440fd9 | ||
|
|
274dd4ada0 | ||
|
|
724fd82419 | ||
|
|
3f2604eff6 | ||
|
|
c761fefb78 | ||
|
|
203cb10ef7 | ||
|
|
90c66b1998 | ||
|
|
fed431f908 | ||
|
|
bd9745ba72 | ||
|
|
8fb123b20e | ||
|
|
333ccd212b | ||
|
|
c8cc8b7115 | ||
|
|
ec44fa95ce | ||
|
|
a25e8ea0bc | ||
|
|
ea02b9a5c3 | ||
|
|
74a63bf003 | ||
|
|
a0f2510b01 | ||
|
|
0820161157 | ||
|
|
56bc215855 | ||
|
|
8687d25f7e | ||
|
|
9cea01fa8b | ||
|
|
e06d01e3ed | ||
|
|
11243a4fb4 | ||
|
|
b9e5cd0df4 | ||
|
|
a1f1edc786 | ||
|
|
e2d8dd0663 | ||
|
|
d1605c5cb2 | ||
|
|
64ca52fb77 | ||
|
|
2f11a3bdaf | ||
|
|
943dc1f59c | ||
|
|
6d1c994bc9 | ||
|
|
93cdee4503 | ||
|
|
dfac6848cc | ||
|
|
8ad0b4e0b9 | ||
|
|
b8cd92f1aa | ||
|
|
1fe48cb820 | ||
|
|
723b046c5b | ||
|
|
035160c9a6 | ||
|
|
01c7ce1da3 | ||
|
|
9cf2910ba1 | ||
|
|
c8da7b7d32 | ||
|
|
9679d31397 | ||
|
|
38bebe1b83 | ||
|
|
ffbc11e8de | ||
|
|
818d9674d9 | ||
|
|
086f8942eb | ||
|
|
c3b492b237 | ||
|
|
9d0dd5066a | ||
|
|
e7f479b26a | ||
|
|
7ee45b4af2 | ||
|
|
5cce1e0929 | ||
|
|
be496bc91c | ||
|
|
59f063e5c3 | ||
|
|
af5820874c | ||
|
|
495db99719 | ||
|
|
123beb5a07 | ||
|
|
7ed4e080a2 | ||
|
|
e91025c0aa | ||
|
|
1ac9f2f50d | ||
|
|
bd9aa13db3 | ||
|
|
ed9d5cfdaf | ||
|
|
bf4547ca5f | ||
|
|
b45a6bcb88 | ||
|
|
ac59c2b300 | ||
|
|
6a8d7a1b91 | ||
|
|
5d71a28e97 | ||
|
|
7d100a1ee7 | ||
|
|
81dca110eb | ||
|
|
9c852108d0 | ||
|
|
e3ac032696 | ||
|
|
64cacfb077 | ||
|
|
ae4cc078ea | ||
|
|
0ee543e932 | ||
|
|
a123638d37 | ||
|
|
58996985ed | ||
|
|
5d0ce7939f | ||
|
|
4abf552d7b | ||
|
|
7c5ba957ac | ||
|
|
77f04e293a | ||
|
|
d1d3237784 | ||
|
|
76f0d26f1e | ||
|
|
65922d3079 | ||
|
|
810041cbe3 | ||
|
|
b9626659ea | ||
|
|
e3d13bee36 | ||
|
|
13bd538aca | ||
|
|
d72a24965b | ||
|
|
dc633fe360 | ||
|
|
39046d663d | ||
|
|
6b01abe9ad | ||
|
|
63e4d31aa6 | ||
|
|
f2a0161709 | ||
|
|
3c1a4a0b9b | ||
|
|
82cc2921d1 | ||
|
|
87edd86854 | ||
|
|
e37dd77923 | ||
|
|
e4f689184f | ||
|
|
85f825e98c | ||
|
|
89592c5180 | ||
|
|
587bd144d5 | ||
|
|
1f048b2426 | ||
|
|
1792ff3be7 | ||
|
|
fc595064e0 | ||
|
|
804b4acb9b | ||
|
|
5c7557914b | ||
|
|
381a9377d9 | ||
|
|
9bdd1aa1ed | ||
|
|
d0df28bfa0 | ||
|
|
1966225450 | ||
|
|
4cee27eec0 | ||
|
|
c7d4eaee79 | ||
|
|
43c1a9b502 | ||
|
|
b937fac3ce | ||
|
|
53d94996ad | ||
|
|
26f6752c1e | ||
|
|
bb429745c0 | ||
|
|
909f0c38f1 | ||
|
|
a790ba05f4 | ||
|
|
11fc4f85d0 | ||
|
|
17452a1695 | ||
|
|
7c3d48e353 | ||
|
|
5d288e407c | ||
|
|
f64fae752f | ||
|
|
82763f052f | ||
|
|
bafc73568a | ||
|
|
d015195617 | ||
|
|
b2f550ccb3 | ||
|
|
41413af42d | ||
|
|
ec60ebde6f | ||
|
|
ce81a61fe7 | ||
|
|
dc76b3fa20 | ||
|
|
828cbee12a | ||
|
|
5f5ef16b91 | ||
|
|
686ef8308a | ||
|
|
b63ad44b10 | ||
|
|
5ef121bc10 | ||
|
|
42c1836db5 | ||
|
|
9dbdef3bd5 | ||
|
|
9fd42ed2f7 | ||
|
|
000835c454 | ||
|
|
de1f934e22 | ||
|
|
7cbd916b00 | ||
|
|
56fcf30cb9 | ||
|
|
ebbdd772a9 | ||
|
|
6268d83173 | ||
|
|
4599467939 | ||
|
|
d3613479c6 | ||
|
|
6bf301f53c | ||
|
|
27d7f21553 | ||
|
|
8f87cff4bd | ||
|
|
8f39766924 | ||
|
|
39669f2717 | ||
|
|
3c1017c43b | ||
|
|
0b18a2d347 | ||
|
|
6262496e70 | ||
|
|
c9963f1805 | ||
|
|
8a2b1bcb97 | ||
|
|
b8ecf7c757 | ||
|
|
cf89fa2253 | ||
|
|
419c1eb90d | ||
|
|
2c214e0362 | ||
|
|
7d04dd0bfd | ||
|
|
f1371a7ee7 | ||
|
|
995a78421a | ||
|
|
352187bee6 | ||
|
|
c6d8121f4a | ||
|
|
030ade428b | ||
|
|
c87595b2da | ||
|
|
42f2674cba | ||
|
|
5359f2651a | ||
|
|
42dcffdad4 | ||
|
|
f7c1743b28 | ||
|
|
64aa6620be | ||
|
|
ed43f8015c | ||
|
|
d3fe7ec858 | ||
|
|
c8b406d050 | ||
|
|
2aa577f110 | ||
|
|
f06d175061 | ||
|
|
74b2116adb | ||
|
|
2204d0af94 | ||
|
|
b8a568765d | ||
|
|
cf29f6468d | ||
|
|
aded46d33e | ||
|
|
b8dd046c84 | ||
|
|
e5fa5e6111 | ||
|
|
b89cf1b3ec | ||
|
|
a33d468d30 | ||
|
|
e481a211b1 | ||
|
|
ca23b5ecfd | ||
|
|
11190268ab | ||
|
|
a19150ddaf | ||
|
|
c17dff4b01 | ||
|
|
47fe136d15 | ||
|
|
8f25402dce | ||
|
|
a9165744e2 | ||
|
|
3ebfad7115 | ||
|
|
c7ef8dda79 | ||
|
|
4a6c178795 | ||
|
|
8908543a9c | ||
|
|
065badc54b | ||
|
|
cd2798368b | ||
|
|
2c30acdcb2 | ||
|
|
4a4a6594d1 | ||
|
|
9624bac3cf |
@@ -1,5 +1,9 @@
|
||||
# Contributing to Frappe / ERPNext
|
||||
|
||||
## Questions
|
||||
|
||||
If you have questions on how to use ERPNext or want help in customization or debugging of your scripts, please post on https://discuss.frappe.io. This is only for bug reports and feature requests.
|
||||
|
||||
## Reporting issues
|
||||
|
||||
We only accept issues that are bug reports or feature requests. Bugs must be isolated and reproducible problems. Please read the following guidelines before opening any issue.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
from __future__ import unicode_literals
|
||||
__version__ = '5.0.13'
|
||||
__version__ = '5.4.1'
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"permlevel": 0,
|
||||
"read_only": 1,
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
@@ -44,7 +44,7 @@
|
||||
"label": "Is Group",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"search_index": 1
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "company",
|
||||
@@ -57,7 +57,7 @@
|
||||
"permlevel": 0,
|
||||
"read_only": 1,
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "root_type",
|
||||
@@ -147,7 +147,8 @@
|
||||
"label": "Lft",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "rgt",
|
||||
@@ -156,7 +157,8 @@
|
||||
"label": "Rgt",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "old_parent",
|
||||
@@ -171,7 +173,7 @@
|
||||
"icon": "icon-money",
|
||||
"idx": 1,
|
||||
"in_create": 0,
|
||||
"modified": "2015-05-28 14:10:40.606010",
|
||||
"modified": "2015-07-20 03:54:14.297995",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Account",
|
||||
@@ -255,5 +257,5 @@
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"search_fields": "is_group"
|
||||
"search_fields": ""
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class Account(Document):
|
||||
self.root_type = par.root_type
|
||||
|
||||
def validate_root_details(self):
|
||||
#does not exists parent
|
||||
# does not exists parent
|
||||
if frappe.db.exists("Account", self.name):
|
||||
if not frappe.db.get_value("Account", self.name, "parent_account"):
|
||||
throw(_("Root cannot be edited."))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"country_code": "ni",
|
||||
"name": "Catalogo de Cuentas",
|
||||
"name": "Catalogo de Cuentas Nicaragua",
|
||||
"is_active": "Yes",
|
||||
"tree": {
|
||||
"Activo": {
|
||||
@@ -72,7 +72,7 @@
|
||||
"IVA Acreditable por Importaciones": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"IVA Acreditable por Prestacion de Servicios": {
|
||||
"IVA Acreditable por Prestacion de Servicios y Uso y Goce de Bienes": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Acreditacion Proporcional": {}
|
||||
@@ -229,11 +229,19 @@
|
||||
"Impuesto al Valor Agregado por Pagar": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Impuesto sobre la Renta": {
|
||||
"Impuesto sobre la Renta por Actividades Economicas": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Impuestos Municipales": {
|
||||
"account_type": "Tax"
|
||||
"Impuesto Municipal Sobre Ingresos": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Recoleccion Basura": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Matricula Municipal": {
|
||||
"account_type": "Tax"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Retenciones por Pagar": {
|
||||
@@ -241,7 +249,13 @@
|
||||
"Retencion Rentas del Trabajo Tarifa Progresiva": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva por Rentas del Trabajo": {
|
||||
"Retencion Definitiva 10% por Rentas del Trabajo - Indemnizacion Adicional": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva 12.5% por Rentas del Trabajo - Dietas": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva 15% por Rentas del Trabajo - No Residentes": {
|
||||
"account_type": "Tax"
|
||||
}
|
||||
},
|
||||
@@ -258,11 +272,26 @@
|
||||
"Retencion 5% compra Madera en Rollo": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva 1.5% Actividades Economicas No Residentes": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva 3% Actividades Economicas No Residentes": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva 10% Actividades Economicas No Residentes": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva 15% Actividades Economicas No Residentes": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Otras Retenciones 10%": {
|
||||
"account_type": "Tax"
|
||||
}
|
||||
},
|
||||
"Rentas y Ganancias de Capital": {
|
||||
"Retencion Defintiva 15% por Rentas de Capital": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Defintiva 10% por Rentas de Capital": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
@@ -272,10 +301,16 @@
|
||||
"Retencion Definitiva 10% por Ganancia de Capital": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva Actividades Economicas No Residentes": {
|
||||
"Retencion Definitiva 0.25% Transacciones Bursatiles": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva Transacciones Bursatiles": {
|
||||
"Retencion Definitiva 1% Transacciones Bursatiles": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva 1.5% Transacciones Bursatiles": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retencion Definitiva 2% Transacciones Bursatiles": {
|
||||
"account_type": "Tax"
|
||||
},
|
||||
"Retenciones Defintiva 5% Fondos de Inversion": {
|
||||
|
||||
@@ -38,12 +38,19 @@
|
||||
"label": "Credit Controller",
|
||||
"options": "Role",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "check_supplier_invoice_uniqueness",
|
||||
"fieldtype": "Check",
|
||||
"label": "Check Supplier Invoice Number Uniqueness",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
}
|
||||
],
|
||||
"icon": "icon-cog",
|
||||
"idx": 1,
|
||||
"issingle": 1,
|
||||
"modified": "2015-02-05 05:11:34.163902",
|
||||
"modified": "2015-07-14 00:51:48.095525",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Accounts Settings",
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on("Bank Reconciliation", {
|
||||
refresh: function(frm) {
|
||||
frm.disable_save();
|
||||
},
|
||||
|
||||
update_clearance_date: function(frm) {
|
||||
return frappe.call({
|
||||
method: "update_details",
|
||||
@@ -33,5 +37,4 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.set_value("from_date", frappe.datetime.month_start());
|
||||
cur_frm.set_value("to_date", frappe.datetime.month_end());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,8 @@ class BankReconciliation(Document):
|
||||
where
|
||||
t2.parent = t1.name and t2.account = %s
|
||||
and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1
|
||||
and ifnull(t1.is_opening, 'No') = 'No' %s""" %
|
||||
and ifnull(t1.is_opening, 'No') = 'No' %s
|
||||
order by t1.posting_date""" %
|
||||
('%s', '%s', '%s', condition), (self.bank_account, self.from_date, self.to_date), as_dict=1)
|
||||
|
||||
self.set('journal_entries', [])
|
||||
|
||||
@@ -54,7 +54,7 @@ class CForm(Document):
|
||||
frappe.throw(_("Please enter atleast 1 invoice in the table"))
|
||||
|
||||
def set_total_invoiced_amount(self):
|
||||
total = sum([flt(d.base_grand_total) for d in self.get('invoices')])
|
||||
total = sum([flt(d.grand_total) for d in self.get('invoices')])
|
||||
frappe.db.set(self, 'total_invoiced_amount', total)
|
||||
|
||||
def get_invoice_details(self, invoice_no):
|
||||
|
||||
@@ -17,7 +17,7 @@ erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
|
||||
return {
|
||||
filters:[
|
||||
['Account', 'company', '=', me.frm.doc.company],
|
||||
['Account', 'report_type', '=', 'Profit and Loss'],
|
||||
['Account', 'root_type', '=', 'Expense'],
|
||||
['Account', 'is_group', '=', '0'],
|
||||
]
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"description": "Define Budget for this Cost Center. To set budget action, see <a href=\"#!List/Company\">Company Master</a>",
|
||||
"description": "Define Budget for this Cost Center. To set budget action, see \"Company List\"",
|
||||
"fieldname": "sb1",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Budget",
|
||||
@@ -139,7 +139,7 @@
|
||||
"icon": "icon-money",
|
||||
"idx": 1,
|
||||
"in_create": 0,
|
||||
"modified": "2015-04-23 02:54:26.934607",
|
||||
"modified": "2015-07-13 05:28:25.504801",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Cost Center",
|
||||
@@ -189,8 +189,8 @@
|
||||
"apply_user_permissions": 1,
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Material User"
|
||||
"role": "Stock User"
|
||||
}
|
||||
],
|
||||
"search_fields": "parent_cost_center, is_group"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe import msgprint, _
|
||||
|
||||
from frappe import _
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
|
||||
class CostCenter(NestedSet):
|
||||
@@ -14,18 +12,46 @@ class CostCenter(NestedSet):
|
||||
def autoname(self):
|
||||
self.name = self.cost_center_name.strip() + ' - ' + \
|
||||
frappe.db.get_value("Company", self.company, "abbr")
|
||||
|
||||
|
||||
def validate(self):
|
||||
self.validate_mandatory()
|
||||
self.validate_accounts()
|
||||
|
||||
def validate_mandatory(self):
|
||||
if self.cost_center_name != self.company and not self.parent_cost_center:
|
||||
msgprint(_("Please enter parent cost center"), raise_exception=1)
|
||||
frappe.throw(_("Please enter parent cost center"))
|
||||
elif self.cost_center_name == self.company and self.parent_cost_center:
|
||||
msgprint(_("Root cannot have a parent cost center"), raise_exception=1)
|
||||
frappe.throw(_("Root cannot have a parent cost center"))
|
||||
|
||||
def validate_accounts(self):
|
||||
if self.is_group==1 and self.get("budgets"):
|
||||
frappe.throw(_("Budget cannot be set for Group Cost Center"))
|
||||
|
||||
check_acc_list = []
|
||||
for d in self.get('budgets'):
|
||||
if d.account:
|
||||
account_details = frappe.db.get_value("Account", d.account,
|
||||
["is_group", "company", "root_type"], as_dict=1)
|
||||
if account_details.is_group:
|
||||
frappe.throw(_("Budget cannot be assigned against Group Account {0}").format(d.account))
|
||||
elif account_details.company != self.company:
|
||||
frappe.throw(_("Account {0} does not belongs to company {1}").format(d.account, self.company))
|
||||
elif account_details.root_type != "Expense":
|
||||
frappe.throw(_("Budget cannot be assigned against {0}, as it's not an Expense account")
|
||||
.format(d.account))
|
||||
|
||||
if [d.account, d.fiscal_year] in check_acc_list:
|
||||
frappe.throw(_("Account {0} has been entered more than once for fiscal year {1}")
|
||||
.format(d.account, d.fiscal_year))
|
||||
else:
|
||||
check_acc_list.append([d.account, d.fiscal_year])
|
||||
|
||||
def convert_group_to_ledger(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint(_("Cannot convert Cost Center to ledger as it has child nodes"), raise_exception=1)
|
||||
frappe.throw(_("Cannot convert Cost Center to ledger as it has child nodes"))
|
||||
elif self.check_gle_exists():
|
||||
msgprint(_("Cost Center with existing transactions can not be converted to ledger"), raise_exception=1)
|
||||
frappe.throw(_("Cost Center with existing transactions can not be converted to ledger"))
|
||||
else:
|
||||
self.is_group = 0
|
||||
self.save()
|
||||
@@ -33,7 +59,7 @@ class CostCenter(NestedSet):
|
||||
|
||||
def convert_ledger_to_group(self):
|
||||
if self.check_gle_exists():
|
||||
msgprint(_("Cost Center with existing transactions can not be converted to group"), raise_exception=1)
|
||||
frappe.throw(_("Cost Center with existing transactions can not be converted to group"))
|
||||
else:
|
||||
self.is_group = 1
|
||||
self.save()
|
||||
@@ -46,21 +72,6 @@ class CostCenter(NestedSet):
|
||||
return frappe.db.sql("select name from `tabCost Center` where \
|
||||
parent_cost_center = %s and docstatus != 2", self.name)
|
||||
|
||||
def validate_budget_details(self):
|
||||
check_acc_list = []
|
||||
for d in self.get('budgets'):
|
||||
if self.is_group==1:
|
||||
msgprint(_("Budget cannot be set for Group Cost Centers"), raise_exception=1)
|
||||
|
||||
if [d.account, d.fiscal_year] in check_acc_list:
|
||||
msgprint(_("Account {0} has been entered more than once for fiscal year {1}").format(d.account, d.fiscal_year), raise_exception=1)
|
||||
else:
|
||||
check_acc_list.append([d.account, d.fiscal_year])
|
||||
|
||||
def validate(self):
|
||||
self.validate_mandatory()
|
||||
self.validate_budget_details()
|
||||
|
||||
def before_rename(self, olddn, newdn, merge=False):
|
||||
# Add company abbr if not provided
|
||||
from erpnext.setup.doctype.company.company import get_name_with_abbr
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
],
|
||||
"icon": "icon-calendar",
|
||||
"idx": 1,
|
||||
"modified": "2015-04-18 07:33:23.922518",
|
||||
"modified": "2015-07-13 05:28:27.745408",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Fiscal Year",
|
||||
@@ -78,11 +78,63 @@
|
||||
{
|
||||
"apply_user_permissions": 1,
|
||||
"delete": 0,
|
||||
"email": 1,
|
||||
"email": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"print": 0,
|
||||
"read": 1,
|
||||
"role": "All"
|
||||
"role": "Sales User"
|
||||
},
|
||||
{
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 0,
|
||||
"export": 0,
|
||||
"permlevel": 0,
|
||||
"print": 0,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Purchase User",
|
||||
"share": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 0,
|
||||
"export": 0,
|
||||
"permlevel": 0,
|
||||
"print": 0,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Accounts User",
|
||||
"share": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 0,
|
||||
"export": 0,
|
||||
"permlevel": 0,
|
||||
"print": 0,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Stock User",
|
||||
"share": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 0,
|
||||
"export": 0,
|
||||
"permlevel": 0,
|
||||
"print": 0,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Employee",
|
||||
"share": 0,
|
||||
"write": 0
|
||||
}
|
||||
],
|
||||
"sort_field": "name",
|
||||
|
||||
@@ -48,7 +48,8 @@
|
||||
"fieldtype": "Dynamic Link",
|
||||
"label": "Party",
|
||||
"options": "party_type",
|
||||
"permlevel": 0
|
||||
"permlevel": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "cost_center",
|
||||
@@ -192,7 +193,7 @@
|
||||
"icon": "icon-list",
|
||||
"idx": 1,
|
||||
"in_create": 1,
|
||||
"modified": "2015-04-27 20:32:48.246818",
|
||||
"modified": "2015-07-09 15:51:04.986518",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "GL Entry",
|
||||
@@ -224,6 +225,19 @@
|
||||
"role": "Accounts Manager",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 0,
|
||||
"export": 1,
|
||||
"permlevel": 0,
|
||||
"print": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Auditor",
|
||||
"share": 0,
|
||||
"write": 0
|
||||
}
|
||||
],
|
||||
"search_fields": "voucher_no,account,posting_date,against_voucher",
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import flt, fmt_money, getdate, formatdate
|
||||
from frappe.utils import flt, fmt_money, getdate, formatdate, cstr
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
class CustomerFrozen(frappe.ValidationError): pass
|
||||
|
||||
class GLEntry(Document):
|
||||
def validate(self):
|
||||
self.flags.ignore_submit_comment = True
|
||||
@@ -17,6 +19,7 @@ class GLEntry(Document):
|
||||
self.validate_posting_date()
|
||||
self.check_pl_account()
|
||||
self.validate_cost_center()
|
||||
self.validate_party()
|
||||
|
||||
def on_update_with_args(self, adv_adj, update_outstanding = 'Yes'):
|
||||
self.validate_account_details(adv_adj)
|
||||
@@ -88,6 +91,13 @@ class GLEntry(Document):
|
||||
|
||||
if self.cost_center and _get_cost_center_company() != self.company:
|
||||
frappe.throw(_("Cost Center {0} does not belong to Company {1}").format(self.cost_center, self.company))
|
||||
|
||||
def validate_party(self):
|
||||
if self.party_type and self.party:
|
||||
frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,'frozen_accounts_modifier')
|
||||
if not frozen_accounts_modifier in frappe.get_roles():
|
||||
if frappe.db.get_value(self.party_type, self.party, "is_frozen"):
|
||||
frappe.throw("{0} {1} is frozen".format(self.party_type, self.party), CustomerFrozen)
|
||||
|
||||
def validate_balance_type(account, adv_adj=False):
|
||||
if not adv_adj and account:
|
||||
@@ -118,7 +128,7 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
|
||||
bal = flt(frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabGL Entry`
|
||||
where against_voucher_type=%s and against_voucher=%s
|
||||
and account = %s and party_type=%s and party=%s""",
|
||||
and account = %s and ifnull(party_type, '')=%s and ifnull(party, '')=%s""",
|
||||
(against_voucher_type, against_voucher, account, party_type, party))[0][0] or 0.0)
|
||||
|
||||
if against_voucher_type == 'Purchase Invoice':
|
||||
@@ -127,8 +137,9 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
|
||||
against_voucher_amount = flt(frappe.db.sql("""
|
||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabGL Entry` where voucher_type = 'Journal Entry' and voucher_no = %s
|
||||
and account = %s and party_type=%s and party=%s and ifnull(against_voucher, '') = ''""",
|
||||
(against_voucher, account, party_type, party))[0][0])
|
||||
and account = %s and ifnull(party_type, '')=%s and ifnull(party, '')=%s
|
||||
and ifnull(against_voucher, '') = ''""",
|
||||
(against_voucher, account, cstr(party_type), cstr(party)))[0][0])
|
||||
|
||||
if not against_voucher_amount:
|
||||
frappe.throw(_("Against Journal Entry {0} is already adjusted against some other voucher")
|
||||
@@ -138,9 +149,9 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
|
||||
if against_voucher_amount < 0:
|
||||
bal = -bal
|
||||
|
||||
# Validation : Outstanding can not be negative
|
||||
if bal < 0 and not on_cancel:
|
||||
frappe.throw(_("Outstanding for {0} cannot be less than zero ({1})").format(against_voucher, fmt_money(bal)))
|
||||
# Validation : Outstanding can not be negative for JV
|
||||
if bal < 0 and not on_cancel:
|
||||
frappe.throw(_("Outstanding for {0} cannot be less than zero ({1})").format(against_voucher, fmt_money(bal)))
|
||||
|
||||
# Update outstanding amt on against voucher
|
||||
if against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
|
||||
@@ -157,3 +168,22 @@ def validate_frozen_account(account, adv_adj=None):
|
||||
frappe.throw(_("Account {0} is frozen").format(account))
|
||||
elif frozen_accounts_modifier not in frappe.get_roles():
|
||||
frappe.throw(_("Not authorized to edit frozen Account {0}").format(account))
|
||||
|
||||
def update_against_account(voucher_type, voucher_no):
|
||||
entries = frappe.db.get_all("GL Entry",
|
||||
filters={"voucher_type": voucher_type, "voucher_no": voucher_no},
|
||||
fields=["name", "party", "against", "debit", "credit", "account"])
|
||||
|
||||
accounts_debited, accounts_credited = [], []
|
||||
for d in entries:
|
||||
if flt(d.debit > 0): accounts_debited.append(d.party or d.account)
|
||||
if flt(d.credit) > 0: accounts_credited.append(d.party or d.account)
|
||||
|
||||
for d in entries:
|
||||
if flt(d.debit > 0):
|
||||
new_against = ", ".join(list(set(accounts_credited)))
|
||||
if flt(d.credit > 0):
|
||||
new_against = ", ".join(list(set(accounts_debited)))
|
||||
|
||||
if d.against != new_against:
|
||||
frappe.db.set_value("GL Entry", d.name, "against", new_against)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
frappe.provide("erpnext.accounts");
|
||||
frappe.require("assets/erpnext/js/utils.js");
|
||||
|
||||
erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
||||
erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({
|
||||
onload: function() {
|
||||
this.load_defaults();
|
||||
this.setup_queries();
|
||||
@@ -109,7 +109,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
||||
|
||||
against_jv: function(doc, cdt, cdn) {
|
||||
var d = frappe.get_doc(cdt, cdn);
|
||||
if (d.against_jv && d.party && !flt(d.credit) && !flt(d.debit)) {
|
||||
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
|
||||
this.get_outstanding('Journal Entry', d.against_jv, d);
|
||||
}
|
||||
},
|
||||
@@ -119,7 +119,8 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
||||
var args = {
|
||||
"doctype": doctype,
|
||||
"docname": docname,
|
||||
"party": child.party
|
||||
"party": child.party,
|
||||
"account": child.account
|
||||
}
|
||||
|
||||
return this.frm.call({
|
||||
@@ -130,10 +131,31 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
|
||||
cur_frm.cscript.update_totals(me.frm.doc);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
accounts_add: function(doc, cdt, cdn) {
|
||||
var row = frappe.get_doc(cdt, cdn);
|
||||
$.each(doc.accounts, function(i, d) {
|
||||
if(d.account && d.party && d.party_type) {
|
||||
row.account = d.account;
|
||||
row.party = d.party;
|
||||
row.party_type = d.party_type;
|
||||
}
|
||||
});
|
||||
|
||||
// set difference
|
||||
if(doc.difference) {
|
||||
if(doc.difference > 0) {
|
||||
row.credit = doc.difference;
|
||||
} else {
|
||||
row.debit = -doc.difference;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
cur_frm.script_manager.make(erpnext.accounts.JournalVoucher);
|
||||
cur_frm.script_manager.make(erpnext.accounts.JournalEntry);
|
||||
|
||||
cur_frm.cscript.refresh = function(doc) {
|
||||
erpnext.toggle_naming_series();
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
"fieldname": "posting_date",
|
||||
"fieldtype": "Date",
|
||||
"in_filter": 1,
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Posting Date",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "posting_date",
|
||||
@@ -310,7 +310,7 @@
|
||||
"depends_on": "eval:doc.voucher_type == 'Write Off Entry'",
|
||||
"fieldname": "write_off_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Write Off Amount <=",
|
||||
"label": "Write Off Amount",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
@@ -445,7 +445,7 @@
|
||||
"icon": "icon-file-text",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-04-27 20:32:31.655580",
|
||||
"modified": "2015-06-29 15:28:12.529019",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Journal Entry",
|
||||
@@ -503,4 +503,4 @@
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"title_field": "title"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cstr, flt, fmt_money, formatdate, getdate, cint
|
||||
from frappe.utils import cstr, flt, fmt_money, formatdate, getdate, date_diff
|
||||
from frappe import msgprint, _, scrub
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
from erpnext.controllers.accounts_controller import AccountsController
|
||||
@@ -35,7 +35,7 @@ class JournalEntry(AccountsController):
|
||||
self.set_print_format_fields()
|
||||
self.validate_against_sales_order()
|
||||
self.validate_against_purchase_order()
|
||||
self.check_credit_days()
|
||||
self.check_due_date()
|
||||
self.validate_expense_claim()
|
||||
self.validate_credit_debit_note()
|
||||
self.validate_empty_accounts_table()
|
||||
@@ -81,29 +81,28 @@ class JournalEntry(AccountsController):
|
||||
frappe.throw(_("Row {0}: Party Type and Party is only applicable against Receivable / Payable account").format(d.idx))
|
||||
|
||||
def check_credit_limit(self):
|
||||
customers = list(set([d.party for d in self.get("accounts") if d.party_type=="Customer" and flt(d.debit) > 0]))
|
||||
customers = list(set([d.party for d in self.get("accounts")
|
||||
if d.party_type=="Customer" and d.party and flt(d.debit) > 0]))
|
||||
if customers:
|
||||
from erpnext.selling.doctype.customer.customer import check_credit_limit
|
||||
for customer in customers:
|
||||
check_credit_limit(customer, self.company)
|
||||
|
||||
def check_credit_days(self):
|
||||
from erpnext.accounts.party import get_credit_days
|
||||
posting_date = None
|
||||
def check_due_date(self):
|
||||
if self.cheque_date:
|
||||
for d in self.get("accounts"):
|
||||
if d.party_type and d.party and d.get("credit" if d.party_type=="Customer" else "debit") > 0:
|
||||
due_date = None
|
||||
if d.against_invoice:
|
||||
posting_date = frappe.db.get_value("Sales Invoice", d.against_invoice, "posting_date")
|
||||
due_date = frappe.db.get_value("Sales Invoice", d.against_invoice, "due_date")
|
||||
elif d.against_voucher:
|
||||
posting_date = frappe.db.get_value("Purchase Invoice", d.against_voucher, "posting_date")
|
||||
due_date = frappe.db.get_value("Purchase Invoice", d.against_voucher, "due_date")
|
||||
|
||||
credit_days = get_credit_days(d.party_type, d.party, self.company)
|
||||
if posting_date and credit_days:
|
||||
date_diff = (getdate(self.cheque_date) - getdate(posting_date)).days
|
||||
if date_diff > flt(credit_days):
|
||||
msgprint(_("Note: Reference Date exceeds allowed credit days by {0} days for {1} {2}")
|
||||
.format(date_diff - flt(credit_days), d.party_type, d.party))
|
||||
if due_date and getdate(self.cheque_date) > getdate(due_date):
|
||||
diff = date_diff(self.cheque_date, due_date)
|
||||
if diff > 0:
|
||||
msgprint(_("Note: Reference Date exceeds invoice due date by {0} days for {1} {2}")
|
||||
.format(diff, d.party_type, d.party))
|
||||
|
||||
def validate_cheque_info(self):
|
||||
if self.voucher_type in ['Bank Entry']:
|
||||
@@ -242,8 +241,8 @@ class JournalEntry(AccountsController):
|
||||
def set_against_account(self):
|
||||
accounts_debited, accounts_credited = [], []
|
||||
for d in self.get("accounts"):
|
||||
if flt(d.debit > 0): accounts_debited.append(d.account)
|
||||
if flt(d.credit) > 0: accounts_credited.append(d.account)
|
||||
if flt(d.debit > 0): accounts_debited.append(d.party or d.account)
|
||||
if flt(d.credit) > 0: accounts_credited.append(d.party or d.account)
|
||||
|
||||
for d in self.get("accounts"):
|
||||
if flt(d.debit > 0): d.against_account = ", ".join(list(set(accounts_credited)))
|
||||
@@ -274,29 +273,27 @@ class JournalEntry(AccountsController):
|
||||
else:
|
||||
msgprint(_("Please enter Reference date"), raise_exception=frappe.MandatoryError)
|
||||
|
||||
company_currency = get_company_currency(self.company)
|
||||
|
||||
for d in self.get('accounts'):
|
||||
if d.against_invoice and d.credit:
|
||||
currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency")
|
||||
|
||||
r.append(_("{0} against Sales Invoice {1}").format(fmt_money(flt(d.credit), currency = currency), \
|
||||
r.append(_("{0} against Sales Invoice {1}").format(fmt_money(flt(d.credit), currency = company_currency), \
|
||||
d.against_invoice))
|
||||
|
||||
if d.against_sales_order and d.credit:
|
||||
currency = frappe.db.get_value("Sales Order", d.against_sales_order, "currency")
|
||||
r.append(_("{0} against Sales Order {1}").format(fmt_money(flt(d.credit), currency = currency), \
|
||||
r.append(_("{0} against Sales Order {1}").format(fmt_money(flt(d.credit), currency = company_currency), \
|
||||
d.against_sales_order))
|
||||
|
||||
if d.against_voucher and d.debit:
|
||||
bill_no = frappe.db.sql("""select bill_no, bill_date, currency
|
||||
bill_no = frappe.db.sql("""select bill_no, bill_date
|
||||
from `tabPurchase Invoice` where name=%s""", d.against_voucher)
|
||||
if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() \
|
||||
not in ['na', 'not applicable', 'none']:
|
||||
r.append(_('{0} against Bill {1} dated {2}').format(fmt_money(flt(d.debit), currency=bill_no[0][2]), bill_no[0][0],
|
||||
r.append(_('{0} against Bill {1} dated {2}').format(fmt_money(flt(d.debit), currency=company_currency), bill_no[0][0],
|
||||
bill_no[0][1] and formatdate(bill_no[0][1].strftime('%Y-%m-%d'))))
|
||||
|
||||
if d.against_purchase_order and d.debit:
|
||||
currency = frappe.db.get_value("Purchase Order", d.against_purchase_order, "currency")
|
||||
r.append(_("{0} against Purchase Order {1}").format(fmt_money(flt(d.credit), currency = currency), \
|
||||
r.append(_("{0} against Purchase Order {1}").format(fmt_money(flt(d.credit), currency = company_currency), \
|
||||
d.against_purchase_order))
|
||||
|
||||
if self.user_remark:
|
||||
@@ -427,12 +424,11 @@ class JournalEntry(AccountsController):
|
||||
def validate_expense_claim(self):
|
||||
for d in self.accounts:
|
||||
if d.against_expense_claim:
|
||||
sanctioned_amount, reimbursed_amount = frappe.db.get_value("Expense Claim", d.against_expense_claim,
|
||||
("total_sanctioned_amount", "total_amount_reimbursed"))
|
||||
pending_amount = cint(sanctioned_amount) - cint(reimbursed_amount)
|
||||
sanctioned_amount, reimbursed_amount = frappe.db.get_value("Expense Claim",
|
||||
d.against_expense_claim, ("total_sanctioned_amount", "total_amount_reimbursed"))
|
||||
pending_amount = flt(sanctioned_amount) - flt(reimbursed_amount)
|
||||
if d.debit > pending_amount:
|
||||
frappe.throw(_("Row No {0}: Amount cannot be greater than Pending Amount against Expense Claim {1}. \
|
||||
Pending Amount is {2}".format(d.idx, d.against_expense_claim, pending_amount)))
|
||||
frappe.throw(_("Row No {0}: Amount cannot be greater than Pending Amount against Expense Claim {1}. Pending Amount is {2}".format(d.idx, d.against_expense_claim, pending_amount)))
|
||||
|
||||
def validate_credit_debit_note(self):
|
||||
if self.stock_entry:
|
||||
@@ -458,11 +454,11 @@ def get_default_bank_cash_account(company, voucher_type, mode_of_payment=None):
|
||||
if voucher_type=="Bank Entry":
|
||||
account = frappe.db.get_value("Company", company, "default_bank_account")
|
||||
if not account:
|
||||
account = frappe.db.get_value("Account", {"company": company, "account_type": "Bank"})
|
||||
account = frappe.db.get_value("Account", {"company": company, "account_type": "Bank", "is_group": 0})
|
||||
elif voucher_type=="Cash Entry":
|
||||
account = frappe.db.get_value("Company", company, "default_cash_account")
|
||||
if not account:
|
||||
account = frappe.db.get_value("Account", {"company": company, "account_type": "Cash"})
|
||||
account = frappe.db.get_value("Account", {"company": company, "account_type": "Cash", "is_group": 0})
|
||||
|
||||
if account:
|
||||
return {
|
||||
@@ -538,25 +534,25 @@ def get_opening_accounts(company):
|
||||
|
||||
|
||||
def get_against_jv(doctype, txt, searchfield, start, page_len, filters):
|
||||
if not filters.get("party"):
|
||||
return []
|
||||
return frappe.db.sql("""select jv.name, jv.posting_date, jv.user_remark
|
||||
from `tabJournal Entry` jv, `tabJournal Entry Account` jv_detail
|
||||
where jv_detail.parent = jv.name and jv_detail.account = %s and jv_detail.party = %s
|
||||
where jv_detail.parent = jv.name and jv_detail.account = %s and ifnull(jv_detail.party, '') = %s
|
||||
and (ifnull(jv_detail.against_invoice, '') = '' and ifnull(jv_detail.against_voucher, '') = ''
|
||||
and ifnull(jv_detail.against_jv, '') = '' )
|
||||
and jv.docstatus = 1 and jv.{0} like %s order by jv.name desc limit %s, %s""".format(searchfield),
|
||||
(filters["account"], filters["party"], "%{0}%".format(txt), start, page_len))
|
||||
(filters.get("account"), cstr(filters.get("party")), "%{0}%".format(txt), start, page_len))
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_outstanding(args):
|
||||
args = eval(args)
|
||||
if args.get("doctype") == "Journal Entry" and args.get("party"):
|
||||
if args.get("doctype") == "Journal Entry":
|
||||
condition = " and party=%(party)s" if args.get("party") else ""
|
||||
|
||||
against_jv_amount = frappe.db.sql("""
|
||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabJournal Entry Account` where parent=%s and party=%s
|
||||
from `tabJournal Entry Account` where parent=%(docname)s and account=%(account)s {0}
|
||||
and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')=''
|
||||
and ifnull(against_jv, '')=''""", (args['docname'], args['party']))
|
||||
and ifnull(against_jv, '')=''""".format(condition), args)
|
||||
|
||||
against_jv_amount = flt(against_jv_amount[0][0]) if against_jv_amount else 0
|
||||
if against_jv_amount > 0:
|
||||
|
||||
@@ -44,6 +44,10 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
this.frm.disable_save();
|
||||
},
|
||||
|
||||
party: function() {
|
||||
var me = this
|
||||
|
||||
@@ -190,8 +190,9 @@ class PaymentReconciliation(Document):
|
||||
if flt(p.allocated_amount) > flt(p.amount):
|
||||
frappe.throw(_("Row {0}: Allocated amount {1} must be less than or equals to JV amount {2}")
|
||||
.format(p.idx, p.allocated_amount, p.amount))
|
||||
|
||||
if flt(p.allocated_amount) > unreconciled_invoices.get(p.invoice_type, {}).get(p.invoice_number):
|
||||
|
||||
invoice_outstanding = unreconciled_invoices.get(p.invoice_type, {}).get(p.invoice_number)
|
||||
if abs(flt(p.allocated_amount) - invoice_outstanding) > 0.009:
|
||||
frappe.throw(_("Row {0}: Allocated amount {1} must be less than or equals to invoice outstanding amount {2}")
|
||||
.format(p.idx, p.allocated_amount, unreconciled_invoices.get(p.invoice_type, {}).get(p.invoice_number)))
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ frappe.ui.form.on("Payment Tool", "onload", function(frm) {
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Payment Tool", "refresh", function(frm) {
|
||||
frm.disable_save();
|
||||
frappe.ui.form.trigger("Payment Tool", "party_type");
|
||||
});
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
"is_submittable": 0,
|
||||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"modified": "2015-02-21 03:59:08.154966",
|
||||
"modified": "2015-06-05 11:17:33.843334",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Payment Tool",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"options": "Territory",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "naming_series",
|
||||
@@ -77,68 +77,6 @@
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"oldfieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"description": "Create Stock Ledger Entries when you submit a Sales Invoice",
|
||||
"fieldname": "update_stock",
|
||||
"fieldtype": "Check",
|
||||
"label": "Update Stock",
|
||||
"permlevel": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "customer",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 0,
|
||||
"label": "Customer",
|
||||
"oldfieldname": "customer_account",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Customer",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "cash_bank_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Cash/Bank Account",
|
||||
"oldfieldname": "cash_bank_account",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "income_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Income Account",
|
||||
"oldfieldname": "income_account",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
||||
"fieldname": "expense_account",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"label": "Expense Account",
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "warehouse",
|
||||
"fieldtype": "Link",
|
||||
@@ -150,45 +88,6 @@
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
"label": "Cost Center",
|
||||
"oldfieldname": "cost_center",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Cost Center",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "taxes_and_charges",
|
||||
"fieldtype": "Link",
|
||||
"label": "Taxes and Charges",
|
||||
"oldfieldname": "charge",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Sales Taxes and Charges Template",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "write_off_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Write Off Account",
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "write_off_cost_center",
|
||||
"fieldtype": "Link",
|
||||
"label": "Write Off Cost Center",
|
||||
"options": "Cost Center",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 1,
|
||||
"fieldname": "letter_head",
|
||||
@@ -222,11 +121,120 @@
|
||||
"options": "Print Heading",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"oldfieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"description": "Create Stock Ledger Entries when you submit a Sales Invoice",
|
||||
"fieldname": "update_stock",
|
||||
"fieldtype": "Check",
|
||||
"label": "Update Stock",
|
||||
"permlevel": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "customer",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 0,
|
||||
"label": "Customer",
|
||||
"oldfieldname": "customer_account",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Customer",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "mode_of_payment",
|
||||
"fieldtype": "Link",
|
||||
"label": "Mode of Payment",
|
||||
"options": "Mode of Payment",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "cash_bank_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Cash/Bank Account",
|
||||
"oldfieldname": "cash_bank_account",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "income_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Income Account",
|
||||
"oldfieldname": "income_account",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
||||
"fieldname": "expense_account",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"label": "Expense Account",
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
"label": "Cost Center",
|
||||
"oldfieldname": "cost_center",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Cost Center",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "write_off_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Write Off Account",
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "write_off_cost_center",
|
||||
"fieldtype": "Link",
|
||||
"label": "Write Off Cost Center",
|
||||
"options": "Cost Center",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "taxes_and_charges",
|
||||
"fieldtype": "Link",
|
||||
"label": "Taxes and Charges",
|
||||
"oldfieldname": "charge",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Sales Taxes and Charges Template",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
}
|
||||
],
|
||||
"icon": "icon-cog",
|
||||
"idx": 1,
|
||||
"modified": "2015-05-20 05:38:44.482696",
|
||||
"modified": "2015-07-28 15:07:14.417200",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "POS Profile",
|
||||
|
||||
@@ -205,9 +205,9 @@ def get_pricing_rules(args):
|
||||
|
||||
def filter_pricing_rules(args, pricing_rules):
|
||||
# filter for qty
|
||||
if pricing_rules and args.get("qty"):
|
||||
pricing_rules = filter(lambda x: (args.qty>=flt(x.min_qty)
|
||||
and (args.qty<=x.max_qty if x.max_qty else True)), pricing_rules)
|
||||
if pricing_rules:
|
||||
pricing_rules = filter(lambda x: (flt(args.get("qty"))>=flt(x.min_qty)
|
||||
and (flt(args.get("qty"))<=x.max_qty if x.max_qty else True)), pricing_rules)
|
||||
|
||||
# find pricing rule with highest priority
|
||||
if pricing_rules:
|
||||
|
||||
@@ -20,26 +20,19 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
this._super();
|
||||
|
||||
// Show / Hide button
|
||||
if(doc.docstatus==1 && doc.outstanding_amount > 0)
|
||||
this.frm.add_custom_button(__('Make Payment Entry'), this.make_bank_entry,
|
||||
frappe.boot.doctype_icons["Journal Entry"]);
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
cur_frm.add_custom_button(__('View Ledger'), function() {
|
||||
frappe.route_options = {
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"company": doc.company,
|
||||
group_by_voucher: 0
|
||||
};
|
||||
frappe.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
}
|
||||
|
||||
if(doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(__('From Purchase Order'),
|
||||
function() {
|
||||
this.show_general_ledger();
|
||||
|
||||
if(!doc.is_return) {
|
||||
if(doc.docstatus==1) {
|
||||
if(doc.outstanding_amount > 0) {
|
||||
this.frm.add_custom_button(__('Make Payment Entry'), this.make_bank_entry);
|
||||
}
|
||||
|
||||
cur_frm.add_custom_button(__('Make Debit Note'), this.make_debit_note);
|
||||
}
|
||||
|
||||
if(doc.docstatus===0) {
|
||||
cur_frm.add_custom_button(__('From Purchase Order'), function() {
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
||||
source_doctype: "Purchase Order",
|
||||
@@ -51,10 +44,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
}, "icon-download", "btn-default");
|
||||
});
|
||||
|
||||
cur_frm.add_custom_button(__('From Purchase Receipt'),
|
||||
function() {
|
||||
cur_frm.add_custom_button(__('From Purchase Receipt'), function() {
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
||||
source_doctype: "Purchase Receipt",
|
||||
@@ -64,8 +56,8 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
}, "icon-download", "btn-default");
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -109,7 +101,14 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
$.each(this.frm.doc["items"] || [], function(i, row) {
|
||||
if(row.purchase_receipt) frappe.model.clear_doc("Purchase Receipt", row.purchase_receipt)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
make_debit_note: function() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_debit_note",
|
||||
frm: cur_frm
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
cur_frm.script_manager.make(erpnext.accounts.PurchaseInvoice);
|
||||
@@ -144,7 +143,7 @@ cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(do
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters:{
|
||||
'is_purchase_item': 'Yes'
|
||||
'is_purchase_item': 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint, formatdate, flt
|
||||
from frappe.utils import cint, formatdate, flt, getdate
|
||||
from frappe import msgprint, _, throw
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
import frappe.defaults
|
||||
@@ -37,13 +37,16 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
super(PurchaseInvoice, self).validate()
|
||||
|
||||
self.po_required()
|
||||
self.pr_required()
|
||||
if not self.is_return:
|
||||
self.po_required()
|
||||
self.pr_required()
|
||||
self.validate_supplier_invoice()
|
||||
self.validate_advance_jv("advances", "purchase_order")
|
||||
|
||||
self.check_active_purchase_items()
|
||||
self.check_conversion_rate()
|
||||
self.validate_credit_to_acc()
|
||||
self.clear_unallocated_advances("Purchase Invoice Advance", "advances")
|
||||
self.validate_advance_jv("advances", "purchase_order")
|
||||
self.check_for_stopped_status()
|
||||
self.validate_with_previous_doc()
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
@@ -70,13 +73,14 @@ class PurchaseInvoice(BuyingController):
|
||||
super(PurchaseInvoice, self).set_missing_values(for_validate)
|
||||
|
||||
def get_advances(self):
|
||||
super(PurchaseInvoice, self).get_advances(self.credit_to, "Supplier", self.supplier,
|
||||
"Purchase Invoice Advance", "advances", "debit", "purchase_order")
|
||||
if not self.is_return:
|
||||
super(PurchaseInvoice, self).get_advances(self.credit_to, "Supplier", self.supplier,
|
||||
"Purchase Invoice Advance", "advances", "debit", "purchase_order")
|
||||
|
||||
def check_active_purchase_items(self):
|
||||
for d in self.get('items'):
|
||||
if d.item_code: # extra condn coz item_code is not mandatory in PV
|
||||
if frappe.db.get_value("Item", d.item_code, "is_purchase_item") != 'Yes':
|
||||
if frappe.db.get_value("Item", d.item_code, "is_purchase_item") != 1:
|
||||
msgprint(_("Item {0} is not Purchase Item").format(d.item_code), raise_exception=True)
|
||||
|
||||
def check_conversion_rate(self):
|
||||
@@ -87,9 +91,7 @@ class PurchaseInvoice(BuyingController):
|
||||
throw(_("Conversion rate cannot be 0 or 1"))
|
||||
|
||||
def validate_credit_to_acc(self):
|
||||
root_type, account_type = frappe.db.get_value("Account", self.credit_to, ["root_type", "account_type"])
|
||||
if root_type != "Liability":
|
||||
frappe.throw(_("Credit To account must be a liability account"))
|
||||
account_type = frappe.db.get_value("Account", self.credit_to, "account_type")
|
||||
if account_type != "Payable":
|
||||
frappe.throw(_("Credit To account must be a Payable account"))
|
||||
|
||||
@@ -125,20 +127,11 @@ class PurchaseInvoice(BuyingController):
|
||||
}
|
||||
})
|
||||
|
||||
if cint(frappe.defaults.get_global_default('maintain_same_rate')):
|
||||
super(PurchaseInvoice, self).validate_with_previous_doc({
|
||||
"Purchase Order Item": {
|
||||
"ref_dn_field": "po_detail",
|
||||
"compare_fields": [["rate", "="]],
|
||||
"is_child_table": True,
|
||||
"allow_duplicate_prev_row_id": True
|
||||
},
|
||||
"Purchase Receipt Item": {
|
||||
"ref_dn_field": "pr_detail",
|
||||
"compare_fields": [["rate", "="]],
|
||||
"is_child_table": True
|
||||
}
|
||||
})
|
||||
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')):
|
||||
self.validate_rate_with_reference_doc([
|
||||
["Purchase Order", "purchase_order", "po_detail"],
|
||||
["Purchase Receipt", "purchase_receipt", "pr_detail"]
|
||||
])
|
||||
|
||||
def set_against_expense_account(self):
|
||||
auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
||||
@@ -165,7 +158,7 @@ class PurchaseInvoice(BuyingController):
|
||||
elif item.expense_account not in against_accounts:
|
||||
# if no auto_accounting_for_stock or not a stock item
|
||||
against_accounts.append(item.expense_account)
|
||||
|
||||
|
||||
self.against_expense_account = ",".join(against_accounts)
|
||||
|
||||
def po_required(self):
|
||||
@@ -236,9 +229,11 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
# this sequence because outstanding may get -negative
|
||||
self.make_gl_entries()
|
||||
self.update_against_document_in_jv()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||
if not self.is_return:
|
||||
self.update_against_document_in_jv()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||
|
||||
self.update_project()
|
||||
|
||||
def make_gl_entries(self):
|
||||
@@ -260,7 +255,7 @@ class PurchaseInvoice(BuyingController):
|
||||
"against": self.against_expense_account,
|
||||
"credit": self.total_amount_to_pay,
|
||||
"remarks": self.remarks,
|
||||
"against_voucher": self.name,
|
||||
"against_voucher": self.return_against if cint(self.is_return) else self.name,
|
||||
"against_voucher_type": self.doctype,
|
||||
})
|
||||
)
|
||||
@@ -272,7 +267,7 @@ class PurchaseInvoice(BuyingController):
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": tax.account_head,
|
||||
"against": self.credit_to,
|
||||
"against": self.supplier,
|
||||
"debit": tax.add_deduct_tax == "Add" and tax.base_tax_amount_after_discount_amount or 0,
|
||||
"credit": tax.add_deduct_tax == "Deduct" and tax.base_tax_amount_after_discount_amount or 0,
|
||||
"remarks": self.remarks,
|
||||
@@ -296,7 +291,7 @@ class PurchaseInvoice(BuyingController):
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": item.expense_account,
|
||||
"against": self.credit_to,
|
||||
"against": self.supplier,
|
||||
"debit": item.base_net_amount,
|
||||
"remarks": self.remarks,
|
||||
"cost_center": item.cost_center
|
||||
@@ -316,7 +311,7 @@ class PurchaseInvoice(BuyingController):
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": stock_received_but_not_billed,
|
||||
"against": self.credit_to,
|
||||
"against": self.supplier,
|
||||
"debit": flt(item.item_tax_amount, self.precision("item_tax_amount", item)),
|
||||
"remarks": self.remarks or "Accounting Entry for Stock"
|
||||
})
|
||||
@@ -342,7 +337,7 @@ class PurchaseInvoice(BuyingController):
|
||||
self.get_gl_dict({
|
||||
"account": expenses_included_in_valuation,
|
||||
"cost_center": cost_center,
|
||||
"against": self.credit_to,
|
||||
"against": self.supplier,
|
||||
"credit": applicable_amount,
|
||||
"remarks": self.remarks or "Accounting Entry for Stock"
|
||||
})
|
||||
@@ -356,7 +351,7 @@ class PurchaseInvoice(BuyingController):
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": self.write_off_account,
|
||||
"against": self.credit_to,
|
||||
"against": self.supplier,
|
||||
"credit": flt(self.write_off_amount),
|
||||
"remarks": self.remarks,
|
||||
"cost_center": self.write_off_cost_center
|
||||
@@ -368,14 +363,15 @@ class PurchaseInvoice(BuyingController):
|
||||
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
|
||||
|
||||
def on_cancel(self):
|
||||
from erpnext.accounts.utils import remove_against_link_from_jv
|
||||
remove_against_link_from_jv(self.doctype, self.name, "against_voucher")
|
||||
if not self.is_return:
|
||||
from erpnext.accounts.utils import remove_against_link_from_jv
|
||||
remove_against_link_from_jv(self.doctype, self.name, "against_voucher")
|
||||
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||
self.make_gl_entries_on_cancel()
|
||||
self.update_project()
|
||||
|
||||
|
||||
def update_project(self):
|
||||
project_list = []
|
||||
for d in self.items:
|
||||
@@ -386,6 +382,17 @@ class PurchaseInvoice(BuyingController):
|
||||
project.save()
|
||||
project_list.append(d.project_name)
|
||||
|
||||
def validate_supplier_invoice(self):
|
||||
if self.bill_date:
|
||||
if getdate(self.bill_date) > getdate(self.posting_date):
|
||||
frappe.throw("Supplier Invoice Date cannot be greater than Posting Date")
|
||||
if self.bill_no:
|
||||
if cint(frappe.db.get_single_value("Accounts Settings", "check_supplier_invoice_uniqueness")):
|
||||
pi = frappe.db.exists("Purchase Invoice", {"bill_no": self.bill_no,
|
||||
"fiscal_year": self.fiscal_year, "name": ("!=", self.name)})
|
||||
if pi:
|
||||
frappe.throw("Supplier Invoice No exists in Purchase Invoice {0}".format(pi))
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
from erpnext.controllers.queries import get_match_cond
|
||||
@@ -401,4 +408,9 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
and tabAccount.company = '%(company)s'
|
||||
and tabAccount.%(key)s LIKE '%(txt)s'
|
||||
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
|
||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)})
|
||||
'txt': "%%%s%%" % frappe.db.escape(txt), 'mcond':get_match_cond(doctype)})
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_debit_note(source_name, target_doc=None):
|
||||
from erpnext.controllers.sales_and_purchase_return import make_return_doc
|
||||
return make_return_doc("Purchase Invoice", source_name, target_doc)
|
||||
@@ -4,9 +4,11 @@
|
||||
// render
|
||||
frappe.listview_settings['Purchase Invoice'] = {
|
||||
add_fields: ["supplier", "supplier_name", "base_grand_total", "outstanding_amount", "due_date", "company",
|
||||
"currency"],
|
||||
"currency", "is_return"],
|
||||
get_indicator: function(doc) {
|
||||
if(flt(doc.outstanding_amount) > 0 && doc.docstatus==1) {
|
||||
if(cint(doc.is_return)==1) {
|
||||
return [__("Return"), "darkgrey", "is_return,=,1"];
|
||||
} else if(flt(doc.outstanding_amount) > 0 && doc.docstatus==1) {
|
||||
if(frappe.datetime.get_diff(doc.due_date) < 0) {
|
||||
return [__("Overdue"), "red", "outstanding_amount,>,0|due_date,<,Today"];
|
||||
} else {
|
||||
|
||||
@@ -275,5 +275,58 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
purchase_invoice.cancel()
|
||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project", "total_purchase_cost"), 0)
|
||||
|
||||
def test_return_purchase_invoice(self):
|
||||
set_perpetual_inventory()
|
||||
|
||||
pi = make_purchase_invoice()
|
||||
|
||||
return_pi = make_purchase_invoice(is_return=1, return_against=pi.name, qty=-2)
|
||||
|
||||
|
||||
# check gl entries for return
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type=%s and voucher_no=%s
|
||||
order by account desc""", ("Purchase Invoice", return_pi.name), as_dict=1)
|
||||
|
||||
self.assertTrue(gl_entries)
|
||||
|
||||
expected_values = {
|
||||
"Creditors - _TC": [100.0, 0.0],
|
||||
"Stock Received But Not Billed - _TC": [0.0, 100.0],
|
||||
}
|
||||
|
||||
for gle in gl_entries:
|
||||
self.assertEquals(expected_values[gle.account][0], gle.debit)
|
||||
self.assertEquals(expected_values[gle.account][1], gle.credit)
|
||||
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
def make_purchase_invoice(**args):
|
||||
pi = frappe.new_doc("Purchase Invoice")
|
||||
args = frappe._dict(args)
|
||||
if args.posting_date:
|
||||
pi.posting_date = args.posting_date
|
||||
if args.posting_time:
|
||||
pi.posting_time = args.posting_time
|
||||
pi.company = args.company or "_Test Company"
|
||||
pi.supplier = args.supplier or "_Test Supplier"
|
||||
pi.currency = args.currency or "INR"
|
||||
pi.is_return = args.is_return
|
||||
pi.return_against = args.return_against
|
||||
|
||||
pi.append("items", {
|
||||
"item_code": args.item or args.item_code or "_Test Item",
|
||||
"warehouse": args.warehouse or "_Test Warehouse - _TC",
|
||||
"qty": args.qty or 5,
|
||||
"rate": args.rate or 50,
|
||||
"conversion_factor": 1.0,
|
||||
"serial_no": args.serial_no,
|
||||
"stock_uom": "_Test UOM"
|
||||
})
|
||||
if not args.do_not_save:
|
||||
pi.insert()
|
||||
if not args.do_not_submit:
|
||||
pi.submit()
|
||||
return pi
|
||||
|
||||
test_records = frappe.get_test_records('Purchase Invoice')
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text",
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Description",
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Text",
|
||||
@@ -49,6 +49,23 @@
|
||||
"read_only": 0,
|
||||
"width": "300px"
|
||||
},
|
||||
{
|
||||
"fieldname": "image",
|
||||
"fieldtype": "Attach",
|
||||
"hidden": 1,
|
||||
"label": "Image",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "image_view",
|
||||
"fieldtype": "Image",
|
||||
"label": "Image View",
|
||||
"options": "image",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "quantity_and_rate",
|
||||
"fieldtype": "Section Break",
|
||||
@@ -452,7 +469,7 @@
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2015-05-27 02:47:16.341373",
|
||||
"modified": "2015-07-02 03:00:44.496683",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Purchase Invoice Item",
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from frappe.model.document import Document
|
||||
from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax
|
||||
from erpnext.accounts.doctype.sales_taxes_and_charges_template.sales_taxes_and_charges_template \
|
||||
import valdiate_taxes_and_charges_template
|
||||
|
||||
class PurchaseTaxesandChargesTemplate(Document):
|
||||
def validate(self):
|
||||
for tax in self.get("taxes"):
|
||||
validate_taxes_and_charges(tax)
|
||||
validate_inclusive_tax(tax, self)
|
||||
valdiate_taxes_and_charges_template(self)
|
||||
|
||||
@@ -7,12 +7,13 @@ import frappe
|
||||
@frappe.whitelist()
|
||||
def get_items(price_list, sales_or_purchase, item=None):
|
||||
condition = ""
|
||||
order_by = ""
|
||||
args = {"price_list": price_list}
|
||||
|
||||
if sales_or_purchase == "Sales":
|
||||
condition = "i.is_sales_item='Yes'"
|
||||
condition = "i.is_sales_item=1"
|
||||
else:
|
||||
condition = "i.is_purchase_item='Yes'"
|
||||
condition = "i.is_purchase_item=1"
|
||||
|
||||
if item:
|
||||
# search serial no
|
||||
@@ -30,16 +31,25 @@ def get_items(price_list, sales_or_purchase, item=None):
|
||||
item_code[0]["barcode"] = item
|
||||
return item_code
|
||||
|
||||
condition += " and (CONCAT(i.name, i.item_name) like %(name)s or (i.variant_of like %(name)s))"
|
||||
args["name"] = "%%%s%%" % item
|
||||
condition += " and ((CONCAT(i.name, i.item_name) like %(name)s) or (i.variant_of like %(name)s) or (i.item_group like %(name)s))"
|
||||
order_by = """if(locate(%(_name)s, i.name), locate(%(_name)s, i.name), 99999),
|
||||
if(locate(%(_name)s, i.item_name), locate(%(_name)s, i.item_name), 99999),
|
||||
if(locate(%(_name)s, i.variant_of), locate(%(_name)s, i.variant_of), 99999),
|
||||
if(locate(%(_name)s, i.item_group), locate(%(_name)s, i.item_group), 99999),"""
|
||||
args["name"] = "%%%s%%" % frappe.db.escape(item)
|
||||
args["_name"] = item.replace("%", "")
|
||||
|
||||
# locate function is used to sort by closest match from the beginning of the value
|
||||
return frappe.db.sql("""select i.name, i.item_name, i.image,
|
||||
item_det.price_list_rate, item_det.currency
|
||||
from `tabItem` i LEFT JOIN
|
||||
(select item_code, price_list_rate, currency from
|
||||
`tabItem Price` where price_list=%s) item_det
|
||||
`tabItem Price` where price_list=%(price_list)s) item_det
|
||||
ON
|
||||
(item_det.item_code=i.name or item_det.item_code=i.variant_of)
|
||||
where
|
||||
ifnull(i.has_variants, 0) = 0 and
|
||||
%s""" % ('%(price_list)s', condition), args, as_dict=1)
|
||||
{condition}
|
||||
order by
|
||||
{order_by}
|
||||
i.name""".format(condition=condition, order_by=order_by), args, as_dict=1)
|
||||
|
||||
@@ -40,22 +40,14 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
this._super();
|
||||
|
||||
cur_frm.dashboard.reset();
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
cur_frm.add_custom_button('View Ledger', function() {
|
||||
frappe.route_options = {
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"company": doc.company,
|
||||
group_by_voucher: 0
|
||||
};
|
||||
frappe.set_route("query-report", "General Ledger");
|
||||
}, "icon-table");
|
||||
|
||||
// var percent_paid = cint(flt(doc.base_grand_total - doc.outstanding_amount) / flt(doc.base_grand_total) * 100);
|
||||
// cur_frm.dashboard.add_progress(percent_paid + "% Paid", percent_paid);
|
||||
|
||||
|
||||
this.frm.toggle_reqd("due_date", !this.frm.doc.is_return);
|
||||
|
||||
this.show_general_ledger();
|
||||
|
||||
if(doc.update_stock) this.show_stock_ledger();
|
||||
|
||||
if(doc.docstatus==1 && !doc.is_return) {
|
||||
if(cint(doc.update_stock)!=1) {
|
||||
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
|
||||
var from_delivery_note = false;
|
||||
@@ -65,24 +57,27 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
});
|
||||
|
||||
if(!from_delivery_note) {
|
||||
cur_frm.page.add_menu_item(__('Make Delivery'), cur_frm.cscript['Make Delivery Note'], "icon-truck")
|
||||
cur_frm.add_custom_button(__('Make Delivery'), cur_frm.cscript['Make Delivery Note'])
|
||||
}
|
||||
}
|
||||
|
||||
if(doc.outstanding_amount!=0) {
|
||||
cur_frm.add_custom_button(__('Make Payment Entry'), cur_frm.cscript.make_bank_entry, "icon-money");
|
||||
if(doc.outstanding_amount!=0 && !cint(doc.is_return)) {
|
||||
cur_frm.add_custom_button(__('Make Payment Entry'), cur_frm.cscript.make_bank_entry);
|
||||
}
|
||||
|
||||
cur_frm.add_custom_button(doc.update_stock ? __('Make Sales Return') : __('Make Credit Note'),
|
||||
this.make_sales_return);
|
||||
}
|
||||
|
||||
// Show buttons only when pos view is active
|
||||
if (doc.docstatus===0 && !cur_frm.page.current_view_name!=="pos") {
|
||||
if (cint(doc.docstatus==0) && cur_frm.page.current_view_name!=="pos" && !doc.is_return) {
|
||||
cur_frm.cscript.sales_order_btn();
|
||||
cur_frm.cscript.delivery_note_btn();
|
||||
}
|
||||
},
|
||||
|
||||
sales_order_btn: function() {
|
||||
this.$sales_order_btn = cur_frm.page.add_menu_item(__('From Sales Order'),
|
||||
this.$sales_order_btn = cur_frm.add_custom_button(__('From Sales Order'),
|
||||
function() {
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
|
||||
@@ -99,7 +94,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
},
|
||||
|
||||
delivery_note_btn: function() {
|
||||
this.$delivery_note_btn = cur_frm.page.add_menu_item(__('From Delivery Note'),
|
||||
this.$delivery_note_btn = cur_frm.add_custom_button(__('From Delivery Note'),
|
||||
function() {
|
||||
frappe.model.map_current_doc({
|
||||
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||
@@ -205,8 +200,14 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
|
||||
items_on_form_rendered: function() {
|
||||
erpnext.setup_serial_no();
|
||||
},
|
||||
|
||||
make_sales_return: function() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_sales_return",
|
||||
frm: cur_frm
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// for backward compatibility: combine new and previous states
|
||||
@@ -283,16 +284,6 @@ cur_frm.cscript.make_bank_entry = function() {
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.debit_to.get_query = function(doc) {
|
||||
return{
|
||||
filters: {
|
||||
'report_type': 'Balance Sheet',
|
||||
'is_group': 0,
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
|
||||
return {
|
||||
filters: [
|
||||
@@ -369,15 +360,15 @@ cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(
|
||||
}
|
||||
|
||||
cur_frm.cscript.income_account = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "income_account");
|
||||
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "income_account");
|
||||
}
|
||||
|
||||
cur_frm.cscript.expense_account = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "expense_account");
|
||||
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "expense_account");
|
||||
}
|
||||
|
||||
cur_frm.cscript.cost_center = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "cost_center");
|
||||
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "cost_center");
|
||||
}
|
||||
|
||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
@@ -392,8 +383,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
cur_frm.set_query("debit_to", function(doc) {
|
||||
return{
|
||||
filters: [
|
||||
@@ -401,4 +390,4 @@ cur_frm.set_query("debit_to", function(doc) {
|
||||
['Account', 'account_type', '=', 'Receivable']
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -21,7 +21,7 @@
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "naming_series",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "SINV-",
|
||||
"options": "SINV-\nSINV-RET-",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
@@ -38,7 +38,8 @@
|
||||
"options": "Customer",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
"read_only": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "customer",
|
||||
@@ -46,7 +47,7 @@
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Name",
|
||||
"label": "Customer Name",
|
||||
"oldfieldname": "customer_name",
|
||||
"oldfieldtype": "Data",
|
||||
"permlevel": 0,
|
||||
@@ -155,7 +156,7 @@
|
||||
"oldfieldtype": "Date",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"reqd": 0,
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
@@ -168,6 +169,28 @@
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "is_return",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Return",
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "is_return",
|
||||
"fieldname": "return_against",
|
||||
"fieldtype": "Link",
|
||||
"label": "Return Against Sales Invoice",
|
||||
"no_copy": 0,
|
||||
"options": "Sales Invoice",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "shipping_address_name",
|
||||
"fieldtype": "Link",
|
||||
@@ -321,9 +344,9 @@
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "sales_bom_help",
|
||||
"fieldname": "product_bundle_help",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Sales BOM Help",
|
||||
"label": "Product Bundle Help",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
@@ -502,7 +525,7 @@
|
||||
{
|
||||
"fieldname": "base_discount_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Discount Amount (Company Currency)",
|
||||
"label": "Additional Discount Amount (Company Currency)",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
@@ -604,7 +627,7 @@
|
||||
"label": "Total Advance",
|
||||
"oldfieldname": "total_advance",
|
||||
"oldfieldtype": "Currency",
|
||||
"options": "",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
@@ -617,7 +640,7 @@
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "outstanding_amount",
|
||||
"oldfieldtype": "Currency",
|
||||
"options": "currency",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
@@ -670,7 +693,7 @@
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "paid_amount",
|
||||
"oldfieldtype": "Currency",
|
||||
"options": "currency",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
@@ -710,7 +733,7 @@
|
||||
"fieldtype": "Currency",
|
||||
"label": "Write Off Amount",
|
||||
"no_copy": 1,
|
||||
"options": "currency",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
@@ -880,7 +903,7 @@
|
||||
"options": "Project",
|
||||
"permlevel": 0,
|
||||
"read_only": 0,
|
||||
"search_index": 1
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.source == 'Campaign'",
|
||||
@@ -1226,6 +1249,15 @@
|
||||
"print_hide": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.is_recurring==1",
|
||||
"fieldname": "recurring_print_format",
|
||||
"fieldtype": "Link",
|
||||
"label": "Recurring Print Format",
|
||||
"options": "Print Format",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "against_income_account",
|
||||
"fieldtype": "Small Text",
|
||||
@@ -1243,7 +1275,7 @@
|
||||
"icon": "icon-file-text",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-05-27 02:48:02.897865",
|
||||
"modified": "2015-07-24 11:48:07.544569",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint, cstr, flt
|
||||
from frappe.utils import cint, flt
|
||||
from frappe import _, msgprint, throw
|
||||
from erpnext.accounts.party import get_party_account, get_due_date
|
||||
from erpnext.controllers.stock_controller import update_gl_entries_after
|
||||
@@ -65,8 +65,8 @@ class SalesInvoice(SellingController):
|
||||
self.set_against_income_account()
|
||||
self.validate_c_form()
|
||||
self.validate_time_logs_are_submitted()
|
||||
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount",
|
||||
"items")
|
||||
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount", "items")
|
||||
self.update_packing_list()
|
||||
|
||||
def on_submit(self):
|
||||
super(SalesInvoice, self).on_submit()
|
||||
@@ -81,14 +81,16 @@ class SalesInvoice(SellingController):
|
||||
|
||||
self.check_prev_docstatus()
|
||||
|
||||
self.update_status_updater_args()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
self.check_credit_limit()
|
||||
if not self.is_return:
|
||||
self.update_status_updater_args()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
self.check_credit_limit()
|
||||
|
||||
# this sequence because outstanding may get -ve
|
||||
self.make_gl_entries()
|
||||
|
||||
if not cint(self.is_pos) == 1:
|
||||
if not cint(self.is_pos) == 1 and not self.is_return:
|
||||
self.update_against_document_in_jv()
|
||||
|
||||
self.update_time_log_batch(self.name)
|
||||
@@ -105,9 +107,11 @@ class SalesInvoice(SellingController):
|
||||
from erpnext.accounts.utils import remove_against_link_from_jv
|
||||
remove_against_link_from_jv(self.doctype, self.name, "against_invoice")
|
||||
|
||||
self.update_status_updater_args()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
if not self.is_return:
|
||||
self.update_status_updater_args()
|
||||
self.update_prevdoc_status()
|
||||
self.update_billing_status_for_zero_amount_refdoc("Sales Order")
|
||||
|
||||
self.validate_c_form_on_cancel()
|
||||
|
||||
self.make_gl_entries_on_cancel()
|
||||
@@ -139,7 +143,7 @@ class SalesInvoice(SellingController):
|
||||
|
||||
if not self.debit_to:
|
||||
self.debit_to = get_party_account(self.company, self.customer, "Customer")
|
||||
if not self.due_date:
|
||||
if not self.due_date and self.customer:
|
||||
self.due_date = get_due_date(self.posting_date, "Customer", self.customer, self.company)
|
||||
|
||||
super(SalesInvoice, self).set_missing_values(for_validate)
|
||||
@@ -170,6 +174,7 @@ class SalesInvoice(SellingController):
|
||||
if pos:
|
||||
if not for_validate and not self.customer:
|
||||
self.customer = pos.customer
|
||||
self.mode_of_payment = pos.mode_of_payment
|
||||
# self.set_customer_defaults()
|
||||
|
||||
for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name',
|
||||
@@ -199,8 +204,9 @@ class SalesInvoice(SellingController):
|
||||
self.set_taxes()
|
||||
|
||||
def get_advances(self):
|
||||
super(SalesInvoice, self).get_advances(self.debit_to, "Customer", self.customer,
|
||||
"Sales Invoice Advance", "advances", "credit", "sales_order")
|
||||
if not self.is_return:
|
||||
super(SalesInvoice, self).get_advances(self.debit_to, "Customer", self.customer,
|
||||
"Sales Invoice Advance", "advances", "credit", "sales_order")
|
||||
|
||||
def get_company_abbr(self):
|
||||
return frappe.db.sql("select abbr from tabCompany where name=%s", self.company)[0][0]
|
||||
@@ -236,21 +242,17 @@ class SalesInvoice(SellingController):
|
||||
reconcile_against_document(lst)
|
||||
|
||||
def validate_debit_to_acc(self):
|
||||
root_type, account_type = frappe.db.get_value("Account", self.debit_to, ["root_type", "account_type"])
|
||||
if root_type != "Asset":
|
||||
frappe.throw(_("Debit To account must be a liability account"))
|
||||
account_type = frappe.db.get_value("Account", self.debit_to, "account_type")
|
||||
if account_type != "Receivable":
|
||||
frappe.throw(_("Debit To account must be a Receivable account"))
|
||||
|
||||
def validate_fixed_asset_account(self):
|
||||
"""Validate Fixed Asset and whether Income Account Entered Exists"""
|
||||
for d in self.get('items'):
|
||||
item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem`
|
||||
where name = %s""", d.item_code)
|
||||
acc = frappe.db.sql("""select account_type from `tabAccount`
|
||||
where name = %s and docstatus != 2""", d.income_account)
|
||||
if item and item[0][1] == 'Yes' and acc and acc[0][0] != 'Fixed Asset':
|
||||
msgprint(_("Account {0} must be of type 'Fixed Asset' as Item {1} is an Asset Item").format(acc[0][0], d.item_code), raise_exception=True)
|
||||
is_asset_item = frappe.db.get_value("Item", d.item_code, "is_asset_item")
|
||||
account_type = frappe.db.get_value("Account", d.income_account, "account_type")
|
||||
if is_asset_item == 1 and account_type != 'Fixed Asset':
|
||||
msgprint(_("Account {0} must be of type 'Fixed Asset' as Item {1} is an Asset Item").format(d.income_account, d.item_code), raise_exception=True)
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
super(SalesInvoice, self).validate_with_previous_doc({
|
||||
@@ -266,20 +268,11 @@ class SalesInvoice(SellingController):
|
||||
},
|
||||
})
|
||||
|
||||
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
|
||||
super(SalesInvoice, self).validate_with_previous_doc({
|
||||
"Sales Order Item": {
|
||||
"ref_dn_field": "so_detail",
|
||||
"compare_fields": [["rate", "="]],
|
||||
"is_child_table": True,
|
||||
"allow_duplicate_prev_row_id": True
|
||||
},
|
||||
"Delivery Note Item": {
|
||||
"ref_dn_field": "dn_detail",
|
||||
"compare_fields": [["rate", "="]],
|
||||
"is_child_table": True
|
||||
}
|
||||
})
|
||||
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')):
|
||||
self.validate_rate_with_reference_doc([
|
||||
["Sales Order", "sales_order", "so_detail"],
|
||||
["Delivery Note", "delivery_note", "dn_detail"]
|
||||
])
|
||||
|
||||
def set_against_income_account(self):
|
||||
"""Set against account for debit to account"""
|
||||
@@ -296,11 +289,13 @@ class SalesInvoice(SellingController):
|
||||
|
||||
def so_dn_required(self):
|
||||
"""check in manage account if sales order / delivery note required or not."""
|
||||
if self.is_return:
|
||||
return
|
||||
dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
|
||||
for i in dic:
|
||||
if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes':
|
||||
for d in self.get('items'):
|
||||
if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
|
||||
if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 1 \
|
||||
and not d.get(i.lower().replace(' ','_')):
|
||||
msgprint(_("{0} is mandatory for Item {1}").format(i,d.item_code), raise_exception=1)
|
||||
|
||||
@@ -369,6 +364,13 @@ class SalesInvoice(SellingController):
|
||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
|
||||
|
||||
def update_packing_list(self):
|
||||
if cint(self.update_stock) == 1:
|
||||
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
|
||||
make_packing_list(self, 'items')
|
||||
else:
|
||||
self.set('packed_items', [])
|
||||
|
||||
|
||||
def get_warehouse(self):
|
||||
user_pos_profile = frappe.db.sql("""select name, warehouse from `tabPOS Profile`
|
||||
@@ -387,20 +389,6 @@ class SalesInvoice(SellingController):
|
||||
return warehouse
|
||||
|
||||
def on_update(self):
|
||||
if cint(self.update_stock) == 1:
|
||||
# Set default warehouse from POS Profile
|
||||
if cint(self.is_pos) == 1:
|
||||
w = self.get_warehouse()
|
||||
if w:
|
||||
for d in self.get('items'):
|
||||
if not d.warehouse:
|
||||
d.warehouse = cstr(w)
|
||||
|
||||
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
|
||||
make_packing_list(self, 'items')
|
||||
else:
|
||||
self.set('packed_items', [])
|
||||
|
||||
if cint(self.is_pos) == 1:
|
||||
if flt(self.paid_amount) == 0:
|
||||
if self.cash_bank_account:
|
||||
@@ -430,13 +418,19 @@ class SalesInvoice(SellingController):
|
||||
def update_stock_ledger(self):
|
||||
sl_entries = []
|
||||
for d in self.get_item_list():
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
|
||||
and d.warehouse:
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 and d.warehouse and flt(d['qty']):
|
||||
self.update_reserved_qty(d)
|
||||
|
||||
incoming_rate = 0
|
||||
if cint(self.is_return) and self.return_against and self.docstatus==1:
|
||||
incoming_rate = self.get_incoming_rate_for_sales_return(d.item_code,
|
||||
self.return_against)
|
||||
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": -1*flt(d.qty),
|
||||
"stock_uom": frappe.db.get_value("Item", d.item_code, "stock_uom")
|
||||
"stock_uom": frappe.db.get_value("Item", d.item_code, "stock_uom"),
|
||||
"incoming_rate": incoming_rate
|
||||
}))
|
||||
|
||||
self.make_sl_entries(sl_entries)
|
||||
|
||||
def make_gl_entries(self, repost_future_gle=True):
|
||||
@@ -446,8 +440,7 @@ class SalesInvoice(SellingController):
|
||||
from erpnext.accounts.general_ledger import make_gl_entries
|
||||
|
||||
# if POS and amount is written off, there's no outstanding and hence no need to update it
|
||||
update_outstanding = cint(self.is_pos) and self.write_off_account \
|
||||
and 'No' or 'Yes'
|
||||
update_outstanding = "No" if (cint(self.is_pos) or self.write_off_account) else "Yes"
|
||||
|
||||
make_gl_entries(gl_entries, cancel=(self.docstatus == 2),
|
||||
update_outstanding=update_outstanding, merge_entries=False)
|
||||
@@ -495,7 +488,7 @@ class SalesInvoice(SellingController):
|
||||
"against": self.against_income_account,
|
||||
"debit": self.base_grand_total,
|
||||
"remarks": self.remarks,
|
||||
"against_voucher": self.name,
|
||||
"against_voucher": self.return_against if cint(self.is_return) else self.name,
|
||||
"against_voucher_type": self.doctype
|
||||
})
|
||||
)
|
||||
@@ -506,7 +499,7 @@ class SalesInvoice(SellingController):
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": tax.account_head,
|
||||
"against": self.debit_to,
|
||||
"against": self.customer,
|
||||
"credit": flt(tax.base_tax_amount_after_discount_amount),
|
||||
"remarks": self.remarks,
|
||||
"cost_center": tax.cost_center
|
||||
@@ -520,7 +513,7 @@ class SalesInvoice(SellingController):
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": item.income_account,
|
||||
"against": self.debit_to,
|
||||
"against": self.customer,
|
||||
"credit": item.base_net_amount,
|
||||
"remarks": self.remarks,
|
||||
"cost_center": item.cost_center
|
||||
@@ -530,7 +523,6 @@ class SalesInvoice(SellingController):
|
||||
# expense account gl entries
|
||||
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
|
||||
and cint(self.update_stock):
|
||||
|
||||
gl_entries += super(SalesInvoice, self).get_gl_entries()
|
||||
|
||||
def make_pos_gl_entries(self, gl_entries):
|
||||
@@ -544,14 +536,14 @@ class SalesInvoice(SellingController):
|
||||
"against": self.cash_bank_account,
|
||||
"credit": self.paid_amount,
|
||||
"remarks": self.remarks,
|
||||
"against_voucher": self.name,
|
||||
"against_voucher": self.return_against if cint(self.is_return) else self.name,
|
||||
"against_voucher_type": self.doctype,
|
||||
})
|
||||
)
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": self.cash_bank_account,
|
||||
"against": self.debit_to,
|
||||
"against": self.customer,
|
||||
"debit": self.paid_amount,
|
||||
"remarks": self.remarks,
|
||||
})
|
||||
@@ -568,14 +560,14 @@ class SalesInvoice(SellingController):
|
||||
"against": self.write_off_account,
|
||||
"credit": self.write_off_amount,
|
||||
"remarks": self.remarks,
|
||||
"against_voucher": self.name,
|
||||
"against_voucher": self.return_against if cint(self.is_return) else self.name,
|
||||
"against_voucher_type": self.doctype,
|
||||
})
|
||||
)
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": self.write_off_account,
|
||||
"against": self.debit_to,
|
||||
"against": self.customer,
|
||||
"debit": self.write_off_amount,
|
||||
"remarks": self.remarks,
|
||||
"cost_center": self.write_off_cost_center
|
||||
@@ -590,7 +582,7 @@ def get_list_context(context=None):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_bank_cash_account(mode_of_payment, company):
|
||||
account = frappe.db.get_value("Mode of Payment Account",
|
||||
account = frappe.db.get_value("Mode of Payment Account",
|
||||
{"parent": mode_of_payment, "company": company}, "default_account")
|
||||
if not account:
|
||||
frappe.msgprint(_("Please set default Cash or Bank account in Mode of Payment {0}").format(mode_of_payment))
|
||||
@@ -614,7 +606,7 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
and tabAccount.company = '%(company)s'
|
||||
and tabAccount.%(key)s LIKE '%(txt)s'
|
||||
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
|
||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)})
|
||||
'txt': "%%%s%%" % frappe.db.escape(txt), 'mcond':get_match_cond(doctype)})
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_delivery_note(source_name, target_doc=None):
|
||||
@@ -662,3 +654,9 @@ def make_delivery_note(source_name, target_doc=None):
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return doclist
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_sales_return(source_name, target_doc=None):
|
||||
from erpnext.controllers.sales_and_purchase_return import make_return_doc
|
||||
return make_return_doc("Sales Invoice", source_name, target_doc)
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
// render
|
||||
frappe.listview_settings['Sales Invoice'] = {
|
||||
add_fields: ["customer", "customer_name", "base_grand_total", "outstanding_amount", "due_date", "company",
|
||||
"currency"],
|
||||
"currency", "is_return"],
|
||||
get_indicator: function(doc) {
|
||||
if(flt(doc.outstanding_amount)==0) {
|
||||
if(cint(doc.is_return)==1) {
|
||||
return [__("Return"), "darkgrey", "is_return,=,1"];
|
||||
} 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()) {
|
||||
return [__("Unpaid"), "orange", "outstanding_amount,>,0|due_date,>,Today"]
|
||||
|
||||
@@ -4,11 +4,9 @@ from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import unittest, copy
|
||||
import time
|
||||
from erpnext.accounts.utils import get_stock_and_account_difference
|
||||
from frappe.utils import nowdate, add_days, flt
|
||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry, get_qty_after_transaction
|
||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||
from erpnext.projects.doctype.time_log_batch.test_time_log_batch import *
|
||||
|
||||
|
||||
class TestSalesInvoice(unittest.TestCase):
|
||||
def make(self):
|
||||
@@ -402,32 +400,6 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
jv.cancel()
|
||||
self.assertEquals(frappe.db.get_value("Sales Invoice", w.name, "outstanding_amount"), 561.8)
|
||||
|
||||
def test_time_log_batch(self):
|
||||
delete_time_log_and_batch()
|
||||
time_log = create_time_log()
|
||||
tlb = create_time_log_batch(time_log)
|
||||
|
||||
tlb = frappe.get_doc("Time Log Batch", tlb.name)
|
||||
tlb.submit()
|
||||
|
||||
si = frappe.get_doc(frappe.copy_doc(test_records[0]))
|
||||
si.get("items")[0].time_log_batch = tlb.name
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
self.assertEquals(frappe.db.get_value("Time Log Batch", tlb.name, "status"), "Billed")
|
||||
|
||||
self.assertEquals(frappe.db.get_value("Time Log", time_log, "status"), "Billed")
|
||||
|
||||
si.cancel()
|
||||
|
||||
self.assertEquals(frappe.db.get_value("Time Log Batch", tlb.name, "status"), "Submitted")
|
||||
|
||||
self.assertEquals(frappe.db.get_value("Time Log", time_log, "status"), "Batched for Billing")
|
||||
|
||||
frappe.delete_doc("Sales Invoice", si.name)
|
||||
delete_time_log_and_batch()
|
||||
|
||||
def test_sales_invoice_gl_entry_without_aii(self):
|
||||
set_perpetual_inventory(0)
|
||||
si = frappe.copy_doc(test_records[1])
|
||||
@@ -756,20 +728,84 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
# hack! because stock ledger entires are already inserted and are not rolled back!
|
||||
self.assertRaises(SerialNoDuplicateError, si.cancel)
|
||||
|
||||
def test_invoice_due_date_against_customers_credit_days(self):
|
||||
# set customer's credit days
|
||||
frappe.db.set_value("Customer", "_Test Customer", "credit_days_based_on", "Fixed Days")
|
||||
frappe.db.set_value("Customer", "_Test Customer", "credit_days", 10)
|
||||
|
||||
si = create_sales_invoice()
|
||||
self.assertEqual(si.due_date, add_days(nowdate(), 10))
|
||||
|
||||
# set customer's credit days is last day of the next month
|
||||
frappe.db.set_value("Customer", "_Test Customer", "credit_days_based_on", "Last Day of the Next Month")
|
||||
|
||||
si1 = create_sales_invoice(posting_date="2015-07-05")
|
||||
self.assertEqual(si1.due_date, "2015-08-31")
|
||||
|
||||
def test_return_sales_invoice(self):
|
||||
set_perpetual_inventory()
|
||||
|
||||
make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, incoming_rate=100)
|
||||
|
||||
actual_qty_0 = get_qty_after_transaction()
|
||||
|
||||
si = create_sales_invoice(qty=5, rate=500, update_stock=1)
|
||||
|
||||
actual_qty_1 = get_qty_after_transaction()
|
||||
self.assertEquals(actual_qty_0 - 5, actual_qty_1)
|
||||
|
||||
# outgoing_rate
|
||||
outgoing_rate = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Sales Invoice",
|
||||
"voucher_no": si.name}, "stock_value_difference") / 5
|
||||
|
||||
# return entry
|
||||
si1 = create_sales_invoice(is_return=1, return_against=si.name, qty=-2, rate=500, update_stock=1)
|
||||
|
||||
actual_qty_2 = get_qty_after_transaction()
|
||||
|
||||
self.assertEquals(actual_qty_1 + 2, actual_qty_2)
|
||||
|
||||
incoming_rate, stock_value_difference = frappe.db.get_value("Stock Ledger Entry",
|
||||
{"voucher_type": "Sales Invoice", "voucher_no": si1.name},
|
||||
["incoming_rate", "stock_value_difference"])
|
||||
|
||||
self.assertEquals(flt(incoming_rate, 3), abs(flt(outgoing_rate, 3)))
|
||||
|
||||
|
||||
# Check gl entry
|
||||
gle_warehouse_amount = frappe.db.get_value("GL Entry", {"voucher_type": "Sales Invoice",
|
||||
"voucher_no": si1.name, "account": "_Test Warehouse - _TC"}, "debit")
|
||||
|
||||
self.assertEquals(gle_warehouse_amount, stock_value_difference)
|
||||
|
||||
party_credited = frappe.db.get_value("GL Entry", {"voucher_type": "Sales Invoice",
|
||||
"voucher_no": si1.name, "account": "Debtors - _TC", "party": "_Test Customer"}, "credit")
|
||||
|
||||
self.assertEqual(party_credited, 1000)
|
||||
|
||||
# Check outstanding amount
|
||||
self.assertFalse(si1.outstanding_amount)
|
||||
self.assertEqual(frappe.db.get_value("Sales Invoice", si.name, "outstanding_amount"), 1500)
|
||||
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
|
||||
def create_sales_invoice(**args):
|
||||
si = frappe.new_doc("Sales Invoice")
|
||||
args = frappe._dict(args)
|
||||
if args.posting_date:
|
||||
si.posting_date = args.posting_date
|
||||
if args.posting_time:
|
||||
si.posting_time = args.posting_time
|
||||
si.posting_date = args.posting_date or nowdate()
|
||||
|
||||
si.company = args.company or "_Test Company"
|
||||
si.customer = args.customer or "_Test Customer"
|
||||
si.debit_to = args.debit_to or "Debtors - _TC"
|
||||
si.update_stock = args.update_stock
|
||||
si.is_pos = args.is_pos
|
||||
si.is_return = args.is_return
|
||||
si.return_against = args.return_against
|
||||
si.currency="INR"
|
||||
si.conversion_rate = 1
|
||||
|
||||
si.append("items", {
|
||||
"item_code": args.item or args.item_code or "_Test Item",
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text",
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Description",
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Text",
|
||||
@@ -68,6 +68,23 @@
|
||||
"reqd": 1,
|
||||
"width": "200px"
|
||||
},
|
||||
{
|
||||
"fieldname": "image",
|
||||
"fieldtype": "Attach",
|
||||
"hidden": 1,
|
||||
"label": "Image",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "image_view",
|
||||
"fieldtype": "Image",
|
||||
"label": "Image View",
|
||||
"options": "image",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "quantity_and_rate",
|
||||
"fieldtype": "Section Break",
|
||||
@@ -505,7 +522,7 @@
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2015-05-27 02:47:15.645114",
|
||||
"modified": "2015-07-02 02:59:08.413213",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice Item",
|
||||
|
||||
@@ -5,21 +5,25 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from erpnext.controllers.accounts_controller import validate_taxes_and_charges, validate_inclusive_tax
|
||||
from frappe.utils.nestedset import get_root_of
|
||||
|
||||
class SalesTaxesandChargesTemplate(Document):
|
||||
def validate(self):
|
||||
if self.is_default == 1:
|
||||
frappe.db.sql("""update `tabSales Taxes and Charges Template`
|
||||
set is_default = 0
|
||||
where ifnull(is_default,0) = 1
|
||||
and name != %s and company = %s""",
|
||||
(self.name, self.company))
|
||||
valdiate_taxes_and_charges_template(self)
|
||||
|
||||
# at least one territory
|
||||
self.validate_table_has_rows("territories")
|
||||
def valdiate_taxes_and_charges_template(doc):
|
||||
if not doc.is_default and not frappe.get_all(doc.doctype, filters={"is_default": 1}):
|
||||
doc.is_default = 1
|
||||
|
||||
for tax in self.get("taxes"):
|
||||
validate_taxes_and_charges(tax)
|
||||
validate_inclusive_tax(tax, self)
|
||||
if doc.is_default == 1:
|
||||
frappe.db.sql("""update `tab{0}` set is_default = 0
|
||||
where ifnull(is_default,0) = 1 and name != %s and company = %s""".format(doc.doctype),
|
||||
(doc.name, doc.company))
|
||||
|
||||
if doc.meta.get_field("territories"):
|
||||
if not doc.territories:
|
||||
doc.append("territories", {"territory": get_root_of("Territory") })
|
||||
|
||||
for tax in doc.get("taxes"):
|
||||
validate_taxes_and_charges(tax)
|
||||
validate_inclusive_tax(tax, doc)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt, cstr
|
||||
from frappe.utils import flt, cstr, cint
|
||||
from frappe import _
|
||||
from frappe.model.meta import get_field_precision
|
||||
from erpnext.accounts.utils import validate_expense_against_budget
|
||||
@@ -56,12 +56,13 @@ def merge_similar_entries(gl_map):
|
||||
|
||||
def check_if_in_list(gle, gl_map):
|
||||
for e in gl_map:
|
||||
if e.account == gle.account and \
|
||||
cstr(e.get('against_voucher'))==cstr(gle.get('against_voucher')) \
|
||||
and cstr(e.get('against_voucher_type')) == \
|
||||
cstr(gle.get('against_voucher_type')) \
|
||||
and cstr(e.get('cost_center')) == cstr(gle.get('cost_center')):
|
||||
return e
|
||||
if e.account == gle.account \
|
||||
and cstr(e.get('party_type'))==cstr(gle.get('party_type')) \
|
||||
and cstr(e.get('party'))==cstr(gle.get('party')) \
|
||||
and cstr(e.get('against_voucher'))==cstr(gle.get('against_voucher')) \
|
||||
and cstr(e.get('against_voucher_type')) == cstr(gle.get('against_voucher_type')) \
|
||||
and cstr(e.get('cost_center')) == cstr(gle.get('cost_center')):
|
||||
return e
|
||||
|
||||
def save_entries(gl_map, adv_adj, update_outstanding):
|
||||
validate_account_for_auto_accounting_for_stock(gl_map)
|
||||
@@ -81,14 +82,15 @@ def make_entry(args, adv_adj, update_outstanding):
|
||||
gle.submit()
|
||||
|
||||
def validate_account_for_auto_accounting_for_stock(gl_map):
|
||||
if gl_map[0].voucher_type=="Journal Entry":
|
||||
aii_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
|
||||
where account_type = 'Warehouse' and ifnull(warehouse, '')!=''""")]
|
||||
if cint(frappe.db.get_single_value("Accounts Settings", "auto_accounting_for_stock")) \
|
||||
and gl_map[0].voucher_type=="Journal Entry":
|
||||
aii_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
|
||||
where account_type = 'Warehouse' and ifnull(warehouse, '')!=''""")]
|
||||
|
||||
for entry in gl_map:
|
||||
if entry.account in aii_accounts:
|
||||
frappe.throw(_("Account: {0} can only be updated via Stock Transactions")
|
||||
.format(entry.account), StockAccountInvalidTransaction)
|
||||
for entry in gl_map:
|
||||
if entry.account in aii_accounts:
|
||||
frappe.throw(_("Account: {0} can only be updated via Stock Transactions")
|
||||
.format(entry.account), StockAccountInvalidTransaction)
|
||||
|
||||
def round_off_debit_credit(gl_map):
|
||||
precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"),
|
||||
@@ -101,8 +103,7 @@ def round_off_debit_credit(gl_map):
|
||||
debit_credit_diff += entry.debit - entry.credit
|
||||
|
||||
debit_credit_diff = flt(debit_credit_diff, precision)
|
||||
print debit_credit_diff, 1.0 / (10**precision)
|
||||
if abs(debit_credit_diff) >= (2.0 / (10**precision)):
|
||||
if abs(debit_credit_diff) >= (5.0 / (10**precision)):
|
||||
frappe.throw(_("Debit and Credit not equal for {0} #{1}. Difference is {2}.")
|
||||
.format(gl_map[0].voucher_type, gl_map[0].voucher_no, debit_credit_diff))
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<button class="btn btn-primary btn-lg">{%= __("Start") %}</button>
|
||||
</p>
|
||||
<p class="pos-setting-message hide">
|
||||
<a class="btn btn-default btn-sm" href="#Form/POS Setting/New POS Setting">
|
||||
{%= __("Make new POS Setting") %}</a>
|
||||
<a class="btn btn-default btn-sm" href="#Form/POS Profile/New POS Profile">
|
||||
{%= __("Make new POS Profile") %}</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import datetime
|
||||
from frappe import _, msgprint, scrub
|
||||
from frappe.defaults import get_user_permissions
|
||||
from frappe.utils import add_days, getdate, formatdate, flt
|
||||
from frappe.utils import add_days, getdate, formatdate, flt, get_first_day, date_diff, nowdate
|
||||
from erpnext.utilities.doctype.address.address import get_address_display
|
||||
from erpnext.utilities.doctype.contact.contact import get_contact_details
|
||||
|
||||
@@ -16,12 +17,16 @@ def get_party_details(party=None, account=None, party_type="Customer", company=N
|
||||
|
||||
if not party:
|
||||
return {}
|
||||
|
||||
if not frappe.db.exists(party_type, party):
|
||||
frappe.throw(_("{0}: {1} does not exists").format(party_type, party))
|
||||
|
||||
return _get_party_details(party, account, party_type,
|
||||
company, posting_date, price_list, currency, doctype)
|
||||
|
||||
def _get_party_details(party=None, account=None, party_type="Customer", company=None,
|
||||
posting_date=None, price_list=None, currency=None, doctype=None, ignore_permissions=False):
|
||||
|
||||
out = frappe._dict(set_account_and_due_date(party, account, party_type, company, posting_date, doctype))
|
||||
|
||||
party = out[party_type.lower()]
|
||||
@@ -69,9 +74,17 @@ def set_contact_details(out, party, party_type):
|
||||
{party_type.lower(): party.name, "is_primary_contact":1}, "name")
|
||||
|
||||
if not out.contact_person:
|
||||
return
|
||||
|
||||
out.update(get_contact_details(out.contact_person))
|
||||
out.update({
|
||||
"contact_person": None,
|
||||
"contact_display": None,
|
||||
"contact_email": None,
|
||||
"contact_mobile": None,
|
||||
"contact_phone": None,
|
||||
"contact_designation": None,
|
||||
"contact_department": None
|
||||
})
|
||||
else:
|
||||
out.update(get_contact_details(out.contact_person))
|
||||
|
||||
def set_other_values(out, party, party_type):
|
||||
# copy
|
||||
@@ -154,43 +167,54 @@ def get_party_account(company, party, party_type):
|
||||
|
||||
return account
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_due_date(posting_date, party_type, party, company):
|
||||
"""Set Due Date = Posting Date + Credit Days"""
|
||||
due_date = None
|
||||
if posting_date:
|
||||
credit_days = get_credit_days(party_type, party, company)
|
||||
due_date = add_days(posting_date, credit_days) if credit_days else posting_date
|
||||
|
||||
if posting_date and party:
|
||||
due_date = posting_date
|
||||
if party_type=="Customer":
|
||||
credit_days_based_on, credit_days = get_credit_days(party_type, party, company)
|
||||
if credit_days_based_on == "Fixed Days" and credit_days:
|
||||
due_date = add_days(posting_date, credit_days)
|
||||
elif credit_days_based_on == "Last Day of the Next Month":
|
||||
due_date = (get_first_day(posting_date, 0, 2) + datetime.timedelta(-1)).strftime("%Y-%m-%d")
|
||||
else:
|
||||
credit_days = get_credit_days(party_type, party, company)
|
||||
if credit_days:
|
||||
due_date = add_days(posting_date, credit_days)
|
||||
|
||||
return due_date
|
||||
|
||||
def get_credit_days(party_type, party, company):
|
||||
if not party:
|
||||
return None
|
||||
|
||||
party_group_doctype = "Customer Group" if party_type=="Customer" else "Supplier Type"
|
||||
credit_days, party_group = frappe.db.get_value(party_type, party, ["credit_days", frappe.scrub(party_group_doctype)])
|
||||
|
||||
if not credit_days:
|
||||
credit_days = frappe.db.get_value(party_group_doctype, party_group, "credit_days") or \
|
||||
frappe.db.get_value("Company", company, "credit_days")
|
||||
|
||||
return credit_days
|
||||
|
||||
def validate_due_date(posting_date, due_date, party_type, party, company):
|
||||
credit_days = get_credit_days(party_type, party, company)
|
||||
|
||||
posting_date, due_date = getdate(posting_date), getdate(due_date)
|
||||
diff = (due_date - posting_date).days
|
||||
|
||||
if diff < 0:
|
||||
frappe.throw(_("Due Date cannot be before Posting Date"))
|
||||
elif credit_days is not None and diff > flt(credit_days):
|
||||
is_credit_controller = frappe.db.get_value("Accounts Settings", None,
|
||||
"credit_controller") in frappe.get_roles()
|
||||
|
||||
if is_credit_controller:
|
||||
msgprint(_("Note: Due / Reference Date exceeds allowed customer credit days by {0} day(s)")
|
||||
.format(diff - flt(credit_days)))
|
||||
if party_type and party:
|
||||
if party_type == "Customer":
|
||||
credit_days_based_on, credit_days, customer_group = \
|
||||
frappe.db.get_value(party_type, party, ["credit_days_based_on", "credit_days", "customer_group"])
|
||||
|
||||
if not credit_days_based_on:
|
||||
credit_days_based_on, credit_days = \
|
||||
frappe.db.get_value("Customer Group", customer_group, ["credit_days_based_on", "credit_days"]) \
|
||||
or frappe.db.get_value("Company", company, ["credit_days_based_on", "credit_days"])
|
||||
|
||||
return credit_days_based_on, credit_days
|
||||
else:
|
||||
max_due_date = formatdate(add_days(posting_date, credit_days))
|
||||
frappe.throw(_("Due / Reference Date cannot be after {0}").format(max_due_date))
|
||||
credit_days, supplier_type = frappe.db.get_value(party_type, party, ["credit_days", "supplier_type"])
|
||||
if not credit_days:
|
||||
credit_days = frappe.db.get_value("Supplier Type", supplier_type, "credit_days") \
|
||||
or frappe.db.get_value("Company", company, "credit_days")
|
||||
|
||||
return credit_days
|
||||
|
||||
def validate_due_date(posting_date, due_date, party_type, party, company):
|
||||
if getdate(due_date) < getdate(posting_date):
|
||||
frappe.throw(_("Due Date cannot be before Posting Date"))
|
||||
else:
|
||||
default_due_date = get_due_date(posting_date, party_type, party, company)
|
||||
if default_due_date != posting_date and getdate(due_date) > getdate(default_due_date):
|
||||
is_credit_controller = frappe.db.get_single_value("Accounts Settings", "credit_controller") in frappe.get_roles()
|
||||
if is_credit_controller:
|
||||
msgprint(_("Note: Due / Reference Date exceeds allowed customer credit days by {0} day(s)")
|
||||
.format(date_diff(due_date, default_due_date)))
|
||||
else:
|
||||
frappe.throw(_("Due / Reference Date cannot be after {0}").format(formatdate(default_due_date)))
|
||||
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"creation": "2014-08-28 11:11:39.796473",
|
||||
"disabled": 0,
|
||||
"doc_type": "Journal Entry",
|
||||
"docstatus": 0,
|
||||
"doctype": "Print Format",
|
||||
"html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n\n<div class=\"page-break\">\n {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n and doc.set(\"select_print_heading\", _(\"Credit Note\")) -%}{%- endif -%}\n {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n {%- for label, value in (\n (_(\"Credit To\"), doc.pay_to_recd_from),\n (_(\"Date\"), frappe.utils.formatdate(doc.voucher_date)),\n (_(\"Amount\"), \"<strong>\" + doc.get_formatted(\"total_amount\") + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n (_(\"Remarks\"), doc.remark)\n ) -%}\n\n <div class=\"row\">\n <div class=\"col-xs-3\"><label class=\"text-right\">{{ label }}</label></div>\n <div class=\"col-xs-9\">{{ value }}</div>\n </div>\n\n {%- endfor -%}\n\n <hr>\n <br>\n <p class=\"strong\">\n {{ _(\"For\") }} {{ doc.company }},<br>\n <br>\n <br>\n <br>\n {{ _(\"Authorized Signatory\") }}\n </p>\n</div>\n\n\n",
|
||||
"idx": 2,
|
||||
"modified": "2015-01-12 11:02:25.716825",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Credit Note",
|
||||
"owner": "Administrator",
|
||||
"parent": "Journal Entry",
|
||||
"parentfield": "__print_formats",
|
||||
"parenttype": "DocType",
|
||||
"print_format_type": "Server",
|
||||
"creation": "2014-08-28 11:11:39.796473",
|
||||
"custom_format": 0,
|
||||
"disabled": 0,
|
||||
"doc_type": "Journal Entry",
|
||||
"docstatus": 0,
|
||||
"doctype": "Print Format",
|
||||
"html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n\n<div class=\"page-break\">\n {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n and doc.set(\"select_print_heading\", _(\"Credit Note\")) -%}{%- endif -%}\n {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n {%- for label, value in (\n (_(\"Credit To\"), doc.pay_to_recd_from),\n (_(\"Date\"), frappe.utils.formatdate(doc.voucher_date)),\n (_(\"Amount\"), \"<strong>\" + doc.get_formatted(\"total_amount\") + \"</strong><br>\" + (doc.total_amount_in_words or \"\") + \"<br>\"),\n (_(\"Remarks\"), doc.remark)\n ) -%}\n\n <div class=\"row\">\n <div class=\"col-xs-3\"><label class=\"text-right\">{{ label }}</label></div>\n <div class=\"col-xs-9\">{{ value }}</div>\n </div>\n\n {%- endfor -%}\n\n <hr>\n <br>\n <p class=\"strong\">\n {{ _(\"For\") }} {{ doc.company }},<br>\n <br>\n <br>\n <br>\n {{ _(\"Authorized Signatory\") }}\n </p>\n</div>\n\n\n",
|
||||
"idx": 2,
|
||||
"modified": "2015-07-22 17:42:01.560817",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Credit Note",
|
||||
"owner": "Administrator",
|
||||
"parent": "Journal Entry",
|
||||
"parentfield": "__print_formats",
|
||||
"parenttype": "DocType",
|
||||
"print_format_type": "Server",
|
||||
"standard": "Yes"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"creation": "2015-07-22 17:45:22.220567",
|
||||
"custom_format": 1,
|
||||
"disabled": 0,
|
||||
"doc_type": "Sales Invoice",
|
||||
"docstatus": 0,
|
||||
"doctype": "Print Format",
|
||||
"font": "Default",
|
||||
"html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 6in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ doc.company }}<br>\n\t{{ doc.select_print_heading or _(\"Credit Note\") }}<br>\n</p>\n\n<hr>\n\n{%- for label, value in (\n (_(\"Receipt No\"), doc.name),\n (_(\"Date\"), doc.get_formatted(\"posting_date\")),\n\t(_(\"Customer\"), doc.customer_name),\n (_(\"Amount\"), \"<strong>\" + doc.get_formatted(\"grand_total\", absolute_value=True) + \"</strong><br>\" + (doc.in_words or \"\")),\n\t(_(\"Against\"), doc.return_against),\n (_(\"Remarks\"), doc.remarks)\n) -%}\n\n\t\t<div class=\"row\">\n\t\t <div class=\"col-xs-4\"><label class=\"text-right\">{{ label }}</label></div>\n\t\t <div class=\"col-xs-8\">{{ value }}</div>\n\t\t</div>\n{%- endfor -%}\n\n<hr>\n<br>\n<p class=\"strong\">\n {{ _(\"For\") }} {{ doc.company }},<br>\n <br>\n <br>\n <br>\n {{ _(\"Authorized Signatory\") }}\n</p>",
|
||||
"modified": "2015-07-22 17:45:22.220567",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Credit Note - Negative Invoice",
|
||||
"owner": "Administrator",
|
||||
"print_format_builder": 0,
|
||||
"print_format_type": "Server",
|
||||
"standard": "Yes"
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"add_total_row": 1,
|
||||
"apply_user_permissions": 1,
|
||||
"creation": "2013-04-22 16:16:03",
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 1,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2014-06-03 07:18:10.985354",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Accounts Payable",
|
||||
"owner": "Administrator",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
"report_name": "Accounts Payable",
|
||||
"report_type": "Report Builder"
|
||||
}
|
||||
"add_total_row": 1,
|
||||
"apply_user_permissions": 1,
|
||||
"creation": "2013-04-22 16:16:03",
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 1,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2015-07-24 01:08:20.996267",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Accounts Payable",
|
||||
"owner": "Administrator",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
"report_name": "Accounts Payable",
|
||||
"report_type": "Script Report"
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class ReceivablePayableReport(object):
|
||||
currency_precision = get_currency_precision() or 2
|
||||
dr_or_cr = "debit" if args.get("party_type") == "Customer" else "credit"
|
||||
|
||||
voucher_details = self.get_voucher_details()
|
||||
voucher_details = self.get_voucher_details(args.get("party_type"))
|
||||
|
||||
future_vouchers = self.get_entries_after(self.filters.report_date, args.get("party_type"))
|
||||
|
||||
@@ -153,23 +153,26 @@ class ReceivablePayableReport(object):
|
||||
|
||||
return self.party_map
|
||||
|
||||
def get_voucher_details(self):
|
||||
def get_voucher_details(self, party_type):
|
||||
voucher_details = frappe._dict()
|
||||
|
||||
if party_type == "Customer":
|
||||
for si in frappe.db.sql("""select name, due_date
|
||||
from `tabSales Invoice` where docstatus=1""", as_dict=1):
|
||||
voucher_details.setdefault(si.name, si)
|
||||
|
||||
for si in frappe.db.sql("""select name, due_date
|
||||
from `tabSales Invoice` where docstatus=1""", as_dict=1):
|
||||
voucher_details.setdefault(si.name, si)
|
||||
|
||||
for pi in frappe.db.sql("""select name, due_date, bill_no, bill_date
|
||||
from `tabPurchase Invoice` where docstatus=1""", as_dict=1):
|
||||
voucher_details.setdefault(pi.name, pi)
|
||||
if party_type == "Supplier":
|
||||
for pi in frappe.db.sql("""select name, due_date, bill_no, bill_date
|
||||
from `tabPurchase Invoice` where docstatus=1""", as_dict=1):
|
||||
voucher_details.setdefault(pi.name, pi)
|
||||
|
||||
return voucher_details
|
||||
|
||||
def get_gl_entries(self, party_type):
|
||||
if not hasattr(self, "gl_entries"):
|
||||
conditions, values = self.prepare_conditions(party_type)
|
||||
self.gl_entries = frappe.db.sql("""select * from `tabGL Entry`
|
||||
self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party, debit, credit,
|
||||
voucher_type, voucher_no, against_voucher_type, against_voucher from `tabGL Entry`
|
||||
where docstatus < 2 and party_type=%s {0} order by posting_date, party"""
|
||||
.format(conditions), values, as_dict=True)
|
||||
|
||||
@@ -187,7 +190,7 @@ class ReceivablePayableReport(object):
|
||||
|
||||
if self.filters.get(party_type_field):
|
||||
conditions.append("party=%s")
|
||||
values.append(self.filters.get(party_type_field))
|
||||
values.append(self.filters.get(party_type_field))
|
||||
|
||||
return " and ".join(conditions), values
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ def get_data(company, root_type, balance_must_be, period_list, ignore_closing_en
|
||||
gl_entries_by_account = get_gl_entries(company, period_list[0]["from_date"], period_list[-1]["to_date"],
|
||||
accounts[0].lft, accounts[0].rgt, ignore_closing_entries=ignore_closing_entries)
|
||||
|
||||
calculate_values(accounts, gl_entries_by_account, period_list)
|
||||
calculate_values(accounts_by_name, gl_entries_by_account, period_list)
|
||||
accumulate_values_into_parents(accounts, accounts_by_name, period_list)
|
||||
out = prepare_data(accounts, balance_must_be, period_list)
|
||||
|
||||
@@ -92,16 +92,14 @@ def get_data(company, root_type, balance_must_be, period_list, ignore_closing_en
|
||||
|
||||
return out
|
||||
|
||||
def calculate_values(accounts, gl_entries_by_account, period_list):
|
||||
for d in accounts:
|
||||
for name in ([d.name] + (d.collapsed_children or [])):
|
||||
for entry in gl_entries_by_account.get(name, []):
|
||||
for period in period_list:
|
||||
entry.posting_date = getdate(entry.posting_date)
|
||||
|
||||
# check if posting date is within the period
|
||||
if entry.posting_date <= period.to_date:
|
||||
d[period.key] = d.get(period.key, 0.0) + flt(entry.debit) - flt(entry.credit)
|
||||
def calculate_values(accounts_by_name, gl_entries_by_account, period_list):
|
||||
for entries in gl_entries_by_account.values():
|
||||
for entry in entries:
|
||||
d = accounts_by_name.get(entry.account)
|
||||
for period in period_list:
|
||||
# check if posting date is within the period
|
||||
if entry.posting_date <= period.to_date:
|
||||
d[period.key] = d.get(period.key, 0.0) + flt(entry.debit) - flt(entry.credit)
|
||||
|
||||
|
||||
def accumulate_values_into_parents(accounts, accounts_by_name, period_list):
|
||||
@@ -159,22 +157,8 @@ def add_total_row(out, balance_must_be, period_list):
|
||||
out.append({})
|
||||
|
||||
def get_accounts(company, root_type):
|
||||
# root lft, rgt
|
||||
root_account = frappe.db.sql("""select lft, rgt from `tabAccount`
|
||||
where company=%s and root_type=%s and ifnull(parent_account, '') = ''
|
||||
order by lft limit 1""",
|
||||
(company, root_type), as_dict=True)
|
||||
|
||||
if not root_account:
|
||||
return None
|
||||
|
||||
lft, rgt = root_account[0].lft, root_account[0].rgt
|
||||
|
||||
accounts = frappe.db.sql("""select * from `tabAccount`
|
||||
where company=%(company)s and lft >= %(lft)s and rgt <= %(rgt)s order by lft""",
|
||||
{ "company": company, "lft": lft, "rgt": rgt }, as_dict=True)
|
||||
|
||||
return accounts
|
||||
return frappe.db.sql("""select name, parent_account, lft, rgt, root_type, report_type, account_name from `tabAccount`
|
||||
where company=%s and root_type=%s order by lft""", (company, root_type), as_dict=True)
|
||||
|
||||
def filter_accounts(accounts, depth=10):
|
||||
parent_children_map = {}
|
||||
@@ -196,14 +180,6 @@ def filter_accounts(accounts, depth=10):
|
||||
filtered_accounts.append(child)
|
||||
add_to_list(child.name, level + 1)
|
||||
|
||||
else:
|
||||
# include all children at level lower than the depth
|
||||
parent_account = accounts_by_name[parent]
|
||||
parent_account["collapsed_children"] = []
|
||||
for d in accounts:
|
||||
if d.lft > parent_account.lft and d.rgt < parent_account.rgt:
|
||||
parent_account["collapsed_children"].append(d.name)
|
||||
|
||||
add_to_list(None, 0)
|
||||
|
||||
return filtered_accounts, accounts_by_name
|
||||
@@ -234,7 +210,7 @@ def get_gl_entries(company, from_date, to_date, root_lft, root_rgt, ignore_closi
|
||||
if from_date:
|
||||
additional_conditions.append("and posting_date >= %(from_date)s")
|
||||
|
||||
gl_entries = frappe.db.sql("""select * from `tabGL Entry`
|
||||
gl_entries = frappe.db.sql("""select posting_date, account, debit, credit, is_opening from `tabGL Entry`
|
||||
where company=%(company)s
|
||||
{additional_conditions}
|
||||
and posting_date <= %(to_date)s
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div style="margin-bottom: 7px;" class="text-center">
|
||||
{%= frappe.boot.letter_heads[frappe.defaults.get_default("letter_head")] %}
|
||||
{%= frappe.boot.letter_heads[filters.letter_head || frappe.defaults.get_default("letter_head")] %}
|
||||
</div>
|
||||
<h2 class="text-center">{%= __("Statement of Account") %}</h2>
|
||||
<h4 class="text-center">{%= (filters.party || filters.account) && ((filters.party || filters.account) + ", ") || "" %} {%= filters.company %}</h4>
|
||||
|
||||
@@ -53,13 +53,9 @@ frappe.query_reports["General Ledger"] = {
|
||||
{
|
||||
"fieldname":"party_type",
|
||||
"label": __("Party Type"),
|
||||
"fieldtype": "Link",
|
||||
"options": "DocType",
|
||||
"get_query": function() {
|
||||
return {
|
||||
filters: {"name": ["in", ["Customer", "Supplier"]]}
|
||||
}
|
||||
}
|
||||
"fieldtype": "Select",
|
||||
"options": ["", "Customer", "Supplier"],
|
||||
"default": ""
|
||||
},
|
||||
{
|
||||
"fieldname":"party",
|
||||
@@ -84,6 +80,13 @@ frappe.query_reports["General Ledger"] = {
|
||||
"fieldname":"group_by_account",
|
||||
"label": __("Group by Account"),
|
||||
"fieldtype": "Check",
|
||||
},
|
||||
{
|
||||
"fieldname":"letter_head",
|
||||
"label": __("Letter Head"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Letter Head",
|
||||
"default": frappe.defaults.get_default("letter_head"),
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt, getdate
|
||||
from frappe.utils import flt, getdate, cstr
|
||||
from frappe import _
|
||||
|
||||
def execute(filters=None):
|
||||
@@ -66,7 +66,7 @@ def get_gl_entries(filters):
|
||||
|
||||
gl_entries = frappe.db.sql("""select posting_date, account, party_type, party,
|
||||
sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit,
|
||||
voucher_type, voucher_no, cost_center, remarks, is_opening, against
|
||||
voucher_type, voucher_no, cost_center, remarks, against, is_opening
|
||||
from `tabGL Entry`
|
||||
where company=%(company)s {conditions}
|
||||
{group_by_condition}
|
||||
@@ -91,6 +91,9 @@ def get_conditions(filters):
|
||||
|
||||
if filters.get("party"):
|
||||
conditions.append("party=%(party)s")
|
||||
|
||||
if not (filters.get("account") or filters.get("party") or filters.get("group_by_account")):
|
||||
conditions.append("posting_date >=%(from_date)s")
|
||||
|
||||
from frappe.desk.reportview import build_match_conditions
|
||||
match_conditions = build_match_conditions("GL Entry")
|
||||
@@ -148,14 +151,15 @@ def initialize_gle_map(gl_entries):
|
||||
|
||||
def get_accountwise_gle(filters, gl_entries, gle_map):
|
||||
opening, total_debit, total_credit = 0, 0, 0
|
||||
|
||||
from_date, to_date = getdate(filters.from_date), getdate(filters.to_date)
|
||||
for gle in gl_entries:
|
||||
amount = flt(gle.debit, 3) - flt(gle.credit, 3)
|
||||
if gle.posting_date < getdate(filters.from_date):
|
||||
if (filters.get("account") or filters.get("party") or filters.get("group_by_account")) \
|
||||
and (gle.posting_date < from_date or cstr(gle.is_opening) == "Yes"):
|
||||
gle_map[gle.account].opening += amount
|
||||
if filters.get("account") or filters.get("party"):
|
||||
opening += amount
|
||||
elif gle.posting_date <= getdate(filters.to_date):
|
||||
elif gle.posting_date <= to_date:
|
||||
gle_map[gle.account].entries.append(gle)
|
||||
gle_map[gle.account].total_debit += flt(gle.debit, 3)
|
||||
gle_map[gle.account].total_credit += flt(gle.credit, 3)
|
||||
|
||||
@@ -14,7 +14,7 @@ def execute(filters=None):
|
||||
source = gross_profit_data.grouped_data if filters.get("group_by") != "Invoice" else gross_profit_data.data
|
||||
|
||||
group_wise_columns = frappe._dict({
|
||||
"invoice": ["parent", "posting_date", "posting_time", "item_code", "item_name", "brand", "description", \
|
||||
"invoice": ["parent", "customer", "posting_date", "posting_time", "item_code", "item_name", "brand", "description", \
|
||||
"warehouse", "qty", "base_rate", "buying_rate", "base_amount",
|
||||
"buying_amount", "gross_profit", "gross_profit_percent", "project"],
|
||||
"item_code": ["item_code", "item_name", "brand", "description", "warehouse", "qty", "base_rate",
|
||||
@@ -86,23 +86,23 @@ class GrossProfitGenerator(object):
|
||||
self.filters = frappe._dict(filters)
|
||||
self.load_invoice_items()
|
||||
self.load_stock_ledger_entries()
|
||||
self.load_sales_bom()
|
||||
self.load_product_bundle()
|
||||
self.load_non_stock_items()
|
||||
self.process()
|
||||
|
||||
def process(self):
|
||||
self.grouped = {}
|
||||
for row in self.si_list:
|
||||
if self.skip_row(row, self.sales_boms):
|
||||
if self.skip_row(row, self.product_bundles):
|
||||
continue
|
||||
|
||||
row.base_amount = flt(row.base_net_amount)
|
||||
|
||||
sales_boms = self.sales_boms.get(row.parenttype, {}).get(row.parent, frappe._dict())
|
||||
product_bundles = self.product_bundles.get(row.parenttype, {}).get(row.parent, frappe._dict())
|
||||
|
||||
# get buying amount
|
||||
if row.item_code in sales_boms:
|
||||
row.buying_amount = self.get_buying_amount_from_sales_bom(row, sales_boms[row.item_code])
|
||||
if row.item_code in product_bundles:
|
||||
row.buying_amount = self.get_buying_amount_from_product_bundle(row, product_bundles[row.item_code])
|
||||
else:
|
||||
row.buying_amount = self.get_buying_amount(row, row.item_code)
|
||||
|
||||
@@ -152,13 +152,13 @@ class GrossProfitGenerator(object):
|
||||
|
||||
self.grouped_data.append(new_row)
|
||||
|
||||
def skip_row(self, row, sales_boms):
|
||||
def skip_row(self, row, product_bundles):
|
||||
if self.filters.get("group_by") != "Invoice" and not row.get(scrub(self.filters.get("group_by"))):
|
||||
return True
|
||||
|
||||
def get_buying_amount_from_sales_bom(self, row, sales_bom):
|
||||
def get_buying_amount_from_product_bundle(self, row, product_bundle):
|
||||
buying_amount = 0.0
|
||||
for bom_item in sales_bom:
|
||||
for bom_item in product_bundle:
|
||||
if bom_item.get("parent_detail_docname")==row.item_row:
|
||||
buying_amount += self.get_buying_amount(row, bom_item.item_code)
|
||||
|
||||
@@ -174,19 +174,16 @@ class GrossProfitGenerator(object):
|
||||
return flt(row.qty) * item_rate
|
||||
|
||||
else:
|
||||
if row.update_stock or row.dn_detail:
|
||||
my_sle = self.sle.get((item_code, row.warehouse))
|
||||
if (row.update_stock or row.dn_detail) and my_sle:
|
||||
parenttype, parent, item_row = row.parenttype, row.parent, row.item_row
|
||||
if row.dn_detail:
|
||||
row.parenttype = "Delivery Note"
|
||||
row.parent = row.delivery_note
|
||||
row.item_row = row.dn_detail
|
||||
|
||||
my_sle = self.sle.get((item_code, row.warehouse))
|
||||
parenttype, parent, item_row = "Delivery Note", row.delivery_note, row.dn_detail
|
||||
|
||||
for i, sle in enumerate(my_sle):
|
||||
# find the stock valution rate from stock ledger entry
|
||||
print sle.voucher_type, row.parenttype, sle.voucher_no, row.parent, \
|
||||
sle.voucher_detail_no, row.item_row
|
||||
if sle.voucher_type == row.parenttype and row.parent == sle.voucher_no and \
|
||||
sle.voucher_detail_no == row.item_row:
|
||||
if sle.voucher_type == parenttype and parent == sle.voucher_no and \
|
||||
sle.voucher_detail_no == item_row:
|
||||
previous_stock_value = len(my_sle) > i+1 and \
|
||||
flt(my_sle[i+1].stock_value) or 0.0
|
||||
return previous_stock_value - flt(sle.stock_value)
|
||||
@@ -218,7 +215,7 @@ class GrossProfitGenerator(object):
|
||||
if self.filters.to_date:
|
||||
conditions += " and posting_date <= %(to_date)s"
|
||||
|
||||
self.si_list = frappe.db.sql("""select item.parenttype, item.parent,
|
||||
self.si_list = frappe.db.sql("""select item.parenttype, item.parent,
|
||||
si.posting_date, si.posting_time, si.project_name, si.update_stock,
|
||||
si.customer, si.customer_group, si.territory,
|
||||
item.item_code, item.item_name, item.description, item.warehouse,
|
||||
@@ -249,15 +246,15 @@ class GrossProfitGenerator(object):
|
||||
|
||||
self.sle[(r.item_code, r.warehouse)].append(r)
|
||||
|
||||
def load_sales_bom(self):
|
||||
self.sales_boms = {}
|
||||
def load_product_bundle(self):
|
||||
self.product_bundles = {}
|
||||
|
||||
for d in frappe.db.sql("""select parenttype, parent, parent_item,
|
||||
item_code, warehouse, -1*qty as total_qty, parent_detail_docname
|
||||
from `tabPacked Item` where docstatus=1""", as_dict=True):
|
||||
self.sales_boms.setdefault(d.parenttype, frappe._dict()).setdefault(d.parent,
|
||||
self.product_bundles.setdefault(d.parenttype, frappe._dict()).setdefault(d.parent,
|
||||
frappe._dict()).setdefault(d.parent_item, []).append(d)
|
||||
|
||||
def load_non_stock_items(self):
|
||||
self.non_stock_items = frappe.db.sql_list("""select name from tabItem
|
||||
where ifnull(is_stock_item, 'No')='No'""")
|
||||
where is_stock_item=0""")
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
|
||||
frappe.query_reports["Payment Period Based On Invoice Date"] = {
|
||||
"filters": [
|
||||
{
|
||||
fieldname:"company",
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
reqd: 1,
|
||||
default: frappe.defaults.get_user_default("company")
|
||||
},
|
||||
{
|
||||
fieldname: "from_date",
|
||||
label: __("From Date"),
|
||||
@@ -23,27 +31,28 @@ frappe.query_reports["Payment Period Based On Invoice Date"] = {
|
||||
default: "Incoming"
|
||||
},
|
||||
{
|
||||
fieldname:"account",
|
||||
label: __("Account"),
|
||||
fieldtype: "Link",
|
||||
options: "Account",
|
||||
get_query: function() {
|
||||
"fieldname":"party_type",
|
||||
"label": __("Party Type"),
|
||||
"fieldtype": "Link",
|
||||
"options": "DocType",
|
||||
"get_query": function() {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_account_list",
|
||||
filters: {
|
||||
"report_type": "Balance Sheet",
|
||||
company: frappe.query_report.filters_by_name.company.get_value()
|
||||
}
|
||||
filters: {"name": ["in", ["Customer", "Supplier"]]}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldname:"company",
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
reqd: 1,
|
||||
default: frappe.defaults.get_user_default("company")
|
||||
"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;
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@ from frappe.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
|
||||
columns = get_columns()
|
||||
validate_filters(filters)
|
||||
|
||||
columns = get_columns(filters)
|
||||
entries = get_entries(filters)
|
||||
invoice_posting_date_map = get_invoice_posting_date_map(filters)
|
||||
against_date = ""
|
||||
@@ -20,67 +21,72 @@ def execute(filters=None):
|
||||
for d in entries:
|
||||
if d.against_voucher:
|
||||
against_date = d.against_voucher and invoice_posting_date_map[d.against_voucher] or ""
|
||||
outstanding_amount = flt(d.debit) or -1 * flt(d.credit)
|
||||
payment_amount = flt(d.debit) or -1 * flt(d.credit)
|
||||
else:
|
||||
against_date = d.against_invoice and invoice_posting_date_map[d.against_invoice] or ""
|
||||
outstanding_amount = flt(d.credit) or -1 * flt(d.debit)
|
||||
payment_amount = flt(d.credit) or -1 * flt(d.debit)
|
||||
|
||||
row = [d.name, d.account, d.posting_date, d.against_voucher or d.against_invoice,
|
||||
row = [d.name, d.party_type, d.party, d.posting_date, d.against_voucher or d.against_invoice,
|
||||
against_date, d.debit, d.credit, d.cheque_no, d.cheque_date, d.remark]
|
||||
|
||||
if d.against_voucher or d.against_invoice:
|
||||
row += get_ageing_data(30, 60, 90, d.posting_date, against_date, outstanding_amount)
|
||||
row += get_ageing_data(30, 60, 90, d.posting_date, against_date, payment_amount)
|
||||
else:
|
||||
row += ["", "", "", "", ""]
|
||||
|
||||
data.append(row)
|
||||
|
||||
return columns, data
|
||||
|
||||
def validate_filters(filters):
|
||||
if (filters.get("payment_type") == "Incoming" and filters.get("party_type") == "Supplier") or \
|
||||
(filters.get("payment_type") == "Outgoing" and filters.get("party_type") == "Customer"):
|
||||
frappe.throw(_("{0} payment entries can not be filtered by {1}")\
|
||||
.format(filters.payment_type, filters.party_type))
|
||||
|
||||
def get_columns():
|
||||
return [_("Journal Entry") + ":Link/Journal Entry:140", _("Account") + ":Link/Account:140",
|
||||
_("Posting Date") + ":Date:100", _("Against Invoice") + ":Link/Purchase Invoice:130",
|
||||
def get_columns(filters):
|
||||
return [_("Journal Entry") + ":Link/Journal Entry:140",
|
||||
_("Party Type") + ":Link/DocType:100", _("Party") + ":Dynamic Link/Party Type:140",
|
||||
_("Posting Date") + ":Date:100",
|
||||
_("Against Invoice") + (":Link/Purchase Invoice:130" if filters.get("payment_type") == "Outgoing" else ":Link/Sales Invoice:130"),
|
||||
_("Against Invoice Posting Date") + ":Date:130", _("Debit") + ":Currency:120", _("Credit") + ":Currency:120",
|
||||
_("Reference No") + "::100", _("Reference Date") + ":Date:100", _("Remarks") + "::150", _("Age") +":Int:40",
|
||||
"0-30:Currency:100", "30-60:Currency:100", "60-90:Currency:100", _("90-Above") + ":Currency:100"
|
||||
]
|
||||
|
||||
def get_conditions(filters):
|
||||
conditions = ""
|
||||
party = None
|
||||
conditions = []
|
||||
|
||||
if filters.get("account"):
|
||||
party = filters["account"]
|
||||
else:
|
||||
conditions += " and company = '%s'" % frappe.db.escape(filters["company"])
|
||||
if not filters.get("party_type"):
|
||||
if filters.get("payment_type") == "Outgoing":
|
||||
filters["party_type"] = "Supplier"
|
||||
else:
|
||||
filters["party_type"] = "Customer"
|
||||
|
||||
if filters.get("party_type"):
|
||||
conditions.append("jvd.party_type=%(party_type)s")
|
||||
|
||||
account_type = "Receivable" if filters.get("payment_type") == "Incoming" else "Payable"
|
||||
if filters.get("party"):
|
||||
conditions.append("jvd.party=%(party)s")
|
||||
|
||||
conditions += """ and account in
|
||||
(select name from tabAccount
|
||||
where account_type = '{0}'
|
||||
and company='{1}')""".format(account_type, frappe.db.escape(filters["company"]))
|
||||
|
||||
if party:
|
||||
conditions += " and jvd.party = '%s'" % frappe.db.escape(party)
|
||||
else:
|
||||
conditions += " and ifnull(jvd.party, '') != ''"
|
||||
if filters.get("company"):
|
||||
conditions.append("jv.company=%(company)s")
|
||||
|
||||
if filters.get("from_date"):
|
||||
conditions += " and jv.posting_date >= '%s'" % filters["from_date"]
|
||||
conditions.append("jv.posting_date >= %(from_date)s")
|
||||
if filters.get("to_date"):
|
||||
conditions += " and jv.posting_date <= '%s'" % filters["to_date"]
|
||||
conditions.append("jv.posting_date <= %(to_date)s")
|
||||
|
||||
return conditions
|
||||
return "and {}".format(" and ".join(conditions)) if conditions else ""
|
||||
|
||||
def get_entries(filters):
|
||||
conditions = get_conditions(filters)
|
||||
entries = frappe.db.sql("""select jv.name, jvd.account, jv.posting_date,
|
||||
entries = frappe.db.sql("""select jv.name, jvd.party_type, jvd.party, jv.posting_date,
|
||||
jvd.against_voucher, jvd.against_invoice, jvd.debit, jvd.credit,
|
||||
jv.cheque_no, jv.cheque_date, jv.remark
|
||||
from `tabJournal Entry Account` jvd, `tabJournal Entry` jv
|
||||
where jvd.parent = jv.name and jv.docstatus=1 %s order by jv.name DESC""" %
|
||||
conditions, as_dict=1, debug=1)
|
||||
conditions, filters, as_dict=1)
|
||||
|
||||
return entries
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ def execute(filters=None):
|
||||
invoice_list = get_invoices(filters)
|
||||
columns, expense_accounts, tax_accounts = get_columns(invoice_list)
|
||||
|
||||
|
||||
if not invoice_list:
|
||||
msgprint(_("No record found"))
|
||||
return columns, invoice_list
|
||||
@@ -30,7 +29,8 @@ def execute(filters=None):
|
||||
purchase_receipt = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", [])))
|
||||
project_name = list(set(invoice_po_pr_map.get(inv.name, {}).get("project_name", [])))
|
||||
|
||||
row = [inv.name, inv.posting_date, inv.supplier, inv.supplier_name, supplier_details.get(inv.supplier),
|
||||
row = [inv.name, inv.posting_date, inv.supplier, inv.supplier_name,
|
||||
supplier_details.get(inv.supplier),
|
||||
inv.credit_to, ", ".join(project_name), inv.bill_no, inv.bill_date, inv.remarks,
|
||||
", ".join(purchase_order), ", ".join(purchase_receipt)]
|
||||
|
||||
@@ -54,8 +54,7 @@ def execute(filters=None):
|
||||
|
||||
# total tax, grand total, outstanding amount & rounded total
|
||||
row += [total_tax, inv.base_grand_total, flt(inv.base_grand_total, 2), inv.outstanding_amount]
|
||||
data.append(row)
|
||||
# raise Exception
|
||||
data.append(row)
|
||||
|
||||
return columns, data
|
||||
|
||||
@@ -107,7 +106,7 @@ def get_conditions(filters):
|
||||
|
||||
def get_invoices(filters):
|
||||
conditions = get_conditions(filters)
|
||||
return frappe.db.sql("""select name, posting_date, credit_to, supplier, supplier_name
|
||||
return frappe.db.sql("""select name, posting_date, credit_to, supplier, supplier_name,
|
||||
bill_no, bill_date, remarks, base_net_total, base_grand_total, outstanding_amount
|
||||
from `tabPurchase Invoice` where docstatus = 1 %s
|
||||
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
||||
|
||||
@@ -30,7 +30,8 @@ def execute(filters=None):
|
||||
delivery_note = list(set(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", [])))
|
||||
|
||||
row = [inv.name, inv.posting_date, inv.customer, inv.customer_name,
|
||||
customer_map.get(inv.customer)["customer_group"], customer_map.get(inv.customer)["territory"],
|
||||
customer_map.get(inv.customer, {}).get("customer_group"),
|
||||
customer_map.get(inv.customer, {}).get("territory"),
|
||||
inv.debit_to, inv.project_name, inv.remarks, ", ".join(sales_order), ", ".join(delivery_note)]
|
||||
|
||||
# map income values
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import cint, flt, getdate, formatdate
|
||||
from frappe.utils import cint, flt, getdate, formatdate, cstr
|
||||
from erpnext.accounts.report.financial_statements import filter_accounts, get_gl_entries
|
||||
|
||||
value_fields = ("opening_debit", "opening_credit", "debit", "credit", "closing_debit", "closing_credit")
|
||||
|
||||
def execute(filters):
|
||||
def execute(filters=None):
|
||||
validate_filters(filters)
|
||||
data = get_data(filters)
|
||||
columns = get_columns()
|
||||
@@ -45,8 +45,8 @@ def validate_filters(filters):
|
||||
filters.to_date = filters.year_end_date
|
||||
|
||||
def get_data(filters):
|
||||
accounts = frappe.db.sql("""select * from `tabAccount` where company=%s order by lft""",
|
||||
filters.company, as_dict=True)
|
||||
accounts = frappe.db.sql("""select name, parent_account, account_name, root_type, report_type, lft, rgt
|
||||
from `tabAccount` where company=%s order by lft""", filters.company, as_dict=True)
|
||||
|
||||
if not accounts:
|
||||
return None
|
||||
@@ -56,17 +56,58 @@ def get_data(filters):
|
||||
min_lft, max_rgt = frappe.db.sql("""select min(lft), max(rgt) from `tabAccount`
|
||||
where company=%s""", (filters.company,))[0]
|
||||
|
||||
gl_entries_by_account = get_gl_entries(filters.company, None, filters.to_date, min_lft, max_rgt,
|
||||
gl_entries_by_account = get_gl_entries(filters.company, filters.from_date, filters.to_date, min_lft, max_rgt,
|
||||
ignore_closing_entries=not flt(filters.with_period_closing_entry))
|
||||
|
||||
total_row = calculate_values(accounts, gl_entries_by_account, filters)
|
||||
opening_balances = get_opening_balances(filters)
|
||||
|
||||
total_row = calculate_values(accounts, gl_entries_by_account, opening_balances, filters)
|
||||
accumulate_values_into_parents(accounts, accounts_by_name)
|
||||
|
||||
data = prepare_data(accounts, filters, total_row)
|
||||
|
||||
return data
|
||||
|
||||
def get_opening_balances(filters):
|
||||
balance_sheet_opening = get_rootwise_opening_balances(filters, "Balance Sheet")
|
||||
pl_opening = get_rootwise_opening_balances(filters, "Profit and Loss")
|
||||
|
||||
balance_sheet_opening.update(pl_opening)
|
||||
return balance_sheet_opening
|
||||
|
||||
|
||||
def get_rootwise_opening_balances(filters, report_type):
|
||||
additional_conditions = " and posting_date >= %(year_start_date)s" \
|
||||
if report_type == "Profit and Loss" else ""
|
||||
|
||||
if not flt(filters.with_period_closing_entry):
|
||||
additional_conditions += " and ifnull(voucher_type, '')!='Period Closing Voucher'"
|
||||
|
||||
gle = frappe.db.sql("""
|
||||
select
|
||||
account, sum(ifnull(debit, 0)) as opening_debit, sum(ifnull(credit, 0)) as opening_credit
|
||||
from `tabGL Entry`
|
||||
where
|
||||
company=%(company)s
|
||||
{additional_conditions}
|
||||
and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes')
|
||||
and account in (select name from `tabAccount` where report_type=%(report_type)s)
|
||||
group by account""".format(additional_conditions=additional_conditions),
|
||||
{
|
||||
"company": filters.company,
|
||||
"from_date": filters.from_date,
|
||||
"report_type": report_type,
|
||||
"year_start_date": filters.year_start_date
|
||||
},
|
||||
as_dict=True)
|
||||
|
||||
opening = frappe._dict()
|
||||
for d in gle:
|
||||
opening.setdefault(d.account, d)
|
||||
|
||||
return opening
|
||||
|
||||
def calculate_values(accounts, gl_entries_by_account, filters):
|
||||
def calculate_values(accounts, gl_entries_by_account, opening_balances, filters):
|
||||
init = {
|
||||
"opening_debit": 0.0,
|
||||
"opening_credit": 0.0,
|
||||
@@ -87,30 +128,18 @@ def calculate_values(accounts, gl_entries_by_account, filters):
|
||||
for d in accounts:
|
||||
d.update(init.copy())
|
||||
|
||||
# add opening
|
||||
d["opening_debit"] = opening_balances.get(d.name, {}).get("opening_debit", 0)
|
||||
d["opening_credit"] = opening_balances.get(d.name, {}).get("opening_credit", 0)
|
||||
|
||||
for entry in gl_entries_by_account.get(d.name, []):
|
||||
posting_date = getdate(entry.posting_date)
|
||||
|
||||
# opening
|
||||
if posting_date < filters.from_date:
|
||||
is_valid_opening = (d.root_type in ("Asset", "Liability", "Equity") or
|
||||
(filters.year_start_date <= posting_date < filters.from_date))
|
||||
|
||||
if is_valid_opening:
|
||||
d["opening_debit"] += flt(entry.debit)
|
||||
d["opening_credit"] += flt(entry.credit)
|
||||
|
||||
elif posting_date <= filters.to_date:
|
||||
|
||||
if entry.is_opening == "Yes" and d.root_type in ("Asset", "Liability", "Equity"):
|
||||
d["opening_debit"] += flt(entry.debit)
|
||||
d["opening_credit"] += flt(entry.credit)
|
||||
|
||||
else:
|
||||
d["debit"] += flt(entry.debit)
|
||||
d["credit"] += flt(entry.credit)
|
||||
if cstr(entry.is_opening) != "Yes":
|
||||
d["debit"] += flt(entry.debit)
|
||||
d["credit"] += flt(entry.credit)
|
||||
|
||||
total_row["debit"] += d["debit"]
|
||||
total_row["credit"] += d["credit"]
|
||||
|
||||
|
||||
return total_row
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ def get_balance_on(account=None, date=None, party_type=None, party=None):
|
||||
# different filter for group and ledger - improved performance
|
||||
if acc.is_group:
|
||||
cond.append("""exists (
|
||||
select * from `tabAccount` ac where ac.name = gle.account
|
||||
select name from `tabAccount` ac where ac.name = gle.account
|
||||
and ac.lft >= %s and ac.rgt <= %s
|
||||
)""" % (acc.lft, acc.rgt))
|
||||
else:
|
||||
@@ -397,7 +397,7 @@ def get_outstanding_invoices(amount_query, account, party_type, party):
|
||||
|
||||
for d in outstanding_voucher_list:
|
||||
payment_amount = frappe.db.sql("""
|
||||
select ifnull(sum(ifnull({amount_query}, 0)), 0)
|
||||
select ifnull(sum({amount_query}), 0)
|
||||
from
|
||||
`tabGL Entry`
|
||||
where
|
||||
|
||||
@@ -44,12 +44,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
if(me.frm.doc.is_subcontracted == "Yes") {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters:{ 'is_sub_contracted_item': 'Yes' }
|
||||
filters:{ 'is_sub_contracted_item': 1 }
|
||||
}
|
||||
} else {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: { 'is_purchase_item': 'Yes' }
|
||||
filters: { 'is_purchase_item': 1 }
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -70,10 +70,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
erpnext.utils.get_address_display(this.frm);
|
||||
},
|
||||
|
||||
contact_person: function() {
|
||||
erpnext.utils.get_contact_details(this.frm);
|
||||
},
|
||||
|
||||
buying_price_list: function() {
|
||||
this.apply_price_list();
|
||||
},
|
||||
@@ -168,8 +164,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
frappe.model.round_floats_in(this.frm.doc, ["base_grand_total", "total_advance", "write_off_amount"]);
|
||||
this.frm.doc.total_amount_to_pay = flt(this.frm.doc.base_grand_total - this.frm.doc.write_off_amount,
|
||||
precision("total_amount_to_pay"));
|
||||
this.frm.doc.outstanding_amount = flt(this.frm.doc.total_amount_to_pay - this.frm.doc.total_advance,
|
||||
precision("outstanding_amount"));
|
||||
if (!this.frm.doc.is_return) {
|
||||
this.frm.doc.outstanding_amount = flt(this.frm.doc.total_amount_to_pay - this.frm.doc.total_advance,
|
||||
precision("outstanding_amount"));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,8 +41,7 @@ class PurchaseCommon(BuyingController):
|
||||
def validate_for_items(self, obj):
|
||||
items = []
|
||||
for d in obj.get("items"):
|
||||
# validation for valid qty
|
||||
if flt(d.qty) < 0 or (d.parenttype != 'Purchase Receipt' and not flt(d.qty)):
|
||||
if not d.qty:
|
||||
frappe.throw(_("Please enter quantity for Item {0}").format(d.item_code))
|
||||
|
||||
# udpate with latest quantities
|
||||
@@ -57,24 +56,25 @@ class PurchaseCommon(BuyingController):
|
||||
d.set(x, f_lst[x])
|
||||
|
||||
item = frappe.db.sql("""select is_stock_item, is_purchase_item,
|
||||
is_sub_contracted_item, end_of_life from `tabItem` where name=%s""", d.item_code)
|
||||
is_sub_contracted_item, end_of_life from `tabItem` where name=%s""",
|
||||
d.item_code, as_dict=1)[0]
|
||||
|
||||
from erpnext.stock.doctype.item.item import validate_end_of_life
|
||||
validate_end_of_life(d.item_code, item[0][3])
|
||||
validate_end_of_life(d.item_code, item.end_of_life)
|
||||
|
||||
# validate stock item
|
||||
if item[0][0]=='Yes' and d.qty and not d.warehouse:
|
||||
if item.is_stock_item==1 and d.qty and not d.warehouse:
|
||||
frappe.throw(_("Warehouse is mandatory for stock Item {0} in row {1}").format(d.item_code, d.idx))
|
||||
|
||||
# validate purchase item
|
||||
if not (obj.doctype=="Material Request" and getattr(obj, "material_request_type", None)=="Material Transfer"):
|
||||
if item[0][1] != 'Yes' and item[0][2] != 'Yes':
|
||||
if item.is_purchase_item != 1 and item.is_sub_contracted_item != 1:
|
||||
frappe.throw(_("{0} must be a Purchased or Sub-Contracted Item in row {1}").format(d.item_code, d.idx))
|
||||
|
||||
items.append(cstr(d.item_code))
|
||||
if items and len(items) != len(set(items)):
|
||||
frappe.msgprint(_("Warning: Same item has been entered multiple times."))
|
||||
|
||||
|
||||
|
||||
def check_for_stopped_status(self, doctype, docname):
|
||||
stopped = frappe.db.sql("""select name from `tab%s` where name = %s and
|
||||
|
||||
@@ -11,39 +11,32 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
this._super();
|
||||
// this.frm.dashboard.reset();
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||
// cur_frm.dashboard.add_progress(cint(doc.per_received) + __("% Received"),
|
||||
// doc.per_received);
|
||||
// cur_frm.dashboard.add_progress(cint(doc.per_billed) + __("% Billed"),
|
||||
// doc.per_billed);
|
||||
|
||||
if(doc.docstatus == 1 && doc.status != 'Stopped') {
|
||||
if(flt(doc.per_received, 2) < 100) {
|
||||
cur_frm.add_custom_button(__('Make Purchase Receipt'),
|
||||
this.make_purchase_receipt);
|
||||
cur_frm.add_custom_button(__('Make Purchase Receipt'), this.make_purchase_receipt);
|
||||
|
||||
if(doc.is_subcontracted==="Yes") {
|
||||
cur_frm.add_custom_button(__('Transfer Material to Supplier'),
|
||||
function() { me.make_stock_entry() });
|
||||
cur_frm.add_custom_button(__('Transfer Material to Supplier'), this.make_stock_entry);
|
||||
}
|
||||
}
|
||||
if(flt(doc.per_billed, 2) < 100)
|
||||
cur_frm.add_custom_button(__('Make Invoice'), this.make_purchase_invoice,
|
||||
frappe.boot.doctype_icons["Purchase Invoice"]);
|
||||
cur_frm.add_custom_button(__('Make Invoice'), this.make_purchase_invoice);
|
||||
|
||||
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100)
|
||||
cur_frm.add_custom_button(__('Stop'), cur_frm.cscript['Stop Purchase Order'],
|
||||
"icon-exclamation", "btn-default");
|
||||
cur_frm.add_custom_button(__('Stop'), cur_frm.cscript['Stop Purchase Order']);
|
||||
|
||||
} else if(doc.docstatus===0) {
|
||||
cur_frm.cscript.add_from_mappers();
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||
cur_frm.add_custom_button(__('Unstop Purchase Order'),
|
||||
cur_frm.cscript['Unstop Purchase Order'], "icon-check");
|
||||
cur_frm.add_custom_button(__('Unstop Purchase Order'), cur_frm.cscript['Unstop Purchase Order']);
|
||||
},
|
||||
|
||||
make_stock_entry: function() {
|
||||
var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; }),
|
||||
me = this;
|
||||
var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; });
|
||||
var me = this;
|
||||
|
||||
if(items.length===1) {
|
||||
me._make_stock_entry(items[0]);
|
||||
return;
|
||||
@@ -96,7 +89,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
}, "icon-download", "btn-default"
|
||||
}
|
||||
);
|
||||
|
||||
cur_frm.add_custom_button(__('From Supplier Quotation'),
|
||||
@@ -110,7 +103,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
company: cur_frm.doc.company
|
||||
}
|
||||
})
|
||||
}, "icon-download", "btn-default"
|
||||
}
|
||||
);
|
||||
|
||||
cur_frm.add_custom_button(__('For Supplier'),
|
||||
@@ -122,7 +115,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
docstatus: ["!=", 2],
|
||||
}
|
||||
})
|
||||
}, "icon-download", "btn-default"
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
@@ -249,7 +242,7 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
|
||||
|
||||
cur_frm.cscript.schedule_date = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "schedule_date");
|
||||
erpnext.utils.copy_value_in_all_row(doc, cdt, cdn, "items", "schedule_date");
|
||||
}
|
||||
|
||||
frappe.provide("erpnext.buying");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"description": "Supplier (vendor) name as entered in supplier master",
|
||||
"description": "",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
"in_filter": 1,
|
||||
@@ -53,7 +53,7 @@
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Name",
|
||||
"label": "Supplier Name",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
@@ -457,7 +457,7 @@
|
||||
{
|
||||
"fieldname": "base_discount_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Discount Amount (Company Currency)",
|
||||
"label": "Additional Discount Amount (Company Currency)",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
@@ -868,12 +868,21 @@
|
||||
"no_copy": 1,
|
||||
"permlevel": 0,
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.is_recurring==1",
|
||||
"fieldname": "recurring_print_format",
|
||||
"fieldtype": "Link",
|
||||
"label": "Recurring Print Format",
|
||||
"options": "Print Format",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
}
|
||||
],
|
||||
"icon": "icon-file-text",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-05-27 02:48:02.452899",
|
||||
"modified": "2015-07-13 05:28:29.397705",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Purchase Order",
|
||||
@@ -890,7 +899,7 @@
|
||||
"print": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Material User",
|
||||
"role": "Stock User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
|
||||
@@ -153,7 +153,7 @@ class PurchaseOrder(BuyingController):
|
||||
item_wh_list = []
|
||||
for d in self.get("items"):
|
||||
if (not po_item_rows or d.name in po_item_rows) and [d.item_code, d.warehouse] not in item_wh_list \
|
||||
and frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes" and d.warehouse:
|
||||
and frappe.db.get_value("Item", d.item_code, "is_stock_item") and d.warehouse:
|
||||
item_wh_list.append([d.item_code, d.warehouse])
|
||||
|
||||
for item_code, warehouse in item_wh_list:
|
||||
|
||||
@@ -5,7 +5,13 @@ frappe.listview_settings['Purchase Order'] = {
|
||||
if(doc.status==="Stopped") {
|
||||
return [__("Stopped"), "darkgrey", "status,=,Stopped"];
|
||||
} else if(flt(doc.per_received) < 100 && doc.status!=="Stopped") {
|
||||
return [__("Not Received"), "orange", "per_received,<,100|status,!=,Stopped"];
|
||||
if(flt(doc.per_billed) < 100) {
|
||||
return [__("To Receive and Bill"), "orange",
|
||||
"per_received,<,100|per_billed,<,100|status,!=,Stopped"];
|
||||
} else {
|
||||
return [__("To Receive"), "orange",
|
||||
"per_received,<,100|per_billed,=,100|status,!=,Stopped"];
|
||||
}
|
||||
} else if(flt(doc.per_received) == 100 && flt(doc.per_billed) < 100 && doc.status!=="Stopped") {
|
||||
return [__("To Bill"), "orange", "per_received,=,100|per_billed,<,100|status,!=,Stopped"];
|
||||
} else if(flt(doc.per_received) == 100 && flt(doc.per_billed) == 100 && doc.status!=="Stopped") {
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Description",
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Small Text",
|
||||
@@ -538,7 +538,7 @@
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2015-05-27 02:47:16.553472",
|
||||
"modified": "2015-06-02 14:19:21.459032",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Purchase Order Item",
|
||||
|
||||
@@ -57,3 +57,7 @@ cur_frm.fields_dict['item_serial_no'].get_query = function(doc, cdt, cdn) {
|
||||
|
||||
return { filters: filter }
|
||||
}
|
||||
|
||||
cur_frm.add_fetch('item_code', 'item_name', 'item_name');
|
||||
cur_frm.add_fetch('item_code', 'description', 'description');
|
||||
|
||||
|
||||
@@ -127,6 +127,14 @@
|
||||
"permlevel": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Item Name",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
@@ -219,7 +227,7 @@
|
||||
"icon": "icon-search",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-04-14 07:37:07.331291",
|
||||
"modified": "2015-06-08 02:40:25.121948",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Quality Inspection",
|
||||
|
||||
@@ -31,7 +31,6 @@ class QualityInspection(Document):
|
||||
(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
|
||||
@@ -39,7 +38,6 @@ class QualityInspection(Document):
|
||||
where t1.parent = %s and t1.item_code = %s and t1.parent = t2.name""",
|
||||
(self.modified, self.purchase_receipt_no, self.item_code))
|
||||
|
||||
|
||||
def item_query(doctype, txt, searchfield, start, page_len, filters):
|
||||
if filters.get("from"):
|
||||
from frappe.desk.reportview import get_match_cond
|
||||
|
||||
@@ -1,247 +1,254 @@
|
||||
{
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "naming_series:",
|
||||
"creation": "2013-01-10 16:34:11",
|
||||
"description": "Supplier of Goods or Services.",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "naming_series:",
|
||||
"creation": "2013-01-10 16:34:11",
|
||||
"description": "Supplier of Goods or Services.",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "basic_info",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "",
|
||||
"oldfieldtype": "Section Break",
|
||||
"options": "icon-user",
|
||||
"fieldname": "basic_info",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "",
|
||||
"oldfieldtype": "Section Break",
|
||||
"options": "icon-user",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
"label": "Series",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "naming_series",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "SUPP-",
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
"label": "Series",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "naming_series",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "SUPP-",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "supplier_name",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 0,
|
||||
"label": "Supplier Name",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "supplier_name",
|
||||
"oldfieldtype": "Data",
|
||||
"permlevel": 0,
|
||||
"fieldname": "supplier_name",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 0,
|
||||
"label": "Supplier Name",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "supplier_name",
|
||||
"oldfieldtype": "Data",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "supplier_type",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Supplier Type",
|
||||
"oldfieldname": "supplier_type",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Supplier Type",
|
||||
"permlevel": 0,
|
||||
"fieldname": "supplier_type",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Supplier Type",
|
||||
"oldfieldname": "supplier_type",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Supplier Type",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"fieldname": "address_contacts",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Address & Contacts",
|
||||
"oldfieldtype": "Column Break",
|
||||
"options": "icon-map-marker",
|
||||
"fieldname": "is_frozen",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Frozen",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"fieldname": "address_contacts",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Address & Contacts",
|
||||
"oldfieldtype": "Column Break",
|
||||
"options": "icon-map-marker",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "address_html",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Address HTML",
|
||||
"permlevel": 0,
|
||||
"fieldname": "address_html",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Address HTML",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "contact_html",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Contact HTML",
|
||||
"permlevel": 0,
|
||||
"fieldname": "contact_html",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Contact HTML",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "default_payable_accounts",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Default Payable Accounts",
|
||||
"fieldname": "default_payable_accounts",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Default Payable Accounts",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"description": "Mention if non-standard receivable account applicable",
|
||||
"fieldname": "accounts",
|
||||
"fieldtype": "Table",
|
||||
"label": "Accounts",
|
||||
"options": "Party Account",
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"description": "Mention if non-standard receivable account applicable",
|
||||
"fieldname": "accounts",
|
||||
"fieldtype": "Table",
|
||||
"label": "Accounts",
|
||||
"options": "Party Account",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "more_info",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "More Info",
|
||||
"oldfieldtype": "Section Break",
|
||||
"options": "icon-file-text",
|
||||
"fieldname": "more_info",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "More Info",
|
||||
"oldfieldtype": "Section Break",
|
||||
"options": "icon-file-text",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "default_currency",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Default Currency",
|
||||
"no_copy": 1,
|
||||
"options": "Currency",
|
||||
"fieldname": "default_currency",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Default Currency",
|
||||
"no_copy": 1,
|
||||
"options": "Currency",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "default_price_list",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"fieldname": "default_price_list",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Price List",
|
||||
"options": "Price List",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "default_taxes_and_charges",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Taxes and Charges",
|
||||
"options": "Purchase Taxes and Charges Template",
|
||||
"fieldname": "default_taxes_and_charges",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Taxes and Charges",
|
||||
"options": "Purchase Taxes and Charges Template",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "credit_days",
|
||||
"fieldtype": "Int",
|
||||
"label": "Credit Days",
|
||||
"fieldname": "credit_days",
|
||||
"fieldtype": "Int",
|
||||
"label": "Credit Days",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "website",
|
||||
"fieldtype": "Data",
|
||||
"label": "Website",
|
||||
"oldfieldname": "website",
|
||||
"oldfieldtype": "Data",
|
||||
"fieldname": "website",
|
||||
"fieldtype": "Data",
|
||||
"label": "Website",
|
||||
"oldfieldname": "website",
|
||||
"oldfieldtype": "Data",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"description": "Statutory info and other general information about your Supplier",
|
||||
"fieldname": "supplier_details",
|
||||
"fieldtype": "Text",
|
||||
"label": "Supplier Details",
|
||||
"oldfieldname": "supplier_details",
|
||||
"oldfieldtype": "Code",
|
||||
"description": "Statutory info and other general information about your Supplier",
|
||||
"fieldname": "supplier_details",
|
||||
"fieldtype": "Text",
|
||||
"label": "Supplier Details",
|
||||
"oldfieldname": "supplier_details",
|
||||
"oldfieldtype": "Code",
|
||||
"permlevel": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"fieldname": "communications",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 1,
|
||||
"label": "Communications",
|
||||
"options": "Communication",
|
||||
"permlevel": 0,
|
||||
"fieldname": "communications",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 1,
|
||||
"label": "Communications",
|
||||
"options": "Communication",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1
|
||||
}
|
||||
],
|
||||
"icon": "icon-user",
|
||||
"idx": 1,
|
||||
"modified": "2015-02-24 17:35:03.821319",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Supplier",
|
||||
"owner": "Administrator",
|
||||
],
|
||||
"icon": "icon-user",
|
||||
"idx": 1,
|
||||
"modified": "2015-07-17 09:39:05.318826",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Supplier",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Purchase User"
|
||||
},
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Purchase Manager",
|
||||
"submit": 0,
|
||||
"amend": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Purchase Manager",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Purchase Master Manager",
|
||||
"share": 1,
|
||||
"submit": 0,
|
||||
"amend": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Purchase Master Manager",
|
||||
"share": 1,
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"apply_user_permissions": 1,
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Material User"
|
||||
},
|
||||
"apply_user_permissions": 1,
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Stock User"
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Material Manager"
|
||||
},
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Stock Manager"
|
||||
},
|
||||
{
|
||||
"apply_user_permissions": 1,
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"apply_user_permissions": 1,
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Accounts User"
|
||||
},
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"email": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Accounts Manager"
|
||||
}
|
||||
],
|
||||
"search_fields": "supplier_name, supplier_type",
|
||||
],
|
||||
"search_fields": "supplier_name, supplier_type",
|
||||
"title_field": "supplier_name"
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"description": "Supplier (vendor) name as entered in supplier master",
|
||||
"description": "",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
"in_filter": 1,
|
||||
@@ -439,7 +439,7 @@
|
||||
{
|
||||
"fieldname": "base_discount_amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Discount Amount (Company Currency)",
|
||||
"label": "Additional Discount Amount (Company Currency)",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
@@ -660,7 +660,7 @@
|
||||
"icon": "icon-shopping-cart",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-05-27 02:48:02.098540",
|
||||
"modified": "2015-07-13 05:28:30.252636",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Supplier Quotation",
|
||||
@@ -723,7 +723,7 @@
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Material User",
|
||||
"role": "Stock User",
|
||||
"submit": 0,
|
||||
"write": 0
|
||||
},
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Description",
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Small Text",
|
||||
@@ -413,7 +413,7 @@
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2015-05-27 02:47:15.853886",
|
||||
"modified": "2015-06-02 14:19:33.922968",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Supplier Quotation Item",
|
||||
|
||||
3
erpnext/change_log/current/readme.md
Normal file
3
erpnext/change_log/current/readme.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Leave change log files in this folder for user release notes.
|
||||
|
||||
(this file is just a place holder, don't delete it)
|
||||
17
erpnext/change_log/v5/v5_0_25.md
Normal file
17
erpnext/change_log/v5/v5_0_25.md
Normal file
@@ -0,0 +1,17 @@
|
||||
- Performance upgrade in Trial Balance, General Ledger, AR/AP, Balance Sheet and P&L Statement reports
|
||||
- Add index on Account and GL Entry, Sales Invoice and Purchase Invoice table
|
||||
- Don't create Time Logs against Production Order if Workstation is not specified in Operations
|
||||
- Task should be mandatory in Time Log only when Project is mentioned but Production Order is not
|
||||
- Supplier invoice no unique validation and supplier invoice date can not be after posting date
|
||||
- Removed BOM No from mandatory from Stock Entry against Production Order
|
||||
- Load tasks in project for printing purpose
|
||||
- Added Customers Not Buying Since Long Time against Sales Invoice
|
||||
- POS - search by Item Group
|
||||
- Payment period based on invoice date: show party columns and filter based on party
|
||||
- Barcode added to Purchase Receipt
|
||||
- Fetch item name and desc on change of item code in Quality Inspection
|
||||
- Show item name in item grid view based 'In List View' property
|
||||
- Validate and update manufactured qty in Stock Entry
|
||||
- Show only users with Expense Approver role in Expense Claim Approver field
|
||||
- Over Production Allowance Percentage Setting added to Manufacturing Settings
|
||||
- Activity Cost - Mandatory removed for Employee
|
||||
1
erpnext/change_log/v5/v5_0_28.md
Normal file
1
erpnext/change_log/v5/v5_0_28.md
Normal file
@@ -0,0 +1 @@
|
||||
- Open notification of Sales Order and Purchase Order based on whether Invoice is created against them. For eg. If a Sales Order is not Invoiced, it will be considered as open. Previously it was considered open if Delivery Note was created against Sales Order.
|
||||
8
erpnext/change_log/v5/v5_1_0.md
Normal file
8
erpnext/change_log/v5/v5_1_0.md
Normal file
@@ -0,0 +1,8 @@
|
||||
- Item variants is now manageable via dedicated tool **Manage Variants**. To learn about it, check [Manual Page for Item variants](https://manual.erpnext.com/contents/stock/item/item-variants)
|
||||
- Against account in General Ledger will show Party instead of Account (which is not useful)
|
||||
- Print format for recurring documents can be set by the users
|
||||
- Recurring documents won't be created for Stopped Sales / Purchase Orders.
|
||||
- Lead status will be changed to 'Opportunity' when Lead converted to Opportunity
|
||||
- Amount in Journal Entry list view
|
||||
- Currency exchange rate is now automatically fetched from fixer.io, instead of jsonrates.com
|
||||
- Item image is now available in Sales / Purchase Invoice
|
||||
3
erpnext/change_log/v5/v5_1_3.md
Normal file
3
erpnext/change_log/v5/v5_1_3.md
Normal file
@@ -0,0 +1,3 @@
|
||||
- Hide zero balance rows in batch-wise balance history report
|
||||
- Autocomplete issue fixed in Manage Variants
|
||||
- Remove user permission (Employee role) if user id is unset from Employee record
|
||||
4
erpnext/change_log/v5/v5_1_4.md
Normal file
4
erpnext/change_log/v5/v5_1_4.md
Normal file
@@ -0,0 +1,4 @@
|
||||
- Mode of Payment added to POS Profile
|
||||
- Expired Batch is not allowed in stock entry of type manufacturing / repack
|
||||
- Validate item rate against reference document with tolerance 0.009
|
||||
- Set Customer name in opportunity as per company name in lead
|
||||
8
erpnext/change_log/v5/v5_1_5.md
Normal file
8
erpnext/change_log/v5/v5_1_5.md
Normal file
@@ -0,0 +1,8 @@
|
||||
- Customer's credit days based on fixed days / last day of the next month **[Sponsored by McLean Images](http://www.mcleans.net.au)**
|
||||
- Production Order is not allowed against Item Template (for Variants)
|
||||
- Currency symbol fixed for outstanding amount and advance amount field in Sales Invoice
|
||||
- A Contact can be linked to Customer, Supplier and Sales partner at the same time
|
||||
- Validation added to prevent task being closed with open dependent tasks
|
||||
- Blocked stock transactions against an expired batch
|
||||
- Added Employees in Newsletter List
|
||||
- Link Address to Customer / Supplier / Lead, based on logged-in user, if created in portal
|
||||
9
erpnext/change_log/v5/v5_2_0.md
Normal file
9
erpnext/change_log/v5/v5_2_0.md
Normal file
@@ -0,0 +1,9 @@
|
||||
- New help videos for Selling, Buying, Human Resource, Manufacturing and Buying
|
||||
- Role rename: **Material User** is now **Stock User**
|
||||
- Role rename: **Material Manager** is now **Stock Manager**
|
||||
- Role rename: **Material Master Manager** is now **Item Manager**
|
||||
- Fixed inconsistent visibility of 'Add to Cart' button
|
||||
- Use Customer's Price List in Shopping Cart
|
||||
- Fixed Address creation from Shopping Cart
|
||||
- Display images in website's Item and Item List pages when the filename has paranthesis in its name
|
||||
|
||||
11
erpnext/change_log/v5/v5_3_0.md
Normal file
11
erpnext/change_log/v5/v5_3_0.md
Normal file
@@ -0,0 +1,11 @@
|
||||
- **Sales Return**: Create Delivery Note or Sales Invoice ('Update Stock' option checked) with negative quantity.
|
||||
- **Purchase Return**: Create Purchase Receipt with negative quantity
|
||||
- **Credit / Debit Note**: Create Sales / Purchase Invoice with negative qtuantity against original invoice.
|
||||
- Outgoing rate in Purchase Return based on reference / original Purchase Receipt rate
|
||||
- Global switch added to disable capacity planning in manufacturing settings
|
||||
- Opening Balance row added to Stock Ledger Report
|
||||
- SMS delivery message and log
|
||||
- Added users, employees, sample data via Setup Wizard
|
||||
- Letter Head option in General Ledger report
|
||||
- Fetch Template Bom if no BOM is set against Item Variant in Production Order
|
||||
- Fetch items from Packing List while raising Material Request against SO
|
||||
9
erpnext/change_log/v5/v5_4_0.md
Normal file
9
erpnext/change_log/v5/v5_4_0.md
Normal file
@@ -0,0 +1,9 @@
|
||||
- Sales / Purchase Return Enahancement - **Sponsored by [Strella Consulting Sdn Bhd](http://www.strellagroup.com)**
|
||||
* Now you can make Return entry by creating Delivery Note, Purchase Receipt or Sales / Purchase Invoice with negative quantity
|
||||
- **Item** form cleanups: "Yes" / "No" type fields changed to checkboxes.<br>
|
||||
**Warning**: This could break your 3rd party integrations with Item, if any
|
||||
- Leave Application: Consideration of **holidays** in calculation of 'Number of Days' is now optional. You can set it in Leave Type record.
|
||||
- Customer / Supplier can be **freezed** now
|
||||
- Fix: Reserved qty calculation while delivering Product Bundle via Sales Invoice
|
||||
- Fix: Deleted stock ledger entries on cancellation of Sales Invoice while Product Bundle delivered
|
||||
- Fix: Fetch default expense account and cost center from item based on selected company
|
||||
@@ -73,6 +73,11 @@ def get_data():
|
||||
"label": _("Setup"),
|
||||
"icon": "icon-cog",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Company",
|
||||
"description": _("Company (not Customer or Supplier) master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Fiscal Year",
|
||||
|
||||
@@ -42,6 +42,11 @@ def get_data():
|
||||
"name": "SMS Center",
|
||||
"description":_("Send mass SMS to your contacts"),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "SMS Log",
|
||||
"description":_("Logs for maintaining sms delivery status"),
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ def get_data():
|
||||
"type": "module"
|
||||
},
|
||||
"Learn": {
|
||||
"color": "#7272FF",
|
||||
"color": "#FCB868",
|
||||
"force_show": True,
|
||||
"icon": "icon-facetime-video",
|
||||
"type": "module",
|
||||
|
||||
@@ -60,7 +60,7 @@ def get_data():
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Salary Manager",
|
||||
"name": "Process Payroll",
|
||||
"label": _("Process Payroll"),
|
||||
"description":_("Generate Salary Slips"),
|
||||
"hide_count": True
|
||||
|
||||
@@ -15,8 +15,12 @@ def get_data():
|
||||
"type": "help",
|
||||
"label": _("Setup Wizard"),
|
||||
"youtube_id": "oIOf_zCFWKQ"
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Customizing Forms"),
|
||||
"youtube_id": "pJhL9mmxV_U"
|
||||
},
|
||||
]
|
||||
|
||||
},
|
||||
@@ -31,7 +35,7 @@ def get_data():
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Opening Stock Balance"),
|
||||
"youtube_id": "yPgrtfeCTs"
|
||||
"youtube_id": "0yPgrtfeCTs"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
@@ -93,6 +97,16 @@ def get_data():
|
||||
"label": _("Customer and Supplier"),
|
||||
"youtube_id": "anoGi_RpQ20"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Sales Order to Payment"),
|
||||
"youtube_id": "7AMq4lqkN4A"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Point-of-Sale"),
|
||||
"youtube_id": "4WkelWkbP_c"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -106,12 +120,7 @@ def get_data():
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Opening Stock Balance"),
|
||||
"youtube_id": "yPgrtfeCTs"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Item Variants"),
|
||||
"youtube_id": "OGBETlCzU5o"
|
||||
"youtube_id": "0yPgrtfeCTs"
|
||||
},
|
||||
]
|
||||
},
|
||||
@@ -123,6 +132,12 @@ def get_data():
|
||||
"label": _("Customer and Supplier"),
|
||||
"youtube_id": "anoGi_RpQ20"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Material Request to Purchase Order"),
|
||||
"youtube_id": "4TN9kPyfIqM"
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -133,6 +148,47 @@ def get_data():
|
||||
"label": _("Bill of Materials"),
|
||||
"youtube_id": "hDV0c1OeWLo"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Production Planning Tool"),
|
||||
"youtube_id": "CzatSl4zJ2Y"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Production Order"),
|
||||
"youtube_id": "ZotgLyp2YFY"
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": _("Human Resource"),
|
||||
"items": [
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Setting up Employees"),
|
||||
"youtube_id": "USfIUdZlUhw"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Leave Management"),
|
||||
"youtube_id": "fc0p_AXebc8"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Expense Claims"),
|
||||
"youtube_id": "5SZHJF--ZFY"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Projects"),
|
||||
"items": [
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Managing Projects"),
|
||||
"youtube_id": "egxIGwtoKI4"
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
@@ -103,6 +103,12 @@ def get_data():
|
||||
"name": "Completed Production Orders",
|
||||
"doctype": "Production Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "BOM Search",
|
||||
"doctype": "BOM"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -48,6 +48,11 @@ def get_data():
|
||||
"name": "SMS Center",
|
||||
"description":_("Send mass SMS to your contacts"),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "SMS Log",
|
||||
"description":_("Logs for maintaining sms delivery status"),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Newsletter",
|
||||
@@ -144,7 +149,7 @@ def get_data():
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Sales BOM",
|
||||
"name": "Product Bundle",
|
||||
"description": _("Bundle items at time of sale."),
|
||||
},
|
||||
{
|
||||
@@ -237,6 +242,12 @@ def get_data():
|
||||
"route": "query-report/Sales Person Target Variance Item Group-Wise",
|
||||
"doctype": "Sales Person",
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "BOM Search",
|
||||
"doctype": "BOM"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
|
||||
@@ -110,43 +110,7 @@ def get_data():
|
||||
"description": _("Setup SMS gateway settings")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Masters"),
|
||||
"icon": "icon-star",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Company",
|
||||
"description": _("Company (not Customer or Supplier) master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Item",
|
||||
"description": _("Item master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Customer",
|
||||
"description": _("Customer master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Supplier",
|
||||
"description": _("Supplier master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Contact",
|
||||
"description": _("Contact master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Address",
|
||||
"description": _("Address master.")
|
||||
},
|
||||
]
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
for module, label, icon in (
|
||||
|
||||
@@ -83,6 +83,11 @@ def get_data():
|
||||
"name": "Stock UOM Replace Utility",
|
||||
"description": _("Change UOM for an Item."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Manage Variants",
|
||||
"description": _("Manage Item Variants."),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -266,7 +271,7 @@ def get_data():
|
||||
{
|
||||
"type": "help",
|
||||
"label": _("Opening Stock Balance"),
|
||||
"youtube_id": "yPgrtfeCTs"
|
||||
"youtube_id": "0yPgrtfeCTs"
|
||||
},
|
||||
{
|
||||
"type": "help",
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
{
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:party_type_name",
|
||||
"creation": "2014-04-07 12:32:18.010384",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "party_type_name",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Party Type Name",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "parent_party_type",
|
||||
"fieldtype": "Link",
|
||||
"label": "Parent Party Type",
|
||||
"options": "Party Type",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"default": "Yes",
|
||||
"fieldname": "allow_children",
|
||||
"fieldtype": "Select",
|
||||
"label": "Allow Children",
|
||||
"options": "Yes\nNo",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "default_price_list",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Default Price List",
|
||||
"options": "Price List",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "lft",
|
||||
"fieldtype": "Int",
|
||||
"hidden": 1,
|
||||
"label": "LFT",
|
||||
"permlevel": 0,
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "rgt",
|
||||
"fieldtype": "Int",
|
||||
"hidden": 1,
|
||||
"label": "RGT",
|
||||
"permlevel": 0,
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "old_parent",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"label": "Old Parent",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"modified": "2015-02-05 05:11:42.046004",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Contacts",
|
||||
"name": "Party Type",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"apply_user_permissions": 1,
|
||||
"create": 1,
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Sales User",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"apply_user_permissions": 1,
|
||||
"create": 1,
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Purchase User",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -9,24 +9,34 @@ from erpnext.setup.utils import get_company_currency, get_exchange_rate
|
||||
from erpnext.accounts.utils import get_fiscal_year, validate_fiscal_year
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document
|
||||
from erpnext.controllers.sales_and_purchase_return import validate_return
|
||||
|
||||
class CustomerFrozen(frappe.ValidationError): pass
|
||||
|
||||
class AccountsController(TransactionBase):
|
||||
def validate(self):
|
||||
if self.get("_action") and self._action != "update_after_submit":
|
||||
self.set_missing_values(for_validate=True)
|
||||
self.validate_date_with_fiscal_year()
|
||||
|
||||
if self.meta.get_field("currency"):
|
||||
self.calculate_taxes_and_totals()
|
||||
self.validate_value("base_grand_total", ">=", 0)
|
||||
if not self.meta.get_field("is_return") or not self.is_return:
|
||||
self.validate_value("base_grand_total", ">=", 0)
|
||||
|
||||
validate_return(self)
|
||||
self.set_total_in_words()
|
||||
|
||||
self.validate_due_date()
|
||||
if self.doctype in ("Sales Invoice", "Purchase Invoice") and not self.is_return:
|
||||
self.validate_due_date()
|
||||
|
||||
if self.meta.get_field("is_recurring"):
|
||||
validate_recurring_document(self)
|
||||
|
||||
if self.meta.get_field("taxes_and_charges"):
|
||||
self.validate_enabled_taxes_and_charges()
|
||||
|
||||
self.validate_party()
|
||||
|
||||
def on_submit(self):
|
||||
if self.meta.get_field("is_recurring"):
|
||||
@@ -38,7 +48,8 @@ class AccountsController(TransactionBase):
|
||||
convert_to_recurring(self, self.get("posting_date") or self.get("transaction_date"))
|
||||
|
||||
def before_recurring(self):
|
||||
self.fiscal_year = None
|
||||
if self.meta.get_field("fiscal_year"):
|
||||
self.fiscal_year = None
|
||||
if self.meta.get_field("due_date"):
|
||||
self.due_date = None
|
||||
|
||||
@@ -46,7 +57,7 @@ class AccountsController(TransactionBase):
|
||||
for fieldname in ["posting_date", "transaction_date"]:
|
||||
if not self.get(fieldname) and self.meta.get_field(fieldname):
|
||||
self.set(fieldname, today())
|
||||
if not self.fiscal_year:
|
||||
if self.meta.get_field("fiscal_year") and not self.fiscal_year:
|
||||
self.fiscal_year = get_fiscal_year(self.get(fieldname))[0]
|
||||
break
|
||||
|
||||
@@ -73,6 +84,9 @@ class AccountsController(TransactionBase):
|
||||
def validate_due_date(self):
|
||||
from erpnext.accounts.party import validate_due_date
|
||||
if self.doctype == "Sales Invoice":
|
||||
if not self.due_date:
|
||||
frappe.throw(_("Due Date is mandatory"))
|
||||
|
||||
validate_due_date(self.posting_date, self.due_date, "Customer", self.customer, self.company)
|
||||
elif self.doctype == "Purchase Invoice":
|
||||
validate_due_date(self.posting_date, self.due_date, "Supplier", self.supplier, self.company)
|
||||
@@ -293,7 +307,7 @@ class AccountsController(TransactionBase):
|
||||
item_codes = list(set(item.item_code for item in self.get("items")))
|
||||
if item_codes:
|
||||
stock_items = [r[0] for r in frappe.db.sql("""select name
|
||||
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
|
||||
from `tabItem` where name in (%s) and is_stock_item=1""" % \
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
|
||||
return stock_items
|
||||
@@ -331,10 +345,27 @@ class AccountsController(TransactionBase):
|
||||
|
||||
return self._abbr
|
||||
|
||||
def validate_party(self):
|
||||
frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,'frozen_accounts_modifier')
|
||||
if frozen_accounts_modifier in frappe.get_roles():
|
||||
return
|
||||
|
||||
party_type = None
|
||||
if self.meta.get_field("customer"):
|
||||
party_type = 'Customer'
|
||||
|
||||
elif self.meta.get_field("supplier"):
|
||||
party_type = 'Supplier'
|
||||
|
||||
if party_type:
|
||||
party = self.get(party_type.lower())
|
||||
if frappe.db.get_value(party_type, party, "is_frozen"):
|
||||
frappe.throw("{0} {1} is frozen".format(party_type, party), CustomerFrozen)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_tax_rate(account_head):
|
||||
return frappe.db.get_value("Account", account_head, "tax_rate")
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_default_taxes_and_charges(master_doctype):
|
||||
default_tax = frappe.db.get_value(master_doctype, {"is_default": 1})
|
||||
|
||||
@@ -26,8 +26,7 @@ class BuyingController(StockController):
|
||||
def validate(self):
|
||||
super(BuyingController, self).validate()
|
||||
if getattr(self, "supplier", None) and not self.supplier_name:
|
||||
self.supplier_name = frappe.db.get_value("Supplier",
|
||||
self.supplier, "supplier_name")
|
||||
self.supplier_name = frappe.db.get_value("Supplier", self.supplier, "supplier_name")
|
||||
self.is_item_table_empty()
|
||||
self.set_qty_as_per_stock_uom()
|
||||
self.validate_stock_or_nonstock_items()
|
||||
@@ -239,8 +238,8 @@ class BuyingController(StockController):
|
||||
t2.rate, t2.stock_uom, t2.name, t2.description
|
||||
from `tabBOM` t1, `tabBOM Item` t2, tabItem t3
|
||||
where t2.parent = t1.name and t1.item = %s
|
||||
and t1.docstatus = 1 and t1.is_active = 1 and t1.name = %s
|
||||
and t2.item_code = t3.name and ifnull(t3.is_stock_item, 'No') = 'Yes'""", (item_code, bom), as_dict=1)
|
||||
and t1.docstatus = 1 and t1.is_active = 1 and t1.name = %s
|
||||
and t2.item_code = t3.name and t3.is_stock_item = 1""", (item_code, bom), as_dict=1)
|
||||
|
||||
if not bom_items:
|
||||
msgprint(_("Specified BOM {0} does not exist for Item {1}").format(bom, item_code), raise_exception=1)
|
||||
@@ -255,7 +254,7 @@ class BuyingController(StockController):
|
||||
self.get("items")))
|
||||
if item_codes:
|
||||
self._sub_contracted_items = [r[0] for r in frappe.db.sql("""select name
|
||||
from `tabItem` where name in (%s) and is_sub_contracted_item='Yes'""" % \
|
||||
from `tabItem` where name in (%s) and is_sub_contracted_item=1""" % \
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
|
||||
return self._sub_contracted_items
|
||||
|
||||
@@ -194,7 +194,7 @@ def bom(doctype, txt, searchfield, start, page_len, filters):
|
||||
and tabBOM.is_active=1
|
||||
and tabBOM.%(key)s like "%(txt)s"
|
||||
%(fcond)s %(mcond)s
|
||||
limit %(start)s, %(page_len)s """ % {'key': searchfield, 'txt': "%%%s%%" % txt,
|
||||
limit %(start)s, %(page_len)s """ % {'key': searchfield, 'txt': "%%%s%%" % frappe.db.escape(txt),
|
||||
'fcond': get_filters_cond(doctype, filters, conditions),
|
||||
'mcond':get_match_cond(doctype), 'start': start, 'page_len': page_len})
|
||||
|
||||
@@ -207,7 +207,7 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters):
|
||||
where `tabProject`.status not in ("Completed", "Cancelled")
|
||||
and %(cond)s `tabProject`.name like "%(txt)s" %(mcond)s
|
||||
order by `tabProject`.name asc
|
||||
limit %(start)s, %(page_len)s """ % {'cond': cond,'txt': "%%%s%%" % txt,
|
||||
limit %(start)s, %(page_len)s """ % {'cond': cond,'txt': "%%%s%%" % frappe.db.escape(txt),
|
||||
'mcond':get_match_cond(doctype),'start': start, 'page_len': page_len})
|
||||
|
||||
def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
|
||||
@@ -229,9 +229,10 @@ def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len,
|
||||
}, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
|
||||
|
||||
def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
||||
if not filters.get("posting_date"):
|
||||
filters["posting_date"] = nowdate()
|
||||
|
||||
cond = ""
|
||||
if filters.get("posting_date"):
|
||||
cond = "and (ifnull(batch.expiry_date, '')='' or batch.expiry_date >= %(posting_date)s)"
|
||||
|
||||
batch_nos = None
|
||||
args = {
|
||||
'item_code': filters.get("item_code"),
|
||||
@@ -251,23 +252,23 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
||||
and sle.warehouse = %(warehouse)s
|
||||
and sle.batch_no like %(txt)s
|
||||
and batch.docstatus < 2
|
||||
and (ifnull(batch.expiry_date, '')='' or batch.expiry_date >= %(posting_date)s)
|
||||
{0}
|
||||
{match_conditions}
|
||||
group by batch_no having sum(sle.actual_qty) > 0
|
||||
order by batch.expiry_date, sle.batch_no desc
|
||||
limit %(start)s, %(page_len)s""".format(match_conditions=get_match_cond(doctype)), args)
|
||||
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args)
|
||||
|
||||
if batch_nos:
|
||||
return batch_nos
|
||||
else:
|
||||
return frappe.db.sql("""select name, expiry_date from `tabBatch`
|
||||
return frappe.db.sql("""select name, expiry_date from `tabBatch` batch
|
||||
where item = %(item_code)s
|
||||
and name like %(txt)s
|
||||
and docstatus < 2
|
||||
and (ifnull(expiry_date, '')='' or expiry_date >= %(posting_date)s)
|
||||
{0}
|
||||
{match_conditions}
|
||||
order by expiry_date, name desc
|
||||
limit %(start)s, %(page_len)s""".format(match_conditions=get_match_cond(doctype)), args)
|
||||
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args, debug=1)
|
||||
|
||||
def get_account_list(doctype, txt, searchfield, start, page_len, filters):
|
||||
filter_list = []
|
||||
|
||||
@@ -33,11 +33,13 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
|
||||
next_date = next_date or nowdate()
|
||||
|
||||
date_field = date_field_map[doctype]
|
||||
|
||||
condition = " and ifnull(status, '') != 'Stopped'" if doctype in ("Sales Order", "Purchase Order") else ""
|
||||
|
||||
recurring_documents = frappe.db.sql("""select name, recurring_id
|
||||
from `tab{}` where ifnull(is_recurring, 0)=1
|
||||
and docstatus=1 and next_date='{}'
|
||||
and next_date <= ifnull(end_date, '2199-12-31')""".format(doctype, next_date))
|
||||
from `tab{0}` where ifnull(is_recurring, 0)=1
|
||||
and docstatus=1 and next_date=%s
|
||||
and next_date <= ifnull(end_date, '2199-12-31') {1}""".format(doctype, condition), next_date)
|
||||
|
||||
exception_list = []
|
||||
for ref_document, recurring_id in recurring_documents:
|
||||
@@ -124,7 +126,7 @@ def send_notification(new_rv):
|
||||
frappe.sendmail(new_rv.notification_email_address,
|
||||
subject= _("New {0}: #{1}").format(new_rv.doctype, new_rv.name),
|
||||
message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name),
|
||||
attachments = [frappe.attach_print(new_rv.doctype, new_rv.name, file_name=new_rv.name)])
|
||||
attachments = [frappe.attach_print(new_rv.doctype, new_rv.name, file_name=new_rv.name, print_format=new_rv.recurring_print_format)])
|
||||
|
||||
def notify_errors(doc, doctype, party, owner):
|
||||
from frappe.utils.user import get_system_managers
|
||||
|
||||
145
erpnext/controllers/sales_and_purchase_return.py
Normal file
145
erpnext/controllers/sales_and_purchase_return.py
Normal file
@@ -0,0 +1,145 @@
|
||||
# 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
|
||||
from frappe import _
|
||||
from frappe.utils import flt, get_datetime, format_datetime
|
||||
|
||||
class StockOverReturnError(frappe.ValidationError): pass
|
||||
|
||||
|
||||
def validate_return(doc):
|
||||
if not doc.meta.get_field("is_return") or not doc.is_return:
|
||||
return
|
||||
|
||||
validate_return_against(doc)
|
||||
validate_returned_items(doc)
|
||||
|
||||
def validate_return_against(doc):
|
||||
if not doc.return_against:
|
||||
frappe.throw(_("{0} is mandatory for Return").format(doc.meta.get_label("return_against")))
|
||||
else:
|
||||
filters = {"doctype": doc.doctype, "docstatus": 1, "company": doc.company}
|
||||
if doc.meta.get_field("customer"):
|
||||
filters["customer"] = doc.customer
|
||||
elif doc.meta.get_field("supplier"):
|
||||
filters["supplier"] = doc.supplier
|
||||
|
||||
if not frappe.db.exists(filters):
|
||||
frappe.throw(_("Invalid {0}: {1}")
|
||||
.format(doc.meta.get_label("return_against"), doc.return_against))
|
||||
else:
|
||||
ref_doc = frappe.get_doc(doc.doctype, doc.return_against)
|
||||
|
||||
# validate posting date time
|
||||
return_posting_datetime = "%s %s" % (doc.posting_date, doc.get("posting_time") or "00:00:00")
|
||||
ref_posting_datetime = "%s %s" % (ref_doc.posting_date, ref_doc.get("posting_time") or "00:00:00")
|
||||
|
||||
if get_datetime(return_posting_datetime) < get_datetime(ref_posting_datetime):
|
||||
frappe.throw(_("Posting timestamp must be after {0}").format(format_datetime(ref_posting_datetime)))
|
||||
|
||||
# validate same exchange rate
|
||||
if doc.conversion_rate != ref_doc.conversion_rate:
|
||||
frappe.throw(_("Exchange Rate must be same as {0} {1} ({2})")
|
||||
.format(doc.doctype, doc.return_against, ref_doc.conversion_rate))
|
||||
|
||||
# validate update stock
|
||||
if doc.doctype == "Sales Invoice" and doc.update_stock and not ref_doc.update_stock:
|
||||
frappe.throw(_("'Update Stock' can not be checked because items are not delivered via {0}")
|
||||
.format(doc.return_against))
|
||||
|
||||
def validate_returned_items(doc):
|
||||
valid_items = frappe._dict()
|
||||
for d in frappe.db.sql("""select item_code, sum(qty) as qty, rate from `tab{0} Item`
|
||||
where parent = %s group by item_code""".format(doc.doctype), doc.return_against, as_dict=1):
|
||||
valid_items.setdefault(d.item_code, d)
|
||||
|
||||
if doc.doctype in ("Delivery Note", "Sales Invoice"):
|
||||
for d in frappe.db.sql("""select item_code, sum(qty) as qty from `tabPacked Item`
|
||||
where parent = %s group by item_code""".format(doc.doctype), doc.return_against, as_dict=1):
|
||||
valid_items.setdefault(d.item_code, d)
|
||||
|
||||
already_returned_items = get_already_returned_items(doc)
|
||||
|
||||
items_returned = False
|
||||
for d in doc.get("items"):
|
||||
if flt(d.qty) < 0:
|
||||
if d.item_code not in valid_items:
|
||||
frappe.throw(_("Row # {0}: Returned Item {1} does not exists in {2} {3}")
|
||||
.format(d.idx, d.item_code, doc.doctype, doc.return_against))
|
||||
else:
|
||||
ref = valid_items.get(d.item_code, frappe._dict())
|
||||
already_returned_qty = flt(already_returned_items.get(d.item_code))
|
||||
max_return_qty = flt(ref.qty) - already_returned_qty
|
||||
|
||||
if already_returned_qty >= ref.qty:
|
||||
frappe.throw(_("Item {0} has already been returned").format(d.item_code), StockOverReturnError)
|
||||
elif abs(d.qty) > max_return_qty:
|
||||
frappe.throw(_("Row # {0}: Cannot return more than {1} for Item {2}")
|
||||
.format(d.idx, ref.qty, d.item_code), StockOverReturnError)
|
||||
elif ref.rate and flt(d.rate) != ref.rate:
|
||||
frappe.throw(_("Row # {0}: Rate must be same as {1} {2}")
|
||||
.format(d.idx, doc.doctype, doc.return_against))
|
||||
|
||||
|
||||
items_returned = True
|
||||
|
||||
if not items_returned:
|
||||
frappe.throw(_("Atleast one item should be entered with negative quantity in return document"))
|
||||
|
||||
def get_already_returned_items(doc):
|
||||
return frappe._dict(frappe.db.sql("""
|
||||
select
|
||||
child.item_code, sum(abs(child.qty)) as qty
|
||||
from
|
||||
`tab{0} Item` child, `tab{1}` par
|
||||
where
|
||||
child.parent = par.name and par.docstatus = 1
|
||||
and ifnull(par.is_return, 0) = 1 and par.return_against = %s and child.qty < 0
|
||||
group by item_code
|
||||
""".format(doc.doctype, doc.doctype), doc.return_against))
|
||||
|
||||
def make_return_doc(doctype, source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
def set_missing_values(source, target):
|
||||
doc = frappe.get_doc(target)
|
||||
doc.is_return = 1
|
||||
doc.return_against = source.name
|
||||
doc.ignore_pricing_rule = 1
|
||||
if doctype == "Sales Invoice":
|
||||
doc.is_pos = 0
|
||||
|
||||
for tax in doc.get("taxes"):
|
||||
if tax.charge_type == "Actual":
|
||||
tax.tax_amount = -1 * tax.tax_amount
|
||||
|
||||
doc.run_method("calculate_taxes_and_totals")
|
||||
|
||||
def update_item(source_doc, target_doc, source_parent):
|
||||
target_doc.qty = -1* source_doc.qty
|
||||
if doctype == "Purchase Receipt":
|
||||
target_doc.received_qty = -1* source_doc.qty
|
||||
elif doctype == "Purchase Invoice":
|
||||
target_doc.purchase_receipt = source_doc.purchase_receipt
|
||||
target_doc.pr_detail = source_doc.pr_detail
|
||||
|
||||
doclist = get_mapped_doc(doctype, source_name, {
|
||||
doctype: {
|
||||
"doctype": doctype,
|
||||
|
||||
"validation": {
|
||||
"docstatus": ["=", 1],
|
||||
}
|
||||
},
|
||||
doctype +" Item": {
|
||||
"doctype": doctype + " Item",
|
||||
"fields": {
|
||||
"purchase_order": "purchase_order",
|
||||
"purchase_receipt": "purchase_receipt"
|
||||
},
|
||||
"postprocess": update_item
|
||||
},
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
return doclist
|
||||
@@ -110,15 +110,14 @@ class SellingController(StockController):
|
||||
from frappe.utils import money_in_words
|
||||
company_currency = get_company_currency(self.company)
|
||||
|
||||
disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None,
|
||||
"disable_rounded_total"))
|
||||
disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total"))
|
||||
|
||||
if self.meta.get_field("base_in_words"):
|
||||
self.base_in_words = money_in_words(disable_rounded_total and
|
||||
self.base_grand_total or self.base_rounded_total, company_currency)
|
||||
abs(self.base_grand_total) or abs(self.base_rounded_total), company_currency)
|
||||
if self.meta.get_field("in_words"):
|
||||
self.in_words = money_in_words(disable_rounded_total and
|
||||
self.grand_total or self.rounded_total, self.currency)
|
||||
abs(self.grand_total) or abs(self.rounded_total), self.currency)
|
||||
|
||||
def calculate_commission(self):
|
||||
if self.meta.get_field("commission_rate"):
|
||||
@@ -171,19 +170,18 @@ class SellingController(StockController):
|
||||
frappe.throw(_("Row {0}: Qty is mandatory").format(d.idx))
|
||||
|
||||
if self.doctype == "Sales Order":
|
||||
if (frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes' or
|
||||
self.has_sales_bom(d.item_code)) and not d.warehouse:
|
||||
frappe.throw(_("Reserved Warehouse required for stock Item {0} in row {1}").format(d.item_code, d.idx))
|
||||
reserved_warehouse = d.warehouse
|
||||
if flt(d.qty) > flt(d.delivered_qty):
|
||||
reserved_qty_for_main_item = flt(d.qty) - flt(d.delivered_qty)
|
||||
|
||||
elif self.doctype == "Delivery Note" and d.against_sales_order:
|
||||
elif (((self.doctype == "Delivery Note" and d.against_sales_order)
|
||||
or (self.doctype == "Sales Invoice" and d.sales_order and self.update_stock))
|
||||
and not self.is_return):
|
||||
# if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
|
||||
# But in this case reserved qty should only be reduced by 10 and not 12
|
||||
|
||||
already_delivered_qty = self.get_already_delivered_qty(self.name,
|
||||
d.against_sales_order, d.so_detail)
|
||||
d.against_sales_order if self.doctype=="Delivery Note" else d.sales_order, d.so_detail)
|
||||
so_qty, reserved_warehouse = self.get_so_qty_and_warehouse(d.so_detail)
|
||||
|
||||
if already_delivered_qty + d.qty > so_qty:
|
||||
@@ -191,7 +189,7 @@ class SellingController(StockController):
|
||||
else:
|
||||
reserved_qty_for_main_item = -flt(d.qty)
|
||||
|
||||
if self.has_sales_bom(d.item_code):
|
||||
if self.has_product_bundle(d.item_code):
|
||||
for p in self.get("packed_items"):
|
||||
if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
|
||||
# the packing details table's qty is already multiplied with parent's qty
|
||||
@@ -214,23 +212,32 @@ class SellingController(StockController):
|
||||
'qty': d.qty,
|
||||
'reserved_qty': reserved_qty_for_main_item,
|
||||
'uom': d.stock_uom,
|
||||
'stock_uom': d.stock_uom,
|
||||
'stock_uom': d.stock_uom,
|
||||
'batch_no': cstr(d.get("batch_no")).strip(),
|
||||
'serial_no': cstr(d.get("serial_no")).strip(),
|
||||
'name': d.name
|
||||
}))
|
||||
return il
|
||||
|
||||
def has_sales_bom(self, item_code):
|
||||
return frappe.db.sql("""select name from `tabSales BOM`
|
||||
def has_product_bundle(self, item_code):
|
||||
return frappe.db.sql("""select name from `tabProduct Bundle`
|
||||
where new_item_code=%s and docstatus != 2""", item_code)
|
||||
|
||||
def get_already_delivered_qty(self, dn, so, so_detail):
|
||||
qty = frappe.db.sql("""select sum(qty) from `tabDelivery Note Item`
|
||||
def get_already_delivered_qty(self, current_docname, so, so_detail):
|
||||
delivered_via_dn = frappe.db.sql("""select sum(qty) from `tabDelivery Note Item`
|
||||
where so_detail = %s and docstatus = 1
|
||||
and against_sales_order = %s
|
||||
and parent != %s""", (so_detail, so, dn))
|
||||
return qty and flt(qty[0][0]) or 0.0
|
||||
and parent != %s""", (so_detail, so, current_docname))
|
||||
|
||||
delivered_via_si = frappe.db.sql("""select sum(qty) from `tabSales Invoice Item`
|
||||
where so_detail = %s and docstatus = 1
|
||||
and sales_order = %s
|
||||
and parent != %s""", (so_detail, so, current_docname))
|
||||
|
||||
total_delivered_qty = (flt(delivered_via_dn[0][0]) if delivered_via_dn else 0) \
|
||||
+ (flt(delivered_via_si[0][0]) if delivered_via_si else 0)
|
||||
|
||||
return total_delivered_qty
|
||||
|
||||
def get_so_qty_and_warehouse(self, so_detail):
|
||||
so_item = frappe.db.sql("""select qty, warehouse from `tabSales Order Item`
|
||||
@@ -252,7 +259,7 @@ def check_active_sales_items(obj):
|
||||
item = frappe.db.sql("""select docstatus, is_sales_item,
|
||||
is_service_item, income_account from tabItem where name = %s""",
|
||||
d.item_code, as_dict=True)[0]
|
||||
if item.is_sales_item == 'No' and item.is_service_item == 'No':
|
||||
if item.is_sales_item == 0 and item.is_service_item == 0:
|
||||
frappe.throw(_("Item {0} must be Sales or Service Item in {1}").format(d.item_code, d.idx))
|
||||
if getattr(d, "income_account", None) and not item.income_account:
|
||||
frappe.db.set_value("Item", d.item_code, "income_account",
|
||||
|
||||
@@ -78,7 +78,7 @@ class StatusUpdater(Document):
|
||||
self.status = s[0]
|
||||
break
|
||||
|
||||
if self.status != _status:
|
||||
if self.status != _status and self.status not in ("Submitted", "Cancelled"):
|
||||
self.add_comment("Label", _(self.status))
|
||||
|
||||
if update:
|
||||
|
||||
@@ -9,6 +9,8 @@ import frappe.defaults
|
||||
|
||||
from erpnext.controllers.accounts_controller import AccountsController
|
||||
from erpnext.accounts.general_ledger import make_gl_entries, delete_gl_entries, process_gl_map
|
||||
from erpnext.stock.utils import update_bin
|
||||
|
||||
|
||||
class StockController(AccountsController):
|
||||
def make_gl_entries(self, repost_future_gle=True):
|
||||
@@ -212,10 +214,38 @@ class StockController(AccountsController):
|
||||
item_codes = list(set([d.item_code for d in self.get("items")]))
|
||||
if item_codes:
|
||||
serialized_items = frappe.db.sql_list("""select name from `tabItem`
|
||||
where has_serial_no='Yes' and name in ({})""".format(", ".join(["%s"]*len(item_codes))),
|
||||
where has_serial_no=1 and name in ({})""".format(", ".join(["%s"]*len(item_codes))),
|
||||
tuple(item_codes))
|
||||
|
||||
return serialized_items
|
||||
|
||||
def get_incoming_rate_for_sales_return(self, item_code, against_document):
|
||||
incoming_rate = 0.0
|
||||
if against_document and item_code:
|
||||
incoming_rate = frappe.db.sql("""select abs(ifnull(stock_value_difference, 0) / actual_qty)
|
||||
from `tabStock Ledger Entry`
|
||||
where voucher_type = %s and voucher_no = %s and item_code = %s limit 1""",
|
||||
(self.doctype, against_document, item_code))
|
||||
incoming_rate = incoming_rate[0][0] if incoming_rate else 0.0
|
||||
|
||||
return incoming_rate
|
||||
|
||||
def update_reserved_qty(self, d):
|
||||
if d['reserved_qty'] < 0 :
|
||||
# Reduce reserved qty from reserved warehouse mentioned in so
|
||||
if not d["reserved_warehouse"]:
|
||||
frappe.throw(_("Reserved Warehouse is missing in Sales Order"))
|
||||
|
||||
args = {
|
||||
"item_code": d['item_code'],
|
||||
"warehouse": d["reserved_warehouse"],
|
||||
"voucher_type": self.doctype,
|
||||
"voucher_no": self.name,
|
||||
"reserved_qty": (self.docstatus==1 and 1 or -1)*flt(d['reserved_qty']),
|
||||
"posting_date": self.posting_date,
|
||||
"is_amended": self.amended_from and 'Yes' or 'No'
|
||||
}
|
||||
update_bin(args)
|
||||
|
||||
def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for_items=None,
|
||||
warehouse_account=None):
|
||||
|
||||
@@ -396,13 +396,15 @@ class calculate_taxes_and_totals(object):
|
||||
# total_advance is only for non POS Invoice
|
||||
|
||||
if self.doc.doctype == "Sales Invoice":
|
||||
self.doc.round_floats_in(self.doc, ["base_grand_total", "total_advance", "write_off_amount", "paid_amount"])
|
||||
total_amount_to_pay = self.doc.base_grand_total - self.doc.write_off_amount
|
||||
self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount,
|
||||
self.doc.precision("outstanding_amount"))
|
||||
if not self.doc.is_return:
|
||||
self.doc.round_floats_in(self.doc, ["base_grand_total", "total_advance", "write_off_amount", "paid_amount"])
|
||||
total_amount_to_pay = self.doc.base_grand_total - self.doc.write_off_amount
|
||||
self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount,
|
||||
self.doc.precision("outstanding_amount"))
|
||||
else:
|
||||
self.doc.round_floats_in(self.doc, ["total_advance", "write_off_amount"])
|
||||
self.doc.total_amount_to_pay = flt(self.doc.base_grand_total - self.doc.write_off_amount,
|
||||
self.doc.precision("total_amount_to_pay"))
|
||||
self.doc.outstanding_amount = flt(self.doc.total_amount_to_pay - self.doc.total_advance,
|
||||
self.doc.precision("outstanding_amount"))
|
||||
if not self.doc.is_return:
|
||||
self.doc.outstanding_amount = flt(self.doc.total_amount_to_pay - self.doc.total_advance,
|
||||
self.doc.precision("outstanding_amount"))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user