To create Consolidated Vendor Invoices while importing data from DIXF:
Below is the Code:
public void createConsolidatedInvoices(isConsolidatedInvoice _consolidatedInvoice = NoYes::No)
{
DMFVendInvoiceInfoTableEntity dmfVendInvoiceInfoTableEntity;
DMFVendInvoiceInfoLineEntity dmfVendInvoiceInfoLineEntity;
PurchFormLetter purchFormLetterConsolidate;
PurchFormletterParmData purchFormletterParmData;
PurchParmUpdate purchParmUpdate;
PurchParmTable purchParmTable;
PurchTable purchTable;
VendInvoiceInfoTable vendInvoiceInfoTable;
VendInvoiceInfoLine vendInvoiceInfoLineLocal;
if (stagingTable is DMFVendInvoiceInfoLineEntity)
{
dmfVendInvoiceInfoLineEntity = stagingTable;
}
if (_consolidatedInvoice)
{
select firstonly purchParmUpdate
join PurchId, Num, ParmId from purchParmTable
join PackingSlipId, TableRefId, ParmId from dmfVendInvoiceInfoTableEntity
join OrigPurchId, InventTransId, TableRefId from vendInvoiceInfoLineLocal
where purchParmUpdate.ParmId == purchParmTable.ParmId &&
purchParmTable.Num == dmfVendInvoiceInfoTableEntity.PackingSlipId &&
purchParmTable.PurchId == vendInvoiceInfoLineLocal.OrigPurchId &&
dmfVendInvoiceInfoTableEntity.TableRefId == dmfVendInvoiceInfoLineEntity.TableRefId &&
vendInvoiceInfoLineLocal.OrigPurchId == dmfVendInvoiceInfoLineEntity.OrigPurchId &&
vendInvoiceInfoLineLocal.InventTransId == dmfVendInvoiceInfoLineEntity.InventTransId;
purchTable = PurchTable::find(purchParmTable.PurchId);
vendInvoiceInfoTable = VendInvoiceInfoTable::find(dmfVendInvoiceInfoTableEntity.ParmId, vendInvoiceInfoLineLocal.TableRefId);
try
{
//ttsbegin;
purchFormletterParmData = PurchFormletterParmData::newData(
DocumentStatus::PackingSlip,
VersioningUpdateType::Initial);
purchFormletterParmData.parmOnlyCreateParmUpdate(true);
purchFormletterParmData.createData(false);
purchFormLetterConsolidate = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetterConsolidate.transDate(systemDateGet());
purchFormLetterConsolidate.proforma(false);
purchFormLetterConsolidate.purchTable(purchTable);
purchFormLetterConsolidate.purchParmUpdate(purchParmUpdate);
purchFormLetterConsolidate.reArrange();
//ttscommit;
}
catch
{
throw error("Error occurred while consolidating the invoices");
}
try
{
//For posting
purchFormLetterInvoice = PurchFormLetter_Invoice::newFromSavedInvoice(vendInvoiceInfoTable);
purchFormLetterInvoice.update(vendInvoiceInfoTable.purchTable(), vendInvoiceInfoTable.Num);
}
catch
{
throw error("Error occurred while posting the invoices");
}
}
}
Best Regards
Pranav :)
Below is the Code:
public void createConsolidatedInvoices(isConsolidatedInvoice _consolidatedInvoice = NoYes::No)
{
DMFVendInvoiceInfoTableEntity dmfVendInvoiceInfoTableEntity;
DMFVendInvoiceInfoLineEntity dmfVendInvoiceInfoLineEntity;
PurchFormLetter purchFormLetterConsolidate;
PurchFormletterParmData purchFormletterParmData;
PurchParmUpdate purchParmUpdate;
PurchParmTable purchParmTable;
PurchTable purchTable;
VendInvoiceInfoTable vendInvoiceInfoTable;
VendInvoiceInfoLine vendInvoiceInfoLineLocal;
if (stagingTable is DMFVendInvoiceInfoLineEntity)
{
dmfVendInvoiceInfoLineEntity = stagingTable;
}
if (_consolidatedInvoice)
{
select firstonly purchParmUpdate
join PurchId, Num, ParmId from purchParmTable
join PackingSlipId, TableRefId, ParmId from dmfVendInvoiceInfoTableEntity
join OrigPurchId, InventTransId, TableRefId from vendInvoiceInfoLineLocal
where purchParmUpdate.ParmId == purchParmTable.ParmId &&
purchParmTable.Num == dmfVendInvoiceInfoTableEntity.PackingSlipId &&
purchParmTable.PurchId == vendInvoiceInfoLineLocal.OrigPurchId &&
dmfVendInvoiceInfoTableEntity.TableRefId == dmfVendInvoiceInfoLineEntity.TableRefId &&
vendInvoiceInfoLineLocal.OrigPurchId == dmfVendInvoiceInfoLineEntity.OrigPurchId &&
vendInvoiceInfoLineLocal.InventTransId == dmfVendInvoiceInfoLineEntity.InventTransId;
purchTable = PurchTable::find(purchParmTable.PurchId);
vendInvoiceInfoTable = VendInvoiceInfoTable::find(dmfVendInvoiceInfoTableEntity.ParmId, vendInvoiceInfoLineLocal.TableRefId);
try
{
//ttsbegin;
purchFormletterParmData = PurchFormletterParmData::newData(
DocumentStatus::PackingSlip,
VersioningUpdateType::Initial);
purchFormletterParmData.parmOnlyCreateParmUpdate(true);
purchFormletterParmData.createData(false);
purchFormLetterConsolidate = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetterConsolidate.transDate(systemDateGet());
purchFormLetterConsolidate.proforma(false);
purchFormLetterConsolidate.purchTable(purchTable);
purchFormLetterConsolidate.purchParmUpdate(purchParmUpdate);
purchFormLetterConsolidate.reArrange();
//ttscommit;
catch
{
throw error("Error occurred while consolidating the invoices");
}
try
{
//For posting
purchFormLetterInvoice = PurchFormLetter_Invoice::newFromSavedInvoice(vendInvoiceInfoTable);
purchFormLetterInvoice.update(vendInvoiceInfoTable.purchTable(), vendInvoiceInfoTable.Num);
}
catch
{
throw error("Error occurred while posting the invoices");
}
}
}
Best Regards
Pranav :)
No comments:
Post a Comment