示例#1
0
        public void Able_to_create_instance_with_persistence_constructor()
        {
            var expectedId        = Guid.NewGuid();
            var expectedNumber    = "Invoice#";
            var expectedCreatedAt = DateTime.UtcNow;
            var expectedSupplier  = SupplierMockBuilder.Build();
            var expectedCustomer  = CustomerMockBuilder.Build();
            var expectedAmount    = new InvoiceAmount(30, 0.19);

            var actual = new Invoice(
                expectedId,
                expectedNumber,
                expectedCreatedAt,
                _order,
                _product,
                expectedSupplier,
                expectedCustomer,
                expectedAmount);

            actual.Id.Should().Be(expectedId);
            actual.Number.Should().Be(expectedNumber);
            actual.CreatedAt.Should().Be(expectedCreatedAt);
            actual.Order.Should().Be(_order);
            actual.Product.Should().Be(_product);
            actual.Supplier.Should().Be(expectedSupplier);
            actual.Customer.Should().Be(expectedCustomer);
            actual.Amount.Should().NotBeNull();
        }
示例#2
0
        public string Update()
        {
            CommissionAmount = (CommissionRate * Amount) / 100;
            CommissionAmount = Math.Round((decimal)CommissionAmount);
            VatOnAmount      = Amount + CommissionAmount;
            VatAmount        = (CommissionAmount + Amount) * VatRate / 100;
            VatAmount        = Math.Round((decimal)VatAmount);
            InvoiceAmount    = Amount + CommissionAmount + VatAmount;

            XDocument doc    = XDocument.Load(@"Transactions.xml");
            var       record = from r in doc.Descendants("Transaction")
                               where (int)r.Element("Invoice").Attribute("Id") == InvoiceId
                               select r;

            foreach (XElement r in record)
            {
                r.Element("Invoice").Element("InvoiceNo").Value        = InvoiceNo;
                r.Element("Invoice").Element("InvoiceDate").Value      = XmlConvert.ToString(InvoiceDate, XmlDateTimeSerializationMode.RoundtripKind);
                r.Element("Invoice").Element("CommissionRate").Value   = CommissionRate.ToString();
                r.Element("Invoice").Element("CommissionAmount").Value = CommissionAmount.ToString();
                r.Element("Invoice").Element("VatRate").Value          = VatRate.ToString();
                r.Element("Invoice").Element("VatAmount").Value        = VatAmount.ToString();
                r.Element("Invoice").Element("InvoiceAmount").Value    = InvoiceAmount.ToString();
                r.Element("Invoice").Element("Source").Value           = Source;
                r.Element("Invoice").Element("Destination").Value      = Destination;
                r.Element("Invoice").Element("TruckNo").Value          = TruckNo;
            }
            doc.Save(@"Transactions.xml");
            return("Record Updated");
        }
示例#3
0
 private static Contract::InvoiceAmount ToContractModel(
     this InvoiceAmount amount)
 {
     return(new Contract::InvoiceAmount
     {
         Total = amount.Total,
         VAT = amount.VAT,
         Subtotal = amount.Subtotal
     });
 }
