Code Unit 90 Checking Invoices value

MauddibMauddib Member Posts: 269
Our code unit 90 has some helpful code that I dont know if its standard or not....

IF PurchHeader."Document Type" = PurchHeader."Document Type"::Invoice THEN
BEGIN
PurchHeader.TESTFIELD("Inv. Approval Status", PurchHeader."Inv. Approval Status"::"Inv. Approved");
// Ensure that the 'Invoice Value' entered on the purchase header matches the Total Amount Incl. VAT
// of the invoice.
CLEAR(codPurchInvRegister);
deCalculatedInvAmount := codPurchInvRegister.fCalculateInvAmount(PurchHeader);
IF deCalculatedInvAmount <> PurchHeader."Invoice Value"
THEN ERROR('The %1 entered to register %2 %3 does not match the calculated amount.',
PurchHeader.FIELDNAME(PurchHeader."Invoice Value"),
PurchHeader."Document Type", PurchHeader."No.");
END;


Is this standard? And can anyone see any problems with changing the if statement to add: OR (PurchHeader."Document Type" = PurchHeader."Document Type"::Order)

as we post most of our invoices from the order not from the invoices screen. So it would be a helpful change to us.

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    This is not standard W1 functionality.

    You can also see this by looking at the names of the variables.

    codPurchInvRegister and deCalculatedInvAmount are names that Navision never would have used.

    If you want the code also to be triggered when invoicing on a order be sure to test if the "Invoice" boolean is true. This is a global varable.

    If this is false the user is only posting a shipment.
  • DenSterDenSter Member Posts: 8,307
    For posting it makes no difference from which form a posting routine is called. The standard application will always use codeunit 90 for any purchase related posting. Codeunit 90 is called from the order form as well as from the invoice form.
Sign In or Register to comment.