Posts

Showing posts from April, 2014

Check if Invoice Date is in current Ledger Period using X++

public boolean AS_isInvoiceInCurrentLedgerPeriod(TransDate _transDate, TransDate _oldDate) {     FiscalCalendarPeriod         oldPeriod;     FiscalCalendarPeriod         newPeriod;     FiscalCalendarRecId          fiscalCalendarRecId = CompanyInfo::fiscalCalendarRecId();     LedgerFiscalCalendarPeriod   ledgerFiscalCalendarPeriod;     if (!FiscalCalendars::findYearEndClosingPeriodByDate(fiscalCalendarRecId, _transDate).RecId)     {         // The transaction date is not in a valid period.         return checkFailed("@GLS54501");     }     oldPeriod = FiscalCalendars::findPeriodByPeriodCodeDate(fiscalCalendarRecId, _oldDate);     newPeriod = FiscalCalendars::findPeriodByPeriodCodeDate(fiscalCalendarRecId, _transDate);     if (!newPeriod.RecId)...

Inventory period open checking using X++

public boolean isInventPeriodOpen(TransDate              testDate,                                  boolean                onDateOk = false,                                  InventTransCurrency_RU _inventTransCurrency = InventTransCurrency_RU::PrimaryCur) {     #ISOCountryRegionCodes     TransDate closingDate = InventClosing::closingDate(false, _inventTransCurrency);     if (!SysCountryRegionCode::isLegalEntityInCountryRegion([#isoRU]) || testDate)     {         if ((testDate <= closingDate && !onDateOk) ||             (testDate <  closingDate &&  onDateOk))         {  ...

Purchase Order Invoice posting with using X++ with custom VendInvoiceInfoLine fields

private boolean postPOInvoice(PurchTable purchTable) {     PurchFormLetter         letter      = purchFormLetter::construct(DocumentStatus::Invoice);     PurchParmUpdate         purchParmUpdate;     PurchLine               purchLineLocal;     VendInvoiceInfoTable    vendInvoiceInfoTable;     VendInvoiceInfoLine     vendInvoiceInfoLine, vendInvoiceInfoLineFrom;          boolean                 ret = true;                   letter.purchTable(purchTable);         letter.initParmDefault();         letter.transDate          (systemdateget());         letter.specQty            (PurchUp...

Sales order invoice posting using X++ with custom SalesParmLine fields

private boolean postSOInvoice(SalesTable salesTable) {     SalesFormLetter     letter      = SalesFormLetter::construct(DocumentStatus::Invoice);     CustInvoiceTrans    custInvoiceTransFrom;     SalesParmLine       salesParmLine;     SalesParmUpdate     salesParmUpdate;     SalesLine           salesLineLocal;          boolean             ret = true;         letter.salesTable(salesTable);         letter.initParmDefault();         letter.transDate          (systemDateGet());         letter.specQty            (SalesUpdate::All);         letter.proforma           (false);       ...