Ejemplo n.º 1
0
        public static Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry GetInvoiceByInvoiceNumberAndSupplierPrimaryKey(string id, string invoicenumber)
        {
            Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry result = null;
            if (application != null)
            {
                try
                {
                    // PURCHASE INVOICES
                    Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntries invoices = Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntriesFactory.Factory.CreateNew();
                    Sage.ObjectStore.Query query = new Sage.ObjectStore.Query();

                    Sage.ObjectStore.Filter filter = new Sage.ObjectStore.Filter(Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry.FIELD_ENTRYTYPE, Sage.Accounting.TradingAccountEntryTypeEnum.TradingAccountEntryTypeInvoice);
                    query.Filters.Add(filter);

                    Sage.ObjectStore.Filter filter1 = new Sage.ObjectStore.Filter(Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry.FIELD_INSTRUMENTNO, invoicenumber);
                    query.Filters.Add(filter1);

                    Sage.Common.Data.DbKey  key     = new Sage.Common.Data.DbKey(Convert.ToInt32(id));
                    Sage.ObjectStore.Filter filter2 = new Sage.ObjectStore.Filter(Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry.FIELD_SUPPLIERACCOUNTDBKEY, key);
                    query.Filters.Add(filter2);

                    invoices.Find(query);

                    result = invoices.First;
                }
                catch (Exception ex)
                {
                    result = null;
                    Logger.WriteLog(ex);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static List <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry> GetNewInvoices(DateTime from)
        {
            List <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry> results = new List <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry>();

            if (application != null)
            {
                // PURCHASE INVOICES
                //Sage.Accounting.PurchaseLedger.PurchaseInvoicePostingFactory.Factory.Fetch()
                Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntries invoices = Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntriesFactory.Factory.CreateNew();
                Sage.ObjectStore.Query query = new Sage.ObjectStore.Query();

                Sage.ObjectStore.Filter filter = new Sage.ObjectStore.Filter(Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry.FIELD_ENTRYTYPE, Sage.Accounting.TradingAccountEntryTypeEnum.TradingAccountEntryTypeInvoice);
                query.Filters.Add(filter);

                Sage.ObjectStore.Filter filter1 = new Sage.ObjectStore.Filter(Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry.FIELD_INSTRUMENTDATE, FilterOperator.GreaterThanOrEqual, from);
                query.Filters.Add(filter1);

                invoices.Find(query);

                List <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry> list = invoices.GetList().Cast <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry>().ToList();
                foreach (Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry entry in list)
                {
                    if ((entry.DocumentStatus == Sage.Accounting.AllocationStatusEnum.DocumentStatusBlank || entry.DocumentStatus == Sage.Accounting.AllocationStatusEnum.DocumentStatusPart) && entry.InstrumentNo.Length > 0)
                    {
                        results.Add(entry);
                    }
                }
            }

            return(results);
        }
Ejemplo n.º 3
0
        public static Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry GetInvoiceByInvoiceNumber(string invoicenumber)
        {
            Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry result = null;
            if (application != null)
            {
                // PURCHASE INVOICES
                Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntries invoices = Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntriesFactory.Factory.CreateNew();
                Sage.ObjectStore.Query query = new Sage.ObjectStore.Query();

                Sage.ObjectStore.Filter filter = new Sage.ObjectStore.Filter(Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry.FIELD_ENTRYTYPE, Sage.Accounting.TradingAccountEntryTypeEnum.TradingAccountEntryTypeInvoice);
                query.Filters.Add(filter);

                Sage.ObjectStore.Filter filter1 = new Sage.ObjectStore.Filter(Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry.FIELD_INSTRUMENTNO, invoicenumber);
                query.Filters.Add(filter1);

                invoices.Find(query);

                result = invoices.First;
            }

            return(result);
        }
Ejemplo n.º 4
0
        public static List <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry> GetCreditNotes()
        {
            List <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry> list = new List <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry>();

            if (application != null)
            {
                Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntries creditnotes = Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntriesFactory.Factory.CreateNew();
                Sage.ObjectStore.Query  query  = new Sage.ObjectStore.Query();
                Sage.ObjectStore.Filter filter = new Sage.ObjectStore.Filter(Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry.FIELD_ENTRYTYPE, Sage.Accounting.TradingAccountEntryTypeEnum.TradingAccountEntryTypeCreditNote);
                query.Filters.Add(filter);

                creditnotes.Find(query);

                foreach (Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry entry in creditnotes.GetList().Cast <Sage.Accounting.PurchaseLedger.PostedPurchaseAccountEntry>().ToList())
                {
                    if (entry.DocumentStatus == Sage.Accounting.AllocationStatusEnum.DocumentStatusBlank && entry.SecondReferenceNo.Length > 0)
                    {
                        list.Add(entry);
                    }
                }
            }

            return(list);
        }