Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Z_DeleteInvoice: locstock not updated
10-17-2018, 11:44 PM
Post: #1
Z_DeleteInvoice: locstock not updated
It looks like the query used to supposedly update locstock is missing and what is used instead in the if statement line 130 is the same $SQL used to update salesorderdetails.


starting line 121:
Code:
$SQL = "UPDATE salesorderdetails SET qtyinvoiced = qtyinvoiced + " . $OrderLine['qty'] . ",
                                             completed = 0
                                WHERE orderno = '" . $ProcessingOrder . "'
                                AND stkcode = '" . $OrderLine['stockid'] . "'";

    $ErrMsg = _('The SQL to reverse the update of the sales order detail records failed because');
    $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true);
    prnMsg(_('The sales order records have been updated as not invoiced'),'info');
/*reverse the update to LocStock */
    if ($OrderLine['mbflag']!='A' AND $OrderLine['mbflag']!='D'){

            $ErrMsg = _('The SQL to reverse update to the location stock records failed because');
            $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
             prnMsg(_('Reversed the location stock quantities for items that decreased'),'info');
    }

Additionally, it appears that controlled items are not handled by the script as stockserialmoves is not called in the process

Thank you for your input!
Find all posts by this user
Quote this message in a reply
10-18-2018, 12:02 AM
Post: #2
RE: Z_DeleteInvoice: locstock not updated
I cannot stress highly enough that people shouldn't use this script. There are a number of gotchas, not just the one you stated - for instance it deletes the stockmoves record, but doesn't update any future quantity on hand records for any transactions that came after the invoice. I could go on...

It is also very bad accounting practice. Any transactions that are incorrect should be properly reversed out, and re-entered correctly so that the full audit trail is available. As an accountant scripts like these horrify me, and I always remove them before putting the code onto a clients server.

If an invoice is wrong, credit it and re-invoice correctly.

Sorry for the rant Smile

Tim
Visit this user's website Find all posts by this user
Quote this message in a reply
10-18-2018, 12:22 AM
Post: #3
RE: Z_DeleteInvoice: locstock not updated
I agree. Unfortunately I have been repeatedly asked to develop an “invoice editor” by the company so I plan to use this script as a starting point for it...

Thx
Find all posts by this user
Quote this message in a reply
10-18-2018, 02:05 AM
Post: #4
RE: Z_DeleteInvoice: locstock not updated
You will also need to take the item costs into consideration if using weighted average costing. Could get messy if other transactions have been entered for that part since the invoice was posted.

I remember years ago it was common for systems not to post transactions immediately but to hold them in a form of stasis till they had been authorised and they could be amended while they were in this stasis. Could cause loads of problems though if transactions were authorised in a different sequence from the input sequence and it went out of fashion.
Visit this user's website Find all posts by this user
Quote this message in a reply
10-18-2018, 05:25 AM (This post was last modified: 10-18-2018 05:33 AM by VortecCPI.)
Post: #5
RE: Z_DeleteInvoice: locstock not updated
(10-18-2018 12:02 AM)falkoner Wrote:  I cannot stress highly enough that people shouldn't use this script. There are a number of gotchas, not just the one you stated - for instance it deletes the stockmoves record, but doesn't update any future quantity on hand records for any transactions that came after the invoice. I could go on...

It is also very bad accounting practice. Any transactions that are incorrect should be properly reversed out, and re-entered correctly so that the full audit trail is available. As an accountant scripts like these horrify me, and I always remove them before putting the code onto a clients server.

If an invoice is wrong, credit it and re-invoice correctly.

Sorry for the rant Smile

Tim

I could not agree more. We had one customer request we break an existing invoice down into four invoices. This is NOT an edit procedure -- It is a credit-and-create-new procedure for sure.

I know a lot of work went into the CREDIT feature and it works. There is a LOT of code in Credit_Invoice.php and it does a LOT of work.

I believe I read that webERP once had an EDIT INVOICE feature and, if it did, I am happy it is now gone.

