Skip to content

Commit 144ecee

Browse files
authored
Update Master (#27)
Update Master
2 parents fd833da + 45901f2 commit 144ecee

23 files changed

Lines changed: 1377 additions & 70 deletions

bloomstack_core/bloomstack_core/doctype/compliance_info/compliance_info.json

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"allow_copy": 0,
33
"allow_events_in_timeline": 0,
44
"allow_guest_to_view": 0,
5-
"allow_import": 0,
5+
"allow_import": 1,
66
"allow_rename": 0,
77
"autoname": "",
88
"beta": 0,
@@ -48,6 +48,38 @@
4848
"translatable": 0,
4949
"unique": 0
5050
},
51+
{
52+
"allow_bulk_edit": 0,
53+
"allow_in_quick_entry": 0,
54+
"allow_on_submit": 0,
55+
"bold": 0,
56+
"collapsible": 0,
57+
"columns": 0,
58+
"fetch_if_empty": 0,
59+
"fieldname": "cb_entity",
60+
"fieldtype": "Column Break",
61+
"hidden": 0,
62+
"ignore_user_permissions": 0,
63+
"ignore_xss_filter": 0,
64+
"in_filter": 0,
65+
"in_global_search": 0,
66+
"in_list_view": 0,
67+
"in_standard_filter": 0,
68+
"length": 0,
69+
"no_copy": 0,
70+
"permlevel": 0,
71+
"precision": "",
72+
"print_hide": 0,
73+
"print_hide_if_no_value": 0,
74+
"read_only": 0,
75+
"remember_last_selected_value": 0,
76+
"report_hide": 0,
77+
"reqd": 0,
78+
"search_index": 0,
79+
"set_only_once": 0,
80+
"translatable": 0,
81+
"unique": 0
82+
},
5183
{
5284
"allow_bulk_edit": 0,
5385
"allow_in_quick_entry": 0,
@@ -190,7 +222,7 @@
190222
"collapsible": 0,
191223
"columns": 0,
192224
"fetch_if_empty": 0,
193-
"fieldname": "column_break_3",
225+
"fieldname": "cb_compliance",
194226
"fieldtype": "Column Break",
195227
"hidden": 0,
196228
"ignore_user_permissions": 0,
@@ -291,7 +323,7 @@
291323
"issingle": 0,
292324
"istable": 0,
293325
"max_attachments": 0,
294-
"modified": "2019-05-02 03:04:22.955723",
326+
"modified": "2019-05-31 00:33:10.835703",
295327
"modified_by": "Administrator",
296328
"module": "Bloomstack Core",
297329
"name": "Compliance Info",

bloomstack_core/bloomstack_core/report/__init__.py

Whitespace-only changes.

bloomstack_core/bloomstack_core/report/address_and_contacts/__init__.py

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2019, Bloom Stack and contributors
2+
// For license information, please see license.txt
3+
/* eslint-disable */
4+
5+
frappe.query_reports["Address And Contacts"] = {
6+
filters: [
7+
{
8+
reqd: 1,
9+
fieldname: "party_type",
10+
label: __("Party Type"),
11+
fieldtype: "Link",
12+
options: "DocType",
13+
get_query: () => {
14+
return {
15+
filters: {
16+
"name": ["in", ["Customer", "Supplier", "Sales Partner"]],
17+
}
18+
}
19+
}
20+
},
21+
{
22+
fieldname: "party_name",
23+
label: __("Party Name"),
24+
fieldtype: "Dynamic Link",
25+
get_options: () => {
26+
let party_type = frappe.query_report.get_filter_value('party_type');
27+
if (!party_type) {
28+
frappe.throw(__("Please select Party Type first"));
29+
}
30+
return party_type;
31+
}
32+
}
33+
]
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"add_total_row": 0,
3+
"creation": "2018-06-01 09:32:13.088771",
4+
"disable_prepared_report": 0,
5+
"disabled": 0,
6+
"docstatus": 0,
7+
"doctype": "Report",
8+
"idx": 0,
9+
"is_standard": "Yes",
10+
"letter_head": "Test",
11+
"modified": "2019-05-13 23:28:25.549924",
12+
"modified_by": "Administrator",
13+
"module": "Bloomstack Core",
14+
"name": "Address And Contacts",
15+
"owner": "Administrator",
16+
"prepared_report": 0,
17+
"ref_doctype": "Address",
18+
"report_name": "Address And Contacts",
19+
"report_type": "Script Report",
20+
"roles": [
21+
{
22+
"role": "Sales User"
23+
},
24+
{
25+
"role": "Purchase User"
26+
},
27+
{
28+
"role": "Maintenance User"
29+
},
30+
{
31+
"role": "Accounts User"
32+
}
33+
]
34+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Copyright (c) 2019, Bloom Stack and contributors
2+
# For license information, please see license.txt
3+
4+
from __future__ import unicode_literals
5+
6+
from six import iteritems
7+
from six.moves import range
8+
9+
import frappe
10+
11+
field_map = {
12+
"Contact": ["first_name", "last_name", "phone", "mobile_no", "email_id", "is_primary_contact"],
13+
"Address": ["address_line1", "address_line2", "city", "state", "pincode", "country", "is_primary_address"]
14+
}
15+
16+
17+
def execute(filters=None):
18+
columns = get_columns(filters)
19+
data = get_data(filters)
20+
21+
return columns, data
22+
23+
24+
def get_party_group(party_type):
25+
if not party_type:
26+
return
27+
28+
group = {
29+
"Customer": "customer_group",
30+
"Supplier": "supplier_group",
31+
"Sales Partner": "partner_type"
32+
}
33+
34+
return group[party_type]
35+
36+
37+
def get_columns(filters):
38+
party_type = filters.get("party_type")
39+
party_group = get_party_group(party_type)
40+
41+
columns = [
42+
"{0}:Link/{0}".format(party_type),
43+
"{0}::150".format(frappe.unscrub(str(party_group)))
44+
]
45+
46+
if party_type == "Customer":
47+
columns.extend([
48+
"Territory",
49+
"Sales Partner"
50+
])
51+
52+
if party_type in ("Customer", "Supplier"):
53+
columns.extend([
54+
"License Type",
55+
"License Number",
56+
"Seller Permit"
57+
])
58+
59+
columns.extend([
60+
"Address Line 1",
61+
"Address Line 2",
62+
"City",
63+
"State",
64+
"Postal Code",
65+
"Country",
66+
"Is Primary Address:Check",
67+
"First Name",
68+
"Last Name",
69+
"Phone",
70+
"Mobile No",
71+
"Email Id",
72+
"Is Primary Contact:Check"
73+
])
74+
75+
return columns
76+
77+
78+
def get_data(filters):
79+
party_type = filters.get("party_type")
80+
party = filters.get("party_name")
81+
party_group = get_party_group(party_type)
82+
83+
return get_party_addresses_and_contact(party_type, party, party_group)
84+
85+
86+
def get_party_details(party_type, party_list, party_details):
87+
for doctype in ("Contact", "Address"):
88+
filters = [
89+
["Dynamic Link", "link_doctype", "=", party_type],
90+
["Dynamic Link", "link_name", "in", party_list]
91+
]
92+
fields = ["`tabDynamic Link`.link_name"] + field_map.get(doctype, [])
93+
94+
records = frappe.get_list(doctype, filters=filters, fields=fields, as_list=True)
95+
96+
for d in records:
97+
details = party_details.get(d[0])
98+
details.setdefault(frappe.scrub(doctype), []).append(d[1:])
99+
100+
return party_details
101+
102+
103+
def add_blank_columns_for(doctype):
104+
return [None for field in field_map.get(doctype, [])]
105+
106+
107+
def get_party_addresses_and_contact(party_type, party, party_group):
108+
data = []
109+
110+
# Build party details
111+
party_details = frappe._dict()
112+
113+
if not party_type:
114+
return []
115+
116+
filters = {"name": party} if party else None
117+
118+
party_list = frappe.get_list(party_type, filters=filters, fields=["name", party_group])
119+
party_names = [d.get("name") for d in party_list]
120+
party_groups = {d.get("name"): d.get(party_group) for d in party_list}
121+
122+
for d in party_names:
123+
party_details.setdefault(d, frappe._dict())
124+
125+
party_details = get_party_details(party_type, party_names, party_details)
126+
127+
# Add a row for each party address and contact, along with party details
128+
for party, details in iteritems(party_details):
129+
territory = sales_partner = license_type = license_number = seller_permit = None
130+
131+
if party_type == "Customer":
132+
territory = frappe.db.get_value(party_type, party, "territory")
133+
sales_partner = frappe.db.get_value(party_type, party, "default_sales_partner")
134+
135+
if party_type in ("Customer", "Supplier"):
136+
if frappe.db.exists("Compliance Info", {"entity_type": party_type, "entity": party}):
137+
license_type, license_number, seller_permit = frappe.db.get_value("Compliance Info",
138+
{"entity_type": party_type, "entity": party},
139+
["license_type", "license_number", "seller_permit"])
140+
141+
# If no addresses and contacts exist, add a single row to display the party
142+
addresses = details.get("address", [])
143+
contacts = details.get("contact", [])
144+
max_length = max(len(addresses), len(contacts), 1)
145+
146+
for idx in range(max_length):
147+
result = [party]
148+
result.append(party_groups.get(party))
149+
150+
if party_type == "Customer":
151+
result.extend([territory, sales_partner])
152+
153+
if party_type in ("Customer", "Supplier"):
154+
result.extend([license_type, license_number, seller_permit])
155+
156+
address = addresses[idx] if idx < len(addresses) else add_blank_columns_for("Address")
157+
contact = contacts[idx] if idx < len(contacts) else add_blank_columns_for("Contact")
158+
159+
result.extend(address)
160+
result.extend(contact)
161+
data.append(result)
162+
163+
return data

bloomstack_core/compliance/doctype/__init__.py

Whitespace-only changes.

bloomstack_core/compliance/doctype/waste_disposal/__init__.py

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* eslint-disable */
2+
// rename this file from _test_[name] to test_[name] to activate
3+
// and remove above this line
4+
5+
QUnit.test("test: Waste Disposal", function (assert) {
6+
let done = assert.async();
7+
8+
// number of asserts
9+
assert.expect(1);
10+
11+
frappe.run_serially([
12+
// insert a new Waste Disposal
13+
() => frappe.tests.make('Waste Disposal', [
14+
// values to be set
15+
{key: 'value'}
16+
]),
17+
() => {
18+
assert.equal(cur_frm.doc.key, 'value');
19+
},
20+
() => done()
21+
]);
22+
23+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (c) 2019, Bloom Stack, Inc and Contributors
3+
# See license.txt
4+
from __future__ import unicode_literals
5+
6+
import unittest
7+
8+
9+
class TestWasteDisposal(unittest.TestCase):
10+
pass

0 commit comments

Comments
 (0)