public ClausePattern(AtomType type, Atom subj, Atom pred, object val, MatchFlag matchFlags) { Type = type; Flags = type.MemberFlags; // Subject = subj; Predicate = pred; Object = val; // MatchFlags = matchFlags; }
// //TODO:probably not wise. public ClausePattern(Atom subj, Atom pred, object val) { Type = Expert.Ent_Belief; Flags = Type.MemberFlags; // Subject = subj; Predicate = pred; Object = val; // MatchFlags = MatchFlag.None; }
public bool Match(Clause clause) { MatchFlag flags = MatchFlags; if (!clause.TypeCheck(Type)) { return(false); } if (((flags & MatchFlag.PredicateX) != MatchFlag.PredicateX) && Predicate != clause.Predicate) { return(false); } if (((flags & MatchFlag.SubjectX) != MatchFlag.SubjectX) && Subject != clause.Subject) { return(false); } if ((flags & MatchFlag.ObjectX) != MatchFlag.ObjectX) { if (Object == null && clause.Object == null) { return(true); } if (Object == null && clause.Object != null) { return(false); } if (Object != null && clause.Object == null) { return(false); } if (!Object.Equals(clause.Object)) { return(false); } } return(true); }
private static MatchFlag GenerateMatchFlagForCashByPickingSimpleCase(Cash cash) { MatchFlag matchFlag = new MatchFlag() { CashIdOfCashByPicking = cash.CashId, CompanyId = cash.CompanyId, CounterPartyCode = cash.CounterPartyCode, CounterPartyId = cash.CounterPartyId, CurrencyCode = cash.CurrencyCode, IsPrematch = true, MatchFlagId = cash.MatchFlagId, MatchingCurrency = cash.MatchingCurrency, MatchingStatusId = cash.MatchingStatusId, PaymentDocumentDate = cash.DocumentDate // the payment document date should be the document date of the Cash }; matchFlag.DocumentMatchings = new List <DocumentMatching>(); foreach (var dm in cash.DocumentMatchings) { var cashLine = cash.CashLines.ToList().Find(cl => ((cl.InitiallyMatchedInvoiceId.HasValue && dm.SourceInvoiceId.HasValue) && cl.InitiallyMatchedInvoiceId.Value == dm.SourceInvoiceId.Value) || ((cl.InitiallyMatchedCashLineId.HasValue && dm.SourceCashLineId.HasValue) && cl.InitiallyMatchedCashLineId.Value == dm.SourceCashLineId.Value) || ((cl.InitiallyMatchedJournalLineId.HasValue && dm.SourceJournalLineId.HasValue) && cl.InitiallyMatchedJournalLineId.Value == dm.SourceJournalLineId.Value)); matchFlag.DocumentMatchings.Add(new DocumentMatching() { TransactionDocumentId = dm.TransactionDocumentId, Amount = dm.Amount, AmountToBePaid = dm.AmountToBePaid, MatchedAmount = dm.AmountToBePaid, ValueDate = dm.InvoiceGLDate ?? dm.DocumentDate, DepartmentId = dm.DepartmentId, TransactionDirectionId = dm.TransactionDirectionId, AmountInFunctionalCurrency = dm.AmountInFunctionalCurrency, AmountInStatutoryCurrency = dm.AmountInStatutoryCurrency, SecondaryDocumentReferenceId = cash.TransactionDocumentId, SourceCashLineId = dm.SourceCashLineId, SourceInvoiceId = dm.SourceInvoiceId, SourceJournalLineId = dm.SourceJournalLineId, MatchedCashLineId = cashLine?.CashLineId, }); matchFlag.DocumentMatchings.Add(new DocumentMatching() { TransactionDocumentId = cash.TransactionDocumentId, Amount = cashLine.Amount.Value, // The cashline contains the signed value AmountToBePaid = cashLine.Amount.Value, // The cashline contains the signed value MatchedAmount = cashLine.Amount.Value, // The cashline contains the signed value ValueDate = cash.DocumentDate, DepartmentId = dm.DepartmentId, TransactionDirectionId = dm.TransactionDirectionId, AmountInFunctionalCurrency = cashLine?.AmountInFunctionalCurrency, // The cashline contains the signed value AmountInStatutoryCurrency = cashLine?.AmountInStatutoryCurrency, // The cashline contains the signed value SecondaryDocumentReferenceId = dm.TransactionDocumentId, SourceCashLineId = cashLine?.CashLineId, MatchedJournalLineId = cashLine?.InitiallyMatchedJournalLineId, MatchedCashLineId = cashLine?.InitiallyMatchedCashLineId, MatchedInvoiceId = cashLine?.InitiallyMatchedInvoiceId }); } return(matchFlag); }
/// <summary> /// Convert NCOA return record to NcoaHistory. /// </summary> /// <returns>NcoaHistory</returns> public NcoaHistory ToNcoaHistory() { var ids = InputIndividualId?.Split('_'); var ncoaHistory = new NcoaHistory() { //PersonId = ( ids?[0] ).AsInteger(), PersonAliasId = (ids?[1]).AsInteger(), FamilyId = (ids?[2]).AsInteger(), LocationId = (ids?[3]).AsInteger(), AddressStatus = AddressStatus == "V" ? Model.AddressStatus.Valid : Model.AddressStatus.Invalid, MoveDate = NcoaDateToDateTime(MoveDate), MoveDistance = (decimal?)MoveDistance, NcoaNote = DeliveryPointVerificationNotes, NcoaRunDateTime = NcoaRunDateTime, OriginalCity = InputAddressCity, OriginalPostalCode = InputAddressPostalCode, OriginalState = InputAddressStateCode, OriginalStreet1 = InputAddressLine1, OriginalStreet2 = InputAddressLine2, Processed = Processed.NotProcessed, UpdatedBarcode = Barcode, UpdatedCity = CityName, UpdatedCountry = CountryCode, UpdatedPostalCode = PostalCode, UpdatedState = StateCode, UpdatedStreet1 = AddressLine1, UpdatedStreet2 = AddressLine2 }; switch (ResidentialDeliveryIndicator) { case "Y": ncoaHistory.UpdatedAddressType = UpdatedAddressType.Residential; break; case "N": ncoaHistory.UpdatedAddressType = UpdatedAddressType.Business; break; default: ncoaHistory.UpdatedAddressType = UpdatedAddressType.None; break; } ; if (ANK == "48") { ncoaHistory.NcoaType = NcoaType.Month48Move; } else if (MatchFlag.IsNotNullOrWhiteSpace() && RecordType == "C") { ncoaHistory.NcoaType = NcoaType.Move; } else { ncoaHistory.NcoaType = NcoaType.NoMove; if (AddressStatus == "V") { ncoaHistory.Processed = Processed.Complete; } } if (AddressStatus != "V") { ncoaHistory.AddressInvalidReason = AddressInvalidReason.NotFound; ncoaHistory.AddressStatus = Model.AddressStatus.Invalid; } else if (Vacant == "Y") { ncoaHistory.AddressInvalidReason = AddressInvalidReason.Vacant; } else { ncoaHistory.AddressInvalidReason = AddressInvalidReason.None; } switch (MatchFlag) { case "M": ncoaHistory.MatchFlag = Model.MatchFlag.Moved; break; case "G": ncoaHistory.MatchFlag = Model.MatchFlag.POBoxClosed; break; case "K": ncoaHistory.MatchFlag = Model.MatchFlag.MovedNoForwarding; break; case "F": ncoaHistory.MatchFlag = Model.MatchFlag.MovedToForeignCountry; break; default: ncoaHistory.MatchFlag = Model.MatchFlag.None; break; } switch (MoveType) { case "I": ncoaHistory.MoveType = Model.MoveType.Individual; break; case "F": ncoaHistory.MoveType = Model.MoveType.Family; break; case "B": ncoaHistory.MoveType = Model.MoveType.Business; break; default: ncoaHistory.MoveType = Model.MoveType.None; break; } return(ncoaHistory); }
private static void GenerateInformationForCashByPickingDiffClient( Cash cash, out IEnumerable <ManualJournalLine> counterpartyTransferJournalLines, out SortedList <int, DocumentMatching> linkBetweenJournalLineNumberAndDM, out MatchFlag matchFlagCpForMatchedDocument, out MatchFlag matchFlagCpForCash, CostType fxRealCostType) { linkBetweenJournalLineNumberAndDM = new SortedList <int, DocumentMatching>(); var counter = 1; var manualJournalLines = new List <ManualJournalLine>(); matchFlagCpForMatchedDocument = new MatchFlag() { CompanyId = cash.CompanyId, CounterPartyCode = cash.CounterPartyCode, // Apparently, the only way to get the counterparty of the matched documents is in the document matching CounterPartyId = cash.DocumentMatchings.First().MatchingCounterpartyId, CurrencyCode = cash.CurrencyCode, IsPrematch = true, PaymentDocumentDate = cash.DocumentDate, DocumentMatchings = new List <DocumentMatching>(), }; matchFlagCpForCash = new MatchFlag() { CashIdOfCashByPicking = cash.CashId, CompanyId = cash.CompanyId, CounterPartyCode = cash.CounterPartyCode, CounterPartyId = cash.CounterPartyId, CurrencyCode = cash.CurrencyCode, IsPrematch = true, PaymentDocumentDate = cash.DocumentDate, DocumentMatchings = new List <DocumentMatching>() }; foreach (var documentMatching in cash.DocumentMatchings) { var cashLine = cash.CashLines.ToList().Find(cl => ((cl.InitiallyMatchedInvoiceId.HasValue && documentMatching.SourceInvoiceId.HasValue) && cl.InitiallyMatchedInvoiceId.Value == documentMatching.SourceInvoiceId.Value) || ((cl.InitiallyMatchedCashLineId.HasValue && documentMatching.SourceCashLineId.HasValue) && cl.InitiallyMatchedCashLineId.Value == documentMatching.SourceCashLineId.Value) || ((cl.InitiallyMatchedJournalLineId.HasValue && documentMatching.SourceJournalLineId.HasValue) && cl.InitiallyMatchedJournalLineId.Value == documentMatching.SourceJournalLineId.Value)); linkBetweenJournalLineNumberAndDM[counter] = documentMatching; // dm for the matched object matchFlagCpForMatchedDocument.DocumentMatchings.Add(new DocumentMatching() { TransactionDocumentId = documentMatching.TransactionDocumentId, MatchedAmount = documentMatching.AmountToBePaid, ValueDate = documentMatching.InvoiceGLDate ?? documentMatching.DocumentDate, DepartmentId = documentMatching.DepartmentId, TransactionDirectionId = documentMatching.TransactionDirectionId, AmountInFunctionalCurrency = documentMatching.AmountInFunctionalCurrency, AmountInStatutoryCurrency = documentMatching.AmountInStatutoryCurrency, SecondaryDocumentReferenceId = cash.TransactionDocumentId, SourceCashLineId = documentMatching.SourceCashLineId, SourceInvoiceId = documentMatching.SourceInvoiceId, SourceJournalLineId = documentMatching.SourceJournalLineId, MatchedCashLineId = cashLine?.CashLineId, PaymentDocumentDate = cash.DocumentDate }); int signForAccountingDocuments = 1; // Depends on the matched document switch ((MasterDocumentType)documentMatching.TransactionDocumentTypeId) { case MasterDocumentType.CP: case MasterDocumentType.SI: case MasterDocumentType.DN: case MasterDocumentType.JL: signForAccountingDocuments = -1; break; case MasterDocumentType.CI: case MasterDocumentType.PI: case MasterDocumentType.CN: signForAccountingDocuments = 1; break; } // dm for the journal - 'removal' from customer 1 var jlDM = new DocumentMatching() { TransactionDocumentId = null, // Will be set later, to represent one of the JL lines MatchedAmount = documentMatching.AmountToBePaid * signForAccountingDocuments, ValueDate = documentMatching.InvoiceGLDate ?? documentMatching.DocumentDate, DepartmentId = documentMatching.DepartmentId, TransactionDirectionId = documentMatching.TransactionDirectionId, AmountInFunctionalCurrency = documentMatching.AmountInFunctionalCurrency * signForAccountingDocuments, AmountInStatutoryCurrency = documentMatching.AmountInStatutoryCurrency * signForAccountingDocuments, SecondaryDocumentReferenceId = cash.TransactionDocumentId, PaymentDocumentDate = cash.DocumentDate }; matchFlagCpForMatchedDocument.DocumentMatchings.Add(jlDM); linkBetweenJournalLineNumberAndDM[counter] = jlDM; // Creation of the manual journal which must have the exact same amounts than the document matching var matchedCounterpartyJL = new ManualJournalLine() { ClientAccountId = cash.MatchingCounterpartyId, AssociatedAccountId = cash.MatchingCounterpartyId, AccountLineTypeId = documentMatching.AccountLineTypeId, Amount = documentMatching.AmountToBePaid * signForAccountingDocuments, Narrative = documentMatching.Narrative, DepartmentId = cash.DepartmentId, // On Diff Client, SecondaryDocuementReference should be the reference to the cash SecondaryDocumentReference = cash.DocumentReference, ExternalDocumentReference = documentMatching.ExternalReference, CharterId = null, SectionId = null, LineNumber = counter++, CostTypeId = fxRealCostType.CostTypeId }; manualJournalLines.Add(matchedCounterpartyJL); // dm of the cash decimal?signedAmountForCash = documentMatching.AmountToBePaid * CalculateSignForCashDocumentMatching( (DirectionType)cash.CashTypeId, (MasterDocumentType)documentMatching.TransactionDocumentTypeId); matchFlagCpForCash.DocumentMatchings.Add(new DocumentMatching() { TransactionDocumentId = cash.TransactionDocumentId, MatchedAmount = cashLine.Amount.Value, // The cashline contains the signed value ValueDate = cash.DocumentDate, DepartmentId = documentMatching.DepartmentId, TransactionDirectionId = documentMatching.TransactionDirectionId, AmountInFunctionalCurrency = cashLine?.AmountInFunctionalCurrency, // The cashline contains the signed value AmountInStatutoryCurrency = cashLine?.AmountInStatutoryCurrency, // The cashline contains the signed value SecondaryDocumentReferenceId = documentMatching.TransactionDocumentId, SourceCashLineId = cashLine?.CashLineId, MatchedJournalLineId = documentMatching.SourceJournalLineId, MatchedCashLineId = documentMatching.SourceCashLineId, MatchedInvoiceId = documentMatching.SourceInvoiceId, PaymentDocumentDate = cash.DocumentDate }); // Second dm for the journal jlDM = new DocumentMatching() { TransactionDocumentId = null, // Will be set later, to represent one of the JL lines MatchedAmount = documentMatching.AmountToBePaid * signForAccountingDocuments * -1, ValueDate = cash.DocumentDate, DepartmentId = documentMatching.DepartmentId, TransactionDirectionId = documentMatching.TransactionDirectionId, AmountInFunctionalCurrency = documentMatching.AmountInFunctionalCurrency * signForAccountingDocuments * -1, // The cashline contains the signed value AmountInStatutoryCurrency = documentMatching.AmountInStatutoryCurrency * signForAccountingDocuments * -1, // The cashline contains the signed value SecondaryDocumentReferenceId = documentMatching.TransactionDocumentId, PaymentDocumentDate = cash.DocumentDate }; matchFlagCpForCash.DocumentMatchings.Add(jlDM); linkBetweenJournalLineNumberAndDM[counter] = jlDM; var cashCounterpartyJL = new ManualJournalLine() { ClientAccountId = cash.PaymentCounterpartyId, AssociatedAccountId = cash.PaymentCounterpartyId, AccountLineTypeId = documentMatching.AccountLineTypeId, Amount = documentMatching.AmountToBePaid * signForAccountingDocuments * -1, Narrative = documentMatching.Narrative, DepartmentId = cash.DepartmentId, // On Diff Client, SecondaryDocuementReference should be the reference to the cash SecondaryDocumentReference = cash.DocumentReference, ExternalDocumentReference = documentMatching.ExternalReference, CharterId = null, SectionId = null, LineNumber = counter++, CostTypeId = fxRealCostType.CostTypeId }; manualJournalLines.Add(cashCounterpartyJL); } counterpartyTransferJournalLines = manualJournalLines; }
private TypeMatch(MatchFlag flag, int dereferences, int data = 0) { this.flag = flag; this.data = data; this.Dereferences = dereferences; }
public async Task <long?> CreateUpdateDocumentMatchingsForCashByPickingCreation(MatchFlag matchFlag, bool isEdit) { var queryParameters = new DynamicParameters(); queryParameters.Add("@CompanyId", matchFlag.CompanyId); queryParameters.Add(DataVersionIdParameter, null); queryParameters.Add("@CashIdOfCashByPicking", matchFlag.CashIdOfCashByPicking); queryParameters.Add("@DocumentMatching", CashToDocumentMatchingTvp(matchFlag.DocumentMatchings, isEdit)); queryParameters.Add("@MatchFlagId", matchFlag.MatchFlagId == 0 ? null : matchFlag.MatchFlagId); queryParameters.Add("@IsPrematch", matchFlag.IsPrematch); queryParameters.Add("@CounterpartyId", matchFlag.CounterPartyId); queryParameters.Add("@CounterPartyCode", matchFlag.CounterPartyCode); queryParameters.Add("@CurrencyCode", matchFlag.CurrencyCode); queryParameters.Add("@MatchingStatusId", matchFlag.MatchingStatusId == 0 ? null : matchFlag.MatchingStatusId); queryParameters.Add("@MatchFlagIdInserted", dbType: DbType.Int64, direction: ParameterDirection.Output); queryParameters.Add("@DocumentReference", dbType: DbType.String, direction: ParameterDirection.Output, size: 10); queryParameters.Add("@CurrentDocumentReferenceNumber", dbType: DbType.Int32, direction: ParameterDirection.Output); queryParameters.Add("@TransactionDocumentId", dbType: DbType.Int64, direction: ParameterDirection.Output); queryParameters.Add("@TransactionDocumentIdRevarsal", dbType: DbType.Int64, direction: ParameterDirection.Output); queryParameters.Add("@MatchFlagCodeInserted", dbType: DbType.String, direction: ParameterDirection.Output, size: 10); queryParameters.Add("@PaymentDocumentDate", matchFlag.PaymentDocumentDate); await ExecuteNonQueryAsync(StoredProcedureNames.CreateUpdateDocumentMatchingForCashByPickingCreation, queryParameters, true); return(queryParameters.Get <long?>("@MatchFlagIdInserted")); }