Unable to post purchase order

When we post Purchase Order P-01807, we get an error “Purchase Invoice 120413 already exist”, but when looking at the posted purchase invoices we do not see 120413 in the table.

We’ve already turned off Mandatory External Document checking for both Sales & Receivables and in Purchase & Payables Setup?

It is breaking on this part of the code:

Zoom on the Purchase Order and look for field Posting no. and you will see 120413, when you post the PO the Posting no. becomes your Posted purchase invoice. This frequently happens when you have both Default and Manual turned on. I would recommend fix the no. series and then turn off the Manual nos. in No. series and you will prevent this issue going forward.

Hi Nav_admin,

It doesn’t matter if “Ext. Doc. No. Mandatory” have been set or not. If the external document no. 120413 has been used once by this vendor, then you cannot use it again.

If you scroll up a few lines from where you debugger is, then you will see the whole code block:

    // Check External Document number
    IF PurchSetup."Ext. Doc. No. Mandatory" OR
      (GenJnlLineExtDocNo <> '')
    THEN BEGIN
      VendLedgEntry.RESET;
      VendLedgEntry.SETCURRENTKEY("External Document No.");
      VendLedgEntry.SETRANGE("Document Type",GenJnlLineDocType);
      VendLedgEntry.SETRANGE("External Document No.",GenJnlLineExtDocNo);
      VendLedgEntry.SETRANGE("Vendor No.","Pay-to Vendor No.");
      IF VendLedgEntry.FINDFIRST THEN
        ERROR(
          Text016,
          VendLedgEntry."Document Type",GenJnlLineExtDocNo);
    END;