示例#4
0
        public string ToJSONString()
        {
            string dateFormat   = "dd-MMM-yyyy";
            string amountFormat = "00.00";

            return(string.Format("$!$\r\n \"invoiceType\": \"{0}\",\r\n \"supplierNumber\": \"{1}\",\r\n \"supplierSiteNumber\": \"{2}\",\r\n \"invoiceDate\": \"{3}\",\r\n \"invoiceNumber\": \"{4}\",\r\n \"invoiceAmount\": {5},\r\n \"payGroup\": \"{6}\",\r\n \"dateInvoiceReceived\": \"{7}\",\r\n \"dateGoodsReceived\": \"{8}\",\r\n \"remittanceCode\": \"{9}\",\r\n \"specialHandling\": \"{10}\",\r\n \"nameLine1\": \"{11}\",\r\n \"nameLine2\": \"{12}\",\r\n \"addressLine1\": \"{13}\",\r\n \"addressLine2\": \"{14}\",\r\n \"addressLine3\": \"{15}\",\r\n \"city\": \"{16}\",\r\n \"country\": \"{17}\",\r\n \"province\": \"{18}\",\r\n \"postalCode\": \"{19}\",\r\n \"qualifiedReceiver\": \"{20}\",\r\n \"terms\": \"{21}\",\r\n \"payAloneFlag\": \"{22}\",\r\n \"paymentAdviceComments\": \"{23}\",\r\n \"remittanceMessage1\": \"{24}\",\r\n \"remittanceMessage2\": \"{25}\",\r\n \"remittanceMessage3\": \"{26}\",\r\n \"glDate\": \"{27}\",\r\n \"invoiceBatchName\": \"{28}\",\r\n \"currencyCode\": \"{29}\",\r\n \"invoiceLineDetails\": [$!$\r\n   \"invoiceLineNumber\": {30},\r\n   \"invoiceLineType\": \"{31}\",\r\n   \"lineCode\": \"{32}\",\r\n   \"invoiceLineAmount\": {33},\r\n   \"defaultDistributionAccount\": \"{34}\",\r\n   \"description\": \"{35}\",\r\n   \"taxClassificationCode\": \"{36}\",\r\n   \"distributionSupplier\": \"{37}\",\r\n   \"info1\": \"{38}\",\r\n   \"info2\": \"{39}\",\r\n   \"info3\": \"{40}\"\r\n   $&$]\r\n$&$",
                                 InvoiceType,
                                 SupplierNumber,
                                 SupplierSiteNumber.ToString("000"),
                                 InvoiceDate.ToLocalTime().ToString(dateFormat),
                                 InvoiceNumber,
                                 InvoiceAmount.ToString(amountFormat),
                                 PayGroup,
                                 DateInvoiceReceived.ToLocalTime().ToString(dateFormat),
                                 DateGoodsReceived.HasValue ? DateGoodsReceived.Value.ToLocalTime().ToString(dateFormat) : "",
                                 RemittanceCode,
                                 (SpecialHandling ? "D" : "N"),
                                 NameLine1,
                                 NameLine2,
                                 AddressLine1,
                                 AddressLine2,
                                 AddressLine3,
                                 City,
                                 Country,
                                 Province,
                                 PostalCode = !string.IsNullOrEmpty(PostalCode) ? PostalCode.Replace(" ", ""): string.Empty,
                                 QualifiedReceiver,
                                 Terms,
                                 PayAloneFlag,
                                 PaymentAdviceComments,
                                 RemittanceMessage1,
                                 RemittanceMessage2,
                                 RemittanceMessage3,
                                 GLDate.HasValue ? GLDate.Value.ToLocalTime().ToString(dateFormat) : "",
                                 InvoiceBatchName,
                                 CurrencyCode,
                                 InvoiceLineNumber,
                                 InvoiceLineType,
                                 LineCode,
                                 InvoiceLineAmount.ToString(amountFormat),
                                 DefaultDistributionAccount,
                                 Description,
                                 TaxClassificationCode,
                                 DistributionSupplier,
                                 Info1,
                                 Info2,
                                 Info3
                                 ).Replace("$!$", "{").Replace("$&$", "}"));
        }
示例#5
0
 public void InsertEmpPoInvoiceNo(string empId = null, string poNo = null, string invoiceNo = null)
 {
     if (!string.IsNullOrEmpty(empId))
     {
         EmployeeId.SendKeys(empId);
     }
     if (!string.IsNullOrEmpty(poNo))
     {
         PONumber.SendKeys(poNo);
     }
     if (!string.IsNullOrEmpty(invoiceNo))
     {
         InvoiceAmount.SendKeys(invoiceNo);
     }
 }
