Ejemplo n.º 1
0
        /// <summary>
        /// search一览
        /// </summary>
        /// <param name="param"></param>
        /// <param name="IType"></param>
        /// <param name="itemCount"></param>
        /// <returns></returns>
        public List <object> Search(EasyUIGridParamModel param, InvoiceType IType, out int itemCount)
        {
            List <object> list   = new List <object>();
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from T_InvoiceType where 1=1");
            Dictionary <string, object> paramList = new Dictionary <string, object>();

            if (IType != null)
            {
                if (!string.IsNullOrEmpty(IType.ID))
                {
                    strSql.Append(" and ID=@ID ");
                    paramList.Add("ID", IType.ID);
                }
                if (!string.IsNullOrEmpty(IType.Name))
                {
                    strSql.Append(" and Standard=@Standard ");
                    paramList.Add("Standard", IType.Standard);
                }
            }
            using (DBHelper db = DBHelper.Create())
            {
                int pageIndex = Convert.ToInt32(param.page) - 1;
                int pageSize  = Convert.ToInt32(param.rows);
                itemCount = db.GetCount(string.Format(DBHelper.StrGetCountSql, strSql.ToString()), paramList);
                list      = db.GetDynaminObjectList(strSql.ToString(), pageIndex, pageSize, "ID", paramList);
            }
            return(list);
        }
Ejemplo n.º 2
0
        public void description_only_items_work()
        {
            const InvoiceType expected = InvoiceType.AccountsPayable;
            var type = Given_a_description_only_invoice().Type;

            Assert.AreEqual(expected, type);
        }
Ejemplo n.º 3
0
        void LlenarMontosIGV(En_ComprobanteElectronico Comprobante, ref InvoiceType invoice)
        {
            List <TaxSubtotalType> oListaSubtotal = new List <TaxSubtotalType>();

            if (Comprobante.MontoTotales != null)
            {
                if (Comprobante.MontoTotales.Gravado != null)
                {
                    if (Comprobante.MontoTotales.Gravado.GravadoIGV != null)
                    {
                        TaxSubtotalType oTotalGravado = LlenarSubTotalCabecera(Comprobante.MontoTotales.Gravado.GravadoIGV.MontoBase, Comprobante.MontoTotales.Gravado.GravadoIGV.MontoTotalImpuesto, Comprobante.Moneda, Comprobante.MontoTotales.Gravado.GravadoIGV.Porcentaje, "1000", "IGV", "VAT");
                        oListaSubtotal.Add(oTotalGravado);
                    }
                }
            }


            TaxTotalType oTaxTotal = new TaxTotalType
            {
                TaxAmount = new TaxAmountType
                {
                    Value      = Comprobante.TotalImpuesto,
                    currencyID = Comprobante.Moneda
                },
                TaxSubtotal = oListaSubtotal.ToArray()
            };

            invoice.TaxTotal = new TaxTotalType[] { oTaxTotal };
        }
Ejemplo n.º 4
0
        private DataTable FnTablaDetalle(InvoiceType ocomprobante)
        {
            DataTable dtDetalle = new DataTable();

            dtDetalle.Columns.Add(new DataColumn("Item", typeof(string)));
            dtDetalle.Columns.Add(new DataColumn("Descripcion", typeof(string)));
            dtDetalle.Columns.Add(new DataColumn("UM", typeof(string)));
            dtDetalle.Columns.Add(new DataColumn("VU", typeof(string)));
            dtDetalle.Columns.Add(new DataColumn("PU", typeof(string)));
            dtDetalle.Columns.Add(new DataColumn("Cantidad", typeof(string)));
            dtDetalle.Columns.Add(new DataColumn("ImporteSinIGV", typeof(string)));

            DataRow fila;

            fila = dtDetalle.NewRow();

            if (ocomprobante.InvoiceLine != null)
            {
                foreach (InvoiceLineType detalle in ocomprobante.InvoiceLine)
                {
                    fila["Item"]          = FnValidarNulo(detalle.ID.Value.ToString());
                    fila["Descripcion"]   = FnValidarNulo(detalle.Item.Description[0].Value.ToString());
                    fila["UM"]            = "UND";
                    fila["VU"]            = FnValidarNulo(detalle.PricingReference.AlternativeConditionPrice[0].PriceAmount.Value.ToString());
                    fila["PU"]            = FnValidarNulo(detalle.PricingReference.AlternativeConditionPrice[0].PriceAmount.Value.ToString());
                    fila["Cantidad"]      = FnValidarNulo(detalle.InvoicedQuantity.Value.ToString());
                    fila["ImporteSinIGV"] = FnValidarNulo(detalle.LineExtensionAmount.Value.ToString());
                }
            }

            dtDetalle.Rows.Add(fila);

            return(dtDetalle);
        }
Ejemplo n.º 5
0
        protected virtual InvoiceType GetInvoiceTypeFromReader(IDataReader reader)
        {
            EntityConverter <InvoiceType> invoiceTypeEntity = new EntityConverter <InvoiceType>();
            InvoiceType invoiceType = invoiceTypeEntity.Convert(reader);

            return(invoiceType);
        }
Ejemplo n.º 6
0
        public void accounts_receivable()
        {
            const InvoiceType expected = InvoiceType.AccountsReceivable;
            var type = Given_a_description_only_invoice(expected).Type;

            Assert.AreEqual(expected, type);
        }
