Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion propms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

__version__ = "1.7.0"
__version__ = "1.8.0"
2 changes: 1 addition & 1 deletion propms/issue_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def getTax(sales_invoice):
def make_sales_pos_payment(invoice_doc, pos_profile_name):
default_mode_of_payment = frappe.db.get_value(
"Sales Invoice Payment",
{"parent": pos_profile_name, "default": 1},
{"parent": invoice_doc.name, "default": 1},
["mode_of_payment", "type", "account"],
as_dict=1,
)
Expand Down
59 changes: 32 additions & 27 deletions propms/lease_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,34 @@ def getCostCenter(name):


@frappe.whitelist()
def leaseInvoiceAutoCreate():
def leaseInvoiceAutoCreate(invoices_schedule=None):
"""Prepare data to create sales invoice from lease invoice schedule. This is called from form button as well as daily schedule"""
try:
# frappe.msgprint("Started")
invoice_start_date = frappe.db.get_single_value(
"Property Management Settings", "invoice_start_date"
)
lease_invoice = frappe.get_all(
"Lease Invoice Schedule",
filters={
"date_to_invoice": ["between", (invoice_start_date, today())],
"invoice_number": "",
"sales_order_number": ""
},
fields=[
"name",
"date_to_invoice",
"invoice_number",
"sales_order_number",
"parent",
"parent",
"invoice_item_group",
"lease_item",
"paid_by",
"currency",
],
order_by="parent, paid_by, invoice_item_group, date_to_invoice, currency, lease_item",
)
if not invoices_schedule:
invoice_start_date = frappe.db.get_single_value(
"Property Management Settings", "invoice_start_date"
)
invoices_schedule = frappe.get_all(
"Lease Invoice Schedule",
filters={
"date_to_invoice": ["between", (invoice_start_date, today())],
"invoice_number": "",
"sales_order_number": ""
},
fields=[
"name",
"date_to_invoice",
"invoice_number",
"sales_order_number",
"parent",
"parent",
"invoice_item_group",
"lease_item",
"paid_by",
"currency",
],
order_by="parent, paid_by, invoice_item_group, date_to_invoice, currency, lease_item",
)
# frappe.msgprint("Lease being generated for " + str(lease_invoice))
row_num = 1 # to identify the 1st line of the list
prev_parent = ""
Expand All @@ -148,7 +148,7 @@ def leaseInvoiceAutoCreate():
item_dict = []
item_json = {}
# frappe.msgprint(str(lease_invoice))
for row in lease_invoice:
for row in invoices_schedule:
# frappe.msgprint(str(invoice_item.name) + " " + str(invoice_item.lease_item))
# Check if same lease, customer, invoice_item_group and date_to_invoice.
# Also should not be 1st row of the list
Expand Down Expand Up @@ -262,3 +262,8 @@ def leaseInvoiceAutoCreate():
@frappe.whitelist()
def test():
return today()


@frappe.whitelist()
def create_lease_voucher(invoice_schedule):
leaseInvoiceAutoCreate([frappe._dict(json.loads(invoice_schedule))])
74 changes: 51 additions & 23 deletions propms/property_management_solution/doctype/lease/lease.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,113 @@
cur_frm.add_fetch('property', 'unit_owner', 'property_owner');

