I don’t have Postman or Insomnia. I do have Swagger, that’s also throwing the error:
Sorry! Something went wrong. Please contact your system administrator. Correlation Id: 9d940985-d629-482c-948f-cf5a004e598a
I don’t have Postman or Insomnia. I do have Swagger, that’s also throwing the error:
Sorry! Something went wrong. Please contact your system administrator. Correlation Id: 9d940985-d629-482c-948f-cf5a004e598a
I definitely agree, much smarter people on this forum, than I.
I feel like doing a function is the best route, it’s something we’ve approached and considered before, others have said that that’s the way to go, and we know it should work since it’s (I believe) the same process DMT uses.
DMT uses the business objects directly whilst REST is a wrapper around those business objects. DMT requires the client DLLs to operate and REST just uses HTTPS to communicate with the endpoints.
You are correct. The logic that DMT uses can be duplicated in an Epicor Function, which also works directly with the business objects but at the server.
That’s what I meant, sorry, it’s early and I apparently can’t put words together. That’s our justification going forward with the Epicor Functions since we can’t seem to get the REST stuff to work for us.
You will eventually end up using both most likely. Just depends on the project.
We already are. The REST stuff works great for getting & creating groups and getting vendors. Creating an AP Invoice is the only thing we’re really having issues with.
What happened when you called it with an empty ds object and a groupid?
Haven’t tried that yet. Will be doing it today to make sure I have all the bases covered.
If you have a correctly formatted Invoice Head, there is really no need to even call the getnew.
Edit: I take that back, I’m not sure if this is the only way to create a group or not.
Somebody chime in.
Wanted to follow up on one of your suggestions. Passing in an empty object as the “ds” parameter returns the same error. Going to provide the stack trace as well.
at Microsoft.OData.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
at Microsoft.OData.Client.DataServiceContext.InnerSynchExecute[TElement](Uri requestUri, String httpMethod, Nullable`1 singleResult, OperationParameter[] operationParameters)
at Microsoft.OData.Client.DataServiceContext.Execute(Uri requestUri, String httpMethod, OperationParameter[] operationParameters)
at OnBaseIntegration.Context.InvoiceContext.<CreateInvoices>d__6.MoveNext() in C:\Users\robert.thompson\source\repos\OnBaseIntegrationService\OnBaseIntegration\Context\InvoiceContext.cs:line 54
at OnBaseIntegration.Services.InvoiceService.<createInvoices>d__17.MoveNext() in C:\Users\robert.thompson\source\repos\OnBaseIntegrationService\OnBaseIntegration\Services\Epicor\InvoiceService.cs:line 46
at OnBaseIntegration.Services.InvoiceService.<CreateInvoices>d__27.MoveNext() in C:\Users\robert.thompson\source\repos\OnBaseIntegrationService\OnBaseIntegration\Services\Epicor\InvoiceService.cs:line 257
Aha!
You must first create a group, or have a valid group.
I made a group called “Test”
Then called /{currentCompany}/Erp.BO.APInvoiceSvc/GetNewAPInvHedInvoice in Swagger with:
{
"ds": {},
"cGroupID": "Test"
}
returned:
{
"parameters": {
"ds": {
"APInvHed": [
{
"Company": "MYCOMPANY",
"OpenPayable": true,
"VendorNum": 0,
"InvoiceNum": "",
"DebitMemo": false,
"InvoiceDate": null,
"TermsCode": "",
"TaxAmt": 0,
"DocTaxAmt": 0,
"DiscountDate": null,
"DiscountAmt": 0,
"DocDiscountAmt": 0,
"DueDate": "2023-04-12T00:00:00-05:00",
"PayDates": "",
"PayAmounts": "",
"DocPayAmounts": "",
"GLPosted": false,
"GroupID": "Test",
"Posted": false,
"FiscalYear": 2023,
"FiscalPeriod": 4,
"StartUp": false,
"InvoiceRef": "",
"EntryPerson": "KLINCECUM",
"InvoiceComment": "",
"InvoiceAmt": 0,
"DocInvoiceAmt": 0,
"DocInvoiceVendorAmt": 0,
"InvoiceBal": 0,
"DocInvoiceBal": 0,
"UnpostedBal": 0,
"DocUnpostedBal": 0,
"InvoiceHeld": false,
"PayHold": false,
"Description": "",
"CurrencyCode": "USD",
"ExchangeRate": 1,
"LockRate": false,
"REFPONum": 0,
"TaxRegionCode": "",
"JournalNum": 0,
"JournalCode": "",
"UpdateTax": false,
"InvoiceVendorAmt": 0,
"LegalNumber": "",
"ExternalID": "",
"FixedAmt": false,
"XRefInvoiceNum": "",
"GlbCompany": "",
"GlbVendorNum": 0,
"GlbInvoiceNum": "",
"DepGainLoss": 0,
"CPay": false,
"CPayLinked": false,
"CPayLegalNumber": "",
"CPayCheckNum": 0,
"CPayCheckDate": null,
"CPayInvoiceBal": 0,
"CPayDocInvoiceBal": 0,
"Rounding": 0,
"GLControlType": "",
"DocRounding": 0,
"GLControlCode": "",
"Rpt1DiscountAmt": 0,
"Rpt2DiscountAmt": 0,
"Rpt3DiscountAmt": 0,
"Rpt1InvoiceAmt": 0,
"Rpt2InvoiceAmt": 0,
"Rpt3InvoiceAmt": 0,
"Rpt1InvoiceBal": 0,
"Rpt2InvoiceBal": 0,
"Rpt3InvoiceBal": 0,
"Rpt1InvoiceVendorAmt": 0,
"Rpt2InvoiceVendorAmt": 0,
"Rpt3InvoiceVendorAmt": 0,
"Rpt1PayAmounts": "",
"Rpt2PayAmounts": "",
"Rpt3PayAmounts": "",
"Rpt1Rounding": 0,
"Rpt2Rounding": 0,
"Rpt3Rounding": 0,
"Rpt1TaxAmt": 0,
"Rpt2TaxAmt": 0,
"Rpt3TaxAmt": 0,
"Rpt1UnpostedBal": 0,
"Rpt2UnpostedBal": 0,
"Rpt3UnpostedBal": 0,
"RateGrpCode": "MAIN",
"Rpt1CPayInvoiceBal": 0,
"Rpt2CPayInvoiceBal": 0,
"Rpt3CPayInvoiceBal": 0,
"AllowOverrideLI": false,
"MatchedFromLI": false,
"ApplyDate": "2023-04-12T00:00:00",
"FiscalYearSuffix": "",
"FiscalCalendarID": "CompCal",
"TaxPoint": "2023-04-12T00:00:00",
"TaxRateDate": "2023-04-12T00:00:00",
"ReadyToCalc": false,
"RecalcBeforePost": false,
"GetDfltTaxIds": true,
"PMUID": 0,
"PayDiscDays": "",
"PayDiscPer": "",
"WithholdAmt": 0,
"DocWithholdAmt": 0,
"Rpt1WithholdAmt": 0,
"Rpt2WithholdAmt": 0,
"Rpt3WithholdAmt": 0,
"PayDiscPartPay": false,
"PIPayment": "",
"CorrectionInv": false,
"TaxRateGrpCode": "",
"LockTaxRate": false,
"SEBankRef": "",
"SEPayCode": "",
"GUIFormatCode": "",
"GUITaxTypeCode": "",
"GUIDeductCode": "",
"PrePayment": false,
"APLOCID": "",
"Plant": "MfgSys",
"GUIImportTaxBasis": 0,
"DocGUIImportTaxBasis": 0,
"Rpt1GUIImportTaxBasis": 0,
"Rpt2GUIImportTaxBasis": 0,
"Rpt3GUIImportTaxBasis": 0,
"OvrDefTaxDate": false,
"Linked": false,
"ClaimRef": "",
"EmpID": "",
"InBankFile": false,
"CNConfirmDate": null,
"BankID": "",
"SelfLegalNumber": "",
"SelfTranDocTypeID": "",
"MainSite": false,
"CardCode": "",
"SiteCode": "",
"BankGiroAcctNbr": "",
"BranchID": "",
"SupAgentName": "",
"SupAgentTaxRegNo": "",
"NonDeductCode": "",
"AssetTypeCode": "",
"Cash": false,
"CreditCard": false,
"Normal": false,
"CardID": "",
"CardHolderTaxID": "",
"CardMemberName": "",
"Excluded": false,
"Deferred": false,
"NonDeductAmt": 0,
"NonDeductDocAmt": 0,
"NonDeductRpt1Amt": 0,
"NonDeductRpt2Amt": 0,
"NonDeductRpt3Amt": 0,
"NonDeductVATAmt": 0,
"NonDeductVATDocAmt": 0,
"NonDeductVATRpt1Amt": 0,
"NonDeductVATRpt2Amt": 0,
"NonDeductVATRpt3Amt": 0,
"ImportNum": "",
"ImportedFrom": "",
"ImportedDate": null,
"AdvTaxInv": false,
"InPrice": false,
"TranDocTypeID": "",
"DevInt1": 0,
"DevInt2": 0,
"DevDec1": 0,
"DevDec2": 0,
"DevDec3": 0,
"DevDec4": 0,
"DevLog1": false,
"DevLog2": false,
"DevChar1": "",
"DevChar2": "",
"DevDate1": null,
"DevDate2": null,
"PaymentNumber": "",
"CycleCode": "",
"Duration": 0,
"EndDate": null,
"MaxValueAmt": 0,
"DocMaxValueAmt": 0,
"Rpt1MaxValueAmt": 0,
"Rpt2MaxValueAmt": 0,
"Rpt3MaxValueAmt": 0,
"HoldInvoice": false,
"CopyLatestInvoice": false,
"OverrideEndDate": false,
"CycleInactive": false,
"RecurSource": false,
"InstanceNum": 0,
"RecurBalance": 0,
"DocRecurBalance": 0,
"Rpt1RecurBalance": 0,
"Rpt2RecurBalance": 0,
"Rpt3RecurBalance": 0,
"LastDate": null,
"IsRecurring": false,
"InvoiceNumList": "",
"IsMaxValue": false,
"SysRevID": 0,
"SysRowID": "00000000-0000-0000-0000-000000000000",
"CHISRCodeLine": "",
"DMReason": "",
"UrgentPayment": false,
"AGDocPageNum": "",
"AGCAICAEMark": "",
"AGCAICAENum": "",
"AGCAICAEExpirationDate": null,
"AGAvTaxCreditFlag": true,
"AGUseGoodDefaultMark": false,
"AGCustomsClearanceNum": "",
"AGCustomsCode": "",
"AGDestinationCode": "",
"HeadNum": 0,
"TranType": "",
"TaxSvcID": "",
"TWDeclareYear": 0,
"TWDeclarePeriod": 0,
"APChkGrpID": "",
"InvoiceType": "",
"PEComputationalCost": "",
"ReferencedByBOE": "",
"PEDUARefNum": "",
"CustomsNumber": "",
"ReceivedDate": null,
"CustOverride": 0,
"PrePaymentNum": "",
"PrePaymentAmt": 0,
"DocPrePaymentAmt": 0,
"Rpt1PrePaymentAmt": 0,
"Rpt2PrePaymentAmt": 0,
"Rpt3PrePaymentAmt": 0,
"PEAPPayNum": 0,
"PEDetTaxAmt": 0,
"PEDetTaxCurrencyCode": "",
"PESUNATDepAmt": 0,
"DocPESUNATDepAmt": 0,
"PESUNATDepDate": null,
"PESUNATDepNum": "",
"PESUNATNum": "",
"DocPEDetTaxAmt": 0,
"MXFiscalFolio": "",
"PEBOEIsMultiGen": false,
"ChangedBy": "",
"ChangeDate": null,
"PrePayHeadNum": 0,
"MXRetentionCode": "",
"PERefDocID": "",
"PEReasonCode": "",
"PEReasonDesc": "",
"MYImportNum": "",
"TWGUIRegNumSeller": "",
"TWGUIRegNumBuyer": "",
"MXTARCode": "",
"GRNIClearing": false,
"PEFiscalCreditOperStatus": -1,
"PEInternatTaxAgr": "",
"PERentType": "",
"PEPurchaseType": "",
"THRefInvoiceNum": "",
"THRefVendorNum": 0,
"JPSummarizationDate": null,
"JPBillingDate": null,
"JPBillingNumber": "",
"SelfInvoice": false,
"Printed": false,
"PurPoint": "",
"PLInvoiceReference": "",
"INPortCode": "",
"RefCancelledby": "",
"CancellationInv": false,
"NettingID": 0,
"WithholdAcctToInterim": false,
"APTaxRoundOption": 0,
"SourcePlant": "",
"AllowMultInvcReceipts": false,
"ApplyAPPrePayAuto": false,
"BankName": "",
"BaseCurrencyID": "USD",
"BaseCurrSymbol": "USD",
"BillAddressList": "",
"CanChangeTaxLiab": false,
"COIFRSCalculation": false,
"COIFRSEnabled": false,
"COIFRSFinancialCharge": 0,
"COIFRSInterestRate": 0,
"COIFRSNumberOfPeriods": 0,
"COIFRSPresentValue": 0,
"CPayIMReceived": false,
"CPayOpenPayable": false,
"CumulativeBalance": 0,
"CurrencySwitch": true,
"CurrInstanceNum": 0,
"CurrSymbol": "USD",
"DisableAplDate": false,
"DocCOIFRSFinancialCharge": 0,
"DocCOIFRSPresentValue": 0,
"DocCumulativeBalance": 0,
"DocInvoiceVariance": 0,
"DocMiscChrgNonDeducTax": 0,
"DocMiscChrgVariance": 0,
"DocScrHdrExpTotal": 0,
"DocSourceRecurBalance": 0,
"DspGuiImportTaxBasis": 0,
"EnableAssignLegNum": false,
"EnableCPay": false,
"EnableDueDate": true,
"EnableExchangeRate": false,
"EnableLockRate": false,
"EnableTaxExRate": false,
"EnableTaxLock": false,
"EnableTranDocType": true,
"EnableVoidLegNum": false,
"ExchangeRateDate": "A",
"GuiTaxBasisFlag": false,
"HasLegNumCnfg": false,
"IBANCode": "",
"InvoiceTypeDesc": "",
"InvoiceVariance": 0,
"IsLatestRecurrence": false,
"IsLcked": false,
"IsOnlyMiscRecords": true,
"LACTaxCalcEnabled": false,
"LatestInvoice": 0,
"LatestInvString": "",
"LegalNumberMessage": "",
"LineOrMscChrgExists": false,
"LockStatus": "Not Posted",
"MiscChrgNonDeducTax": 0,
"MiscChrgVariance": 0,
"NextInvoiceDate": null,
"NoChangeRecur": false,
"PayMethod": "",
"PEFiscalCreditOperStatusDsp": "",
"PEIsNRInvc": false,
"PLVendorAutoInvoiceNum": false,
"PostInvtyWipCos": true,
"RecalcAmts": "",
"Recurring": false,
"RecurringState": "",
"Rpt1COIFRSFinancialCharge": 0,
"Rpt1COIFRSPresentValue": 0,
"Rpt1CumulativeBalance": 0,
"Rpt1InvoiceVariance": 0,
"Rpt1MiscChrgNonDeducTax": 0,
"Rpt1MiscChrgVariance": 0,
"Rpt1ScrDiscountAmt": 0,
"Rpt1ScrHdrExpTotal": 0,
"Rpt1ScrHdrMiscChrgTotal": 0,
"Rpt1ScrInvLineTotal": 0,
"Rpt1ScrInvoiceAmt": 0,
"Rpt1ScrInvoiceBal": 0,
"Rpt1ScrInvoiceVendorAmt": 0,
"Rpt1ScrLACTaxAmt": 0,
"Rpt1ScrRounding": 0,
"Rpt1ScrTaxAmt": 0,
"Rpt1ScrTotBOEWithholding": 0,
"Rpt1ScrTotDedTaxAmt": 0,
"Rpt1ScrTotInvoiceAmt": 0,
"Rpt1ScrTotReportableAmt": 0,
"Rpt1ScrTotSelfAmt": 0,
"Rpt1ScrTotTaxableAmt": 0,
"Rpt1ScrTotWithholdingAmt": 0,
"Rpt1ScrUnpostedBal": 0,
"Rpt1SourceRecurBalance": 0,
"Rpt2COIFRSFinancialCharge": 0,
"Rpt2COIFRSPresentValue": 0,
"Rpt2CumulativeBalance": 0,
"Rpt2InvoiceVariance": 0,
"Rpt2MiscChrgNonDeducTax": 0,
"Rpt2MiscChrgVariance": 0,
"Rpt2ScrDiscountAmt": 0,
"Rpt2ScrHdrExpTotal": 0,
"Rpt2ScrHdrMiscChrgTotal": 0,
"Rpt2ScrInvLineTotal": 0,
"Rpt2ScrInvoiceAmt": 0,
"Rpt2ScrInvoiceBal": 0,
"Rpt2ScrInvoiceVendorAmt": 0,
"Rpt2ScrLACTaxAmt": 0,
"Rpt2ScrRounding": 0,
"Rpt2ScrTaxAmt": 0,
"Rpt2ScrTotBOEWithholding": 0,
"Rpt2ScrTotDedTaxAmt": 0,
"Rpt2ScrTotInvoiceAmt": 0,
"Rpt2ScrTotReportableAmt": 0,
"Rpt2ScrTotSelfAmt": 0,
"Rpt2ScrTotTaxableAmt": 0,
"Rpt2ScrTotWithholdingAmt": 0,
"Rpt2ScrUnpostedBal": 0,
"Rpt2SourceRecurBalance": 0,
"Rpt3COIFRSFinancialCharge": 0,
"Rpt3COIFRSPresentValue": 0,
"Rpt3CumulativeBalance": 0,
"Rpt3InvoiceVariance": 0,
"Rpt3MiscChrgNonDeducTax": 0,
"Rpt3MiscChrgVariance": 0,
"Rpt3ScrDiscountAmt": 0,
"Rpt3ScrHdrExpTotal": 0,
"Rpt3ScrHdrMiscChrgTotal": 0,
"Rpt3ScrInvLineTotal": 0,
"Rpt3ScrInvoiceAmt": 0,
"Rpt3ScrInvoiceBal": 0,
"Rpt3ScrInvoiceVendorAmt": 0,
"Rpt3ScrLACTaxAmt": 0,
"Rpt3ScrRounding": 0,
"Rpt3ScrTaxAmt": 0,
"Rpt3ScrTotBOEWithholding": 0,
"Rpt3ScrTotDedTaxAmt": 0,
"Rpt3ScrTotInvoiceAmt": 0,
"Rpt3ScrTotReportableAmt": 0,
"Rpt3ScrTotSelfAmt": 0,
"Rpt3ScrTotTaxableAmt": 0,
"Rpt3ScrTotWithholdingAmt": 0,
"Rpt3ScrUnpostedBal": 0,
"Rpt3SourceRecurBalance": 0,
"RptScrTotWithholdingAmt": 0,
"RvnJrnUID": 0,
"ScrDiscountAmt": 0,
"ScrDocDiscountAmt": 0,
"ScrDocHdrMiscChrgTotal": 0,
"ScrDocInvLineTotal": 0,
"ScrDocInvoiceAmt": 0,
"ScrDocInvoiceBal": 0,
"ScrDocInvoiceVendorAmt": 0,
"ScrDocRounding": 0,
"ScrDocTaxAmt": 0,
"ScrDocTotBOEWithholding": 0,
"ScrDocTotDedTaxAmt": 0,
"ScrDocTotInvoiceAmt": 0,
"ScrDocTotReportableAmt": 0,
"ScrDocTotSelfAmt": 0,
"ScrDocTotTaxableAmt": 0,
"ScrDocTotWithholdingAmt": 0,
"ScrDocUnpostedBal": 0,
"ScrHdrExpTotal": 0,
"ScrHdrMiscChrgTotal": 0,
"ScrInvLineTotal": 0,
"ScrInvoiceAmt": 0,
"ScrInvoiceBal": 0,
"ScrInvoiceRef": "",
"ScrInvoiceVendorAmt": 0,
"ScrLACDocTaxAmt": 0,
"ScrLACTaxAmt": 0,
"ScrRounding": 0,
"ScrTaxAmt": 0,
"ScrTotBOEWithholding": 0,
"ScrTotDedTaxAmt": 0,
"ScrTotInvoiceAmt": 0,
"ScrTotReportableAmt": 0,
"ScrTotSelfAmt": 0,
"ScrTotTaxableAmt": 0,
"ScrTotWithholdingAmt": 0,
"ScrUnpostedBal": 0,
"SkipRecurring": false,
"SourceInvoiceNum": "",
"SourceLastDate": null,
"SourceRecurBalance": 0,
"SwiftCode": "",
"SystemTranType": "APInvoice",
"TaxExchangeRate": 0,
"TaxLinesExist": false,
"TaxRateLinesExist": false,
"TotalInstanceNum": 0,
"TranDocTypeDescription": "",
"TransApplyDate": "2023-04-12T00:00:00",
"UseTaxRate": false,
"VendorInactive": false,
"VendorPayHold": false,
"VNDateReceived": null,
"VNInvoiceType": "",
"XRateLabel": "Exchange Rate",
"AllowChgAfterPrint": true,
"FormattedVendorNameAddress": "",
"SiteIsLegalEntity": false,
"BitFlag": 0,
"AGCustomsDescription": "",
"AGDestinationDescription": "",
"APInvRecurringCycleInactive": false,
"APInvRecurringCycleDescription": "",
"APLOCIDDescription": "",
"CurrencyCodeCurrName": "US Dollars",
"CurrencyCodeCurrSymbol": "USD",
"CurrencyCodeCurrencyID": "USD",
"CurrencyCodeCurrDesc": "US Dollars",
"CurrencyCodeDocumentDesc": "All currencies appear in US Dollars",
"GLCntrlDescription": "",
"GLCntrlTypeDescription": "",
"JournalCodeJrnlDescription": "",
"PayMethodType": 0,
"PayMethodSummarizePerCustomer": false,
"PayMethodName": "",
"RateGrpCodeDescription": "Main Rate Type",
"SourcePlantName": "",
"TaxRateGrpDescription": "",
"TaxRegionCodeDescription": "",
"TermsCodeDescription": "",
"TermsCodeTermsType": "",
"THRefVendorNumName": "",
"THRefVendorNumVendorID": "",
"VendBankPMUID": 0,
"VendBankCardCode": "",
"VendBankBankAcctNumber": "",
"VendBankIBANCode": "",
"VendBankBankGiroAcctNbr": "",
"VendBankSwiftNum": "",
"VendBankLocalBIC": "",
"VendBankBankName": "",
"VendorNumCurrencyCode": "",
"VendorNumZIP": "",
"VendorNumAddress2": "",
"VendorNumAddress3": "",
"VendorNumCity": "",
"VendorNumAddress1": "",
"VendorNumCountry": "",
"VendorNumVendorID": "",
"VendorNumTermsCode": "",
"VendorNumDefaultFOB": "",
"VendorNumState": "",
"VendorNumName": "",
"XbSystAPTaxLnLevel": false,
"XbSystIsDiscountforDebitM": false,
"RowMod": "A"
}
],
"APInvHedAttch": [],
"APIHAPInvExp": [],
"APIHAPInvExpTGLC": [],
"APIHAPInvMsc": [],
"RcvMisc": [],
"APIHAPLnTax": [],
"APInvDtl": [],
"APInvDtlAttch": [],
"APInvDtlDEASch": [],
"APInvExp": [],
"APInvExpTGLC": [],
"GlbAPIETGLC": [],
"APInvJob": [],
"APInvMsc": [],
"APInvLnMscTax": [],
"APInvPB": [],
"APLnTax": [],
"APInvDtlTGLC": [],
"APInvHedMscTax": [],
"APInvSched": [],
"APInvTax": [],
"PESUNATDtl": [],
"EntityGLC": [],
"PEAPInvTax": [],
"AdditionalForms_ParametersView": [],
"LegalNumGenOpts": [],
"SupplierXRef": [],
"TaxConnectStatus": [
{
"Company": "MYCOMPANY",
"ETCOffline": false,
"ErrorMessage": "",
"TCStatus": false,
"SysRowID": "00000000-0000-0000-0000-000000000000",
"RowMod": ""
}
],
"ExtensionTables": []
}
}
}
So first call:
/{currentCompany}/Erp.BO.APInvGrpSvc/GetNewAPInvGrp
then
/{currentCompany}/Erp.BO.APInvGrpSvc/Update
then
/{currentCompany}/Erp.BO.APInvoiceSvc/GetNewAPInvHedInvoice
That being said, this is good knowledge, but I would still do all my processing in a function,
and work with the BOs directly instead of via rest.
My own loading process is nothing more than a a jsonifed python dictionary loaded via the
/Erp.BO.APInvoiceSvc/APInvoices"
Roughly my invoice object looks like after a lot of trial and error (APInvExpTGLCs caught me for a while as Key1…Key6 need to be strings!)
I still can’t using this actually set GLAccount as SysGLControlType and SysGLControlCode seem to over-ride what ever I put in GLAccount or Segment1 and `Segment2.
Think I need to run an update process after creating invoice header to add in GLAccount.
import pytz
import datetime
company = 'company_id'
vendor_num = 818
invoice_num = 'invoice_num'
group_id = '1204D'
invoice_amt = 1100.00 # Includes GST!
line_amt = 1000.00 # Exclude GST
gst_amt = 100.00
account = '51010' # Keep as string
venue_code = '1001' # Keep as string
full_account = str(account)+"|"+str(venue_code)
disp_account = str(account)+"-"+str(venue_code)
entry_person = 'Entry Person'
utc_now = pytz.utc.localize(datetime.datetime.utcnow()).astimezone(pytz.timezone('Australia/Brisbane'))
comments = 'An AP Invoice comment. This is the default line commentary but that can be overwritten.'
# invoice_date = str(datetime.datetime.utcnow().replace(microsecond=0).isoformat())
# invoice_date = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S+%z')
invoice_date = utc_now.isoformat()
print(invoice_date)
new_invoice = {
'Company': company,
'OpenPayable': True,
'VendorNum': vendor_num,
'InvoiceNum': invoice_num,
'DebitMemo': False,
'InvoiceDate': invoice_date, # '2023-04-04T00:00:00+10:00', # invoice_date, # '2023-03-18', # T00:00:00+10:00', # Invoice Date must be in correct date time format! - can I get away without TZ?
'Description': 'A brief invoice description can go here',
'GroupID': group_id,
'Posted': False,
'FiscalYear': 2023,
'FiscalPeriod': 10,
'EntryPerson': entry_person,
'InvoiceAmt': invoice_amt,
'ScrDocInvoiceAmt': invoice_amt,
'ScrDocInvoiceVendorAmt': invoice_amt,
'ScrDocTotDedTaxAmt': gst_amt,
'Plant' : 'MfgSys',
'InvoiceComment': comments,
'IsOnlyMiscRecords': True,
'GLControlType': 'AP Account',
'GLControlCode': 'GEN',
"APInvDtls" : [
{
"Company": company,
"VendorNum": vendor_num,
"InvoiceNum": invoice_num,
"InvoiceLine": 1,
"LineType": "M",
"UnitCost": line_amt,
"DocUnitCost": line_amt,
"Description": "DRINKS!",
"LineComment": "A useful line comment",
"TaxCatID": "GST",
"MultiCompany": False,
"TotalTax": gst_amt,
"DebitMemo": False,
"ScrDocExtCost": line_amt,
"ScrLineDiscAmt": line_amt,
"ScrUnitCost": line_amt,
"ScrVendorQty": 1,
"TotDistribAmt": line_amt,
"APInvExps": [
{
# "Company": company,
# "VendorNum": vendor_num,
# "InvoiceNum": invoice_num,
# "InvoiceLine": 1,
# "InvExpSeq": 1,
# "ExpAmt": line_amt,
# # "RefType": "string",
# # "RefCode": "string",
# # "RefCodeDesc": "string",
# # "GlbCompany": "string",
# # "GlbVendorNum": 0,
# # "GlbInvoiceNum": "string",
# # "GlbInvoiceLine": 0,
# # "GlbInvExpSeq": 0,
# # "ExtCompanyID": "string",
# # "ExtRefType": "string",
# # "ExtRefCode": "string",
# # "MultiCompany": true,
# # "Rpt1ExpAmt": 0,
# # "Rpt2ExpAmt": 0,
# # "Rpt3ExpAmt": 0,
# "DocExpAmt": line_amt,
# # "SysRevID": 0,
# # "SysRowID": "00000000-0000-0000-0000-000000000000",
# # "NonDedTax": true,
# # "NonDedTaxRelatedToSchema": "string",
# # "NonDedTaxRelatedToTable": "string",
# # "NonDedTaxRelatedToSysRowID": "00000000-0000-0000-0000-000000000000",
# "Plant": "MfgSys",
# "AllowUpdate": True,
# "BookID": "MAIN",
# "COACode": "MAIN",
# # "CurrencyCode": "string",
# # "CurrencySwitch": true,
# # "DebitMemo": true,
# "DocScrExpAmt": 900,
# # "EnableExtRefCode": true,
# # "EnableMultiCompany": true,
# # "EnableRefCode": true,
# # "ExpDispGLAcct": "string",
# # "ExpGlbDispGLAcct": "string",
# # "ExtCOACode": "string",
# # "ExtGLAccount": "string",
# # "ExtGLAccountDesc": "string",
# # "ExtRefAcctChart": "string",
# # "ExtRefAcctDept": "string",
# # "ExtRefAcctDiv": "string",
# # "ExtRefCodeList": "string",
# # "ExtRefCodeStatus": "string",
# # "ExtRefDisplayAccount": "string",
# "GLAccount": full_account,
# "GLAccountDesc": "A descriptions",
# "GroupID": group_id,
# # "Posted": true,
# # "RefCodeList": "string",
# # "RefCodeStatus": "string",
# # "Rpt1ScrExpAmt": 0,
# # "Rpt2ScrExpAmt": 0,
# # "Rpt3ScrExpAmt": 0,
# # "ScrExpAmt": 0,
# # "BitFlag": 0,
# # "ExtRefCodeRefCodeDesc": "string",
# # "InvoiceNumDescription": "string",
# # "VendorNumAddress3": "string",
# # "VendorNumTermsCode": "string",
# # "VendorNumAddress1": "string",
# # "VendorNumState": "string",
# # "VendorNumVendorID": "string",
# # "VendorNumAddress2": "string",
# # "VendorNumCurrencyCode": "string",
# # "VendorNumName": "string",
# # "VendorNumCountry": "string",
# # "VendorNumDefaultFOB": "string",
# # "VendorNumCity": "string",
# # "VendorNumZIP": "string",
# # "RowMod": "string",
"APInvExpTGLCs": [
{
"Company": company,
"RelatedToFile": "APInvExp",
"Key1": str(vendor_num),
"Key2": invoice_num,
"Key3": "1",
"Key4": "0",
"Key5": group_id,
"Key6": "",
"TGLCTranNum": 1,
"GLAcctContext": "Expense",
"BookID": "MAIN",
"COACode": "MAIN",
"GLAccount": full_account,
"UserCanModify": True,
"SegValue1": account,
"SegValue2": venue_code,
"SysGLControlType": "AP Account",
"SysGLControlCode": "GEN",
"TransAmt": line_amt,
"VendorNum": vendor_num,
"APInvoiceNum": invoice_num,
"CreateDate": invoice_date,
"FiscalCalendarID": "MASTER",
"InvoiceNum": invoice_num,
"GroupID": group_id,
}
],
}
],
}
],
"EntityGLCs": [
{
"Company": company,
"RelatedToFile": "APInvHed",
"Key1": str(vendor_num), #Key1 is a string and vendor_num is an int!
"Key2": invoice_num,
"Key3": group_id,
"Key4": "",
"Key5": "",
"Key6": "",
"GLControlType": "AP Account",
"GLControlCode": "GEN",
"GroupID": group_id,
"HeadNum": "0",
"InvoiceNum": invoice_num,
"VendorNum": vendor_num,
}
],
}