@@ -1,7 +1,7 @@ | |||
import frappe | |||
import xhiveframework | |||
import json | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def change_contract_status(doc, status): | |||
""" | |||
Validates if property already on rent between the from and to dates | |||
@@ -9,11 +9,11 @@ def change_contract_status(doc, status): | |||
doc = json.loads(doc) | |||
if status == "Hold": | |||
doc = frappe.get_doc("Property Contract", doc["name"]) | |||
doc = xhiveframework.get_doc("Property Contract", doc["name"]) | |||
doc.status = status | |||
doc.save() | |||
unit_doc = frappe.get_doc("Unit", doc.unit) | |||
unit_doc = xhiveframework.get_doc("Unit", doc.unit) | |||
unit_doc.status = "Vacant" | |||
unit_doc.save() | |||
return | |||
@@ -25,13 +25,13 @@ def change_contract_status(doc, status): | |||
"unit_name": doc["unit_name"], | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields = ["name"], | |||
filters = filters) | |||
if len(property_contract)> 0: | |||
frappe.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
xhiveframework.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
# Get Property Contaract if to date is between new from and new to date | |||
@@ -41,13 +41,13 @@ def change_contract_status(doc, status): | |||
"unit_name": doc["unit_name"], | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields = ["name"], | |||
filters = filters) | |||
if len(property_contract)> 0: | |||
frappe.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
xhiveframework.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
# Get Property Contaract if from date is after new from date and to date is before new to date | |||
@@ -58,19 +58,19 @@ def change_contract_status(doc, status): | |||
"unit_name": doc["unit_name"], | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields = ["name"], | |||
filters = filters) | |||
if len(property_contract)> 0: | |||
frappe.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
xhiveframework.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
doc = frappe.get_doc("Property Contract", doc["name"]) | |||
doc = xhiveframework.get_doc("Property Contract", doc["name"]) | |||
doc.status = status | |||
doc.save() | |||
unit_doc = frappe.get_doc("Unit", doc.unit_name) | |||
unit_doc = xhiveframework.get_doc("Unit", doc.unit_name) | |||
unit_doc.status = "Leased" | |||
unit_doc.save() |
@@ -1,17 +1,17 @@ | |||
import frappe | |||
import xhiveframework | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def get_tiles_data(): | |||
''' | |||
function will use to get property dashboard's tiles data | |||
''' | |||
properties = frappe.db.count("Property") | |||
units = frappe.db.count("Unit") | |||
sold_units = frappe.db.count("Unit", {"status": "Sold"}) | |||
rented_units = frappe.db.count("Unit", {"status": "Rented"}) | |||
available_units = frappe.db.count("Unit", {"status": "Available"}) | |||
properties = xhiveframework.db.count("Property") | |||
units = xhiveframework.db.count("Unit") | |||
sold_units = xhiveframework.db.count("Unit", {"status": "Sold"}) | |||
rented_units = xhiveframework.db.count("Unit", {"status": "Rented"}) | |||
available_units = xhiveframework.db.count("Unit", {"status": "Available"}) | |||
data = { | |||
"total_property": properties, | |||
@@ -1,6 +1,6 @@ | |||
# -*- coding: utf-8 -*- | |||
from __future__ import unicode_literals | |||
from frappe import _ | |||
from xhiveframework import _ | |||
def get_data(): | |||
return [ | |||
@@ -1,5 +1,5 @@ | |||
from __future__ import unicode_literals | |||
from frappe import _ | |||
from xhiveframework import _ | |||
def get_data(): | |||
@@ -66,7 +66,7 @@ def get_data(): | |||
"type": "doctype", | |||
"name": "Property Type", | |||
"onboard": 1 | |||
}, | |||
}, | |||
{ | |||
"type": "doctype", | |||
"name": "Unit Activity", | |||
@@ -1,25 +1,25 @@ | |||
import frappe | |||
import xhiveframework | |||
def submit(doc, method): | |||
if hasattr(doc, 'property') and doc.property: | |||
prop = frappe.get_doc('Property', doc.property) | |||
prop = xhiveframework.get_doc('Property', doc.property) | |||
prop.customer = doc.customer | |||
prop.customer_name = doc.customer_name | |||
prop.save() | |||
if hasattr(doc, 'unit') and doc.unit: | |||
unit = frappe.get_doc('Unit', doc.unit) | |||
unit = xhiveframework.get_doc('Unit', doc.unit) | |||
unit.customer = doc.customer | |||
unit.customer_name = doc.customer_name | |||
unit.save() | |||
def cancel(doc, method): | |||
if hasattr(doc, 'property') and doc.property: | |||
prop = frappe.get_doc('Property', doc.property) | |||
prop = xhiveframework.get_doc('Property', doc.property) | |||
prop.customer = None | |||
prop.customer_name = None | |||
prop.save() | |||
if hasattr(doc, 'unit') and doc.unit: | |||
unit = frappe.get_doc('Unit', doc.unit) | |||
unit = xhiveframework.get_doc('Unit', doc.unit) | |||
unit.customer = None | |||
unit.customer_name = None | |||
unit.save() | |||
unit.save() |
@@ -62,7 +62,7 @@ doctype_js = { | |||
# Desk Notifications | |||
# ------------------ | |||
# See frappe.core.notifications.get_notification_config | |||
# See xhiveframework.core.notifications.get_notification_config | |||
# notification_config = "muezzin.notifications.get_notification_config" | |||
@@ -71,11 +71,11 @@ doctype_js = { | |||
# Permissions evaluated in scripted ways | |||
# permission_query_conditions = { | |||
# "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", | |||
# "Event": "xhiveframework.desk.doctype.event.event.get_permission_query_conditions", | |||
# } | |||
# | |||
# has_permission = { | |||
# "Event": "frappe.desk.doctype.event.event.has_permission", | |||
# "Event": "xhiveframework.desk.doctype.event.event.has_permission", | |||
# } | |||
# Document Events | |||
@@ -120,12 +120,12 @@ scheduler_events = { | |||
# ------------------------------ | |||
# | |||
# override_whitelisted_methods = { | |||
# "frappe.desk.doctype.event.event.get_events": "muezzin.event.get_events" | |||
# "xhiveframework.desk.doctype.event.event.get_events": "muezzin.event.get_events" | |||
# } | |||
# | |||
# each overriding function accepts a `data` argument; | |||
# generated from the base implementation of the doctype dashboard, | |||
# along with any modifications made in other Frappe apps | |||
# along with any modifications made in other Xhiveframework apps | |||
# override_doctype_dashboards = { | |||
# "Task": "muezzin.task.get_dashboard_data" | |||
# } | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Auction', { | |||
xhiveframework.ui.form.on('Auction', { | |||
refresh: function(frm) { | |||
frm.set_query('property', () => { | |||
return { | |||
@@ -19,7 +19,7 @@ frappe.ui.form.on('Auction', { | |||
property: function(frm) { | |||
if (frm.doc.property) { | |||
frappe.db.get_value('Property', frm.doc.property, 'property_type') | |||
xhiveframework.db.get_value('Property', frm.doc.property, 'property_type') | |||
.then( r=> { | |||
if (r.message) { | |||
frm.doc.property_type = r.message.property_type; | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class Auction(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestAuction(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Auction Free Card', { | |||
xhiveframework.ui.form.on('Auction Free Card', { | |||
refresh: function(frm) { | |||
frm.set_query('units', () => { | |||
if (frm.doc.auction) { | |||
@@ -3,22 +3,22 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
from frappe.model.document import Document | |||
import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class AuctionFreeCard(Document): | |||
def set_unit(self): | |||
result = frappe.db.get_list('Auction Unit', {'parent': self.auction}, 'unit') | |||
result = xhiveframework.db.get_list('Auction Unit', {'parent': self.auction}, 'unit') | |||
for row in result: | |||
self.append('units', { | |||
'unit': row.unit | |||
}) | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def get_unit(doctype, txt, searchfield, start, page_len, filters): | |||
return frappe.db.sql("""select unit | |||
return xhiveframework.db.sql("""select unit | |||
from `tabAuction Unit` | |||
where | |||
parent = {auction}""" | |||
.format(auction = frappe.db.escape(filters.get("auction")) | |||
)) | |||
.format(auction = xhiveframework.db.escape(filters.get("auction")) | |||
)) |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestAuctionFreeCard(unittest.TestCase): | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class AuctionUnit(Document): | |||
pass |
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class ContractAnnualRaise(Document): | |||
pass |
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class ContractPayments(Document): | |||
pass |
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Court', { | |||
xhiveframework.ui.form.on('Court', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class Court(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestCourt(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Discount Request', { | |||
xhiveframework.ui.form.on('Discount Request', { | |||
refresh: function (frm) { | |||
get_brand_names(frm) | |||
}, | |||
@@ -24,7 +24,7 @@ frappe.ui.form.on('Discount Request', { | |||
let get_brand_names = function (frm) { | |||
if (frm.doc.customer) { | |||
frappe.call({ | |||
xhiveframework.call({ | |||
method: "get_brand_names", | |||
doc: frm.doc, | |||
callback: function (data) { | |||
@@ -36,4 +36,4 @@ let get_brand_names = function (frm) { | |||
} | |||
}) | |||
} | |||
} | |||
} |
@@ -3,9 +3,9 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
from frappe.model.document import Document | |||
from frappe.utils import flt | |||
import xhiveframework | |||
from xhiveframework.model.document import Document | |||
from xhiveframework.utils import flt | |||
class DiscountRequest(Document): | |||
@@ -17,7 +17,7 @@ class DiscountRequest(Document): | |||
def get_brand_names(self): | |||
list_items = [] | |||
brands = frappe.get_all("Tenant Brand Name", filters={"parent": self.customer}, fields=['tenant_brand_name'], | |||
brands = xhiveframework.get_all("Tenant Brand Name", filters={"parent": self.customer}, fields=['tenant_brand_name'], | |||
order_by="tenant_brand_name") | |||
if brands: | |||
for item in brands: | |||
@@ -30,9 +30,9 @@ class DiscountRequest(Document): | |||
"invoice": ["=", '']} | |||
if self.apply_discount_on != "All": | |||
filters['reason'] = self.apply_discount_on | |||
payments = frappe.db.get_all("Contract Payments", filters=filters, order_by="date") | |||
payments = xhiveframework.db.get_all("Contract Payments", filters=filters, order_by="date") | |||
for row in payments: | |||
doc = frappe.get_doc("Contract Payments", row["name"]) | |||
doc = xhiveframework.get_doc("Contract Payments", row["name"]) | |||
if type == 'Add': | |||
doc.amount -= ( | |||
((flt(self.percentage) / 100) * flt(doc.amount)) if self.discount_type == 'Percentage' else flt( | |||
@@ -49,4 +49,4 @@ class DiscountRequest(Document): | |||
doc.flags.ignore_validate_update_after_submit = True | |||
doc.save() | |||
frappe.db.commit() | |||
xhiveframework.db.commit() |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestDiscountRequest(unittest.TestCase): | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class Document(Document): | |||
pass |
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Document Type', { | |||
xhiveframework.ui.form.on('Document Type', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class DocumentType(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestDocumentType(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Maintenance Ticket', { | |||
xhiveframework.ui.form.on('Maintenance Ticket', { | |||
refresh: function(frm) { | |||
queries(frm); | |||
}, | |||
@@ -44,4 +44,4 @@ function queries(frm) { | |||
// frm.doc.latitude = frm.fields_dict.property_location.map.getCenter()['lat']; | |||
// frm.doc.longitude = frm.fields_dict.property_location.map.getCenter()['lng']; | |||
// } | |||
// } | |||
// } |
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class MaintenanceTicket(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestMaintenanceTicket(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Opening Phase', { | |||
xhiveframework.ui.form.on('Opening Phase', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class OpeningPhase(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestOpeningPhase(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Property', { | |||
xhiveframework.ui.form.on('Property', { | |||
refresh: function(frm) { | |||
if (!frm.is_dirty()) { | |||
create_custom_buttons(frm); | |||
@@ -12,8 +12,8 @@ frappe.ui.form.on('Property', { | |||
const create_custom_buttons = function(frm) { | |||
frm.add_custom_button(__('Journal Entry'), () => { | |||
let doc = frm.doc | |||
frappe.run_serially([ | |||
() => frappe.new_doc('Journal Entry'), | |||
xhiveframework.run_serially([ | |||
() => xhiveframework.new_doc('Journal Entry'), | |||
() => { | |||
cur_frm.doc.cost_center = doc.cost_center; | |||
cur_frm.doc.property = doc.name; | |||
@@ -24,8 +24,8 @@ const create_custom_buttons = function(frm) { | |||
frm.add_custom_button(__('Sales Invoice'), () => { | |||
let doc = frm.doc | |||
frappe.run_serially([ | |||
() => frappe.new_doc('Sales Invoice'), | |||
xhiveframework.run_serially([ | |||
() => xhiveframework.new_doc('Sales Invoice'), | |||
() => { | |||
cur_frm.doc.cost_center = doc.cost_center; | |||
cur_frm.doc.property = doc.name; | |||
@@ -36,8 +36,8 @@ const create_custom_buttons = function(frm) { | |||
frm.add_custom_button(__('Payment Entry'), () => { | |||
let doc = frm.doc | |||
frappe.run_serially([ | |||
() => frappe.new_doc('Payment Entry'), | |||
xhiveframework.run_serially([ | |||
() => xhiveframework.new_doc('Payment Entry'), | |||
() => { | |||
cur_frm.doc.cost_center = doc.cost_center; | |||
cur_frm.doc.property = doc.name; | |||
@@ -55,4 +55,4 @@ const create_custom_buttons = function(frm) { | |||
} | |||
]); | |||
}, __('Create')); | |||
} | |||
} |
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class Property(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestProperty(unittest.TestCase): | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
from frappe import _ | |||
import xhiveframework | |||
from xhiveframework import _ | |||
import datetime | |||
# from datetime import datetime, timedelta | |||
import dateutil | |||
@@ -13,8 +13,8 @@ from calendar import weekday, monthrange | |||
from collections import Counter | |||
from dateutil.relativedelta import relativedelta | |||
from dateutil.rrule import rrule, MONTHLY, YEARLY | |||
from frappe.model.document import Document | |||
from frappe.utils import flt, date_diff, getdate, cint, nowdate,get_datetime | |||
from xhiveframework.model.document import Document | |||
from xhiveframework.utils import flt, date_diff, getdate, cint, nowdate,get_datetime | |||
class PropertyContract(Document): | |||
@@ -35,13 +35,13 @@ class PropertyContract(Document): | |||
"unit": self.unit, | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields = ["name"], | |||
filters = filters) | |||
if len(property_contract)> 0: | |||
frappe.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
xhiveframework.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
# Get Property Contaract if to date is between new from and new to date | |||
@@ -51,13 +51,13 @@ class PropertyContract(Document): | |||
"unit": self.unit, | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields = ["name"], | |||
filters = filters) | |||
if len(property_contract)> 0: | |||
frappe.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
xhiveframework.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
# Get Property Contaract if from date is after new from date and to date is before new to date | |||
@@ -68,17 +68,17 @@ class PropertyContract(Document): | |||
"unit": self.unit, | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields = ["name"], | |||
filters = filters) | |||
if len(property_contract)> 0: | |||
frappe.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
xhiveframework.throw(f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
diff_days = date_diff(self.rent_end_date,getdate()) | |||
if flt(diff_days) > 0: | |||
frappe.db.set_value("Unit", self.unit, "status", "Leased") | |||
xhiveframework.db.set_value("Unit", self.unit, "status", "Leased") | |||
def add_contract_annual_raise(self): | |||
self.contract_annual_raise = [] | |||
@@ -100,7 +100,7 @@ class PropertyContract(Document): | |||
duration = self.duration - 1 if self.duration > 1 else self.duration | |||
month = dateutil.relativedelta.relativedelta(months=duration) | |||
end_date = start_date + month | |||
if not self.annual_raise_start_date: | |||
duration_to_add = 13 - start_date.month | |||
months = dateutil.relativedelta.relativedelta(months = duration_to_add) | |||
@@ -109,7 +109,7 @@ class PropertyContract(Document): | |||
annual_raise_start_date = datetime.datetime.strptime(str(self.annual_raise_start_date), "%Y-%m-%d") | |||
service_charge_start_date = datetime.datetime.strptime(str(self.service_charge_start_date), "%Y-%m-%d") | |||
frequency = 0 | |||
if self.type == 'Customized c': | |||
if self.payments_scheduling: | |||
@@ -319,14 +319,14 @@ class PropertyContract(Document): | |||
self.save() | |||
def on_cancel(self): | |||
frappe.db.set_value("Unit", self.unit, "status", "Vacant") | |||
xhiveframework.db.set_value("Unit", self.unit, "status", "Vacant") | |||
def create_row_invoice(self,rowid): | |||
create_sales_invoice(self.name,rowid) | |||
def get_brand_names(self): | |||
list_items = [] | |||
brands = frappe.get_all("Tenant Brand Name", filters={"parent": self.renter}, fields=['tenant_brand_name'], order_by="tenant_brand_name") | |||
brands = xhiveframework.get_all("Tenant Brand Name", filters={"parent": self.renter}, fields=['tenant_brand_name'], order_by="tenant_brand_name") | |||
if brands: | |||
for item in brands: | |||
list_items.append(item["tenant_brand_name"]) | |||
@@ -335,10 +335,10 @@ class PropertyContract(Document): | |||
def update_duration(self): | |||
duration = self.get_dates_diff(self.rent_start_date,self.rent_end_date) | |||
# frappe.msgprint(str(duration)) | |||
# xhiveframework.msgprint(str(duration)) | |||
duration_months = (cint(duration["years"]) * 12) + cint(duration["months"]) + (1 if cint(duration["days"]) > 0 or getdate(self.rent_end_date).day == 1 else 0) | |||
# frappe.msgprint(str(duration_months)) | |||
# xhiveframework.msgprint(str(duration_months)) | |||
self.duration = duration_months | |||
return duration_months | |||
@@ -360,15 +360,15 @@ def create_sales_invoice(docname="",rowid=""): | |||
print("Starting Creation..........") | |||
condiction = "" | |||
if docname and rowid: | |||
row_doc = frappe.get_doc("Contract Payments",rowid) | |||
row_doc = xhiveframework.get_doc("Contract Payments",rowid) | |||
condiction = " and C.parent = '%s' " % docname | |||
# condiction += " and C.`name` = '%s' " % rowid | |||
condiction += " and C.date = '%s' " % row_doc.date | |||
invoices = frappe.db.sql(""" | |||
invoices = xhiveframework.db.sql(""" | |||
select *,P.`name` contract_name,C.date invoice_date,C.amount row_amount | |||
from `tabProperty Contract` P | |||
inner JOIN | |||
`tabContract Payments` C | |||
`tabContract Payments` C | |||
on P.`name` = C.parent | |||
-- and CURRENT_DATE() >= C.date | |||
and P.rent_item is not NULL | |||
@@ -388,30 +388,30 @@ def create_sales_invoice(docname="",rowid=""): | |||
print("Finished.") | |||
def create_sales_invoices(invoices): | |||
# frappe.throw(str(args)) | |||
default_company = frappe.db.get_default("Company") | |||
si = frappe.new_doc("Sales Invoice") | |||
# xhiveframework.throw(str(args)) | |||
default_company = xhiveframework.db.get_default("Company") | |||
si = xhiveframework.new_doc("Sales Invoice") | |||
if isinstance(invoices,list): | |||
args = frappe._dict(invoices[0]) | |||
args = xhiveframework._dict(invoices[0]) | |||
else: | |||
args = frappe._dict(invoices) | |||
args = xhiveframework._dict(invoices) | |||
invoice_date = args.date or nowdate() | |||
si.posting_date = invoice_date | |||
debit_to = frappe.db.get_value("Company", default_company, 'default_receivable_account') | |||
debit_to = xhiveframework.db.get_value("Company", default_company, 'default_receivable_account') | |||
if debit_to: | |||
si.debit_to = debit_to # Default Receivable Account | |||
else: | |||
frappe.throw(_("Please set Default Receivable Account in Company " + default_company)) | |||
xhiveframework.throw(_("Please set Default Receivable Account in Company " + default_company)) | |||
si.set_posting_time = 1 | |||
si.postint_date = args.invoice_date | |||
si.due_date = args.invoice_date | |||
si.customer = args.renter | |||
si.tax_id = frappe.db.get_value("Customer",args.renter,"tax_id") | |||
si.tax_id = xhiveframework.db.get_value("Customer",args.renter,"tax_id") | |||
si.debit_to = debit_to | |||
print(str(si.postint_date)+"================================================="+str(si.due_date)) | |||
@@ -420,7 +420,7 @@ def create_sales_invoices(invoices): | |||
si.property = args.property_name | |||
si.unit = args.unit | |||
si.property_contract = args.contract_name | |||
invoice_curerncy = frappe.db.get_value('Customer', args.renter, "default_currency") or frappe.get_cached_value('Company', default_company, "default_currency") | |||
invoice_curerncy = xhiveframework.db.get_value('Customer', args.renter, "default_currency") or xhiveframework.get_cached_value('Company', default_company, "default_currency") | |||
si.currency=invoice_curerncy | |||
conversion_rate = 1 | |||
@@ -428,26 +428,26 @@ def create_sales_invoices(invoices): | |||
conversion_rate = get_conversion_rate(invoice_curerncy,invoice_date) | |||
if conversion_rate == 0: | |||
message = _("Please Insert Currency Exchange for day {0}".format(invoice_date)) | |||
frappe.throw(frappe.bold(message)) | |||
xhiveframework.throw(xhiveframework.bold(message)) | |||
si.conversion_rate = conversion_rate | |||
tax_list = [] | |||
old_template = "" | |||
for item in invoices: | |||
default_income_account = None | |||
item_income_account = frappe.db.get_value("Item Default", {"parent":(item.rent_item if item.reason =="Rent" else item.service_item)}, 'income_account') | |||
company_default_income_account = frappe.db.get_value("Company", default_company, 'default_income_account') | |||
item_income_account = xhiveframework.db.get_value("Item Default", {"parent":(item.rent_item if item.reason =="Rent" else item.service_item)}, 'income_account') | |||
company_default_income_account = xhiveframework.db.get_value("Company", default_company, 'default_income_account') | |||
if item_income_account: | |||
default_income_account = item_income_account | |||
elif company_default_income_account: | |||
default_income_account = company_default_income_account | |||
else: | |||
frappe.throw(_("Please set Default Income Account in Company " + default_company)) | |||
xhiveframework.throw(_("Please set Default Income Account in Company " + default_company)) | |||
cost_center = frappe.db.get_value("Company", default_company, 'cost_center') | |||
cost_center = xhiveframework.db.get_value("Company", default_company, 'cost_center') | |||
if not cost_center: | |||
frappe.throw(_("Please set Default Cost Center in Company " + default_company)) | |||
xhiveframework.throw(_("Please set Default Cost Center in Company " + default_company)) | |||
tax_template_name = "" | |||
@@ -475,11 +475,11 @@ def create_sales_invoices(invoices): | |||
if old_template=="": | |||
old_template = tax_template_name | |||
tax_data = frappe.db.sql(""" | |||
tax_data = xhiveframework.db.sql(""" | |||
select * | |||
from `tabItem Tax Template Detail` | |||
where parent='{tax_template_name}' | |||
""".format(tax_template_name=tax_template_name),as_dict=True,debug=False) | |||
if tax_data: | |||
@@ -505,20 +505,20 @@ def create_sales_invoices(invoices): | |||
try: | |||
Sinv_ID = si.insert(ignore_mandatory = True) | |||
for row in invoices: | |||
frappe.db.sql("""update `tabContract Payments` set invoice = '{0}' where `name` = '{1}' """.format(Sinv_ID.name,row.name),debug=True) | |||
xhiveframework.db.sql("""update `tabContract Payments` set invoice = '{0}' where `name` = '{1}' """.format(Sinv_ID.name,row.name),debug=True) | |||
return Sinv_ID | |||
except Exception as e: | |||
print("Error......"+str(e)) | |||
frappe.throw(_(e)) | |||
xhiveframework.throw(_(e)) | |||
def get_conversion_rate(invoice_curerncy,invoice_date): | |||
conversion_rate = 0 | |||
exchange_rate = frappe.db.sql(""" | |||
select exchange_rate | |||
from `tabCurrency Exchange` | |||
where from_currency ='{invoice_curerncy}' | |||
and to_currency='EGP' | |||
exchange_rate = xhiveframework.db.sql(""" | |||
select exchange_rate | |||
from `tabCurrency Exchange` | |||
where from_currency ='{invoice_curerncy}' | |||
and to_currency='EGP' | |||
and date ='{invoice_date}' | |||
""".format(invoice_curerncy=invoice_curerncy,invoice_date=invoice_date),as_dict=True) | |||
if exchange_rate: | |||
@@ -529,17 +529,17 @@ def get_conversion_rate(invoice_curerncy,invoice_date): | |||
def update_unit_status(): | |||
units = frappe.db.get_list("Property Contract",filters={"docstatus":1,"rent_end_date":getdate()},fields=["unit"]) | |||
units = xhiveframework.db.get_list("Property Contract",filters={"docstatus":1,"rent_end_date":getdate()},fields=["unit"]) | |||
if units: | |||
for unit in units: | |||
frappe.db.set_value("Unit", unit["unit"], "status", "Vacant") | |||
xhiveframework.db.set_value("Unit", unit["unit"], "status", "Vacant") | |||
def update_unit_status_basd_on_reservation(): | |||
print("==========================starting============================") | |||
units = frappe.db.get_list("Reservations",filters={"docstatus":1,"reservation_end":["<",get_datetime()]},fields=["unit"]) | |||
units = xhiveframework.db.get_list("Reservations",filters={"docstatus":1,"reservation_end":["<",get_datetime()]},fields=["unit"]) | |||
if units: | |||
for unit in units: | |||
frappe.db.set_value("Unit", unit["unit"], "status", "Vacant") | |||
print("==========================Finished============================") | |||
xhiveframework.db.set_value("Unit", unit["unit"], "status", "Vacant") | |||
print("==========================Finished============================") |
@@ -1,17 +1,17 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Property Contract', { | |||
xhiveframework.ui.form.on('Property Contract', { | |||
onload: function (frm) { | |||
get_brand_names(frm) | |||
}, | |||
generate_payment_scheduale: function (frm) { | |||
frm.doc.payment = [] | |||
frappe.call({ | |||
xhiveframework.call({ | |||
method: 'add_payment', | |||
doc: frm.doc, | |||
callback: function (res) { | |||
frappe.show_alert('Generated Successfully') | |||
xhiveframework.show_alert('Generated Successfully') | |||
cur_frm.reload_doc() | |||
} | |||
@@ -61,7 +61,7 @@ frappe.ui.form.on('Property Contract', { | |||
if (frm.doc.docstatus == 1 && frm.doc.status != "Hold") { | |||
frm.add_custom_button("Hold Contract", () => { | |||
frappe.call({ | |||
xhiveframework.call({ | |||
method: "muezzin.api.property_contract.change_contract_status", | |||
args: { | |||
doc: frm.doc, | |||
@@ -75,7 +75,7 @@ frappe.ui.form.on('Property Contract', { | |||
} | |||
if (frm.doc.docstatus == 1 && frm.doc.status == "Hold") { | |||
frm.add_custom_button("Release Contract", () => { | |||
frappe.call({ | |||
xhiveframework.call({ | |||
method: "muezzin.api.property_contract.change_contract_status", | |||
args: { | |||
doc: frm.doc, | |||
@@ -203,7 +203,7 @@ frappe.ui.form.on('Property Contract', { | |||
} | |||
} | |||
}); | |||
frappe.ui.form.on('Contract Payments', { | |||
xhiveframework.ui.form.on('Contract Payments', { | |||
create_invoice: function (frm, cdt, cdn) { | |||
var row = locals[cdt][cdn]; | |||
if (!row.invoice) { | |||
@@ -216,7 +216,7 @@ frappe.ui.form.on('Contract Payments', { | |||
} | |||
}) | |||
} else { | |||
frappe.throw(__('Invoice Already Created..')) | |||
xhiveframework.throw(__('Invoice Already Created..')) | |||
} | |||
} | |||
}) | |||
@@ -225,7 +225,7 @@ const update_payment = function (frm) { | |||
if (!frm.doc.rent_start_date) { | |||
frm.doc.duration = null; | |||
frm.refresh_field('duration'); | |||
frappe.msgprint('Enter Rent Start Date.') | |||
xhiveframework.msgprint('Enter Rent Start Date.') | |||
} else { | |||
if (frm.doc.type && frm.doc.duration) { | |||
frm.call('add_payment'); | |||
@@ -241,7 +241,7 @@ const update_annual_raise_amount = function (frm) { | |||
if (!frm.doc.rent_start_date) { | |||
frm.doc.duration = null; | |||
frm.refresh_field('duration'); | |||
frappe.msgprint('Enter Rent Start Date.') | |||
xhiveframework.msgprint('Enter Rent Start Date.') | |||
} else { | |||
if (frm.doc.annual_raise === 'Annual Irregular' && frm.doc.duration) { | |||
frm.call('add_contract_annual_raise'); | |||
@@ -310,7 +310,7 @@ const update_duration = function (frm) { | |||
// let duration = get_time_diff(frm.doc.rent_end_date, frm.doc.rent_start_date) | |||
// frm.set_value('duration', duration) | |||
frappe.call({ | |||
xhiveframework.call({ | |||
method:'update_duration', | |||
doc:frm.doc, | |||
callback:function(r){ | |||
@@ -334,7 +334,7 @@ const get_time_diff = (end, start) => { | |||
let get_brand_names = function (frm) { | |||
if (frm.doc.renter) { | |||
frappe.call({ | |||
xhiveframework.call({ | |||
method: "muezzin.property_management.doctype.property_contract.property_contract.get_brand_names", | |||
args: { | |||
renter:frm.doc.renter | |||
@@ -348,4 +348,4 @@ let get_brand_names = function (frm) { | |||
} | |||
}) | |||
} | |||
} | |||
} |
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
from frappe import _ | |||
import xhiveframework | |||
from xhiveframework import _ | |||
import datetime | |||
# from datetime import datetime, timedelta | |||
import dateutil | |||
@@ -13,8 +13,8 @@ from calendar import weekday, monthrange | |||
from collections import Counter | |||
from dateutil.relativedelta import relativedelta | |||
from dateutil.rrule import rrule, MONTHLY, YEARLY | |||
from frappe.model.document import Document | |||
from frappe.utils import flt, date_diff, getdate, cint, nowdate | |||
from xhiveframework.model.document import Document | |||
from xhiveframework.utils import flt, date_diff, getdate, cint, nowdate | |||
class PropertyContract(Document): | |||
@@ -36,12 +36,12 @@ class PropertyContract(Document): | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields=["name"], | |||
filters=filters) | |||
if len(property_contract) > 0: | |||
frappe.throw( | |||
xhiveframework.throw( | |||
f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
# Get Property Contaract if to date is between new from and new to date | |||
@@ -52,12 +52,12 @@ class PropertyContract(Document): | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields=["name"], | |||
filters=filters) | |||
if len(property_contract) > 0: | |||
frappe.throw( | |||
xhiveframework.throw( | |||
f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
# Get Property Contaract if from date is after new from date and to date is before new to date | |||
@@ -69,19 +69,19 @@ class PropertyContract(Document): | |||
"status": ["!=", "Hold"] | |||
} | |||
property_contract = frappe.get_list("Property Contract", | |||
property_contract = xhiveframework.get_list("Property Contract", | |||
fields=["name"], | |||
filters=filters) | |||
if len(property_contract) > 0: | |||
frappe.throw( | |||
xhiveframework.throw( | |||
f"This property unit already contain a contract <a href='#Form/Property%20Contract/{property_contract[0].name}'>{property_contract[0].name}</a> that not ended yet.") | |||
diff_days = date_diff(self.rent_end_date, getdate()) | |||
if flt(diff_days) > 0: | |||
frappe.db.set_value("Unit", self.unit, "status", "Leased") | |||
xhiveframework.db.set_value("Unit", self.unit, "status", "Leased") | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def add_contract_annual_raise(self): | |||
self.contract_annual_raise = [] | |||
start_date = datetime.datetime.strptime(self.rent_start_date, "%Y-%m-%d") | |||
@@ -95,7 +95,7 @@ class PropertyContract(Document): | |||
'amount': 0, | |||
}) | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def add_payment(self): | |||
self.payments = [] | |||
@@ -321,15 +321,15 @@ class PropertyContract(Document): | |||
self.save() | |||
def on_cancel(self): | |||
frappe.db.set_value("Unit", self.unit, "status", "Vacant") | |||
xhiveframework.db.set_value("Unit", self.unit, "status", "Vacant") | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def create_row_invoice(self, rowid): | |||
create_sales_invoice(self.name, rowid) | |||
def get_brand_names(self): | |||
list_items = [] | |||
brands = frappe.get_all("Tenant Brand Name", filters={"parent": self.renter}, fields=['tenant_brand_name'], | |||
brands = xhiveframework.get_all("Tenant Brand Name", filters={"parent": self.renter}, fields=['tenant_brand_name'], | |||
order_by="tenant_brand_name") | |||
if brands: | |||
for item in brands: | |||
@@ -337,14 +337,14 @@ class PropertyContract(Document): | |||
return list_items | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def update_duration(self): | |||
duration = self.get_dates_diff(self.rent_start_date, self.rent_end_date) | |||
# frappe.msgprint(str(duration)) | |||
# xhiveframework.msgprint(str(duration)) | |||
duration_months = (cint(duration["years"]) * 12) + cint(duration["months"]) + ( | |||
1 if cint(duration["days"]) > 0 or getdate(self.rent_end_date).day == 1 else 0) | |||
# frappe.msgprint(str(duration_months)) | |||
# xhiveframework.msgprint(str(duration_months)) | |||
self.duration = duration_months | |||
return duration_months | |||
@@ -367,15 +367,15 @@ def create_sales_invoice(docname="", rowid=""): | |||
print("Starting Creation..........") | |||
condiction = "" | |||
if docname and rowid: | |||
row_doc = frappe.get_doc("Contract Payments", rowid) | |||
row_doc = xhiveframework.get_doc("Contract Payments", rowid) | |||
#condiction = " and P.`name` = '%s' " % docname | |||
condiction += " and C.`name` = '%s' " % rowid | |||
condiction += " and C.date = '%s' " % row_doc.date | |||
invoices = frappe.db.sql(""" | |||
invoices = xhiveframework.db.sql(""" | |||
select *,P.`name` contract_name,C.date invoice_date | |||
from `tabProperty Contract` P | |||
inner JOIN | |||
`tabContract Payments` C | |||
`tabContract Payments` C | |||
on P.`name` = C.parent | |||
-- and CURRENT_DATE() >= C.date | |||
and P.rent_item is not NULL | |||
@@ -395,26 +395,26 @@ def create_sales_invoice(docname="", rowid=""): | |||
def create_sales_invoices(args): | |||
# frappe.throw(str(args)) | |||
default_company = frappe.db.get_default("Company") | |||
si = frappe.new_doc("Sales Invoice") | |||
args = frappe._dict(args) | |||
# xhiveframework.throw(str(args)) | |||
default_company = xhiveframework.db.get_default("Company") | |||
si = xhiveframework.new_doc("Sales Invoice") | |||
args = xhiveframework._dict(args) | |||
si.posting_date = args.date or nowdate() | |||
invoice_date = args.date or nowdate() | |||
debit_to = frappe.db.get_value("Company", default_company, 'default_receivable_account') | |||
debit_to = xhiveframework.db.get_value("Company", default_company, 'default_receivable_account') | |||
if debit_to: | |||
si.debit_to = debit_to # Default Receivable Account | |||
else: | |||
frappe.throw(_("Please set Default Receivable Account in Company " + default_company)) | |||
xhiveframework.throw(_("Please set Default Receivable Account in Company " + default_company)) | |||
si.set_posting_time = 1 | |||
si.postint_date = args.invoice_date | |||
si.due_date = args.invoice_date | |||
si.customer = args.renter | |||
si.tax_id = frappe.db.get_value("Customer", args.renter, "tax_id") | |||
si.tax_id = xhiveframework.db.get_value("Customer", args.renter, "tax_id") | |||
si.debit_to = debit_to | |||
print(str(si.postint_date) + "=================================================" + str(si.due_date)) | |||
@@ -423,7 +423,7 @@ def create_sales_invoices(args): | |||
si.property = args.property_name | |||
si.unit = args.unit | |||
si.property_contract = args.contract_name | |||
invoice_curerncy = frappe.get_cached_value('Customer', args.renter, "default_currency") or frappe.get_cached_value( | |||
invoice_curerncy = xhiveframework.get_cached_value('Customer', args.renter, "default_currency") or xhiveframework.get_cached_value( | |||
'Company', default_company, "default_currency") | |||
si.currency = invoice_curerncy | |||
conversion_rate = 1 | |||
@@ -431,25 +431,25 @@ def create_sales_invoices(args): | |||
conversion_rate = get_conversion_rate(invoice_curerncy,invoice_date) | |||
if conversion_rate == 0: | |||
message = _("Please Insert Currency Exchange for day {0}".format(invoice_date)) | |||
frappe.throw(frappe.bold(message)) | |||
xhiveframework.throw(xhiveframework.bold(message)) | |||
si.conversion_rate = conversion_rate | |||
default_income_account = None | |||
item_income_account = frappe.db.get_value("Item Default", { | |||
item_income_account = xhiveframework.db.get_value("Item Default", { | |||
"parent": (args.rent_item if args.reason == "Rent" else args.service_item)}, 'income_account') | |||
company_default_income_account = frappe.db.get_value("Company", default_company, 'default_income_account') | |||
company_default_income_account = xhiveframework.db.get_value("Company", default_company, 'default_income_account') | |||
if item_income_account: | |||
default_income_account = item_income_account | |||
elif company_default_income_account: | |||
default_income_account = company_default_income_account | |||
else: | |||
frappe.throw(_("Please set Default Income Account in Company " + default_company)) | |||
xhiveframework.throw(_("Please set Default Income Account in Company " + default_company)) | |||
cost_center = frappe.db.get_value("Company", default_company, 'cost_center') | |||
cost_center = xhiveframework.db.get_value("Company", default_company, 'cost_center') | |||
if not cost_center: | |||
frappe.throw(_("Please set Default Cost Center in Company " + default_company)) | |||
xhiveframework.throw(_("Please set Default Cost Center in Company " + default_company)) | |||
si.append("items", { | |||
"item_code": (args.rent_item if args.reason == "Rent" else args.service_item), | |||
@@ -471,17 +471,17 @@ def create_sales_invoices(args): | |||
tax_template_name = args.rent_sales_taxes_and_charges_template | |||
if tax_template_name: | |||
tax_data = frappe.db.sql(""" | |||
tax_data = xhiveframework.db.sql(""" | |||
select T.`name` taxes_and_charges,S.charge_type,S.description,S.rate,S.account_head | |||
from `tabSales Taxes and Charges Template` T | |||
INNER JOIN | |||
INNER JOIN | |||
`tabSales Taxes and Charges` S | |||
on T.`name` = S.parent | |||
and S.parenttype='Sales Taxes and Charges Template' | |||
and T.`name`='{tax_template_name}' | |||
""".format(tax_template_name=tax_template_name), as_dict=True, debug=False) | |||
# frappe.throw(str(args.service_sales_taxes_and_charges_template)) | |||
# xhiveframework.throw(str(args.service_sales_taxes_and_charges_template)) | |||
if tax_data: | |||
tax_data = tax_data[0] | |||
si.taxes_and_charges = tax_data["taxes_and_charges"] | |||
@@ -499,24 +499,24 @@ def create_sales_invoices(args): | |||
Sinv_ID = None | |||
try: | |||
Sinv_ID = si.insert(ignore_mandatory=True) | |||
frappe.db.sql("""update `tabContract Payments` set invoice = '{0}' where `name` = '{1}' """.format(Sinv_ID.name, | |||
xhiveframework.db.sql("""update `tabContract Payments` set invoice = '{0}' where `name` = '{1}' """.format(Sinv_ID.name, | |||
args.name), | |||
debug=True) | |||
return Sinv_ID | |||
except Exception as e: | |||
print("Error......" + str(e)) | |||
frappe.throw(_(e)) | |||
xhiveframework.throw(_(e)) | |||
def get_conversion_rate(invoice_curerncy,invoice_date): | |||
conversion_rate = 0 | |||
exchange_rate = frappe.db.sql(""" | |||
select exchange_rate | |||
from `tabCurrency Exchange` | |||
where from_currency ='{invoice_curerncy}' | |||
and to_currency='EGP' | |||
exchange_rate = xhiveframework.db.sql(""" | |||
select exchange_rate | |||
from `tabCurrency Exchange` | |||
where from_currency ='{invoice_curerncy}' | |||
and to_currency='EGP' | |||
-- and date ='{invoice_date}' | |||
ORDER BY date desc | |||
ORDER BY date desc | |||
limit 1 | |||
""".format(invoice_curerncy=invoice_curerncy,invoice_date=invoice_date),as_dict=True) | |||
if exchange_rate: | |||
@@ -526,20 +526,20 @@ def get_conversion_rate(invoice_curerncy,invoice_date): | |||
def update_unit_status(): | |||
units = frappe.db.get_list("Property Contract", filters={"docstatus": 1, "rent_end_date": getdate()}, | |||
units = xhiveframework.db.get_list("Property Contract", filters={"docstatus": 1, "rent_end_date": getdate()}, | |||
fields=["unit"]) | |||
if units: | |||
for unit in units: | |||
frappe.db.set_value("Unit", unit["unit"], "status", "Vacant") | |||
xhiveframework.db.set_value("Unit", unit["unit"], "status", "Vacant") | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def get_brand_names(renter): | |||
list_items = [] | |||
brands = frappe.get_all("Tenant Brand Name", filters={"parent": renter}, fields=['tenant_brand_name'], | |||
brands = xhiveframework.get_all("Tenant Brand Name", filters={"parent": renter}, fields=['tenant_brand_name'], | |||
order_by="tenant_brand_name") | |||
if brands: | |||
for item in brands: | |||
list_items.append(item["tenant_brand_name"]) | |||
return list_items | |||
return list_items |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestPropertyContract(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Property Type', { | |||
xhiveframework.ui.form.on('Property Type', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class PropertyType(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestPropertyType(unittest.TestCase): | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class PropertyUnitDetail(Document): | |||
pass |
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Real Estate Offer', { | |||
xhiveframework.ui.form.on('Real Estate Offer', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class RealEstateOffer(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestRealEstateOffer(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Real Estate Order', { | |||
xhiveframework.ui.form.on('Real Estate Order', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class RealEstateOrder(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestRealEstateOrder(unittest.TestCase): | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class ReservationRepaymentSchedule(Document): | |||
pass |
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Reservations', { | |||
xhiveframework.ui.form.on('Reservations', { | |||
refresh: function (frm) { | |||
if (frm.doc.docstatus == 1) { | |||
frm.add_custom_button(__("Contract"), () => { | |||
@@ -27,12 +27,12 @@ frappe.ui.form.on('Reservations', { | |||
}, | |||
create_new_contract: function (frm) { | |||
if (frm.doc.reservation_type == 'Selling') { | |||
frappe.model.open_mapped_doc({ | |||
xhiveframework.model.open_mapped_doc({ | |||
method: "muezzin.property_management.doctype.reservations.reservations.make_unit_sale_contract", | |||
frm: cur_frm | |||
}) | |||
} else { | |||
frappe.model.open_mapped_doc({ | |||
xhiveframework.model.open_mapped_doc({ | |||
method: "muezzin.property_management.doctype.reservations.reservations.make_property_contract", | |||
frm: cur_frm | |||
}) | |||
@@ -55,8 +55,8 @@ frappe.ui.form.on('Reservations', { | |||
}, | |||
customer_primary_address: function (frm) { | |||
if (frm.doc.customer_primary_address) { | |||
frappe.call({ | |||
method: 'frappe.contacts.doctype.address.address.get_address_display', | |||
xhiveframework.call({ | |||
method: 'xhiveframework.contacts.doctype.address.address.get_address_display', | |||
args: { | |||
"address_dict": frm.doc.customer_primary_address | |||
}, | |||
@@ -3,13 +3,13 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe, math, json | |||
from frappe import _ | |||
import erpnext | |||
from frappe.model.document import Document | |||
from frappe.utils import flt, rounded, add_months, nowdate, getdate,get_datetime | |||
from erpnext.controllers.accounts_controller import AccountsController | |||
from frappe.model.mapper import get_mapped_doc | |||
import xhiveframework, math, json | |||
from xhiveframework import _ | |||
import xhiveerp | |||
from xhiveframework.model.document import Document | |||
from xhiveframework.utils import flt, rounded, add_months, nowdate, getdate,get_datetime | |||
from xhiveerp.controllers.accounts_controller import AccountsController | |||
from xhiveframework.model.mapper import get_mapped_doc | |||
class Reservations(Document): | |||
@@ -22,12 +22,12 @@ class Reservations(Document): | |||
def on_submit(self): | |||
if(get_datetime() < get_datetime(self.reservation_end)): | |||
frappe.db.set_value("Unit", self.unit, "status", "Reserved") | |||
xhiveframework.db.set_value("Unit", self.unit, "status", "Reserved") | |||
else: | |||
frappe.db.set_value("Unit", self.unit, "status", "Vacant") | |||
xhiveframework.db.set_value("Unit", self.unit, "status", "Vacant") | |||
def on_cancel(self): | |||
frappe.db.set_value("Unit", self.unit, "status", "Vacant") | |||
xhiveframework.db.set_value("Unit", self.unit, "status", "Vacant") | |||
def set_missing_fields(self): | |||
if self.repayment_method == "Repay Over Number of Periods": | |||
@@ -65,13 +65,13 @@ class Reservations(Document): | |||
def validate_repayment_method(repayment_method, amount, monthly_repayment_amount, repayment_periods): | |||
if repayment_method == "Repay Over Number of Periods" and not repayment_periods: | |||
frappe.throw(_("Please enter Repayment Periods")) | |||
xhiveframework.throw(_("Please enter Repayment Periods")) | |||
if repayment_method == "Repay Fixed Amount per Period": | |||
if not monthly_repayment_amount: | |||
frappe.throw(_("Please enter repayment Amount")) | |||
xhiveframework.throw(_("Please enter repayment Amount")) | |||
if monthly_repayment_amount > amount: | |||
frappe.throw(_("Monthly Repayment Amount cannot be greater than Amount")) | |||
xhiveframework.throw(_("Monthly Repayment Amount cannot be greater than Amount")) | |||
def get_monthly_repayment_amount(repayment_method, amount, rate_of_interest, repayment_periods,advance_payment): | |||
if rate_of_interest: | |||
@@ -81,12 +81,12 @@ def get_monthly_repayment_amount(repayment_method, amount, rate_of_interest, rep | |||
/ ((1 + monthly_interest_rate)**repayment_periods - 1)) | |||
else: | |||
monthly_repayment_amount = math.ceil(flt((amount-advance_payment)) / repayment_periods) | |||
# frappe.msgprint(str(repayment_periods)) | |||
# xhiveframework.msgprint(str(repayment_periods)) | |||
return monthly_repayment_amount | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def make_unit_sale_contract(source_name, target_doc=None): | |||
doclist = get_mapped_doc("Reservations", source_name, { | |||
"Reservations": { | |||
@@ -107,7 +107,7 @@ def make_unit_sale_contract(source_name, target_doc=None): | |||
return doclist | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def make_property_contract(source_name, target_doc=None): | |||
doclist = get_mapped_doc("Reservations", source_name, { | |||
"Reservations": { | |||
@@ -125,4 +125,4 @@ def make_property_contract(source_name, target_doc=None): | |||
} | |||
}, target_doc) | |||
return doclist | |||
return doclist |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestReservations(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Script', { | |||
xhiveframework.ui.form.on('Script', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class Script(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestScript(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Tenant Brand Name', { | |||
xhiveframework.ui.form.on('Tenant Brand Name', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class TenantBrandName(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestTenantBrandName(unittest.TestCase): | |||
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestUnit(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Unit', { | |||
xhiveframework.ui.form.on('Unit', { | |||
onload(frm) { | |||
frm.set_query("sub_activity", () => { | |||
return { | |||
@@ -30,7 +30,7 @@ frappe.ui.form.on('Unit', { | |||
frm.doc.unit_price = null; | |||
frm.doc.gla = null; | |||
frm.refresh_field('gla'); | |||
frappe.msgprint('Unit Area must be greater than zero.') | |||
xhiveframework.msgprint('Unit Area must be greater than zero.') | |||
} else if (frm.doc.gla && frm.doc.price_psm) { | |||
frm.doc.unit_price = frm.doc.gla * frm.doc.price_psm; | |||
} | |||
@@ -42,7 +42,7 @@ frappe.ui.form.on('Unit', { | |||
frm.doc.price_psm = null; | |||
frm.doc.unit_price = null; | |||
frm.refresh_field('price_psm'); | |||
frappe.msgprint('Price must be greater than zero.') | |||
xhiveframework.msgprint('Price must be greater than zero.') | |||
} else if (frm.doc.gla && frm.doc.price_psm) { | |||
frm.doc.unit_price = frm.doc.gla * frm.doc.price_psm; | |||
} | |||
@@ -53,8 +53,8 @@ frappe.ui.form.on('Unit', { | |||
const create_custom_buttons = function(frm) { | |||
frm.add_custom_button(__('Journal Entry'), () => { | |||
let doc = frm.doc | |||
frappe.run_serially([ | |||
() => frappe.new_doc('Journal Entry'), | |||
xhiveframework.run_serially([ | |||
() => xhiveframework.new_doc('Journal Entry'), | |||
() => { | |||
cur_frm.doc.cost_center = doc.cost_center; | |||
cur_frm.doc.property = doc.property; | |||
@@ -68,14 +68,14 @@ const create_custom_buttons = function(frm) { | |||
// frm.add_custom_button(__('Sales Invoice'), () => { | |||
// let doc = frm.doc | |||
// frappe.run_serially([ | |||
// () => frappe.new_doc('Sales Invoice'), | |||
// xhiveframework.run_serially([ | |||
// () => xhiveframework.new_doc('Sales Invoice'), | |||
// () => { | |||
// cur_frm.doc.cost_center = doc.cost_center; | |||
// cur_frm.doc.property = doc.property; | |||
// cur_frm.doc.unit = doc.name; | |||
// let customer = doc.property_owner_customer; | |||
// frappe.model.set_value(cur_frm.doc.doctype, cur_frm.doc.name, "customer", customer); | |||
// xhiveframework.model.set_value(cur_frm.doc.doctype, cur_frm.doc.name, "customer", customer); | |||
// cur_frm.refresh(); | |||
// } | |||
// ]); | |||
@@ -83,40 +83,40 @@ const create_custom_buttons = function(frm) { | |||
frm.add_custom_button(__('Payment Entry'), () => { | |||
let doc = frm.doc | |||
frappe.run_serially([ | |||
() => frappe.new_doc('Payment Entry'), | |||
xhiveframework.run_serially([ | |||
() => xhiveframework.new_doc('Payment Entry'), | |||
() => { | |||
cur_frm.doc.cost_center = doc.cost_center; | |||
cur_frm.doc.property = doc.property; | |||
cur_frm.doc.unit = doc.name; | |||
if (doc.property_owner_customer) { | |||
cur_frm.doc.party_type = 'Customer'; | |||
let party = doc.property_owner_customer; | |||
frappe.model.set_value("Payment Entry", cur_frm.doc.name, "party", party) | |||
xhiveframework.model.set_value("Payment Entry", cur_frm.doc.name, "party", party) | |||
} | |||
if (doc.property_owner_supplier) { | |||
cur_frm.doc.party_type = 'Supplier'; | |||
let party = doc.property_owner_supplier; | |||
frappe.model.set_value("Payment Entry", cur_frm.doc.name, "party", party) | |||
xhiveframework.model.set_value("Payment Entry", cur_frm.doc.name, "party", party) | |||
} | |||
cur_frm.refresh(); | |||
} | |||
]); | |||
}, __('Create')); | |||
frm.add_custom_button(__('Purchase Invoice'), () => { | |||
let doc = frm.doc | |||
frappe.run_serially([ | |||
() => frappe.new_doc('Purchase Invoice'), | |||
xhiveframework.run_serially([ | |||
() => xhiveframework.new_doc('Purchase Invoice'), | |||
() => { | |||
cur_frm.doc.cost_center = doc.cost_center; | |||
cur_frm.doc.property = doc.property; | |||
cur_frm.doc.unit = doc.name; | |||
let supplier = doc.property_owner_supplier; | |||
frappe.model.set_value(cur_frm.doc.doctype, cur_frm.doc.name, "supplier", supplier); | |||
xhiveframework.model.set_value(cur_frm.doc.doctype, cur_frm.doc.name, "supplier", supplier); | |||
cur_frm.refresh(); | |||
} | |||
]); | |||
@@ -124,8 +124,8 @@ const create_custom_buttons = function(frm) { | |||
frm.add_custom_button(__('Contract'), () => { | |||
let doc = frm.doc | |||
frappe.run_serially([ | |||
() => frappe.new_doc('Property Contract'), | |||
xhiveframework.run_serially([ | |||
() => xhiveframework.new_doc('Property Contract'), | |||
() => { | |||
cur_frm.doc.property_name = doc.property; | |||
cur_frm.doc.unit_name = doc.name; | |||
@@ -143,8 +143,8 @@ const update_gla = function(frm) { | |||
var make_sales_invoice = function () { | |||
frappe.model.open_mapped_doc({ | |||
xhiveframework.model.open_mapped_doc({ | |||
method: "muezzin.property_management.doctype.unit.unit.make_sales_invoice", | |||
frm: cur_frm | |||
}); | |||
} | |||
} |
@@ -3,17 +3,17 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
from frappe.model.document import Document | |||
import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class Unit(Document): | |||
pass | |||
@frappe.whitelist() | |||
@xhiveframework.whitelist() | |||
def make_sales_invoice(source_name, target_doc=None): | |||
from frappe.model.mapper import get_mapped_doc | |||
from xhiveframework.model.mapper import get_mapped_doc | |||
doclist = get_mapped_doc("Unit", source_name, { | |||
"Unit": { | |||
@@ -24,4 +24,4 @@ def make_sales_invoice(source_name, target_doc=None): | |||
} | |||
}, target_doc) | |||
return doclist | |||
return doclist |
@@ -1,5 +1,5 @@ | |||
from __future__ import unicode_literals | |||
from frappe import _ | |||
from xhiveframework import _ | |||
def get_data(): | |||
return { | |||
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestUnitActivity(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Unit Activity', { | |||
xhiveframework.ui.form.on('Unit Activity', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class UnitActivity(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestUnitSaleContract(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Unit Sale Contract', { | |||
xhiveframework.ui.form.on('Unit Sale Contract', { | |||
refresh: function (frm) { | |||
frm.add_custom_button(__("Print Cheque"), () => { | |||
frm.events.print_cheques(frm) | |||
@@ -14,7 +14,7 @@ frappe.ui.form.on('Unit Sale Contract', { | |||
let show_dialog = function (frm) { | |||
var d = new frappe.ui.Dialog({ | |||
var d = new xhiveframework.ui.Dialog({ | |||
title: __('Select Bank'), | |||
fields: [ | |||
{ | |||
@@ -32,4 +32,4 @@ let show_dialog = function (frm) { | |||
primary_action_label: __('Print Bank Cheque') | |||
}); | |||
d.show(); | |||
} | |||
} |
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class UnitSaleContract(Document): | |||
pass |
@@ -3,7 +3,7 @@ | |||
# See license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
# import xhiveframework | |||
import unittest | |||
class TestUnitType(unittest.TestCase): | |||
@@ -1,7 +1,7 @@ | |||
// Copyright (c) 2021, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Unit Type', { | |||
xhiveframework.ui.form.on('Unit Type', { | |||
// refresh: function(frm) { | |||
// } | |||
@@ -3,8 +3,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
# import frappe | |||
from frappe.model.document import Document | |||
# import xhiveframework | |||
from xhiveframework.model.document import Document | |||
class UnitType(Document): | |||
pass |
@@ -1,12 +1,12 @@ | |||
frappe.pages["property-dashboard"].on_page_load = function (wrapper) { | |||
frappe.property_dashboard = new PropertyDashboard(wrapper); | |||
xhiveframework.pages["property-dashboard"].on_page_load = function (wrapper) { | |||
xhiveframework.property_dashboard = new PropertyDashboard(wrapper); | |||
}; | |||
class PropertyDashboard { | |||
constructor(wrapper) { | |||
this.page = wrapper.page; | |||
frappe.run_serially([ | |||
xhiveframework.run_serially([ | |||
() => this.make_page(wrapper), | |||
() => this.make_action_bar(wrapper), | |||
() => this.make_charts(wrapper), | |||
@@ -14,7 +14,7 @@ class PropertyDashboard { | |||
} | |||
make_page(wrapper) { | |||
this.page = frappe.ui.make_app_page({ | |||
this.page = xhiveframework.ui.make_app_page({ | |||
parent: wrapper, | |||
title: "Property Dashboard", | |||
single_column: true, | |||
@@ -33,14 +33,14 @@ class PropertyDashboard { | |||
const layout = $(wrapper).find(".layout-main-section"); | |||
// server call to get data | |||
frappe.call({ | |||
xhiveframework.call({ | |||
method: "muezzin.api.property_dashboard.get_tiles_data", | |||
freeze: true, | |||
callback: (r) => { | |||
const data = r.message; | |||
const context = { tiles: data }; | |||
const tiles = frappe.render_template("dashboard-tiles", context); | |||
const tiles = xhiveframework.render_template("dashboard-tiles", context); | |||
layout.html(""); | |||
layout.html(tiles); | |||
}, | |||
@@ -2,26 +2,26 @@ | |||
// For license information, please see license.txt | |||
/* eslint-disable */ | |||
frappe.query_reports["Property Management Revenue"] = { | |||
xhiveframework.query_reports["Property Management Revenue"] = { | |||
"filters": [ | |||
{ | |||
"label": "Company", | |||
"fieldname": "company", | |||
"fieldtype": "Link", | |||
"options": "Company", | |||
"default": frappe.defaults.get_user_default("Company"), | |||
"default": xhiveframework.defaults.get_user_default("Company"), | |||
}, | |||
{ | |||
"label": "From Date", | |||
"fieldname": "from_date", | |||
"fieldtype": "Date", | |||
"default": frappe.datetime.year_start() | |||
"default": xhiveframework.datetime.year_start() | |||
}, | |||
{ | |||
"label": "To Date", | |||
"fieldname": "to_date", | |||
"fieldtype": "Date", | |||
"default": frappe.datetime.year_end() | |||
"default": xhiveframework.datetime.year_end() | |||
}, | |||
{ | |||
"label": "Status", | |||
@@ -2,12 +2,12 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
from frappe import _ | |||
import xhiveframework | |||
from xhiveframework import _ | |||
from dateutil import relativedelta | |||
import datetime | |||
from dateutil.rrule import rrule, MONTHLY | |||
from frappe.utils import date_diff, flt | |||
from xhiveframework.utils import date_diff, flt | |||
def execute(filters=None): | |||
columns = [ | |||
@@ -273,13 +273,13 @@ def get_data(filters): | |||
else: | |||
q_filter = {"docstatus": ["!=", "2"]} | |||
result = frappe.get_list('Property Contract', q_filter, ['name']) | |||
result = xhiveframework.get_list('Property Contract', q_filter, ['name']) | |||
for row in result: | |||
contract = frappe.get_doc('Property Contract', row) | |||
contract = xhiveframework.get_doc('Property Contract', row) | |||
if not contract.unit: | |||
continue | |||
unit = frappe.get_doc('Unit', contract.unit) | |||
prop = frappe.get_doc('Property', contract.property_name) | |||
unit = xhiveframework.get_doc('Unit', contract.unit) | |||
prop = xhiveframework.get_doc('Property', contract.property_name) | |||
# Calculate Month Left | |||
date1 = datetime.datetime.strptime(str(contract.rent_end_date), '%Y-%m-%d') | |||
@@ -287,7 +287,7 @@ def get_data(filters): | |||
date_diffrance = date_diff(date2, date1) | |||
r = relativedelta.relativedelta(date1, date2) | |||
# frappe.msgprint(str(r)) | |||
# xhiveframework.msgprint(str(r)) | |||
months_left = abs(r.months) | |||
years_left = abs(r.years) | |||
@@ -369,10 +369,10 @@ def get_data(filters): | |||
fieldname = f'{day}-{month}-{row.year}' | |||
if fieldname in contract_months and contract_months[fieldname]: | |||
# frappe.msgprint(str(contract_months[fieldname])) | |||
# xhiveframework.msgprint(str(contract_months[fieldname])) | |||
col_data[fieldname] = contract_months[fieldname] | |||
# frappe.msgprint(str(col_data)) | |||
# xhiveframework.msgprint(str(col_data)) | |||
## NOTE | |||
# check if this label exists in dict of payments made above | |||
# if exists then payment for this contract is there so append it in columns | |||
@@ -1,26 +1,26 @@ | |||
// Copyright (c) 2016, Havenir Solutions and contributors | |||
// For license information, please see license.txt | |||
/* eslint-disable */ | |||
frappe.query_reports["Rent Roll"] = { | |||
xhiveframework.query_reports["Rent Roll"] = { | |||
"filters": [ | |||
{ | |||
"label": "Company", | |||
"fieldname": "company", | |||
"fieldtype": "Link", | |||
"options": "Company", | |||
"default": frappe.defaults.get_user_default("Company"), | |||
"default": xhiveframework.defaults.get_user_default("Company"), | |||
}, | |||
{ | |||
"label": "From Date", | |||
"fieldname": "from_date", | |||
"fieldtype": "Date", | |||
"default": frappe.datetime.year_start() | |||
"default": xhiveframework.datetime.year_start() | |||
}, | |||
{ | |||
"label": "To Date", | |||
"fieldname": "to_date", | |||
"fieldtype": "Date", | |||
"default": frappe.datetime.year_end() | |||
"default": xhiveframework.datetime.year_end() | |||
}, | |||
{ | |||
"label": "Status", | |||
@@ -2,8 +2,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
from frappe import _ | |||
import xhiveframework | |||
from xhiveframework import _ | |||
from dateutil import relativedelta | |||
import datetime | |||
import dateutil | |||
@@ -11,7 +11,7 @@ import calendar | |||
from calendar import weekday, monthrange | |||
from collections import Counter | |||
from dateutil.rrule import rrule, MONTHLY, YEARLY | |||
from frappe.utils import date_diff, flt | |||
from xhiveframework.utils import date_diff, flt | |||
def execute(filters=None): | |||
@@ -232,7 +232,7 @@ def execute(filters=None): | |||
start_date = datetime.datetime.strptime(str(filters.from_date), "%Y-%m-%d") | |||
end_date = datetime.datetime.strptime(str(filters.to_date), "%Y-%m-%d") | |||
# date_diffrance = date_diff(start_date, end_date) | |||
# if date_diffrance < 0: | |||
# end_date += relativedelta.relativedelta(days= abs(date_diffrance)) | |||
@@ -243,7 +243,7 @@ def execute(filters=None): | |||
month = '{:02d}'.format(row.month) | |||
day = '{:02d}'.format(row.day) | |||
label = f'{day}-{month_name}-{row.year}' | |||
fieldname = f'{day}-{month}-{row.year}' | |||
columns.append( | |||
@@ -266,13 +266,13 @@ def get_data(filters): | |||
else: | |||
q_filter = { "docstatus" : ["!=","2"]} | |||
result = frappe.get_list('Property Contract', q_filter, ['name']) | |||
result = xhiveframework.get_list('Property Contract', q_filter, ['name']) | |||
for row in result: | |||
contract = frappe.get_doc('Property Contract', row) | |||
contract = xhiveframework.get_doc('Property Contract', row) | |||
if not contract.unit: | |||
continue | |||
unit = frappe.get_doc('Unit', contract.unit) | |||
prop = frappe.get_doc('Property', contract.property_name) | |||
unit = xhiveframework.get_doc('Unit', contract.unit) | |||
prop = xhiveframework.get_doc('Property', contract.property_name) | |||
# Calculate Month Left | |||
date1 = datetime.datetime.strptime(str(contract.rent_end_date), '%Y-%m-%d') | |||
@@ -280,14 +280,14 @@ def get_data(filters): | |||
date_diffrance = date_diff(date2, date1) | |||
r = relativedelta.relativedelta(date1, date2) | |||
# frappe.msgprint(str(r)) | |||
# xhiveframework.msgprint(str(r)) | |||
months_left = abs(r.months) | |||
years_left = abs(r.years) | |||
if date_diffrance > 0: | |||
months_left = 0 | |||
years_left = 0 | |||
col_data = { | |||
'location': prop.property_location, | |||
'brand_name': contract.brand_name, | |||
@@ -363,15 +363,15 @@ def get_data(filters): | |||
if fieldname in contract_months and contract_months[fieldname]: | |||
#frappe.msgprint(str(contract_months[fieldname])) | |||
#xhiveframework.msgprint(str(contract_months[fieldname])) | |||
col_data[fieldname] = contract_months[fieldname] | |||
# frappe.msgprint(str(col_data)) | |||
# xhiveframework.msgprint(str(col_data)) | |||
## NOTE | |||
# check if this label exists in dict of payments made above | |||
# if exists then payment for this contract is there so append it in columns | |||
# all that's left is correct syntax to append in columns where date is same as column label | |||
# And calculation of yearly payment if required | |||
data.append(col_data) | |||
return data |
@@ -2,26 +2,26 @@ | |||
// For license information, please see license.txt | |||
/* eslint-disable */ | |||
frappe.query_reports["Service Charge Roll"] = { | |||
xhiveframework.query_reports["Service Charge Roll"] = { | |||
"filters": [ | |||
{ | |||
"label": "Company", | |||
"fieldname": "company", | |||
"fieldtype": "Link", | |||
"options": "Company", | |||
"default": frappe.defaults.get_user_default("Company"), | |||
"default": xhiveframework.defaults.get_user_default("Company"), | |||
}, | |||
{ | |||
"label": "From Date", | |||
"fieldname": "from_date", | |||
"fieldtype": "Date", | |||
"default": frappe.datetime.year_start() | |||
"default": xhiveframework.datetime.year_start() | |||
}, | |||
{ | |||
"label": "To Date", | |||
"fieldname": "to_date", | |||
"fieldtype": "Date", | |||
"default": frappe.datetime.year_end() | |||
"default": xhiveframework.datetime.year_end() | |||
}, | |||
{ | |||
"label": "Status", | |||
@@ -2,8 +2,8 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
from frappe import _ | |||
import xhiveframework | |||
from xhiveframework import _ | |||
from dateutil import relativedelta | |||
import datetime | |||
import dateutil | |||
@@ -11,7 +11,7 @@ import calendar | |||
from calendar import weekday, monthrange | |||
from collections import Counter | |||
from dateutil.rrule import rrule, MONTHLY, YEARLY | |||
from frappe.utils import date_diff | |||
from xhiveframework.utils import date_diff | |||
def execute(filters=None): | |||
@@ -278,13 +278,13 @@ def get_data(filters): | |||
else: | |||
q_filter = { "docstatus" : ["!=","2"]} | |||
result = frappe.get_list('Property Contract', q_filter, ['name']) | |||
result = xhiveframework.get_list('Property Contract', q_filter, ['name']) | |||
for row in result: | |||
contract = frappe.get_doc('Property Contract', row) | |||
contract = xhiveframework.get_doc('Property Contract', row) | |||
if not contract.unit: | |||
continue | |||
unit = frappe.get_doc('Unit', contract.unit) | |||
prop = frappe.get_doc('Property', contract.property_name) | |||
unit = xhiveframework.get_doc('Unit', contract.unit) | |||
prop = xhiveframework.get_doc('Property', contract.property_name) | |||
# Calculate Month Left | |||
date1 = datetime.datetime.strptime(str(contract.rent_end_date), '%Y-%m-%d') | |||
@@ -292,7 +292,7 @@ def get_data(filters): | |||
date_diffrance = date_diff(date2, date1) | |||
r = relativedelta.relativedelta(date1, date2) | |||
# frappe.msgprint(str(r)) | |||
# xhiveframework.msgprint(str(r)) | |||
months_left = abs(r.months) | |||
years_left = abs(r.years) | |||
@@ -373,9 +373,9 @@ def get_data(filters): | |||
fieldname = f'{day}-{month}-{row.year}' | |||
if fieldname in contract_months and contract_months[fieldname]: | |||
# frappe.msgprint(str(contract_months[fieldname])) | |||
# xhiveframework.msgprint(str(contract_months[fieldname])) | |||
col_data[fieldname] = contract_months[fieldname] | |||
# frappe.msgprint(str(col_data)) | |||
# xhiveframework.msgprint(str(col_data)) | |||
## NOTE | |||
# check if this label exists in dict of payments made above | |||
# if exists then payment for this contract is there so append it in columns | |||
@@ -2,7 +2,7 @@ | |||
// For license information, please see license.txt | |||
/* eslint-disable */ | |||
frappe.query_reports["Sold Unit"] = { | |||
xhiveframework.query_reports["Sold Unit"] = { | |||
"filters": [ | |||
] | |||
@@ -2,7 +2,7 @@ | |||
# For license information, please see license.txt | |||
from __future__ import unicode_literals | |||
import frappe | |||
import xhiveframework | |||
def execute(filters=None): | |||
columns = get_columns(filters) | |||
@@ -11,111 +11,111 @@ def execute(filters=None): | |||
def get_columns(filters): | |||
columns = [ | |||
{ | |||
{ | |||
"label": "Sr", | |||
"fieldname": "serial_number", | |||
"fieldtype": "Int", | |||
"width": 50 | |||
}, | |||
{ | |||
{ | |||
"label": "Name", | |||
"fieldname": "unit", | |||
"fieldtype": "Link", | |||
"options": "Unit", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Docstatus", | |||
"fieldname": "docstatus", | |||
"fieldtype": "Int", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Unit Number", | |||
"fieldname": "unit_number", | |||
"fieldtype": "Data", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Role (Floor Number)", | |||
"fieldname": "role_floor_number", | |||
"fieldtype": "Data", | |||
"width": 150 | |||
}, | |||
{ | |||
{ | |||
"label": "Contract Year", | |||
"fieldname": "contract_year", | |||
"fieldtype": "Data", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Unit Type", | |||
"fieldname": "unit_type", | |||
"fieldtype": "Link", | |||
"options": "Unit Type", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Property Owner (Customer)", | |||
"fieldname": "property_owner", | |||
"fieldtype": "Data", | |||
"width": 200 | |||
}, | |||
{ | |||
{ | |||
"label": "Unit Area (per Square Meter)", | |||
"fieldname": "unit_area", | |||
"fieldtype": "Int", | |||
"width": 200 | |||
}, | |||
{ | |||
{ | |||
"label": "Price (per Square Meter)", | |||
"fieldname": "price_psm", | |||
"fieldtype": "Data", | |||
"width": 200 | |||
}, | |||
{ | |||
{ | |||
"label": "Unit Price", | |||
"fieldname": "unit_price", | |||
"fieldtype": "Float", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Unit Total Cost", | |||
"fieldname": "unit_valuation_rate", | |||
"fieldtype": "Float", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Total Invoiced", | |||
"fieldname": "total_invoiced", | |||
"fieldtype": "Float", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Total Paid", | |||
"fieldname": "total_paid", | |||
"fieldtype": "Float", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Unit Profit", | |||
"fieldname":"unit_profit", | |||
"fieldtype": "Float", | |||
"width": 100 | |||
}, | |||
{ | |||
{ | |||
"label": "Total Outstanding", | |||
"fieldname": "total_outstanding", | |||
"fieldtype": "Float", | |||
"width": 150 | |||
}, | |||
] | |||
return columns | |||
def build_data(filters): | |||
data = [] | |||
sub_filters = {} | |||
fields = [ | |||
"name", | |||
@@ -129,8 +129,8 @@ def build_data(filters): | |||
"unit_price", | |||
"unit_valuation_rate", | |||
] | |||
units = frappe.get_list("Unit", sub_filters, fields) | |||
units = xhiveframework.get_list("Unit", sub_filters, fields) | |||
i = 1 | |||
for row in units: | |||
sub_filters = { | |||
@@ -142,20 +142,20 @@ def build_data(filters): | |||
"grand_total", | |||
"outstanding_amount", | |||
] | |||
invoiced = 0 | |||
outstanding = 0 | |||
paid = 0 | |||
invoices = frappe.get_list("Sales Invoice", sub_filters, fields) | |||
invoices = xhiveframework.get_list("Sales Invoice", sub_filters, fields) | |||
for invoice in invoices: | |||
invoiced += invoice.grand_total | |||
outstanding += invoice.outstanding_amount | |||
paid = invoiced - outstanding | |||
unit_profit = row.unit_valuation_rate-invoiced | |||
record = { | |||
"serial_number": i, | |||
"unit": row.name, | |||
@@ -173,8 +173,8 @@ def build_data(filters): | |||
"unit_profit":unit_profit, | |||
"total_outstanding": outstanding, | |||
} | |||
i = i + 1 | |||
data.append(record) | |||
return data | |||
return data |
@@ -1,16 +1,16 @@ | |||
frappe.ui.form.on("Payment Entry", { | |||
xhiveframework.ui.form.on("Payment Entry", { | |||
onload(frm, dt, dn) { | |||
if (frm.is_new()) { | |||
const item = frm.doc.references[0]; | |||
let doctype = "Sales Invoice"; | |||
let doc_name = item.reference_name; | |||
frappe.db.get_value(doctype, doc_name, "unit").then((r) => { | |||
frappe.model.set_value(dt, dn, "unit", r.message.unit); | |||
xhiveframework.db.get_value(doctype, doc_name, "unit").then((r) => { | |||
xhiveframework.model.set_value(dt, dn, "unit", r.message.unit); | |||
}); | |||
frappe.db.get_value(doctype, doc_name, "property").then((r) => { | |||
frappe.model.set_value(dt, dn, "property", r.message.property); | |||
xhiveframework.db.get_value(doctype, doc_name, "property").then((r) => { | |||
xhiveframework.model.set_value(dt, dn, "property", r.message.property); | |||
}); | |||
} | |||
}, | |||