Print Pro Form Invoive while Printing Proforma Packing Slip based on delivery address

Hi All,

I have a requirement in which, I have to print a Pro forma Invoice Report when i print the Pro forma Packing slip.

The scenario is like when i Print Proforma Packing slip it shows two packing slip. As the delivery address is different for lines.

So for every different Delivery Address it prints different Packing Slips. So at the same time i should provide a check box to print proforma invoice. If the check box is checks it will print the Proforma Invoice. But based on delivery address. SO if there are three packing slips then it should print three Proforma Invoice Report.

Can any body help for that?

Thnx,

Kirtan

Hi,

I have done something similar before, it is quite a popular requirement from customers. Which AX version are you talking about ?

Just to be honest with you - you haven’t asked any specific questions so far. You basically just gave us a whole description of the task that you have been given to do. Have you started anything yet?

Hi,

The ax version is 5.0.

I tried to do it by adding code to click method of ok button on SalesEditline form.

The code is as below.

SalesFormLetter sales = SalesFormLetter::construct(DocumentStatus::Invoice)

SalesTable salestbl ;

;

salestbl = SalesParmTable.salesTable(false);

ttsbegin;

sales.update(salestbl,systemdateget(),SalesUpdate::PackingSlip,AccountOrder::None,NoYes::Yes,NoYes::Yes);

ttscommit;

Here sales invoice is printed but packing slip is necessary for that.

I also called the SalesInvoiceCopy output menu item also.

But this open the dialog box which is not needed.

Apart form that i also modified the PrintJornal method of CustInvoiceJour table.

But of no use.

Any help will be good for me.

Thnx,

Kirtan

Finally found the solution for this problem.

I had to print the Pro forma invoice for all the proforma packing slip.

TO achieve this i did the following thing.

I created new method in salesformletter class.

ex. printProformaInvoice()

In this method copy and paste all the code of run method.

Comment all the code in which remove or delete operation in involved.

//Added on dt 09/08/2012 KD

public void ProformaInvoice()
{
#OCCRetryCount
QueryRun query;
Counter infoLogCounter;
LogText logText;
boolean updateError;
dataAreaId curExtPreProgress = curext();
SalesFormLetterEndMultiThread salesFormLetterEndMultiThread;
FormLetterMultiThread formLetterMultiThread;
;

startDateTimeUpdate = DateTimeUtil::newDateTime(systemdateget(),timenow(),DateTimeUtil::getUserPreferredTimeZone());

this.progressInit("@SYS25781", progressTotal, #AviFormLetter);
progress.setText("@SYS26577");

if (salesParmUpdate.LateSelection)
{
if (!SalesParmUpdate::exist(this.parmId()))
{
this.parmId(NumberSeq::newGetNum(CompanyInfo::numRefParmId()).num());
this.createParmUpdateFromParmUpdateRecord(this.salesParmUpdate());
}

if (this.isInBatch())
{
// this.resetParmListCommonCS();
this.transDate(systemdateget());
}

chooseLines = new QueryRun(salesParmUpdate.LateSelectionQuery);
this.chooseLines();

if (salesParmUpdate.numberOfLines() < 1)
checkFailed("@SYS26185");
}
else
{
if (this.isInBatch())
{
this.transDate(salesParmTable.Transdate);
}
}

if ( reArrangeNow && !this.reArrange(false) &&
!salesTable.QuotationId)
{
throw error("@SYS18447");
}

if (this.canMultiThread())
{
batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);
salesFormLetterEndMultiThread = SalesFormLetterEndMultiThread::newFormLetter(this,
salesParmUpdate.ParmId,
salesParmUpdate.Proforma);
batchHeader.addRuntimeTask(salesFormLetterEndMultiThread,this.parmCurrentBatch().RecId);
}

query = this.queryBuild();

if (printout == Printout::After && ! this.proforma())
{
journalList = this.newJournalList();
}

setprefix("@SYS25781");

while (query.next())
{
infoLogCounter = infolog.num();

infolog.updateViewSet(this);

if (printout == Printout::Current || this.proforma())
{
journalList = this.newJournalList();
}

salesParmTable = query.get(tablenum(SalesParmTable));

if (salesParmTable.SalesId != salesTable.SalesId)
{
salesTable = salesParmTable.salesTable();
}

if (this.checkIfSalesOrderExist(salesTable))
{
try
{
if (batchHeader)
{
formLetterMultiThread = FormLetterMultiThread::newFormLetter(this);
batchHeader.addRuntimeTask(formLetterMultiThread,this.parmCurrentBatch().RecId);
ttsbegin;
batchHeader.save();
ttscommit;
}
else
{
this.createJournal();
}
}

catch (Exception::Deadlock)
{
#if.never //#Speedtest
if (speedExecute_Sales)
speedExecute_Sales.timing(SpeedSalesTiming::DeadLockInvoice, salesParmLine.itemId);
#endif
// this.removeRecIdSuspension();
// this.removeJournalFromList();
retry;
}

catch (Exception::UpdateConflict)
{
// this.removeRecIdSuspension();
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
// this.removeJournalFromList();
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}

catch (Exception::Error)
{
// this.removeRecIdSuspension();
// this.removeJournalFromList();
updateError = true;

ttsbegin;

logText = Info::infoCon2Str(infolog.copy(infoLogCounter+1,infolog.num()));

infolog.updateViewSet(this, false);

this.setForUpdateSalesParmTable();

salesParmTable.Log = logText;
salesParmTable.updateParmJobStatusContainErrors();

ttscommit;
}
}
else
{
if (salesParmUpdate.SumBy == AccountOrder::None)
info(strfmt("@SYS15067", salesParmTable.SalesId));
}

infolog.updateViewSet(this, false);
}

/* if (batchHeader)
{
batchHeader.save();
}
else
*/
if(!batchHeader)
{
if (printout == Printout::After && ! salesParmUpdate.Proforma)
this.printJournal();

// this.endUpdate();
}
progress = null;

if (updateError)
throw error("@SYS78886");
}
//Ended on dt 09/08/2012 by KD