frappe.ui.form.on('Lease', {
setup: function(frm) {
frm.set_query("lease_item", "lease_item", function() {
setup: function (frm) {
frm.set_query("lease_item", "lease_item", function () {
return {
"filters": [
["item_group","=", "Lease Items"],
["item_group", "=", "Lease Items"],
]
};
});
frm.set_query("property", function() {
frm.set_query("property", function () {
return {
"filters": {
"company": frm.doc.company,
"company": frm.doc.company,
},
};
});
},
refresh: function(frm) {
cur_frm.add_custom_button(__("Make Invoice Schedule"), function() {
refresh: function (frm) {
cur_frm.add_custom_button(__("Make Invoice Schedule"), function () {
make_lease_invoice_schedule(cur_frm);
});
cur_frm.add_custom_button(__("Generate Pending Invoice"), function() {
cur_frm.add_custom_button(__("Generate Pending Invoice"), function () {
generate_pending_invoice();
});
cur_frm.add_custom_button(__("Make Invoice Schedule for all Lease"), function() {
cur_frm.add_custom_button(__("Make Invoice Schedule for all Lease"), function () {
getAllLease(cur_frm);
});
},
onload: function(frm) {
frappe.realtime.on("lease_invoice_schedule_progress", function(data) {
onload: function (frm) {
frappe.realtime.on("lease_invoice_schedule_progress", function (data) {
if (data.reload && data.reload === 1) {
frm.reload_doc();
}
if (data.progress) {
let progress_bar = $(cur_frm.dashboard.progress_area).find(".progress-bar");
if (progress_bar) {
$(progress_bar).removeClass("progress-bar-danger").addClass("progress-bar-success progress-bar-striped");
$(progress_bar).css("width", data.progress+"%");
$(progress_bar).css("width", data.progress + "%");
}
}
});
}
});

var make_lease_invoice_schedule = function(frm){
var make_lease_invoice_schedule = function (frm) {
var doc = frm.doc;
frappe.call({
method: "propms.property_management_solution.doctype.lease.lease.make_lease_invoice_schedule",
args: {leasedoc: doc.name},
callback: function(){
method: "propms.property_management_solution.doctype.lease.lease.make_lease_invoice_schedule",
args: { leasedoc: doc.name },
callback: function () {
cur_frm.reload_doc();
}
});
};

var generate_pending_invoice = function(){
var generate_pending_invoice = function () {
frappe.call({
method: "propms.lease_invoice.leaseInvoiceAutoCreate",
args: {},
callback: function(){
callback: function () {
cur_frm.reload_doc();
}
});
};

var getAllLease = function(){
var getAllLease = function () {
frappe.confirm(
'Are you sure to initiate this long process?',
function(){
function () {
frappe.call({
method: "propms.property_management_solution.doctype.lease.lease.getAllLease",
args: {},
callback: function(){
callback: function () {
cur_frm.reload_doc();
}
});
},
function(){
function () {
frappe.msgprint(__("Closed before starting long process!"));
window.close();
}
)
);
};

frappe.ui.form.on('Lease Invoice Schedule', {
create_voucher: function (frm, cdt, cdn) {
// check if document is saved
if (frm.is_dirty()) {
frappe.msgprint("Please save the document first");
return;
}
const row = locals[cdt][cdn];
if (row.invoice_number || row.sales_order_number) {
frappe.msgprint("Voucher already created");
return;
}
frappe.call({
method: "propms.lease_invoice.create_lease_voucher",
args: {
invoice_schedule: row,
},
callback: function (r) {
// reload the doc
frm.reload_doc();
// refresh child table
frm.refresh_field("lease_invoice_schedule");
}
});

}
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"paid_by",
"lease_item_name",
"document_type",
"create_voucher",
"invoice_number",
"sales_order_number",
"qty",
Expand Down Expand Up @@ -114,11 +115,17 @@
"fieldtype": "Select",
"label": "Document Type",
"options": "\nSales Invoice\nSales Order"
},
{
"depends_on": "eval: !doc.sales_order_number && !doc.invoice_number && doc.document_type",
"fieldname": "create_voucher",
"fieldtype": "Button",
"label": "Create Voucher"
}
],
"istable": 1,
"links": [],
"modified": "2022-05-28 15:13:40.233162",
"modified": "2023-01-04 16:35:55.362846",
"modified_by": "Administrator",
"module": "Property Management Solution",
"name": "Lease Invoice Schedule",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"charts": [],
"content": "[{\"type\":\"header\",\"data\":{\"text\":\"<span class=\\\"h4\\\">Your Shortcuts</span>\",\"col\":12}},{\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Lease\",\"col\":4}},{\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Property\",\"col\":4}},{\"type\":\"card\",\"data\":{\"card_name\":\"Documents\",\"col\":5}}]",
"creation": "2020-12-28 17:56:01.070160",
"docstatus": 0,
"doctype": "Workspace",
"hide_custom": 0,
"idx": 0,
"label": "Real Estate Management",
"links": [
{
"hidden": 0,
"is_query_report": 0,
"label": "Documents",
"link_count": 2,
"onboard": 0,
"type": "Card Break"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Apartment Status",
"link_count": 0,
"link_to": "Apartment Status",
"link_type": "DocType",
"onboard": 0,
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Daily Checklist Detail",
"link_count": 0,
"link_to": "Daily Checklist Detail",
"link_type": "DocType",
"onboard": 0,
"type": "Link"
}
],
"modified": "2022-12-11 18:45:25.174279",
"modified_by": "av-dev1@aakvatech.com",
"module": "Property Management Solution",
"name": "Real Estate Management",
"owner": "info@aakvatech.com",
"public": 1,
"quick_lists": [],
"roles": [],
"sequence_id": 374.0,
"shortcuts": [
{
"doc_view": "",
"label": "Lease",
"link_to": "Lease",
"type": "DocType"
},
{
"doc_view": "",
"label": "Property",
"link_to": "Property",
"type": "DocType"
}
],
"title": "Real Estate Management"
}