示例#6
0
        private void AddFilters(DictionaryOnDemandComboBox dcbShipments)
        {
            dcbShipments.SelectedIdNullable = null;
            dcbShipments.SelectedText       = string.Empty;

            dcbShipments.Filters.Clear();

            if (InvoiceAmount != 0)
            {
                dcbShipments.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn()
                {
                    Name      = "ShipmentAmount",
                    DbType    = DbType.Decimal,
                    Operation = FilterOperation.Equal,
                    Value     = InvoiceAmount.ToString()
                });
            }
            if (ExecutorCompanyLegalAccountId.HasValue)
            {
                dcbShipments.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn()
                {
                    Name      = "ExecutorCompanyLegalAccountID",
                    DbType    = DbType.Guid,
                    Operation = FilterOperation.Equal,
                    Value     = ExecutorCompanyLegalAccountId.Value.ToString()
                });
            }
            if (BuyerCompanyLegalAccountId.HasValue)
            {
                dcbShipments.Filters.Add(new DictionaryOnDemandComboBox.DictionaryFilterColumn()
                {
                    Name      = "BuyerCompanyLegalAccountID",
                    DbType    = DbType.Guid,
                    Operation = FilterOperation.Equal,
                    Value     = BuyerCompanyLegalAccountId.Value.ToString()
                });
            }

            dcbShipments.ShowEmpty = false;

            var shipment = _dataManager.Shipment.SelectForInvoice(InvoiceAmount, BuyerCompanyLegalAccountId, ExecutorCompanyLegalAccountId).FirstOrDefault();

            if (shipment != null)
            {
                dcbShipments.SelectedId   = shipment.ID;
                dcbShipments.SelectedText = string.Format("Отгрузка № {0} от {1}", shipment.Number, shipment.CreatedAt.ToString("dd.MM.yyyy"));
            }
        }
示例#7
0
        public void All_numbers_should_be_rounded_to_two_decimals()
        {
            var expectedSubtotal = 10.01;
            var expectedVATRate  = 0.2;
            var expectedVAT      = 2.0;
            var expectedTotal    = 12.01;

            var actual = new InvoiceAmount(
                10.0099,
                0.1999);

            actual.Subtotal.Should().Be(expectedSubtotal);
            actual.VATRate.Should().Be(expectedVATRate);
            actual.VAT.Should().Be(expectedVAT);
            actual.Total.Should().Be(expectedTotal);
        }
示例#8
0
        public void Able_to_create_instance()
        {
            var expectedSubtotal = 10.0;
            var expectedVATRate  = 0.2;
            var expectedVAT      = 2.0;
            var expectedTotal    = 12.0;

            var actual = new InvoiceAmount(
                expectedSubtotal,
                expectedVATRate);

            actual.Subtotal.Should().Be(expectedSubtotal);
            actual.VATRate.Should().Be(expectedVATRate);
            actual.VAT.Should().Be(expectedVAT);
            actual.Total.Should().Be(expectedTotal);
        }
示例#9
0
        protected internal override NameValueCollection GetNameValueCollection(string accessID)
        {
            var collection = new NameValueCollection();

            collection.Add("accessID", accessID ?? string.Empty);
            collection.Add("timestamp", Convert.ToString(Common.GetUnixTimestamp()));
            collection.Add("first_name", FirstName ?? string.Empty);
            collection.Add("last_name", LastName ?? string.Empty);
            collection.Add("email", Email ?? string.Empty);
            collection.Add("discount_code", DiscountCode ?? string.Empty);
            collection.Add("order_timestamp", Convert.ToString(Common.GetUnixTimestamp(OrderDateTime)));
            collection.Add("browser_ip", BrowserIP ?? string.Empty);
            collection.Add("user_agent", UserAgent ?? string.Empty);
            collection.Add("invoice_amount", InvoiceAmount.ToString("N2"));
            collection.Add("currency_code", CurrencyCode ?? string.Empty);
            collection.Add("external_reference_id", ExternalReferenceID ?? string.Empty);

            return(collection);
        }
