@@ -91,6 +91,7 @@ def on_submit(self):
91
91
frappe .throw (_ ("Difference Amount must be zero" ))
92
92
self .make_gl_entries ()
93
93
self .update_expense_claim ()
94
+ self .update_sales_commission ()
94
95
self .update_outstanding_amounts ()
95
96
self .update_advance_paid ()
96
97
self .update_donation ()
@@ -101,7 +102,7 @@ def on_cancel(self):
101
102
self .ignore_linked_doctypes = ('GL Entry' , 'Stock Ledger Entry' , 'Sales Commission' )
102
103
self .make_gl_entries (cancel = 1 )
103
104
self .update_expense_claim ()
104
- self .update_sales_commission ()
105
+ self .update_sales_commission (cancel = 1 )
105
106
self .update_outstanding_amounts ()
106
107
self .update_advance_paid ()
107
108
self .update_donation (cancel = 1 )
@@ -884,13 +885,14 @@ def update_expense_claim(self):
884
885
else :
885
886
update_reimbursed_amount (doc , d .allocated_amount )
886
887
887
- def update_sales_commission (self ):
888
+ def update_sales_commission (self , cancel = 0 ):
888
889
if self .payment_type in ("Pay" ) and self .party :
889
890
for d in self .get ("references" ):
890
891
if d .reference_doctype == "Sales Commission" and d .reference_name :
891
- frappe .db .set_value ("Sales Commission" , d .reference_name , "status" , "Unpaid" )
892
- frappe .db .set_value ("Sales Commission" , d .reference_name , "reference_doctype" , "" )
893
- frappe .db .set_value ("Sales Commission" , d .reference_name , "reference_name" , "" )
892
+ if cancel :
893
+ frappe .db .set_value ("Sales Commission" , d .reference_name , "status" , "Unpaid" )
894
+ else :
895
+ frappe .db .set_value ("Sales Commission" , d .reference_name , "status" , "Paid" )
894
896
895
897
def update_donation (self , cancel = 0 ):
896
898
if self .payment_type == "Receive" and self .party_type == "Donor" and self .party :
0 commit comments