Пример #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (issueDate_ != null)
            {
                hash ^= IssueDate.GetHashCode();
            }
            if (supplier_ != null)
            {
                hash ^= Supplier.GetHashCode();
            }
            if (CustomerRef.Length != 0)
            {
                hash ^= CustomerRef.GetHashCode();
            }
            if (Text.Length != 0)
            {
                hash ^= Text.GetHashCode();
            }
            if (Currency.Length != 0)
            {
                hash ^= Currency.GetHashCode();
            }
            if (Total != 0F)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Total);
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #2
0
            public XElement GenerateAddRq()
            {
                XElement Add = new XElement(nameof(ExpenseLine) + "Add");

                Add.Add(AccountRef.ToQBXML(nameof(AccountRef)));
                Add.Add(Amount.ToQBXML(nameof(Amount)));
                Add.Add(Memo.ToQBXML(nameof(Memo)));
                Add.Add(CustomerRef.ToQBXML(nameof(CustomerRef)));
                Add.Add(ClassRef.ToQBXML(nameof(ClassRef)));
                Add.Add(BillableStatus.ToQBXML(nameof(BillableStatus)));
                Add.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef)));
                Add.Add(DataExt.ToQBXML(nameof(DataExt)));
                return(Add);
            }
Пример #3
0
            public XElement GenerateModRq()
            {
                XElement Mod = new XElement(nameof(ExpenseLine) + "Mod");

                Mod.Add(TxnLineID.ToQBXML(nameof(TxnLineID)));
                Mod.Add(AccountRef.ToQBXML(nameof(AccountRef)));
                Mod.Add(Amount.ToQBXML(nameof(Amount)));
                Mod.Add(Memo.ToQBXML(nameof(Memo)));
                Mod.Add(CustomerRef.ToQBXML(nameof(CustomerRef)));
                Mod.Add(ClassRef.ToQBXML(nameof(ClassRef)));
                Mod.Add(BillableStatus.ToQBXML(nameof(BillableStatus)));
                Mod.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef)));

                return(Mod);
            }