Ejemplo n.º 7
0
        private DataTable FnTablaReceptor(InvoiceType ocomprobante)
        {
            DataTable dtReceptor = new DataTable();

            dtReceptor.Columns.Add(new DataColumn("RucReceptor", typeof(string)));
            dtReceptor.Columns.Add(new DataColumn("RazonSocialReceptor", typeof(string)));
            dtReceptor.Columns.Add(new DataColumn("NombreComercialReceptor", typeof(string)));
            dtReceptor.Columns.Add(new DataColumn("DepartamentoReceptor", typeof(string)));
            dtReceptor.Columns.Add(new DataColumn("ProvinciaReceptor", typeof(string)));
            dtReceptor.Columns.Add(new DataColumn("DistritoReceptor", typeof(string)));
            dtReceptor.Columns.Add(new DataColumn("DireccionReceptor", typeof(string)));

            DataRow fila;

            fila = dtReceptor.NewRow();

            if (ocomprobante.AccountingCustomerParty != null)
            {
                fila["RucReceptor"]             = FnValidarNulo(ocomprobante.AccountingCustomerParty.Party.PartyIdentification[0].ID.Value.ToString());
                fila["RazonSocialReceptor"]     = FnValidarNulo(ocomprobante.AccountingCustomerParty.Party.PartyLegalEntity[0].RegistrationName.Value.ToString());
                fila["NombreComercialReceptor"] = FnValidarNulo(ocomprobante.AccountingCustomerParty.Party.PartyName[0].Name.Value.ToString());
                fila["DepartamentoReceptor"]    = FnValidarNulo(ocomprobante.AccountingCustomerParty.Party.PartyLegalEntity[0].RegistrationAddress.CountrySubentity.Value.ToString());
                fila["ProvinciaReceptor"]       = FnValidarNulo(ocomprobante.AccountingCustomerParty.Party.PartyLegalEntity[0].RegistrationAddress.CityName.Value.ToString());
                fila["DistritoReceptor"]        = FnValidarNulo(ocomprobante.AccountingCustomerParty.Party.PartyLegalEntity[0].RegistrationAddress.District.Value.ToString());
                fila["DireccionReceptor"]       = FnValidarNulo(ocomprobante.AccountingCustomerParty.Party.PartyLegalEntity[0].RegistrationAddress.AddressLine[0].Line.Value.ToString());
            }

            dtReceptor.Rows.Add(fila);

            return(dtReceptor);
        }
Ejemplo n.º 8
0
        public Aisino.FTaxBase.PZSQType this[InvoiceType invoiceType_0]
        {
            get
            {
                Aisino.FTaxBase.PZSQType type = null;
                if (this.PZSQType.Count > 0)
                {
                    using (List <Aisino.FTaxBase.PZSQType> .Enumerator enumerator = this.PZSQType.GetEnumerator())
                    {
                        Aisino.FTaxBase.PZSQType current;
                        while (enumerator.MoveNext())
                        {
                            current = enumerator.Current;
                            if (current.invType == invoiceType_0)
                            {
                                goto Label_003D;
                            }
                        }
                        return(type);

Label_003D:
                        type = current;
                    }
                }
                return(type);
            }
        }
        private async Task <Invoice> Given_an_invoice(InvoiceType type = InvoiceType.AccountsPayable, InvoiceStatus status = InvoiceStatus.Authorised, decimal amount = 100m, string accountCode = "100", Contact contact = null)
        {
            if (contact == null)
            {
                contact = new Contact {
                    Name = "ABC Bank"
                }
            }
            ;

            return(await Api.CreateAsync(new Invoice
            {
                Contact = contact,
                Type = type,
                Date = DateTime.UtcNow,
                DueDate = DateTime.UtcNow.AddDays(90),
                LineAmountTypes = LineAmountType.Inclusive,
                Status = status,
                LineItems = new List <LineItem>
                {
                    new LineItem
                    {
                        AccountCode = "200",
                        Description = "Good value item 1",
                        LineAmount = 100m
                    },
                    new LineItem
                    {
                        AccountCode = "200",
                        Description = "Good value item 2",
                        LineAmount = 100m
                    }
                }
            }));
        }
 public EFinansSendEInvoice(
     InvoiceType invoiceType = null,
     IMapper mapper          = null)
 {
     this.IMapper = mapper;
     this.Invoice = invoiceType;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <InvoiceType> GetList(InvoiceType IType)
        {
            List <InvoiceType>          list        = new List <InvoiceType>();
            StringBuilder               strWhereSql = new StringBuilder();
            Dictionary <string, object> paramList   = new Dictionary <string, object>();

            if (IType != null)
            {
                if (!string.IsNullOrEmpty(IType.ID))
                {
                    strWhereSql.Append(" and ID=@ID ");
                    paramList.Add("ID", IType.ID);
                }
                if (!string.IsNullOrEmpty(IType.Name))
                {
                    strWhereSql.Append(" and Standard=@Standard ");
                    paramList.Add("Standard", IType.Standard);
                }
            }
            using (DBHelper db = DBHelper.Create())
            {
                list = db.GetList <InvoiceType>(strWhereSql.ToString(), paramList, "ID", "");
            }
            return(list);
        }
Ejemplo n.º 12
0
        private void GridDoldur(InvoiceType invocice)
        {
            dataGridView1.Rows.Clear();

            if ((invoice != null) && (invoice.InvoiceLine != null))
            {
                dataGridView1.Visible = false;
                dataGridView1.Rows.Clear();
                foreach (var item in invoice.InvoiceLine)
                {
                    var row = new DataGridViewRow();
                    row.CreateCells(dataGridView1);
                    row.Cells[0].Value = item.Item.Name.Value;                  //Aciklama
                    row.Cells[1].Value = item.InvoicedQuantity.Value;           //Miktar
                    row.Cells[2].Value = item.Price.PriceAmount.Value;          //Birim Fiyat
                    row.Cells[3].Value = GetIskontoOran(item.AllowanceCharge);  //Iskonto Oran
                    row.Cells[4].Value = GetIskontoTutar(item.AllowanceCharge); //Iskonto Tutar
                    row.Cells[5].Value = GetKdvOran(item.TaxTotal);             //KDV Oran
                    row.Cells[6].Value = GetKdvTutar(item.TaxTotal);            //KDV Tutar
                    row.Cells[7].Value = item.LineExtensionAmount.Value;        //Mal Hizmet Tutarı

                    row.Tag = item;
                    dataGridView1.Rows.Add(row);
                }
                dataGridView1.Visible = true;
            }
        }
Ejemplo n.º 13
0
        public UserInvoiceDataInfo GetUserInvoiceDataInfoByTitle(string invoiceTitle, int userId)
        {
            Database database = base.database;

            object[] obj = new object[5]
            {
                "SELECT * FROM Hishop_UserInvoiceDatas WHERE InvoiceTitle = @InvoiceTitle AND UserId = @UserId AND (InvoiceType = ",
                null,
                null,
                null,
                null
            };
            InvoiceType invoiceType = InvoiceType.Enterprise;

            obj[1]      = invoiceType.GetHashCode();
            obj[2]      = " OR InvoiceType = ";
            invoiceType = InvoiceType.Enterprise_Electronic;
            obj[3]      = invoiceType.GetHashCode();
            obj[4]      = ") ORDER BY LastUseTime DESC,ID DESC";
            DbCommand sqlStringCommand = database.GetSqlStringCommand(string.Concat(obj));

            base.database.AddInParameter(sqlStringCommand, "InvoiceTitle", DbType.String, invoiceTitle);
            base.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, userId);
            using (IDataReader objReader = base.database.ExecuteReader(sqlStringCommand))
            {
                return(DataHelper.ReaderToModel <UserInvoiceDataInfo>(objReader));
            }
        }
