Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Z_DeleteCreditNote
10-03-2019, 07:07 AM
Post: #1
Z_DeleteCreditNote
Hi

I'm getting the following messages when trying to delete a Credit Note

INFORMATION Message : The number of stock movements to be deleted is: 5
INFORMATION Message : The custallocns record has been deleted
INFORMATION Message : The debtortranstaxes record has been deleted
INFORMATION Message : Deleted the credit note stock move taxesinfo



Database Error 1451 : SQL to delete the stock movement record failed with the message
Cannot delete or update a parent row: a foreign key constraint fails (`weberb_test`.`stockserialmoves`, CONSTRAINT `stockserialmoves_ibfk_1` FOREIGN KEY (`stockmoveno`) REFERENCES `stockmoves` (`stkmoveno`))
Database SQL Failure : The SQL that failed was
DELETE FROM stockmoves WHERE type=11 AND transno = '76'
Database Rollback Due to Error Above : Rolling Back Transaction OK


Anyway to bypass the key constraint?

Please no rant about not using this script deleting credit notes :-)
I'm currently working on an invoice editing feature that does things by the book:
1) auto-generating a full credit with returned goods
2) auto-clone the initial order with identical lots
3)
- if new order invoice issued, it becomes the revised order and tag the old one and new ones as revised/revision to clearly identify them as related
- if new order is discarded by user before being invoiced: the autogenerated credit note is deleted (that's why I'm using Z_DeleteCreditNote.php for: to put everything back to the original state and cancel my autogenerated Credit Note)

Thanks
Find all posts by this user
Quote this message in a reply
10-03-2019, 11:49 AM
Post: #2
RE: Z_DeleteCreditNote
Hello, HDeriauFF!

Please try the attached script.
I've never worked with serial items, so there could potentially be some other delete needed. If another error occurs, post a reply, and we'll work it through one step at a time.


Attached File(s)
.php  Z_DeleteCreditNote.php (Size: 6.03 KB / Downloads: 4)
Find all posts by this user
Quote this message in a reply
10-03-2019, 12:07 PM
Post: #3
RE: Z_DeleteCreditNote
Yes I figured out it had to do with the stockserialmoves. All fixed, thx!
Find all posts by this user
Quote this message in a reply
10-03-2019, 12:48 PM (This post was last modified: 10-03-2019 01:23 PM by TurboPT.)
Post: #4
RE: Z_DeleteCreditNote
So does that mean the script worked, or ?
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)