コード例 #1
0
ファイル: Creditnote.cs プロジェクト: sundowndk/Didius
        public static Creditnote Create(Invoice Invoice, bool Simulate)
        {
            List<CreditnoteLine> lines = new List<CreditnoteLine> ();

            //			Customer customer = Customer.Load (Invoice.CustomerId);

            foreach (InvoiceLine invoiceline1 in Invoice.Lines)
            {
                try
                {
                    Item item = Item.Load (invoiceline1.ItemId);
                    Bid bid = Bid.Load (item.CurrentBidId);
                    List<Invoice> invoices = Invoice.List (item);
                    invoices.Sort (delegate (Invoice i1, Invoice i2) { return i1.No.CompareTo (i2.No);});
                    invoices.Reverse ();

                    if (bid.CustomerId == Invoice.CustomerId)
                    {
                        if (item.Invoiced)
                        {
                            bool ok = true;
                            foreach (Invoice invoice in invoices)
                            {
                                foreach (InvoiceLine invoiceline2 in invoice.Lines)
                                {
                                    if (invoiceline2.ItemId == invoiceline1.ItemId)
                                    {
                                        if (invoice.No > Invoice.No)
                                        {
                                            ok = false;
                                        }
                                    }
                                }
                            }

                            if (ok)
                            {
                                lines.Add (new CreditnoteLine (invoiceline1));
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    // LOG: LogDebug.ExceptionUnknown
                    SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.CREDITNOTE", exception.Message));
                }
            }

            return Create (Customer.Load (Invoice.CustomerId), lines, Simulate);
        }
コード例 #2
0
ファイル: Creditnote.cs プロジェクト: sundowndk/Didius
 public static Creditnote Create(Invoice Invoice)
 {
     return Create (Invoice, false);
 }
コード例 #3
0
ファイル: Invoice.cs プロジェクト: sundowndk/Didius
        public static Invoice Load(Guid Id)
        {
            Invoice result;

            //			try
            //			{
                Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (SorentoLib.Services.Datastore.Get<XmlDocument> (DatastoreAisle, Id.ToString ()).SelectSingleNode ("(//didius.invoice)[1]")));
                result = new Invoice ();

                result._id = new Guid ((string)item["id"]);

                if (item.ContainsKey ("createtimestamp"))
                {
                    result._createtimestamp = int.Parse ((string)item["createtimestamp"]);
                }

                if (item.ContainsKey ("updatetimestamp"))
                {
                    result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]);
                }

                if (item.ContainsKey ("no"))
                {
                    result._no = int.Parse ((string)item["no"]);
                }

                if (item.ContainsKey ("auctionids"))
                {
                    result._auctionids = SNDK.Convert.StringToList<Guid> ((string)item["auctionids"]);
                }

                if (item.ContainsKey ("customerid"))
                {
                    result._customerid = new Guid ((string)item["customerid"]);
                }

                if (item.ContainsKey ("lines"))
                {
                    foreach (XmlDocument invoiceline in (List<XmlDocument>)item["lines"])
                    {
                        result._lines.Add (InvoiceLine.FromXmlDocument (invoiceline));
                    }
                }
            //			}
            //			catch (Exception exception)
            //			{
                // LOG: LogDebug.ExceptionUnknown
            //				SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.INVOICE", exception.Message));

                // EXCEPTION: Excpetion.InvoiceLoadGuid
            //				throw new Exception (string.Format (Strings.Exception.InvoiceLoadGuid, Id, exception.Message));
            //			}

            return result;
        }
コード例 #4
0
ファイル: Helpers.cs プロジェクト: sundowndk/Didius
        public static void MailInvoice(Invoice Invoice, string PdfFilename)
        {
            Customer customer = Customer.Load (Invoice.CustomerId);

            string _from = SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender);

            string to = customer.Email;
            //			string to = "*****@*****.**";

            string subject = SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_template_invoice_subject);
            subject = ReplacePlaceholders (customer, subject);
            subject = ReplacePlaceholders (Invoice, subject);

            string body = SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_template_invoice_body);
            body = ReplacePlaceholders (customer, body);
            body = ReplacePlaceholders (Invoice, body);

            bool isbodyhtml = SorentoLib.Services.Settings.Get<bool> (Enums.SettingsKey.didius_email_template_invoice_isbodyhtml);

            List<SorentoLib.Tools.Helpers.SendMailAttatchment> attatchments = new List<SorentoLib.Tools.Helpers.SendMailAttatchment> ();
            attatchments.Add (new SorentoLib.Tools.Helpers.SendMailAttatchment (SNDK.IO.FileToByteArray (PdfFilename), "faktura"+ Invoice.No +".pdf", SNDK.IO.GetMimeType (PdfFilename)));

            SorentoLib.Tools.Helpers.SendMail (_from, to, subject, body, isbodyhtml, attatchments);
        }
コード例 #5
0
ファイル: Invoice.cs プロジェクト: sundowndk/Didius
        public static Invoice Create(Auction Auction, Customer Customer, bool Simulate)
        {
            Invoice result = new Invoice (Customer);

            List<Item> items;

            if (Auction != null)
            {
                items = Item.List (Auction);
            }
            else
            {
                items = Item.List ();
            }

            foreach (Item item in items)
            {
                if (item.AppovedForInvoice)
                {
                    if (!item.Invoiced)
                    {
                        if (item.CurrentBid != null)
                        {
                            if (item.CurrentBid.CustomerId == Customer.Id)
                            {
                                Case _case = Case.Load (item.CaseId);
                                result._auctionids.Add (_case.AuctionId);

                                result.Lines.Add (new InvoiceLine (item));
                            }
                        }
                    }
                }
            }

            if (result.Lines.Count == 0)
            {
                // EXCEPTION: Exception.InvoiceEmpty
                throw new Exception (string.Format (Strings.Exception.InvoiceEmpty));
            }

            if (!Simulate)
            {
                foreach (InvoiceLine line in result.Lines)
                {
                    Item item = Item.Load (line.ItemId);
                    item.Invoiced = true;
                    item.Save ();
                }

                result.Save ();
            }

            return result;
        }