示例#10
0
 public static Invoice Build(
     Guid?id              = null,
     string number        = "Invoice #",
     DateTime?createdAt   = null,
     Order order          = null,
     Product product      = null,
     Supplier supplier    = null,
     Customer customer    = null,
     InvoiceAmount amount = null)
 {
     return(new Invoice(
                id ?? Guid.NewGuid(),
                number,
                createdAt ?? DateTime.UtcNow.Date,
                order ?? OrderMockBuilder.Build(),
                product ?? ProductMockBuilder.Build(),
                supplier ?? SupplierMockBuilder.Build(),
                customer ?? CustomerMockBuilder.Build(),
                amount ?? new InvoiceAmount(30, 0.19)));
 }
示例#11
0
        public void Able_to_create_instance()
        {
            var expectedSupplier = SupplierMockBuilder.Build();
            var expectedCustomer = CustomerMockBuilder.Build();
            var expectedAmount   = new InvoiceAmount(30, 0.19);

            var actual = new Invoice(
                _order,
                _product,
                expectedSupplier,
                expectedCustomer);

            actual.Id.Should().NotBeEmpty();
            actual.Number.Should().NotBeNullOrEmpty();
            actual.CreatedAt.Should().BeCloseTo(DateTime.UtcNow, precision: 1000);
            actual.Order.Should().Be(_order);
            actual.Product.Should().Be(_product);
            actual.Supplier.Should().Be(expectedSupplier);
            actual.Customer.Should().Be(expectedCustomer);
            actual.Amount.Should().Be(expectedAmount);
        }
示例#12
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 31, Configuration.FieldSeparator),
                       Id,
                       ProviderInvoiceNumber?.ToDelimitedString(),
                       PayerInvoiceNumber?.ToDelimitedString(),
                       ContractAgreementNumber?.ToDelimitedString(),
                       InvoiceControl?.ToDelimitedString(),
                       InvoiceReason?.ToDelimitedString(),
                       InvoiceType?.ToDelimitedString(),
                       InvoiceDateTime.HasValue ? InvoiceDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       InvoiceAmount?.ToDelimitedString(),
                       PaymentTerms,
                       ProviderOrganization?.ToDelimitedString(),
                       PayerOrganization?.ToDelimitedString(),
                       Attention?.ToDelimitedString(),
                       LastInvoiceIndicator,
                       InvoiceBookingPeriod.HasValue ? InvoiceBookingPeriod.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       Origin,
                       InvoiceFixedAmount?.ToDelimitedString(),
                       SpecialCosts?.ToDelimitedString(),
                       AmountForDoctorsTreatment?.ToDelimitedString(),
                       ResponsiblePhysician?.ToDelimitedString(),
                       CostCenter?.ToDelimitedString(),
                       InvoicePrepaidAmount?.ToDelimitedString(),
                       TotalInvoiceAmountWithoutPrepaidAmount?.ToDelimitedString(),
                       TotalAmountOfVat?.ToDelimitedString(),
                       VatRatesApplied != null ? string.Join(Configuration.FieldRepeatSeparator, VatRatesApplied.Select(x => x.ToString(Consts.NumericFormat, culture))) : null,
                       BenefitGroup?.ToDelimitedString(),
                       ProviderTaxId,
                       PayerTaxId,
                       ProviderTaxStatus?.ToDelimitedString(),
                       PayerTaxStatus?.ToDelimitedString(),
                       SalesTaxId
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
示例#13
0
        public InvoiceAmount ComputePrice(TotalBill order)
        {
            var invoiceAmount = new InvoiceAmount();
            var content       = (int)System.Enum.Parse(typeof(User_Type), order.UserType);


            var GetDiscount = getDiscountType.GetDiscountByType(content);

            order.DiscountPercentage = GetDiscount.Body.DiscountPercentage;
            decimal nonDiscounted = order.orders.Sum(p => p.Price);

            #region
            //OLD IMPLEMENTATION

            //decimal baseDiscount = _discountPoliciesMethods.BaseDiscount(order);
            //decimal[] discounts = new[] {

            //    _discountPoliciesMethods.CustomeTypeDiscount(order),

            //    _discountPoliciesMethods.CustomerLoyaltyDiscount(order),

            //};
            //decimal bestDiscount = discounts.Max(discount => discount);

            //var totalDiscount = bestDiscount + baseDiscount;

            #endregion
            var totalDiscount2 = discountMethodProcessor.GetTotalDiscount(order);
            var total          = nonDiscounted - totalDiscount2;
            invoiceAmount.InvoicePrice       = total.ToString();
            invoiceAmount.DiscountCalculated = totalDiscount2.ToString();

            invoiceAmount.UndiscountedPrice = nonDiscounted.ToString();
            logger.Information($"Invoice to be paid  => {JsonConvert.SerializeObject(invoiceAmount)}");

            return(invoiceAmount);
        }
