예제 #1
0
        /// <summary>
        /// Encodes the specified bill information.
        /// </summary>
        /// <param name="billInfo">The bill information.</param>
        /// <returns>The encoded bill information text.</returns>
        internal static string Encode(SwicoBillInformation billInfo)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("//S1");

            if (billInfo.InvoiceNumber != null)
            {
                sb.Append("/10/").Append(EscapedText(billInfo.InvoiceNumber));
            }
            if (billInfo.InvoiceDate != null)
            {
                sb.Append("/11/").Append(S1Date(billInfo.InvoiceDate.Value));
            }
            if (billInfo.CustomerReference != null)
            {
                sb.Append("/20/").Append(EscapedText(billInfo.CustomerReference));
            }
            if (billInfo.VatNumber != null)
            {
                sb.Append("/30/").Append(EscapedText(billInfo.VatNumber));
            }
            if (billInfo.VatDate != null)
            {
                sb.Append("/31/").Append(S1Date(billInfo.VatDate.Value));
            }
            else if (billInfo.VatStartDate != null && billInfo.VatEndDate != null)
            {
                sb.Append("/31/")
                .Append(S1Date(billInfo.VatStartDate.Value))
                .Append(S1Date(billInfo.VatEndDate.Value));
            }
            if (billInfo.VatRate != null)
            {
                sb.Append("/32/").Append(S1Number(billInfo.VatRate.Value));
            }
            else if (billInfo.VatRateDetails != null && billInfo.VatRateDetails.Count > 0)
            {
                sb.Append("/32/");
                AppendTupleList(sb, billInfo.VatRateDetails);
            }
            if (billInfo.VatImportTaxes != null && billInfo.VatImportTaxes.Count > 0)
            {
                sb.Append("/33/");
                AppendTupleList(sb, billInfo.VatImportTaxes);
            }
            if (billInfo.PaymentConditions != null && billInfo.PaymentConditions.Count > 0)
            {
                sb.Append("/40/");
                AppendTupleList(sb, billInfo.PaymentConditions);
            }

            return(sb.Length > 4 ? sb.ToString() : null);
        }
예제 #2
0
 /// <summary>
 /// Retrieves the Swico structured bill information from the text in bill information property.
 /// <para>
 /// If <see cref="BillInformation"/> contains Swico S1 bill information, the
 /// result is returned in a <see cref="SwicoBillInformation"/> instance.
 /// Minor errors in the text are silently ignored. If <see cref="BillInformation"/> does not
 /// contain Swico bill information or the text has major errors, <c>null</c> is returned.
 /// </para>
 /// </summary>
 /// <returns>structured bill information (or <c>null</c> if no Swico bill information is found)</returns>
 /// <remarks>
 /// The bill information property likely contains structured bill information if it starts with <c>//S1/</c>.
 /// </remarks>
 public SwicoBillInformation RetrieveSwicoBillInformation()
 {
     return(SwicoBillInformation.DecodeText(BillInformation));
 }
예제 #3
0
 /// <summary>
 /// Sets the bill information according to Swico S1 syntax from the specified structured bill information.
 /// <para>
 /// Sets the <see cref="BillInformation"/> property to a value similar to <c>//S1/10/...</c>.
 /// </para>
 /// </summary>
 /// <param name="billInformation">structured bill information</param>
 public void SetSwicoBillInformation(SwicoBillInformation billInformation)
 {
     BillInformation = billInformation.EncodeAsText();
 }