Пример #1
0
        public void WriteCustInvCharges(Prism810Context context, CustomerInvoiceConfigModel configModel, Type810Header header)
        {
            if (!context.IsCustomerInvoice)
            {
                return;
            }

            if (!header.HeaderKey.HasValue)
            {
                return;
            }

            var headerKey = header.HeaderKey.Value;
            var charges   = marketDataAccess.ListDetailItemChargesByHeader(headerKey);

            if (charges == null || charges.Length == 0)
            {
                return;
            }

            var lineNumber = 1;

            foreach (var charge in charges)
            {
                if (charge.ChargeCode.Equals("D140", StringComparison.Ordinal) && !configModel.TaxesAsCharge)
                {
                    continue;
                }

                var rate = charge.Rate;
                if (rate.Length > 0)
                {
                    rate = decimal.Round(decimal.Parse(rate), 5).ToString();
                }

                var uom = charge.UOM;
                if (string.IsNullOrEmpty(uom))
                {
                    uom = "EA";
                }

                var amount = charge.Amount;
                if (amount.Contains("."))
                {
                    amount = amount.Substring(0, amount.IndexOf('.') + 3);
                }

                var line = string.Format("40|{0}|{1}|{2}||{3}|{4}|{5}|{6}|{7}||{8}||", context.TradingPartnerId,
                                         lineNumber, charge.ChargeIndicator, charge.ChargeCode, amount, rate, uom, charge.Quantity,
                                         charge.Description);

                lineNumber++;
                context.AddToRunningTotal(amount);

                context.AppendLine(line);
                logger.TraceFormat("Wrote 810 \"40\" PRISM line for Header {0}", header.HeaderKey);
            }
        }
Пример #2
0
        public void WriteCustInvAccountTaxCharges(Prism810Context context, CustomerInvoiceConfigModel configModel, Type810Header header)
        {
            if (!context.IsCustomerInvoice)
            {
                return;
            }

            if (configModel.TaxesAsCharge)
            {
                return;
            }

            if (!header.HeaderKey.HasValue)
            {
                return;
            }

            var headerKey = header.HeaderKey.Value;
            var charges   = marketDataAccess.ListDetailItemChargesByHeader(headerKey);

            if (charges == null || charges.Length == 0)
            {
                return;
            }

            foreach (var charge in charges)
            {
                if (!charge.ChargeCode.Equals("D140", StringComparison.Ordinal))
                {
                    continue;
                }

                var amount = charge.Amount;
                if (amount.Contains("."))
                {
                    amount = amount.Substring(0, amount.IndexOf('.') + 3);
                }

                var line = string.Format("20|{0}|LS|{1}||||", context.TradingPartnerId, amount);
                context.AppendLine(line);
                logger.TraceFormat("Wrote 810 \"20\" PRISM line for Header {0}", header.HeaderKey);

                if (configModel.IncludeTaxesInTotal)
                {
                    context.AddToRunningTotal(amount);
                }
            }
        }