示例#14
0
        static void AddToGridByDate(DataGridView grid, M2OrderItem item, M2OrderByDatesItems invoice, M2OrderByDateBillingAddress billingAddress)
        {
            try
            {
                string sku = item.sku;
                double CGST, SGST, BASE_AMOUNT, RateBasic, DeliveryCharge, BaseDiscountAmount, LineAmount, InvoiceAmount;
                string IGST, TaxRate;
                string customerName, customerLastName;
                customerName     = invoice.customer_firstname;
                customerLastName = invoice.customer_lastname;
                if (customerName == null)
                {
                    customerName     = billingAddress.firstname;
                    customerLastName = billingAddress.lastname;
                }

                ReadFromExcelFile(sku);
                TaxRate = masterItem.IGST + "%";
                IGST    = masterItem.IGST;
                CGST    = masterItem.CGST;
                SGST    = masterItem.SGST;

                StringBuilder stringBuilder = new StringBuilder();
                List <string> streets       = new List <string>(billingAddress.street);
                foreach (var street in streets)
                {
                    stringBuilder.Append(street);
                }

                BASE_AMOUNT = item.base_row_total_incl_tax;
                //discount amount per line
                BaseDiscountAmount = item.base_discount_amount;

                //get the base amount before tax
                if (BaseDiscountAmount > 0)
                {
                    LineAmount = BASE_AMOUNT - BaseDiscountAmount;
                    //line amount before tax
                    RateBasic = LineAmount * 100 / (100 + Double.Parse(masterItem.IGST));
                }
                else
                {
                    LineAmount = BASE_AMOUNT;
                    //line amount before tax
                    RateBasic = BASE_AMOUNT * 100 / (100 + Double.Parse(masterItem.IGST));
                }

                DeliveryCharge = invoice.shipping_amount;

                //check billing state
                if (billingAddress.region.Equals(STATE))
                {
                    //calculate taxe on base rate + delivery charge
                    CGST = (RateBasic + DeliveryCharge) * CGST / 100;
                    SGST = (RateBasic + DeliveryCharge) * SGST / 100;
                    IGST = "0";
                    //invoice amount
                    InvoiceAmount = RateBasic + DeliveryCharge + CGST + SGST;
                }
                else
                {
                    CGST = 0;
                    SGST = 0;
                    //calculate taxe on base rate + delivery charge
                    IGST = ((RateBasic + DeliveryCharge) * Double.Parse(masterItem.IGST) / 100).ToString("#.##");
                    //invoice amount
                    InvoiceAmount = RateBasic + DeliveryCharge + Double.Parse(IGST);
                }


                //add row to data table
                dt.Rows.Add(invoice.increment_id, invoice.created_at, "POS Invoice", "Main Location", customerName + " " + customerLastName, stringBuilder.ToString(),
                            "", "", "", billingAddress.country_id, billingAddress.region, "", "", "POS Sales", item.name, "", TaxRate, "", "", item.qty_ordered, "NO",
                            item.base_price_incl_tax, RateBasic.ToString("#.##"), item.discount_percent, LineAmount, invoice.shipping_amount, CGST.ToString("#.##"),
                            SGST.ToString("#.##"), IGST, "", InvoiceAmount.ToString("#.##"), "", "", "", sku);

                // set data grid view data source
                grid.DataSource             = dt;
                grid.Columns["SKU"].Visible = false;
                grid.AllowUserToAddRows     = false;
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "Error");
            }
        }