Esempio n. 1
0
 public override IQueryable <T> CorrectedFiltering(IQueryable <T> query, Sungero.Domain.PropertyFilteringEventArgs e)
 {
     query = base.CorrectedFiltering(query, e);
     return(query.Where(x => (OutgoingTaxInvoices.Is(x) || UniversalTransferDocuments.Is(x)) && x.IsAdjustment != true));
 }
Esempio n. 2
0
        public List <IAccountingDocumentBase> FindAccountingDocuments(string number, string date,
                                                                      string butin, string butrrc,
                                                                      string cuuid, string ctin, string ctrrc,
                                                                      bool corrective,
                                                                      bool incomingTaxInvoice,
                                                                      bool outgoingTaxInvoice,
                                                                      bool contractStatement,
                                                                      bool waybill,
                                                                      bool universalTransferDocument)
        {
            var result = AccountingDocumentBases.GetAll()
                         .Where(a => incomingTaxInvoice && IncomingTaxInvoices.Is(a) ||
                                outgoingTaxInvoice && OutgoingTaxInvoices.Is(a) ||
                                contractStatement && ContractStatements.Is(a) ||
                                waybill && Waybills.Is(a) ||
                                universalTransferDocument && UniversalTransferDocuments.Is(a));

            // Фильтр по НОР.
            if (string.IsNullOrWhiteSpace(butin) || string.IsNullOrWhiteSpace(butrrc))
            {
                return(new List <IAccountingDocumentBase>());
            }

            var businessUnit = Sungero.Company.BusinessUnits.GetAll().FirstOrDefault(x => x.TIN == butin && x.TRRC == butrrc);

            if (businessUnit == null)
            {
                return(new List <IAccountingDocumentBase>());
            }
            else
            {
                result = result.Where(x => Equals(x.BusinessUnit, businessUnit));
            }

            // Фильтр по номеру.
            var relevantNumbers = this.GetRelevantNumbers(number);

            result = result.Where(x => relevantNumbers.Contains(x.RegistrationNumber));

            // Фильтр по дате.
            DateTime parsedDate;

            if (!string.IsNullOrWhiteSpace(date) && DateTime.TryParseExact(date,
                                                                           "dd'.'MM'.'yyyy",
                                                                           System.Globalization.CultureInfo.InvariantCulture,
                                                                           System.Globalization.DateTimeStyles.None,
                                                                           out parsedDate))
            {
                result = result.Where(x => x.RegistrationDate == parsedDate);
            }

            // Фильтр по контрагенту.
            var counterparties = Sungero.Parties.PublicFunctions.Module.Remote.FindCounterparty(cuuid, ctin, ctrrc, string.Empty);

            if (counterparties.Any())
            {
                result = result.Where(x => counterparties.Contains(x.Counterparty));
            }

            // Фильтр корректировочный или нет.
            result = result.Where(x => x.IsAdjustment == corrective);

            return(result.ToList());
        }