Ejemplo n.º 14
0
        private IICType GetIICandIICSignature(RegisterInvoiceRequest invoiceRequest, X509Certificate2 certificate, string issuerTIN)
        {
            IICType iicType = null;

            if (invoiceRequest.Signature != null)
            {
                throw new Exception("Invoice already signed");
            }

            if (invoiceRequest != null && invoiceRequest.Invoice.IIC == null &&
                invoiceRequest.Invoice.IICSignature == null)
            {
                InvoiceType  invoice          = invoiceRequest.Invoice;
                IICGenerator iicTypeGenerator = new IICGenerator(certificate);

                IICConfig iicConfig = new IICConfig()
                {
                    IssuerTIN       = issuerTIN,
                    DateTimeCreated = invoice.IssueDateTime.ToString(Fiscalization.DATE_FORMAT_LONG),
                    InvoiceNumber   = invoice.InvNum,
                    BusinUnitCode   = invoice.BusinUnitCode,
                    TCRCode         = invoice.TCRCode,
                    SoftCode        = invoice.SoftCode,
                    TotalPrice      = invoice.TotPrice.ToString()
                };

                iicType = iicTypeGenerator.Generate(iicConfig);
            }

            return(iicType);
        }
Ejemplo n.º 15
0
        public static Invoice Create(InvoiceType type, Company party)
        {
            var invoice = Create(type);

            invoice.Company = party;
            return(invoice);
        }
Ejemplo n.º 16
0
        public static string writeDiscInvoiceConvertUblToXml(InvoiceType createdUBL, string invoiceType)
        {
            //olusturulan xmli diske kaydediyor
            string xmlPath = "";

            if (invoiceType == nameof(EI.Invoice.Invoices))
            {
                xmlPath = invoiceFolderDraftPath + createdUBL.ID.Value + "." + nameof(EI.DocumentType.XML);
            }
            else if (invoiceType == nameof(EI.Invoice.ArchiveInvoices))
            {
                xmlPath = archiveFolderPath + createdUBL.ID.Value + "." + nameof(EI.DocumentType.XML);
            }

            createInboxIfDoesNotExist(Path.GetDirectoryName(xmlPath)); //dosya yolu yoksa olustur

            using (FileStream stream = new FileStream(xmlPath, FileMode.Create))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(createdUBL.GetType());
                xmlSerializer.Serialize(stream, createdUBL, InvoiceSerializer.GetXmlSerializerNamespace());
            }
            return(xmlPath);
            ////
            ////xmli strıng durunde return edıyoruz contentını dondurmek ıcın  asagıdakı kodu acarız
            //using (StringWriter textWriter = new StringWriter())
            //{
            //    XmlSerializer xmlSerializer = new XmlSerializer(createdUBL.GetType());

            //    xmlSerializer.Serialize(textWriter, createdUBL, InvoiceSerializer.GetXmlSerializerNamespace());
            //    return textWriter.ToString();
            //}
        }