After doing this the method is ready.

After this,i did modifcation in SalesEditLines form in “CloseOk()” method.

The code is as below.

void closeOk()
{
args args;
object object;

//Added on dt 09/08/2012 by KD
SalesFormLetter sales = SalesFormLetter::construct(DocumentStatus::Invoice);
SalesParmTable salesParm;
//Ended on dt 09/08/2012 by KD
;

if ((salesParmUpdate.GiroType == PaymentStubInclAll::FIK751 || salesParmUpdate.GiroType == PaymentStubInclAll::FIK752)
&& strlen(CompanyInfo::find().fiCreditorID_DK) == 0)
{
throw error("@SYP2557");
}

if (salesParmUpdate.GiroType == PaymentStubInclAll::FIK751)
{
throw error("@SYP2572");
}

if (salesParmUpdate)
salesParmUpdate_ds.write();

if (salesParmTable.RecId)
salesParmTable_ds.write();

if (salesParmSubTable)
salesParmSubTable_ds.write();

if (salesParmLine)
salesParmLine_ds.write();

if (salesEditLinesForm.giro())
element.checkGiroSettings();

salesFormLetter.initParameters(salesParmUpdate.data(),
print_Combo.selection(),
printFormletter.value(),
printCODLabelChoice,
printCallTagChoice,
printShippingLabelChoice,
usePrintManagement.value(),
true);
//
if (EInvoiceParameters_MX::isElectronicInvoiceEnabled())
{
salesFormLetter.initEInvoiceFields_MX(sendByMail_MX.value());
}
//

salesFormLetter.editLinesChanged(editLinesChanged);
salesFormLetter.reArrangeNow(reArrangeNow);

super();

//Added on dt 09/08/2012 by KD

if(chkPrintInvoice.checked())
{

ttsbegin;

salesParm = SalesParmTable_ds.cursor();
sales.salesTable(salesParm.salesTable());
sales.transDate(systemdateget());
sales.proforma(true);
sales.printFormLetter(true);
sales.printCODLabel (NoYes::No);
sales.printFreightSlip (NoYes::No);
sales.printShippingLabel (NoYes::No);
sales.usePrintManagement(false);
sales.creditRemaining(false);
sales.createParmUpdate(false);
sales.initParameters(salesParmUpdate,Printout::Current);
sales.giroType(salesTable.GiroType);
sales.ProformaInvoice();

ttscommit;

}
//Ended on dt 09/08/2012 by KD
}

And then added a new check box control named “chkPrintInvoice” on the form.

This worked for me as it was needed.

Hope this would be helpfull for you.

Thnx,

Kirtan