fix: share transfer validations for journal entry (#19018)
* fix share transfer validations for journal entry * fix: share transfer test * fix: tests
This commit is contained in:
parent
e4f8bda1ea
commit
72949e7f73
@ -86,17 +86,23 @@ class ShareTransfer(Document):
|
|||||||
frappe.throw(_('The field From Shareholder cannot be blank'))
|
frappe.throw(_('The field From Shareholder cannot be blank'))
|
||||||
if self.from_folio_no is None or self.from_folio_no is '':
|
if self.from_folio_no is None or self.from_folio_no is '':
|
||||||
self.to_folio_no = self.autoname_folio(self.to_shareholder)
|
self.to_folio_no = self.autoname_folio(self.to_shareholder)
|
||||||
|
if self.asset_account is None:
|
||||||
|
frappe.throw(_('The field Asset Account cannot be blank'))
|
||||||
elif (self.transfer_type == 'Issue'):
|
elif (self.transfer_type == 'Issue'):
|
||||||
self.from_shareholder = ''
|
self.from_shareholder = ''
|
||||||
if self.to_shareholder is None or self.to_shareholder == '':
|
if self.to_shareholder is None or self.to_shareholder == '':
|
||||||
frappe.throw(_('The field To Shareholder cannot be blank'))
|
frappe.throw(_('The field To Shareholder cannot be blank'))
|
||||||
if self.to_folio_no is None or self.to_folio_no is '':
|
if self.to_folio_no is None or self.to_folio_no is '':
|
||||||
self.to_folio_no = self.autoname_folio(self.to_shareholder)
|
self.to_folio_no = self.autoname_folio(self.to_shareholder)
|
||||||
|
if self.asset_account is None:
|
||||||
|
frappe.throw(_('The field Asset Account cannot be blank'))
|
||||||
else:
|
else:
|
||||||
if self.from_shareholder is None or self.to_shareholder is None:
|
if self.from_shareholder is None or self.to_shareholder is None:
|
||||||
frappe.throw(_('The fields From Shareholder and To Shareholder cannot be blank'))
|
frappe.throw(_('The fields From Shareholder and To Shareholder cannot be blank'))
|
||||||
if self.to_folio_no is None or self.to_folio_no is '':
|
if self.to_folio_no is None or self.to_folio_no is '':
|
||||||
self.to_folio_no = self.autoname_folio(self.to_shareholder)
|
self.to_folio_no = self.autoname_folio(self.to_shareholder)
|
||||||
|
if self.equity_or_liability_account is None:
|
||||||
|
frappe.throw(_('The field Equity/Liability Account cannot be blank'))
|
||||||
if self.from_shareholder == self.to_shareholder:
|
if self.from_shareholder == self.to_shareholder:
|
||||||
frappe.throw(_('The seller and the buyer cannot be the same'))
|
frappe.throw(_('The seller and the buyer cannot be the same'))
|
||||||
if self.no_of_shares != self.to_no - self.from_no + 1:
|
if self.no_of_shares != self.to_no - self.from_no + 1:
|
||||||
|
@ -24,7 +24,9 @@ class TestShareTransfer(unittest.TestCase):
|
|||||||
"to_no" : 500,
|
"to_no" : 500,
|
||||||
"no_of_shares" : 500,
|
"no_of_shares" : 500,
|
||||||
"rate" : 10,
|
"rate" : 10,
|
||||||
"company" : "_Test Company"
|
"company" : "_Test Company",
|
||||||
|
"asset_account" : "Cash - _TC",
|
||||||
|
"equity_or_liability_account": "Creditors - _TC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype" : "Share Transfer",
|
"doctype" : "Share Transfer",
|
||||||
@ -37,7 +39,8 @@ class TestShareTransfer(unittest.TestCase):
|
|||||||
"to_no" : 200,
|
"to_no" : 200,
|
||||||
"no_of_shares" : 100,
|
"no_of_shares" : 100,
|
||||||
"rate" : 15,
|
"rate" : 15,
|
||||||
"company" : "_Test Company"
|
"company" : "_Test Company",
|
||||||
|
"equity_or_liability_account": "Creditors - _TC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype" : "Share Transfer",
|
"doctype" : "Share Transfer",
|
||||||
@ -50,7 +53,8 @@ class TestShareTransfer(unittest.TestCase):
|
|||||||
"to_no" : 500,
|
"to_no" : 500,
|
||||||
"no_of_shares" : 300,
|
"no_of_shares" : 300,
|
||||||
"rate" : 20,
|
"rate" : 20,
|
||||||
"company" : "_Test Company"
|
"company" : "_Test Company",
|
||||||
|
"equity_or_liability_account": "Creditors - _TC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype" : "Share Transfer",
|
"doctype" : "Share Transfer",
|
||||||
@ -63,7 +67,8 @@ class TestShareTransfer(unittest.TestCase):
|
|||||||
"to_no" : 400,
|
"to_no" : 400,
|
||||||
"no_of_shares" : 200,
|
"no_of_shares" : 200,
|
||||||
"rate" : 15,
|
"rate" : 15,
|
||||||
"company" : "_Test Company"
|
"company" : "_Test Company",
|
||||||
|
"equity_or_liability_account": "Creditors - _TC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype" : "Share Transfer",
|
"doctype" : "Share Transfer",
|
||||||
@ -75,7 +80,9 @@ class TestShareTransfer(unittest.TestCase):
|
|||||||
"to_no" : 500,
|
"to_no" : 500,
|
||||||
"no_of_shares" : 100,
|
"no_of_shares" : 100,
|
||||||
"rate" : 25,
|
"rate" : 25,
|
||||||
"company" : "_Test Company"
|
"company" : "_Test Company",
|
||||||
|
"asset_account" : "Cash - _TC",
|
||||||
|
"equity_or_liability_account": "Creditors - _TC"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
for d in share_transfers:
|
for d in share_transfers:
|
||||||
@ -94,7 +101,8 @@ class TestShareTransfer(unittest.TestCase):
|
|||||||
"to_no" : 100,
|
"to_no" : 100,
|
||||||
"no_of_shares" : 100,
|
"no_of_shares" : 100,
|
||||||
"rate" : 15,
|
"rate" : 15,
|
||||||
"company" : "_Test Company"
|
"company" : "_Test Company",
|
||||||
|
"equity_or_liability_account": "Creditors - _TC"
|
||||||
})
|
})
|
||||||
self.assertRaises(ShareDontExists, doc.insert)
|
self.assertRaises(ShareDontExists, doc.insert)
|
||||||
|
|
||||||
@ -108,6 +116,8 @@ class TestShareTransfer(unittest.TestCase):
|
|||||||
"to_no" : 200,
|
"to_no" : 200,
|
||||||
"no_of_shares" : 200,
|
"no_of_shares" : 200,
|
||||||
"rate" : 15,
|
"rate" : 15,
|
||||||
"company" : "_Test Company"
|
"company" : "_Test Company",
|
||||||
|
"asset_account" : "Cash - _TC",
|
||||||
|
"equity_or_liability_account": "Creditors - _TC"
|
||||||
})
|
})
|
||||||
self.assertRaises(ShareDontExists, doc.insert)
|
self.assertRaises(ShareDontExists, doc.insert)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user