Ejemplo n.º 17
0
        //public static string GenerarXML(InvoiceType item)
        //{
        //    //byte[] xmlByte = null;

        //    XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

        //    ns.Add("", "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
        //    ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
        //    ns.Add("ds", "http://www.w3.org/2000/09/xmldsig#");
        //    ns.Add("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2");
        //    ns.Add("sac", "urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1");
        //    ns.Add("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2");
        //    ns.Add("udt", "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2");
        //    ns.Add("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2");
        //    ns.Add("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
        //    ns.Add("ccts", "urn:un:unece:uncefact:documentation:2");

        //    XmlSerializer nXmlSerializer = new XmlSerializer(typeof(InvoiceType));
        //    XmlWriter xtWriter;
        //    XmlWriterSettings setting = new XmlWriterSettings();
        //    setting.Indent = true;
        //    setting.IndentChars = "\t";
        //    StringBuilder xmlString = new StringBuilder();
        //    xtWriter = XmlWriter.Create(xmlString, setting);
        //    xtWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
        //    nXmlSerializer.Serialize(xtWriter, item, ns);
        //    xtWriter.Close();

        //    XmlDocument xmlDocument = new XmlDocument();
        //    xmlDocument.LoadXml(xmlString.ToString());
        //    XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xmlDocument.NameTable);
        //    xmlNamespaceManager.AddNamespace("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2");
        //    xmlNamespaceManager.AddNamespace("", "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");

        //    var xmlNode = xmlDocument.DocumentElement.SelectNodes("ext:UBLExtensions/ext:UBLExtension", xmlNamespaceManager);
        //    xmlNode[0].AppendChild(xmlDocument.CreateNode(XmlNodeType.Element, "ext", "ExtensionContent", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"));

        //    XDocument xDocument = XDocument.Parse(xmlDocument.OuterXml);

        //    return xDocument.ToString();
        //}

        public static string GenerarXML(InvoiceType item)
        {
            XmlSerializer           serializer = new XmlSerializer(typeof(InvoiceType));
            XmlSerializerNamespaces oxmlnames  = new XmlSerializerNamespaces();

            oxmlnames.Add("", "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
            oxmlnames.Add("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2");
            oxmlnames.Add("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
            oxmlnames.Add("ccts", "urn:un:unece:uncefact:documentation:2");
            oxmlnames.Add("ds", "http://www.w3.org/2000/09/xmldsig#");
            oxmlnames.Add("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2");
            oxmlnames.Add("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2");
            oxmlnames.Add("sac", "urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1");
            oxmlnames.Add("udt", "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2");
            oxmlnames.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");

            MemoryStream ms = new MemoryStream();

            serializer.Serialize(ms, item, oxmlnames);
            ms.Position = 0;

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.PreserveWhitespace = true;
            xmlDocument.Load(ms);

            //XmlNamespaceManager ns = new XmlNamespaceManager(xmlDocument.NameTable);
            //ns.AddNamespace("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");

            XmlDeclaration xmlDeclaration = xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null);

            xmlDocument.ReplaceChild(xmlDeclaration, xmlDocument.FirstChild);

            return(xmlDocument.OuterXml);
        }
Ejemplo n.º 18
0
        private Invoice Given_an_invoice(InvoiceType type = InvoiceType.AccountsPayable, InvoiceStatus status = InvoiceStatus.Authorised, decimal amount = 100m, string accountCode = "100", Contact contact = null)
        {
            if (contact == null)
                contact = new Contact {Name = "ABC Bank"};

            return Api.Create(new Invoice
            {
                Contact = contact,
                Type = type,
                Date = DateTime.UtcNow,
                DueDate = DateTime.UtcNow.AddDays(90),
                LineAmountTypes = LineAmountType.Inclusive,
                Status = status,
                LineItems = new List<LineItem>
                {
                    new LineItem
                    {
                        AccountCode = "200",
                        Description = "Good value item 1",
                        LineAmount = 100m
                    },
                    new LineItem
                    {
                        AccountCode = "200",
                        Description = "Good value item 2",
                        LineAmount = 100m
                    }
                }

            });
        }
Ejemplo n.º 19
0
 protected override object[] doService(object[] param)
 {
     object[] objArray = new object[] { false };
     if (param.Length == 1)
     {
         FPLX        fplx = Invoice.ParseFPLX(param[0].ToString());
         InvoiceType type = (InvoiceType)2;
         TaxCard     card = TaxCardFactory.CreateTaxCard();
         if (((int)fplx != 0x29) && ((int)fplx != 2))
         {
             return(objArray);
         }
         if ((int)fplx == 0x29)
         {
             type = (InvoiceType)0x29;
         }
         card.GetCurrentInvCode(type);
         if (card.RetCode != 0)
         {
             MessageManager.ShowMsgBox(card.ErrCode);
             objArray[0] = false;
             return(objArray);
         }
         if (new JSFPJSelect(fplx).ShowDialog() == DialogResult.OK)
         {
             objArray[0] = true;
         }
     }
     return(objArray);
 }
Ejemplo n.º 20
0
        public void ReadInvoiceBogusNode()
        {
            string      filename = "InvoiceBogusXml.xml";
            InvoiceType doc      = UblDoc <InvoiceType> .Create(filename);

            Assert.AreEqual(null, doc, "Should not be possible to read malformed xml");
        }
Ejemplo n.º 21
0
        public BaseInvoiceUBL(string profileId, string invoiceTypeCode)
        {
            baseInvoiceUBL = new InvoiceType();

            createInvoiceHeader(profileId, invoiceTypeCode);
            createSignature();
        }
Ejemplo n.º 22
0
 public Invoice(int id, DateTime creation, string note, Client client, List <InvoiceItem> items, List <InvoicePayment> payments,
                DateTime?invoiceDate, DateTime?dueDate, InvoiceType invoiceType, InvoiceStatus status)
     : this(note, client, items, payments, invoiceDate, dueDate, invoiceType, status)
 {
     Id           = id;
     CreationDate = creation;
 }
Ejemplo n.º 23
0
        private string GenerateDirectoryName(InvoiceType type, DateTime date)
        {
            var sb = new StringBuilder();

            sb.Append(destinationDirectory);

            sb.Append(date.Year);
            sb.Append("\\");
            sb.Append(date.Month);
            sb.Append(" - ");
            sb.Append(((Month)date.Month).GetDescription());
            sb.Append("\\");


            if (type == InvoiceType.Cost)
            {
                sb.Append("Faktury kosztowe");
            }
            else if (type == InvoiceType.Sale)
            {
                sb.Append("Faktury sprzedaży");
            }
            sb.Append("\\");

            return(sb.ToString());           //return type D:\Faktury\year\monthNumber - monthName\invoiceType\fileName.ext
        }
Ejemplo n.º 24
0
        public static Invoice CreateInvoiceFromBill(
            string number,
            string buyerId,
            string sellerId,
            DateTime issueDate,
            Bill bill,
            InvoiceType invoiceType               = InvoiceType.Purchase,
            InvoiceVariant invoiceVariant         = InvoiceVariant.Invoice,
            InvoicePaymentType invoicePaymentType = InvoicePaymentType.BankTransfer,
            int daysOfDelayedPayment              = 0)
        {
            var invoice = Invoice.Create(
                number,
                buyerId,
                sellerId,
                issueDate,
                invoiceType,
                invoiceVariant,
                invoicePaymentType,
                daysOfDelayedPayment);

            var invoiceItem = InvoiceItem.Create(
                1,
                bill.Amount,
                Item.Create(
                    string.Format("Bill from {0} for Project: {0}", bill.Date, bill.Project.Name), Мeasure.Pcs), invoice);

            bill.AttachInvoice(invoice.Id);

            return(invoice);
        }
Ejemplo n.º 25
0
        public Invoice(DateTime date, InvoiceType type, double amount)

        {
            this.Amount = amount;
            this.Type   = type;
            this.Date   = date;
        }
Ejemplo n.º 26
0
        } // !_writeOptionalContact()

        private string _translateInvoiceType(InvoiceType type)
        {
            switch (type)
            {
            case InvoiceType.SelfBilledInvoice:
            case InvoiceType.Invoice: return("RECHNUNG");

            case InvoiceType.SelfBilledCreditNote:
            case InvoiceType.CreditNote: return("GUTSCHRIFT");

            case InvoiceType.DebitNote: return("BELASTUNGSANZEIGE");

            case InvoiceType.DebitnoteRelatedToFinancialAdjustments: return("WERTBELASTUNG");

            case InvoiceType.PartialInvoice: return("TEILRECHNUNG");

            case InvoiceType.PrepaymentInvoice: return("VORAUSZAHLUNGSRECHNUNG");

            case InvoiceType.InvoiceInformation: return("KEINERECHNUNG");

            case InvoiceType.Correction:
            case InvoiceType.CorrectionOld: return("KORREKTURRECHNUNG");

            case InvoiceType.Unknown: return("");

            default: return("");
            }
        } // !_translateInvoiceType()
