Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging fixes #15734

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
423549e
Fixed PDC data in AR/AP report:
SaiFi0102 Sep 8, 2018
fa7c8a9
update employee and user records
Zlash65 Sep 25, 2018
4c07970
remove user permission from HR Manager user
Zlash65 Sep 25, 2018
796bffb
fix payroll and stock related data
Zlash65 Sep 26, 2018
0309bbe
function call requires company as parameter
Zlash65 Sep 27, 2018
a259466
add relevant department to employees
Zlash65 Sep 27, 2018
c24d2fd
setup leave & expense approver for each department
Zlash65 Sep 27, 2018
143d4da
Production Plan fix
Zlash65 Sep 27, 2018
dcf7401
random time fix and other minor fixes
Zlash65 Sep 27, 2018
523f77e
make_rm_stock_entry fix
Zlash65 Sep 28, 2018
e895845
import fix
Zlash65 Oct 1, 2018
e64dcfc
timesheet logic changed to job card
Zlash65 Oct 1, 2018
d080a17
minor random trigger changes and exception handling
Zlash65 Oct 1, 2018
8b1133c
item data fix for default supplier, exception handling for purchase o…
Zlash65 Oct 1, 2018
275ef82
codacy fixes
Zlash65 Oct 2, 2018
d1fbaf8
custom field added for item - domainification, password changed
Zlash65 Oct 10, 2018
fd9c451
company name picked up dynamically, domainification
Zlash65 Oct 10, 2018
62592d3
setup data for retail added
Zlash65 Oct 10, 2018
6a8957b
item data updated with retail data
Zlash65 Oct 10, 2018
10dfd4a
Show project attachments in portal view
jodeq Sep 10, 2018
7c44326
Currency symbol bug fix (#15690)
deepeshgarg007 Oct 15, 2018
7844b79
[Bug-Fix] accounts_receivable.html (#15688)
bibinqcs Oct 15, 2018
615571d
Add safe decode for payer name (#15692)
chdecultot Oct 15, 2018
44ec05f
fix(bom): deadlock issue via bom replace tool (#15694)
nabinhait Oct 15, 2018
4bb90ad
Currency symbol bug fix (#15698)
deepeshgarg007 Oct 15, 2018
666e6e6
feat: Add provision for prebilled subscription invoices
joeirimpan Oct 3, 2018
a5a9269
Update accounts_receivable.py
rohitwaghchaure Oct 16, 2018
19be730
Merge pull request #15700 from joeirimpan/staging-fixes
rohitwaghchaure Oct 16, 2018
8aca568
fix(margin): Make user avatar display in line
shreyashah115 Oct 16, 2018
8266091
fix(report): Add column for Item Name
shreyashah115 Oct 16, 2018
bfb88f7
Merge pull request #15701 from shreyashah115/item-stock
shreyashah115 Oct 16, 2018
22731e3
Merge pull request #15376 from jodeq/show_project-attachments-in-portal
shreyashah115 Oct 16, 2018
ff0deed
fix(discount-amount): Print hide discount_amount if print without amo…
shreyashah115 Oct 16, 2018
e45868a
fix(discount-amount): Print hide discount_amount if print without amo…
shreyashah115 Oct 16, 2018
8e71074
fix(report): Add column for Item Name (#15702)
shreyashah115 Oct 16, 2018
0cbb9b5
Deprecating subscriber doctype (#15695)
deepeshgarg007 Oct 16, 2018
4fdbff7
Merge pull request #15547 from Zlash65/demo-refactor
codingCoffee Oct 16, 2018
bb1b6b4
bumped to version 10.1.60
codingCoffee Oct 17, 2018
bbd8b04
Merge branch 'hotfix'
codingCoffee Oct 17, 2018
77b6092
Merge branch 'master' into staging-fixes
codingCoffee Oct 17, 2018
a7a32d7
bumped to version 11.0.3-beta.12
codingCoffee Oct 17, 2018
961b7de
Merge branch 'staging-fixes' into staging
codingCoffee Oct 17, 2018
e2afbb7
Merge pull request #15703 from SaiFi0102/AR-AP-PDC-Fix
rohitwaghchaure Oct 17, 2018
007fbfb
[Feature] ERPNext Quickbooks Migrator (#15718)
adityahase Oct 17, 2018
7a7615e
Safe encode payer name (#15726)
chdecultot Oct 18, 2018
25e9db5
Do not display gender for companies (#15728)
barredterra Oct 18, 2018
25edac4
Production Analytics Query Report (#15673)
deepeshgarg007 Oct 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from erpnext.hooks import regional_overrides
from frappe.utils import getdate

__version__ = '10.1.59'
__version__ = '10.1.60'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_payment_url(self):
"reference_doctype": "Payment Request",
"reference_docname": self.name,
"payer_email": self.email_to or frappe.session.user,
"payer_name": data.customer_name,
"payer_name": frappe.safe_encode(data.customer_name),
"order_id": self.name,
"currency": self.currency
})
Expand Down
2 changes: 0 additions & 2 deletions erpnext/accounts/doctype/subscriber/subscriber.js

This file was deleted.

129 changes: 0 additions & 129 deletions erpnext/accounts/doctype/subscriber/subscriber.json

This file was deleted.

9 changes: 0 additions & 9 deletions erpnext/accounts/doctype/subscriber/subscriber.py

This file was deleted.

14 changes: 0 additions & 14 deletions erpnext/accounts/doctype/subscriber/subscriber_dashboard.py

This file was deleted.

43 changes: 38 additions & 5 deletions erpnext/accounts/doctype/subscription/subscription.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
Expand All @@ -20,7 +21,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "subscriber",
"fieldname": "customer",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
Expand All @@ -29,10 +30,10 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Subscriber",
"label": "Customer",
"length": 0,
"no_copy": 0,
"options": "Subscriber",
"options": "Customer",
"permlevel": 0,
"precision": "",
"print_hide": 0,
Expand Down Expand Up @@ -437,6 +438,38 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "generate_invoice_at_period_start",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Generate Invoice At Beginning Of Period",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
Expand Down Expand Up @@ -814,7 +847,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-08-21 16:15:44.533482",
"modified": "2018-10-14 10:38:55.545540",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Subscription",
Expand Down Expand Up @@ -890,4 +923,4 @@
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}
}
32 changes: 21 additions & 11 deletions erpnext/accounts/doctype/subscription/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def create_invoice(self, prorate):
invoice = frappe.new_doc('Sales Invoice')
invoice.set_posting_time = 1
invoice.posting_date = self.current_invoice_start
invoice.customer = self.get_customer(self.subscriber)
invoice.customer = self.customer

# Subscription is better suited for service items. I won't update `update_stock`
# for that reason
Expand Down Expand Up @@ -282,13 +282,6 @@ def create_invoice(self, prorate):

return invoice

@staticmethod
def get_customer(subscriber_name):
"""
Returns the `Customer` linked to the `Subscriber`
"""
return frappe.db.get_value('Subscriber', subscriber_name, 'customer')

def get_items_from_plans(self, plans, prorate=0):
"""
Returns the `Item`s linked to `Subscription Plan`
Expand All @@ -297,7 +290,7 @@ def get_items_from_plans(self, plans, prorate=0):
prorate_factor = get_prorata_factor(self.current_invoice_end, self.current_invoice_start)

items = []
customer = self.get_customer(self.subscriber)
customer = self.customer
for plan in plans:
item_code = frappe.db.get_value("Subscription Plan", plan.plan, "item")
if not prorate:
Expand All @@ -321,6 +314,23 @@ def process(self):

self.save()

@property
def is_postpaid_to_invoice(self):
return getdate(nowdate()) > getdate(self.current_invoice_end) or \
(getdate(nowdate()) >= getdate(self.current_invoice_end) and getdate(self.current_invoice_end) == getdate(self.current_invoice_start)) and \
not self.has_outstanding_invoice()

@property
def is_prepaid_to_invoice(self):
if not self.generate_invoice_at_period_start:
return False

if self.is_new_subscription():
return True

# Check invoice dates and make sure it doesn't have outstanding invoices
return getdate(nowdate()) >= getdate(self.current_invoice_start) and not self.has_outstanding_invoice()

def process_for_active(self):
"""
Called by `process` if the status of the `Subscription` is 'Active'.
Expand All @@ -330,15 +340,15 @@ def process_for_active(self):
2. Change the `Subscription` status to 'Past Due Date'
3. Change the `Subscription` status to 'Cancelled'
"""
if getdate(nowdate()) > getdate(self.current_invoice_end) or (getdate(nowdate()) >= getdate(self.current_invoice_end) and getdate(self.current_invoice_end) == getdate(self.current_invoice_start)) and not self.has_outstanding_invoice():
if self.is_postpaid_to_invoice or self.is_prepaid_to_invoice:
self.generate_invoice()
if self.current_invoice_is_past_due():
self.status = 'Past Due Date'

if self.current_invoice_is_past_due() and getdate(nowdate()) > getdate(self.current_invoice_end):
self.status = 'Past Due Date'

if self.cancel_at_period_end and getdate(nowdate()) > self.current_invoice_end:
if self.cancel_at_period_end and getdate(nowdate()) > getdate(self.current_invoice_end):
self.cancel_subscription_at_period_end()

def cancel_subscription_at_period_end(self):
Expand Down
48 changes: 48 additions & 0 deletions erpnext/accounts/doctype/subscription/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,51 @@ def test_subscription_invoice_discount_amount(self):
self.assertEqual(invoice.apply_discount_on, 'Grand Total')

subscription.delete()

def test_prepaid_subscriptions(self):
# Create a non pre-billed subscription, processing should not create
# invoices.
subscription = frappe.new_doc('Subscription')
subscription.subscriber = '_Test Customer'
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
subscription.save()
subscription.process()

self.assertEqual(len(subscription.invoices), 0)

# Change the subscription type to prebilled and process it.
# Prepaid invoice should be generated
subscription.generate_invoice_at_period_start = True
subscription.save()
subscription.process()

self.assertEqual(len(subscription.invoices), 1)

def test_prepaid_subscriptions_with_prorate_true(self):
settings = frappe.get_single('Subscription Settings')
to_prorate = settings.prorate
settings.prorate = 1
settings.save()

subscription = frappe.new_doc('Subscription')
subscription.subscriber = '_Test Customer'
subscription.generate_invoice_at_period_start = True
subscription.append('plans', {'plan': '_Test Plan Name', 'qty': 1})
subscription.save()
subscription.cancel_subscription()

self.assertEqual(len(subscription.invoices), 1)

current_inv = subscription.get_current_invoice()
self.assertEqual(current_inv.status, "Unpaid")

diff = flt(date_diff(nowdate(), subscription.current_invoice_start) + 1)
plan_days = flt(date_diff(subscription.current_invoice_end, subscription.current_invoice_start) + 1)
prorate_factor = flt(diff / plan_days)

self.assertEqual(flt(current_inv.grand_total, 2), flt(prorate_factor * 900, 2))

settings.prorate = to_prorate
settings.save()

subscription.delete()