how to create vendor prepayment by using x++code.

if any one knows about vendor prepayment plz give me suggestions as soon as possible.

I am written this code but its not working properly.if any one knows give me reply

static void TheaxaptaCreatePOInvoice(Args _args)
{
NumberSeq numberSeq;

Purchtable Purchtable;

PurchLine PurchLine;
PurchFormLetter purchFormLetter;
;
ttsbegin;
numberSeq = NumberSeq::newGetNumFromCode(purchParameters::numRefPurchaseOrderId().NumberSequence,true);
// Initialize Purchase order values
Purchtable.initValue();
Purchtable.PurchId = numberSeq.num();
Purchtable.OrderAccount = ‘3000’;
Purchtable.initFromVendTable();
if (!Purchtable.validateWrite())
{
throw Exception::Error;
}
Purchtable.insert();
// Initialize Purchase Line items
PurchLine.PurchId = Purchtable.PurchId;
PurchLine.ItemId = ‘B-R14’;
PurchLine.createLine(true, true, true, true, true, false);
ttscommit;
purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchtable, // Purchase record Buffer
“Inv_”+purchTable.PurchId, // Invoice Number
systemdateget()); // Transaction date
if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt(“Posted invoiced journal for purchase order %1”,purchTable.PurchId));
}
}

You are posting a normal invoice. I don’t see any code related to prepayment.

What are you expecting from this code?

sir, my requirement is create vendor prepayment invoice using x++ code.could u plz know the code send me

purchFormLetter.parmInvoiceType(PurchInvoiceType::VendorAdvance);

Add this line before calling the purchFormLetter.update

You also need to create a prepayment for that purchase order before posting the prepayment invoice. Create a record in \Data Dictionary\Tables\PurchPrepayTable

sir , same above i will use add one line in this code .its correct or not.

static void TheaxaptaCreatePOInvoice(Args _args)
{
NumberSeq numberSeq;

Purchtable Purchtable;

PurchLine PurchLine;
PurchFormLetter purchFormLetter;
;
ttsbegin;
numberSeq = NumberSeq::newGetNumFromCode(purchParameters::numRefPurchaseOrderId().NumberSequence,true);
// Initialize Purchase order values
Purchtable.initValue();
Purchtable.PurchId = numberSeq.num();
Purchtable.OrderAccount = ‘3000’;
Purchtable.initFromVendTable();
if (!Purchtable.validateWrite())
{
throw Exception::Error;
}
Purchtable.insert();
// Initialize Purchase Line items
PurchLine.PurchId = Purchtable.PurchId;
PurchLine.ItemId = ‘B-R14’;
PurchLine.createLine(true, true, true, true, true, false);
ttscommit;
//purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);

purchFormLetter.parmInvoiceType(PurchInvoiceType::VendorAdvance);
purchFormLetter.update(purchtable, // Purchase record Buffer
“Inv_”+purchTable.PurchId, // Invoice Number
systemdateget()); // Transaction date
if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt(“Posted invoiced journal for purchase order %1”,purchTable.PurchId));
}
}

I think you are not doing this.

how do the prepayment invoice throw x++ sir. i am created in table record

purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);

purchFormLetter.parmInvoiceType(PurchInvoiceType::VendorAdvance);
purchFormLetter.update(purchtable, // Purchase record Buffer
“Inv_”+purchTable.PurchId, // Invoice Number
systemdateget()); // Transaction date

sir,when i am post the prepayment which calsses and methods called

It uses the same classes as normal invoice posting and additionally look VendAdvanceInvoice* classes