Ejemplo n.º 27
0
        /// <summary>
        /// 保存设置
        /// </summary>
        /// <param name="invoiceType">发票类型</param>
        /// <param name="dtSetting">设置数据</param>
        /// <returns></returns>
        public static bool SaveSetting(InvoiceType invoiceType, DataTable dtSetting)
        {
            try
            {
                System.Data.DataSet ds = GetInvoiceSettingConfig( );
                string invoiceName     = "门诊收费发票";
                if (invoiceType == InvoiceType.挂号发票)
                {
                    invoiceName = "门诊挂号发票";
                }
                DataRow[] drs = ds.Tables["INVOICE_ITEMS"].Select("INVOICE_NAME='" + invoiceName + "'");
                foreach (DataRow dr in drs)
                {
                    ds.Tables["INVOICE_ITEMS"].Rows.Remove(dr);
                }
                foreach (DataRow dr in dtSetting.Rows)
                {
                    ds.Tables["INVOICE_ITEMS"].Rows.Add(dr.ItemArray);
                }

                ds.WriteXml(configFilePath);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        } // !_translateInvoiceType()

        private int _encodeInvoiceType(InvoiceType type)
        {
            if ((int)type > 1000)
            {
                type -= 1000;
            }

            // only these types are allowed
            // 84: 'Wertbelastung/Wertrechnung ohne Warenbezug'
            // 380: 'Handelsrechnung (Rechnung für Waren und Dienstleistungen)'
            // 389: 'Selbst ausgestellte Rechnung (Steuerrechtliche Gutschrift/Gutschriftsverfahren)'
            //
            // this is documented in ZUGFeRD-Format_1p0_c1p0_Codelisten.pdf
            // all other types are mapped accordingly
            switch (type)
            {
            case InvoiceType.SelfBilledInvoice: return((int)InvoiceType.SelfBilledInvoice);

            case InvoiceType.DebitnoteRelatedToFinancialAdjustments: return((int)InvoiceType.DebitnoteRelatedToFinancialAdjustments);

            case InvoiceType.Unknown: return((int)InvoiceType.Unknown);

            default: return((int)InvoiceType.Invoice);
            }
        } // !_translateInvoiceType()
Ejemplo n.º 29
0
        public void insertDraftInvoice(InvoiceType invoiceUbl, string xmlPath)
        {
            using (DatabaseContext dbContext = new DatabaseContext())
            {
                Invoices draftCreatedInv = new Invoices();

                draftCreatedInv.ID          = invoiceUbl.ID.Value;
                draftCreatedInv.uuid        = invoiceUbl.UUID.Value;
                draftCreatedInv.direction   = EI.Direction.DRAFT.ToString();
                draftCreatedInv.draftFlag   = EI.ActiveOrPasive.N.ToString(); //load ınv yapmadıklarımız flag N
                draftCreatedInv.cDate       = invoiceUbl.IssueDate.Value;
                draftCreatedInv.profileId   = invoiceUbl.ProfileID.Value;
                draftCreatedInv.invoiceType = invoiceUbl.InvoiceTypeCode.Value;
                draftCreatedInv.suplier     = invoiceUbl.AccountingSupplierParty.Party.PartyName.Name.Value;
                draftCreatedInv.receiverVkn = invoiceUbl.AccountingCustomerParty.Party.PartyIdentification.First().ID.Value;
                draftCreatedInv.senderVkn   = invoiceUbl.AccountingSupplierParty.Party.PartyIdentification.First().ID.Value; //sıfırıncı ındexde tc ya da vkn tutuluyor
                draftCreatedInv.status      = "";                                                                            //simdilik bos deger atıyoruz load ınv yaparken guncellenecektır
                draftCreatedInv.stateNote   = nameof(EI.StateNote.CREATED);
                draftCreatedInv.draftFlag   = nameof(EI.ActiveOrPasive.N);                                                   //bizim olusturdugumuz fatura flag N
                draftCreatedInv.folderPath  = xmlPath;

                dbContext.invoices.Add(draftCreatedInv);
                dbContext.SaveChanges();
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Pairs cash voucher with unpaid invoice.
        /// </summary>
        /// <param name="cashVoucherId">Id of cash voucher.</param>
        /// <param name="invoiceType">Invoice type.</param>
        /// <param name="invoiceId">Id of invoice.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns><see cref="ApiResult{TData}"/> instance containing <c>true</c> if pairing was successful, otherwise <c>false</c>.</returns>
        public Task <ApiResult <bool> > PairAsync(int cashVoucherId, InvoiceType invoiceType, int invoiceId, CancellationToken cancellationToken = default)
        {
            var resource = $"{ResourceUrl}/Pair/{cashVoucherId}/{invoiceType}/{invoiceId}";
            var request  = CreateRequest(resource, Method.POST);

            return(ExecuteAsync <bool>(request, cancellationToken));
        }
Ejemplo n.º 31
0
        } // !_translateInvoiceType()

        private int _encodeInvoiceType(InvoiceType type)
        {
            if ((int)type > 1000)
            {
                type -= 1000;
            }

            // only these types are allowed
            // 84: 'Wertbelastung/Wertrechnung ohne Warenbezug'
            // 380: 'Handelsrechnung (Rechnung für Waren und Dienstleistungen)'
            // 389: 'Selbst ausgestellte Rechnung (Steuerrechtliche Gutschrift/Gutschriftsverfahren)'
            switch (type)
            {
            case InvoiceType.Correction: return((int)InvoiceType.Invoice);

            case InvoiceType.CreditNote: return((int)InvoiceType.Invoice);

            case InvoiceType.DebitNote: return((int)InvoiceType.Invoice);

            case InvoiceType.Invoice: return((int)InvoiceType.Invoice);

            case InvoiceType.SelfBilledInvoice: return((int)InvoiceType.SelfBilledInvoice);

            default: return((int)InvoiceType.Unknown);
            }
        } // !_translateInvoiceType()
Ejemplo n.º 32
0
 public Task<Invoice> Given_a_description_only_invoice(InvoiceType type = InvoiceType.AccountsPayable)
 {
     return Api.CreateAsync(new Invoice
     {
         Contact = new Contact { Name = "Richard" },
         Type = type,
         LineItems = new List<LineItem>
         {
             new LineItem
             {
                 Description = "This is description only",
                 LineAmount = 100m
             }
         }
     });
 }
Ejemplo n.º 33
0
 public Invoice Given_a_description_only_invoice(InvoiceType type)
 {
     return Api.Create(new Invoice
     {
         Contact = new Contact { Name = "Richard" },
         Type = type,
         Items = new List<LineItem>
         {
             new LineItem
             {
                 Description = "This is description only",
                 LineAmount = 23.6m
             }
         }
     });
 }
Ejemplo n.º 34
0
 private IEnumerable<Invoice> Given_a_bad_invoice(InvoiceType type = InvoiceType.AccountsPayable, InvoiceStatus status = InvoiceStatus.Draft, bool summariseErrors = true)
 {
     Api.Invoices.SummarizeErrors(summariseErrors);
     return Api.Create(new[]
     {
         new Invoice
         {
             Contact = new Contact {Name = "ABC Bank"},
             Type = type,
             Date = DateTime.UtcNow,
             DueDate = DateTime.UtcNow.AddDays(90),
             LineAmountTypes = LineAmountType.Inclusive,
             Status = status,
             Items = new List<LineItem>
             {
                 new LineItem
                 {
                     AccountCode = "200",
                     Description = "Good value item",
                     LineAmount = 100m
                 }
             }
         },
         new Invoice
         {
             Contact = new Contact
             {
                 Name = "ABC Bank",
                 EmailAddress = "this_is_!_valid"
             },
             Type = type,
             Date = DateTime.UtcNow,
             DueDate = DateTime.UtcNow.AddDays(90),
             LineAmountTypes = LineAmountType.Inclusive,
             Status = status,
             Items = new List<LineItem>
             {
                 new LineItem
                 {
                     AccountCode = "200",
                     Description = "Good value item",
                     LineAmount = 100m
                 }
             }
         }
     });
 }
Ejemplo n.º 35
0
        public async Task<IActionResult> SendToCustomer(int? customerId, InvoiceType? invoiceType, int? quotationTypeId, int? companyId, int? lateDays)
        {
            try
            {
                var data = await _invoiceManager.GetLateInvoices(customerId, invoiceType, quotationTypeId, companyId, lateDays);
                var body = await new HtmlEngineFactory(_httpContextAccessor, _viewEngine, _tempDataProvider, _hostingEnvironment).GetHtml("viewLateInvoices.cshtml", data);
                var customerData = data.FirstOrDefault();
                if (customerData != null)
                {
                    var email = customerData.Customer.Email;
                    var ccEmails = _dbContext.CustomerPropertyNames.Where(c => c.CustomerId == customerData.Customer.Id && customerData.Invoices.Any(i => i.PropertyName.Id == c.PropertyNameId && !string.IsNullOrEmpty(c.CustomerAdminstratorEmail))).Select(c => c.CustomerAdminstratorEmail).Distinct().ToArray();

                    await NotificationManager.SendAsync(email, ccEmails, "Relevé factures", body);
                }
                return new ObjectResult(Infrastructure.ActionResult.Success());
            }
            catch(Exception ex)
            {
                return HttpBadRequest(Infrastructure.ActionResult.Failed(ex.Message));
            }
        }
        public Invoice CreateInvoice(InvoiceType type)
        {
            Invoice invoice = null;

            switch (type)
            {
                case (InvoiceType.Job):
                    invoice = new InvoiceJob();
                    break;
                case (InvoiceType.Mail):
                    invoice = new InvoiceMail();
                    break;
                case (InvoiceType.FG):
                    invoice = new InvoiceFg();
                    break;
                case (InvoiceType.PE):
                    invoice = new InvoicePe();
                    break;
            }

            return invoice;
        }
Ejemplo n.º 37
0
        public Invoice Given_an_invoice(InvoiceType type = InvoiceType.AccountsPayable, InvoiceStatus status = InvoiceStatus.Draft)
        {
            return Api.Create(new Invoice
            {
                Contact = new Contact { Name = "ABC Bank" },
                Type = type,
                Date = DateTime.UtcNow,
                DueDate = DateTime.UtcNow.AddDays(90),
                LineAmountTypes = LineAmountType.Inclusive,
                Status = status,
                Items = new List<LineItem>
                {
                    new LineItem
                    {
                        AccountCode = "200",
                        Description = "Good value item",
                        LineAmount = 100m
                    }
                }

            });
        }
        public void Given_approved_invoice_with_tracking_option(InvoiceType type = InvoiceType.AccountsPayable, InvoiceStatus status = InvoiceStatus.Draft)
        {
            Guid category = category1_.Id;
            string name = category1_.Name;
            string option = category1_.Options.FirstOrDefault().Name;

            var inv = Api.Create(new Invoice
            {
                Contact = new Contact { Name = "Wayne Enterprises" },
                Type = type,
                Date = DateTime.UtcNow,
                DueDate = DateTime.UtcNow.AddDays(90),
                LineAmountTypes = LineAmountType.Inclusive,
                Status = status,
                Items = new List<LineItem>
                {
                    new LineItem
                    {
                        AccountCode = "200",
                        Description = "Good value item",
                        LineAmount = 100m,
                        Tracking = new ItemTracking
                            {
                                new ItemTrackingCategory
                                {
                                    Id = category,
                                    Name = name,
                                    Option = option
                                }
                            }
                    }
                }

            });

            inv.Status = InvoiceStatus.Authorised;
            invoice_ = Api.Update(inv);
        }
Ejemplo n.º 39
0
 public Invoice(DateTime date, InvoiceType type, double amount)
 {
     Amount = amount;
     Type = type;
     Date = date;
 }
Ejemplo n.º 40
0
 /// <summary>
 ///     设置发票
 /// </summary>
 /// <param name="invoiceId">发票Id</param>
 /// <param name="invoiceNumber">发票编号</param>
 /// <param name="invoiceType">发票类型</param>
 public void SetInvoice(int invoiceId, string invoiceNumber, InvoiceType invoiceType)
 {
     InvoiceId = invoiceId;
     InvoiceNumber = invoiceNumber;
     InvoiceType = invoiceType;
 }
        public Invoice GenerateInvoice(InvoiceType type)
        {
            Invoice invoice = _factory.CreateInvoice(type);

            return invoice;
        }
    // # CreateAndSendInvoice API Operation 
    // Use the CreateAndSendInvoice API operation to create and send an invoice.   
    public CreateAndSendInvoiceResponse CreateAndSendInvoiceAPIOperation()
    {
        // Create the CreateAndSendInvoiceResponse object
        CreateAndSendInvoiceResponse responseCreateAndSendInvoice = new CreateAndSendInvoiceResponse();

        try
        {
            // # CreateAndSendInvoiceRequest
            // Use the CreateAndSendInvoiceRequest message to create and send a new
            // invoice. The requester should authenticate the caller and verify that
            // the merchant requesting the invoice has an existing PayPal account in
            // good standing. Once the invoice is created, PayPal sends it to the
            // specified payer, who is notified of the pending invoice.

            // The code for the language in which errors are returned, which must be
            // en_US.
            RequestEnvelope envelopeRequest = new RequestEnvelope();
            envelopeRequest.errorLanguage = "en_US";

            List<InvoiceItemType> invoiceItemList = new List<InvoiceItemType>();

            // InvoiceItemType which takes mandatory params:
            // 
            // * `Item Name` - SKU or name of the item.
            // * `Quantity` - Item count.
            // * `Amount` - Price of the item, in the currency specified by the
            // invoice.
            InvoiceItemType invoiceItem = new InvoiceItemType("Item", Convert.ToDecimal("2"), Convert.ToDecimal("4.00"));
            invoiceItemList.Add(invoiceItem);

            // Invoice item.
            InvoiceItemListType itemList = new InvoiceItemListType(invoiceItemList);

            // InvoiceType which takes mandatory params:
            // 
            // * `Merchant Email` - Merchant email address.
            // * `Personal Email` - Payer email address.
            // * `InvoiceItemList` - List of items included in this invoice.
            // * `CurrencyCode` - Currency used for all invoice item amounts and
            // totals.
            // * `PaymentTerms` - Terms by which the invoice payment is due. It is
            // one of the following values:
            //  * DueOnReceipt - Payment is due when the payer receives the invoice.
            //  * DueOnDateSpecified - Payment is due on the date specified in the
            //  invoice.
            //  * Net10 - Payment is due 10 days from the invoice date.
            //  * Net15 - Payment is due 15 days from the invoice date.
            //  * Net30 - Payment is due 30 days from the invoice date.
            //  * Net45 - Payment is due 45 days from the invoice date.
            InvoiceType invoice = new InvoiceType("*****@*****.**", "*****@*****.**", itemList, "USD", PaymentTermsType.DUEONRECEIPT);

            // CreateAndSendInvoiceRequest which takes mandatory params:
            // 
            // * `Request Envelope` - Information common to each API operation, such
            // as the language in which an error message is returned.
            // * `Invoice` - Merchant, payer, and invoice information.
            CreateAndSendInvoiceRequest requestCreateAndSendInvoice = new CreateAndSendInvoiceRequest(envelopeRequest, invoice);

            // Create the service wrapper object to make the API call
            InvoiceService service = new InvoiceService();

            // # API call 
            // Invoke the CreateAndSendInvoice method in service
            responseCreateAndSendInvoice = service.CreateAndSendInvoice(requestCreateAndSendInvoice);

            if (responseCreateAndSendInvoice != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "CreateAndSendInvoice API Operation - ";
                acknowledgement += responseCreateAndSendInvoice.responseEnvelope.ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseCreateAndSendInvoice.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // ID of the created invoice.
                    logger.Info("Invoice ID : " + responseCreateAndSendInvoice.invoiceID + "\n");
                    Console.WriteLine("Invoice ID : " + responseCreateAndSendInvoice.invoiceID + "\n");
                }
                // # Error Values			
                else
                {
                    List<ErrorData> errorMessages = responseCreateAndSendInvoice.error;
                    foreach (ErrorData error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.message + "\n");
                        Console.WriteLine("API Error Message : " + error.message + "\n");
                    }
                }
            }
        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseCreateAndSendInvoice;
    }
Ejemplo n.º 43
0
 public Invoice Given_an_authorised_invoice(InvoiceType type = InvoiceType.AccountsPayable)
 {
     return Given_an_invoice(type, InvoiceStatus.Authorised);
 }
Ejemplo n.º 44
0
 public Invoice(InvoiceType invoiceType)
 {
     InvoiceType = invoiceType;
     LineItems = new List<LineItem>();
 }
Ejemplo n.º 45
0
 public async Task<Infrastructure.ActionResult> DeleteAsync(string projectId, InvoiceType invoiceType)
 {
     try
     {
         _dbContext.ProjectInvoices.RemoveRange(_dbContext.ProjectInvoices.Where(i => i.ProjectId == projectId && i.Type == invoiceType));
         _dbContext.SaveChanges();
         return Infrastructure.ActionResult.Success();
     }
     catch (Exception ex)
     {
         return Infrastructure.ActionResult.Failed(ex);
     }
 }
Ejemplo n.º 46
0
        public async Task<IEnumerable<GrouppedInvoice>> GetLateInvoices(int? customerId, InvoiceType? invoiceType, int? quotationTypeId, int? companyId, int? lateDays)
        {
            var invoices = await (from i in _dbContext.LateInvoicesStatementView
                                    join c in _dbContext.Customers on i.CustomerId equals c.Id into c1
                                    from cust in c1.DefaultIfEmpty()
                                    join p in _dbContext.PropertyNames on i.PropertyNameId equals p.Id into p1
                                    from prop in p1.DefaultIfEmpty()
                                  where (!customerId.HasValue || i.CustomerId == customerId) &&
                                        (!invoiceType.HasValue || i.InvoiceType == invoiceType) &&
                                        (!quotationTypeId.HasValue || i.QuotationTypeId == quotationTypeId) &&
                                        (!companyId.HasValue || i.CompanyId == companyId) &&
                                        i.Status != InvoiceStatus.Paid &&
                                        i.LateDays >= (lateDays ?? 0)
                                  select new GrouppedInvoice.Invoice
                                  {
                                      CustomerId = i.CustomerId,
                                      CustomerName = i.CustomerName,
                                      Customer = cust,
                                      Id = i.Id,
                                      InvoiceAmount = i.InvoiceAmount,
                                      InvoiceDate = i.InvoiceDate,
                                      InvoiceNumber = i.InvoiceNumber,
                                      InvoiceType = i.InvoiceType,
                                      LateDays = i.LateDays,
                                      PropertyName = prop,
                                      QuotationNumber = i.QuotationNumber,
                                      Status = i.Status,
                                      QuotationPurpose = i.QuotationPurpose,
                                      PartialPaymentsSum = i.PartialPaymentsSum,
                                      LeftToPay = i.LeftToPay
                                  })
                      .ToListAsync();

            List<GrouppedInvoice> result = new List<GrouppedInvoice>();
            foreach (var invoice in invoices)
            {
                var item = result.FirstOrDefault(r => r.Customer.Id == invoice.CustomerId);
                if (item != null)
                {
                    item.Total += invoice.InvoiceAmount;
                    item.LeftToPayTotal += invoice.LeftToPay;
                    item.Invoices.Add(invoice);
                }
                else
                {
                    result.Add(
                        new GrouppedInvoice
                        {
                            Customer = invoice.Customer,
                            Total = invoice.InvoiceAmount,
                            LeftToPayTotal = invoice.LeftToPay,
                            Invoices = new List<GrouppedInvoice.Invoice> { invoice }
                        });
                }
            }
            return result;
        }
Ejemplo n.º 47
0
 public Invoice Given_an_draft_invoice(InvoiceType type = InvoiceType.AccountsPayable)
 {
     return Given_an_invoice(type);
 }
Ejemplo n.º 48
0
 public Invoice(DateTime date, InvoiceType type, double amount)
 {
     this.Amount = amount;
     this.Type = type;
     this.Date = date;
 }
Ejemplo n.º 49
0
 public InvoiceCreator(InvoiceType typeOfInvoice)
     : base(typeOfInvoice)
 {
 }
Ejemplo n.º 50
0
 /// <summary>
 /// 设置发票类型
 /// </summary>
 /// <param name="invoiceType">发票类型</param>
 public void SetInvoiceType(InvoiceType invoiceType)
 {
     InvoiceType = invoiceType;
 }
Ejemplo n.º 51
0
 public static InvoiceRequest CreateInvoiceRequest(InvoiceType invoice)
 {
     InvoiceRequest request = new InvoiceRequest() { Id = "test", Item = invoice };
     HeaderType header = new HeaderType() { DateTime = Misc.FormatCurrentTime(), MessageID = Guid.NewGuid().ToString() };
     request.Header = header;
     return request;
 }
Ejemplo n.º 52
0
 public async Task<IActionResult> ViewLateInvoices(int? customerId, InvoiceType? invoiceType, int? quotationTypeId, int? companyId, int? lateDays)
 {
     var data = await _invoiceManager.GetLateInvoices(customerId, invoiceType, quotationTypeId, companyId, lateDays);
     return View(data);
 }
Ejemplo n.º 53
0
 protected InvoiceCreatorBase(InvoiceType typeOfInvoice)
 {
     _typeOfInvoice = typeOfInvoice;
 }