Пример #4
0
        public string toXmlAdd()
        {
            if (Amount > 0)
            {
                string xml = Environment.NewLine + "<ExpenseLineAdd>";
                if (AccountRef != null)
                {
                    xml += Environment.NewLine + AccountRef.toXmlRef();
                }

                System.Globalization.CultureInfo myInfo = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");

                xml += Environment.NewLine + "<Amount>" + Amount.ToString("0.00", myInfo) + "</Amount>";
                if (Memo != string.Empty)
                {
                    xml += Environment.NewLine + "<Memo>" + Memo + "</Memo>";
                }

                if (CustomerRef != null)
                {
                    xml += CustomerRef.toXmlRef();
                }
                if (ClassRef != null)
                {
                    xml += ClassRef.toXmlRef();
                }

                if (BillableStatus != null && BillableStatus != string.Empty)
                {
                    xml += Environment.NewLine + "<BillableStatus>" + BillableStatus + "</BillableStatus> ";
                }


                xml += Environment.NewLine + "</ExpenseLineAdd>";
                return(xml);
            }
            else
            {
                return(string.Empty);
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            CustomerRef first  = new CustomerRef(1, "Sasha", "Hell");
            CustomerRef second = new CustomerRef(2, "Alex", "Penn");
            CustomerRef third  = new CustomerRef(2, "Olga", "Enn");

            Console.WriteLine("---class---");

            Console.WriteLine(second.Equals(third, new ClassComparer.EqualityByName()));
            Console.WriteLine(second.CompareTo(third));
            Console.WriteLine(second.CompareTo(third, new ClassComparer.CompareByLastName()));
            Console.WriteLine(second.CompareTo(third, new ClassComparer.CompareByLastName().Compare));

            Console.WriteLine("-------------------");
            Console.WriteLine(second < second);
            Console.WriteLine(second > second);
            Console.WriteLine(first.Clone().ToString());

            Console.WriteLine("---structure---");

            CustomerVal valFirst = new CustomerVal(1, "Sasha", "Hell");
            CustomerVal valSec   = new CustomerVal(2, "Alex", "Penn");
            CustomerVal valThird = new CustomerVal(2, "Olga", "Enn");

            object obj = valSec;

            Console.WriteLine(obj.Equals(valSec));
            Console.WriteLine(valSec.Equals(obj));
            Console.WriteLine(valSec.Equals(valThird, new StructComparer.EqualityByName()));

            Console.WriteLine(valSec.CompareTo(valThird));
            Console.WriteLine(valSec.CompareTo(valThird, new StructComparer.CompareByLastName()));
            Console.WriteLine(valSec.CompareTo(valThird, new StructComparer.CompareByLastName().Compare));

            Console.WriteLine("-------------------");
            Console.WriteLine(valSec < valSec);
            Console.WriteLine(valSec > valSec);
            Console.WriteLine(valFirst.Clone().ToString());
        }
Пример #6
0
            public XElement ToQBXML(string name, BaseRef OverrideItemAccountRef = null)
            {
                XElement xElement = new XElement(name);

                xElement.Add(TxnLineID.ToQBXML(nameof(TxnLineID)));
                xElement.Add(ItemRef.ToQBXML(nameof(ItemRef)));
                xElement.Add(InventorySiteRef.ToQBXML(nameof(InventorySiteRef)));
                xElement.Add(InventorySiteLocationRef.ToQBXML(nameof(InventorySiteLocationRef)));
                xElement.Add(SerialNumber.ToQBXML(nameof(SerialNumber)));
                xElement.Add(LotNumber.ToQBXML(nameof(LotNumber)));
                xElement.Add(Desc.ToQBXML(nameof(Desc)));
                xElement.Add(UnitOfMeasure.ToQBXML(nameof(UnitOfMeasure)));
                xElement.Add(OverrideUOMSetRef.ToQBXML(nameof(OverrideUOMSetRef)));
                xElement.Add(Cost.ToQBXML(nameof(Cost)));
                xElement.Add(Amount.ToQBXML(nameof(Amount)));
                xElement.Add(CustomerRef.ToQBXML(nameof(CustomerRef)));
                xElement.Add(ClassRef.ToQBXML(nameof(ClassRef)));
                xElement.Add(BillableStatus.ToQBXML(nameof(BillableStatus)));
                xElement.Add(OverrideItemAccountRef.ToQBXML(nameof(OverrideItemAccountRef)));
                xElement.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef)));
                return(xElement);
            }
Пример #7
0
            public virtual XElement GenerateModRq(BaseRef OverrideItemAccountRef = null)
            {
                XElement xElement = new XElement(nameof(ItemLine) + "Mod");

                xElement.Add(TxnLineID.ToQBXML(nameof(TxnLineID)));
                xElement.Add(ItemRef.ToQBXML(nameof(ItemRef)));
                xElement.Add(InventorySiteRef.ToQBXML(nameof(InventorySiteRef)));
                xElement.Add(InventorySiteLocationRef.ToQBXML(nameof(InventorySiteLocationRef)));
                xElement.Add(SerialNumber.ToQBXML(nameof(SerialNumber)));
                xElement.Add(LotNumber.ToQBXML(nameof(LotNumber)));
                xElement.Add(Desc.ToQBXML(nameof(Desc)));
                xElement.Add(Quantity.ToQBXML(nameof(Quantity)));
                xElement.Add(UnitOfMeasure.ToQBXML(nameof(UnitOfMeasure)));
                xElement.Add(OverrideUOMSetRef.ToQBXML(nameof(OverrideUOMSetRef)));
                xElement.Add(Cost.ToQBXML(nameof(Cost)));
                xElement.Add(Amount.ToQBXML(nameof(Amount)));
                xElement.Add(CustomerRef.ToQBXML(nameof(CustomerRef)));
                xElement.Add(ClassRef.ToQBXML(nameof(ClassRef)));
                xElement.Add(BillableStatus.ToQBXML(nameof(BillableStatus)));
                xElement.Add(OverrideItemAccountRef.ToQBXML(nameof(OverrideItemAccountRef)));
                xElement.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef)));
                return(xElement);
            }