I see an EDIT INVOICE feature as a HUGE can of worms...

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
10-20-2018, 04:24 AM (This post was last modified: 10-20-2018 04:25 AM by dalescott.)
Post: #6
RE: Z_DeleteInvoice: locstock not updated
(10-18-2018 12:02 AM)falkoner Wrote:  ...I always remove them before putting the code onto a clients server.

Hi Tim, what other scripts do you remove?

Cheers,
Dale

http://www.dalescott.net
Visit this user's website Find all posts by this user
Quote this message in a reply
10-20-2018, 04:49 AM
Post: #7
RE: Z_DeleteInvoice: locstock not updated
(10-18-2018 05:25 AM)VortecCPI Wrote:  
(10-18-2018 12:02 AM)falkoner Wrote:  I cannot stress highly enough that people shouldn't use this script. There are a number of gotchas, not just the one you stated - for instance it deletes the stockmoves record, but doesn't update any future quantity on hand records for any transactions that came after the invoice. I could go on...

It is also very bad accounting practice. Any transactions that are incorrect should be properly reversed out, and re-entered correctly so that the full audit trail is available. As an accountant scripts like these horrify me, and I always remove them before putting the code onto a clients server.

If an invoice is wrong, credit it and re-invoice correctly.

Sorry for the rant Smile

Tim

I could not agree more. We had one customer request we break an existing invoice down into four invoices. This is NOT an edit procedure -- It is a credit-and-create-new procedure for sure.

I know a lot of work went into the CREDIT feature and it works. There is a LOT of code in Credit_Invoice.php and it does a LOT of work.

I believe I read that webERP once had an EDIT INVOICE feature and, if it did, I am happy it is now gone.

I see an EDIT INVOICE feature as a HUGE can of worms...

I know I know…

I got this request because the full crediting of an invoice from an order that that has dozens (if not hundreds for us) of lines of expirable controlled items is a total pain: you have to enter each quantity, each lot number each expiration date. Even if you need to credit one line, you have to manually delete all the others one by one, then replace the order from scratch …


I've already automated the ConfirmDispatchInvoice script to expedite the lot picking process, I'm thinking of porting the same capability to the crediting process by automatically inserting the controlled lots info and having a single click "recreate order" capability.

We'll see how that goes :-)
Find all posts by this user
Quote this message in a reply
10-20-2018, 05:21 AM
Post: #8
RE: Z_DeleteInvoice: locstock not updated
Wow... Sounds very interesting...

Years ago we used to invoice Family Dollar for each store (alarm monitoring) and our invoices had up to 7,500 lines. The Oracle invoice import tool had to be rebuilt to accept our invoices because they were so large.

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
10-20-2018, 05:21 PM
Post: #9
RE: Z_DeleteInvoice: locstock not updated
(10-20-2018 04:49 AM)HDeriauFF Wrote:  I got this request because the full crediting of an invoice from an order that that has dozens (if not hundreds for us) of lines of expirable controlled items is a total pain: you have to enter each quantity, each lot number each expiration date. Even if you need to credit one line, you have to manually delete all the others one by one, then replace the order from scratch …

Would it help for the credit screen to default to having quantities of zero on every line and then you just fill in the quantities for those lines you wish to amend?

Tim
Visit this user's website Find all posts by this user
Quote this message in a reply
10-20-2018, 11:19 PM
Post: #10
RE: Z_DeleteInvoice: locstock not updated
   
(10-20-2018 05:21 PM)falkoner Wrote:  Would it help for the credit screen to default to having quantities of zero on every line and then you just fill in the quantities for those lines you wish to amend?

Tim


I started improving the page by replacing all "delete" links with is a "select/deselect all" checkbox system (see screenshot).

Question about CreditIitemsControlled.php: could you please confirm on your end that the correct lot and quantity are displayed on the left table, but the expiry date is always set to 0000-00-00 no matter what?
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


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