Пример #8
0
        static void Main(string[] args)
        {
            Car myCar = new Car(
                "Mini Cooper", 
                1.6f, 
                new DateTime(2010, 10, 1), 
                CarColor.Black, 
                25000);


            CustomerRef r = new CustomerRef();
            r.Email = "1";
            Console.WriteLine(r.Email);

            Customer customer = new Customer();
            //customer.Address.Country = "Ukraine";
            Console.WriteLine(customer.Sex);
            Console.WriteLine(customer.Address);
            Console.WriteLine(customer.Address.Country);

            Console.ReadLine();
        }
Пример #9
0
        private void ProcessInvoice(VendIvc invoice, ApexDataDataContext apexData)
        {
            PO po = apexData.POs.Where(s => s.Po1 == invoice.PO).SingleOrDefault(); //get the corresponding P/O

            if (po == null)
            {
                _StatusLines.Add(new StatusLine
                {
                    Invoice = invoice.Invoice,
                    PO      = invoice.PO.Trim(),
                    Message = "The invoice points to an invalid P/O!?"
                });
                return;
            }
            if (po.Vendor == null)
            {
                _StatusLines.Add(new StatusLine
                {
                    Invoice = invoice.Invoice,
                    PO      = invoice.PO.Trim(),
                    Message = "There is no vendor on this P/O"
                });
                return;
            }

            Job job = apexData.Jobs.Where(s => s.Job1 == po.Job).SingleOrDefault(); //get the job

            if (job == null)
            {
                _StatusLines.Add(new StatusLine
                {
                    Invoice = invoice.Invoice,
                    PO      = invoice.PO.Trim(),
                    Message = "There is no job on this P/O"
                });
                return;
            }

            QBJob qbjob = apexData.QBJobs.Where(s => s.ApexCompany == _ApexTargetCompany &&
                                                s.ApexJobID == po.Job).SingleOrDefault();

            if (qbjob == null)
            {
                _StatusLines.Add(new StatusLine
                {
                    Invoice = invoice.Invoice,
                    PO      = invoice.PO.Trim(),
                    Message = "This P/O has an invalid QuickBooks job reference"
                });
                return;
            }

            QBVendor qbvendor = apexData.QBVendors.Where(s => s.ApexCompany == _ApexTargetCompany &&
                                                         s.ApexVendorID == po.Vendor).SingleOrDefault();

            if (qbvendor == null)
            {
                _StatusLines.Add(new StatusLine
                {
                    Invoice = invoice.Invoice,
                    PO      = invoice.PO.Trim(),
                    Message = "This P/O has an invalid QuickBooks vendor reference"
                });
                return;
            }

            var qbxml = new QBXML();

            qbxml.ItemsElementName = new ItemsChoiceType99[1] {
                ItemsChoiceType99.QBXMLMsgsRq
            };
            var qbMsgsRq = new QBXMLMsgsRq();

            qbMsgsRq.onError = QBXMLMsgsRqOnError.continueOnError;

            var billaddrq = new BillAddRqType();

            billaddrq.requestID = "1";

            TermsRef termsref = new TermsRef
            {
                FullName = po.VendorTerms
            };

            string ApexGLRef = apexData.Costcodes
                               .Where(s => s.Schedule == "STD" && s.CostCode1 == po.POLines.Select(l => l.CostCode).FirstOrDefault())
                               .Select(s => s.GL).FirstOrDefault();

            if (String.IsNullOrEmpty(ApexGLRef))
            {
                ApexGLRef = "M";
            }

            string QBGLAcctFullName = GLAcctUtility.GLAcctList
                                      .Where(s => s.ApexCompany == _ApexTargetCompany && s.ApexGLRef == ApexGLRef)
                                      .Select(s => s.QBGLAcctFullName).SingleOrDefault();

            AccountRef accountref = new AccountRef
            {
                FullName = QBGLAcctFullName
            };

            AccountRef creditaccountref = new AccountRef
            {
                FullName = "Cash Discount on Payables"
            };

            //Classes in QuickBooks equate to Divisions in Apex for this client
            ClassRef classref = new ClassRef
            {
                FullName = apexData.Divisions.Where(s => s.Company == po.Company && s.Division1 == po.Division).Select(s => s.Name).SingleOrDefault()
            };

            CustomerRef customerref = new CustomerRef
            {
                ListID = qbjob.QBListID
            };

            ExpenseLineAdd expenseline = new ExpenseLineAdd
            {
                AccountRef  = accountref,
                Amount      = invoice.IvcAmt?.ToString("F2"),
                CustomerRef = customerref,
                Memo        = job.Job1 + " " + qbjob.QBJobName.Substring(0, qbjob.QBJobName.IndexOf(':'))
            };

            if (classref.FullName != null)
            {
                expenseline.ClassRef = classref;
            }

            ExpenseLineAdd[] expenseLines;

            if ((invoice.Discount ?? 0) != 0)  //Add an expense line for the discount amount if the discount is not zero
            {
                ExpenseLineAdd creditexpenseline = new ExpenseLineAdd
                {
                    AccountRef = creditaccountref,
                    Amount     = (0 - invoice.Discount ?? 0).ToString("F2"),
                    ClassRef   = classref,
                    Memo       = job.Job1 + " " + qbjob.QBJobName.Substring(0, qbjob.QBJobName.IndexOf(':'))
                };

                expenseLines    = new ExpenseLineAdd[2];
                expenseLines[0] = expenseline;
                expenseLines[1] = creditexpenseline;
            }
            else
            {
                expenseLines    = new ExpenseLineAdd[1];
                expenseLines[0] = expenseline;
            }

            VendorRef vendorref = new VendorRef
            {
                ListID = qbvendor.QBListID
            };

            var billadd = new BillAdd
            {
                DueDate        = invoice.PayDate?.ToString("yyyy-MM-dd"),
                Memo           = "From Apex",
                RefNumber      = invoice.Invoice,
                TermsRef       = termsref,
                TxnDate        = invoice.IvcDate?.ToString("yyyy-MM-dd"),
                ExpenseLineAdd = expenseLines,
                VendorRef      = vendorref
            };

            qbMsgsRq.Items = new object[1] {
                billaddrq
            };
            qbxml.Items = new object[1] {
                qbMsgsRq
            };
            billaddrq.BillAdd = billadd;

            XmlSerializer           serializer = new XmlSerializer(typeof(QBXML));
            XmlSerializerNamespaces ns         = new XmlSerializerNamespaces();

            ns.Add("", ""); //Don't use a namespace in the XML for QuickBooks
            MemoryStream ms = new MemoryStream();

            serializer.Serialize(ms, qbxml, ns);
            ms.Seek(0, SeekOrigin.Begin);
            var    sr         = new StreamReader(ms);
            string xmlRequest = sr.ReadToEnd();

            xmlRequest = xmlRequest.Replace("<?xml version=\"1.0\"?>", "<?xml version=\"1.0\"?><?qbxml version=\"4.0\"?>");
            if (DEBUGMODE)
            {
                File.WriteAllText("c:\\QB\\BillAddQBXML.xml", xmlRequest);
            }
            _Response = _Rp.ProcessRequest(_Ticket, xmlRequest);
            if (DEBUGMODE)
            {
                File.WriteAllText("c:\\QB\\BillAddResponse.xml", _Response);
            }

            QBXML  rsXML      = GetQbxml(serializer);
            string message    = ((BillAddRsType)((QBXMLMsgsRs)rsXML?.Items?[0])?.Items?[0]).statusMessage;
            string statuscode = ((BillAddRsType)((QBXMLMsgsRs)rsXML?.Items?[0])?.Items?[0]).statusCode;

            _StatusLines.Add(new StatusLine
            {
                Invoice    = invoice.Invoice,
                PO         = invoice.PO.Trim(),
                Message    = message,
                StatusCode = statuscode
            });

            if (statuscode == "0") //Apex's part is done now that the invoice has been successfully sent to QuickBooks to be paid
            {
                QBInvoice qbIvc = new QBInvoice
                {
                    Invoice  = invoice.Invoice,
                    PO       = invoice.PO,
                    SentDate = DateTime.Now
                };
                apexData.QBInvoices.InsertOnSubmit(qbIvc);

                invoice.IvcStatus = "P";
                apexData.SubmitChanges();
            }
        }