Exemplo n.º 1
0
 private PaymentNote Map(tblDocument tblDoc)
 {
     var doc = new PaymentNote(tblDoc.Id);
     _Map(tblDoc, doc);
     doc.PaymentNoteType = (PaymentNoteType)tblDoc.OrderOrderTypeId;
     doc._SetLineItems(tblDoc.tblLineItems.Select(n => MapPayementLineItem(n)).ToList());
     return doc;
 }
 private InventoryTransferNote Map(tblDocument tblDoc)
 {
     var itn = PrivateConstruct<InventoryTransferNote>(tblDoc.Id);
     _Map(tblDoc, itn);
     itn.DocumentIssueredOnBehalfCostCentre = _costCentreRepository.GetById(tblDoc.OrderIssuedOnBehalfOfCC.Value);
     itn._SetLineItems(tblDoc.tblLineItems.Select(n => MapITNLineItem(n)).ToList());
     return itn;
 }
Exemplo n.º 3
0
 private CreditNote Map(tblDocument tblDoc)
 {
     var cn = new CreditNote(tblDoc.Id);
     _Map(tblDoc, cn);
     cn.InvoiceId = tblDoc.InvoiceOrderId == null ? Guid.Empty : tblDoc.InvoiceOrderId.Value;
     cn._SetLineItems(tblDoc.tblLineItems.Select(n => MapCreditLineItem(n)).ToList());
     return cn;
 }
 private InventoryAdjustmentNote Map(tblDocument tblDoc)
 {
     var doc = PrivateConstruct<InventoryAdjustmentNote>(tblDoc.Id); //new InventoryAdjustmentNote(tblDoc.Id); 
     _Map(tblDoc, doc);
     doc.InventoryAdjustmentNoteType = tblDoc.OrderOrderTypeId.HasValue == true ? (InventoryAdjustmentNoteType)tblDoc.OrderOrderTypeId.Value : 0;
     doc._SetLineItems(tblDoc.tblLineItems.Select(n => MapIANLineItem(n)).ToList());
     return doc;
 }
Exemplo n.º 5
0
 private PaymentNote Map(tblDocument tblDoc)
 {
     var pn = new PaymentNote(tblDoc.Id);
     _Map(tblDoc, pn);
     pn.PaymentNoteType = (PaymentNoteType)tblDoc.OrderOrderTypeId;
     pn._SetLineItems(tblDoc.tblLineItems.Select(n => MapPayementLineItem(n)).ToList());
     return pn;
 }
Exemplo n.º 6
0
 private ReturnsNote Map(tblDocument tblDoc)
 {
     var doc = PrivateConstruct<ReturnsNote>(tblDoc.Id);
      doc.EnableAddCommands();
     _Map(tblDoc, doc);
     doc.ReturnsNoteType = tblDoc.OrderOrderTypeId.HasValue ? (ReturnsNoteType)tblDoc.OrderOrderTypeId : ReturnsNoteType.SalesmanToDistributor;
     var lineItem = tblDoc.tblLineItems.Select(MapReturnsNoteLineItem).ToList();
     doc._SetLineItems(lineItem);
     return doc;
 }
Exemplo n.º 7
0
 private tblDocument _NewDocument(Guid documentId,
     DocumentType documentType,
     Guid documentIssuerCostCentreId,
     Guid documentIssuerUserId,
     Guid documentIssuerCostCentreApplicationId,
     DateTime documentDateIssued,
     DocumentStatus documentStatus,
     string documentReference,
     DateTime sendDateTime,
     Guid documentRecipientCostCentreId,
      Guid documentparentId,
     double? longitude = null,
     double? latitude = null
     )
 {
     var doc = new tblDocument
         {
             Id = documentId,
             DocumentIssuerCostCentreId = documentIssuerCostCentreId,
             DocumentIssuerUserId = documentIssuerUserId,
             DocumentRecipientCostCentre = documentRecipientCostCentreId,
             DocumentTypeId = (int) documentType,
             DocumentDateIssued = documentDateIssued,
             DocumentStatusId = (int) documentStatus,
             DocumentReference = documentReference,
             IM_DateCreated = DateTime.Now,
             DocumentIssuerCostCentreApplicationId = documentIssuerCostCentreApplicationId,
             IM_IsActive = true,
             Latitude = latitude,
             Longitude = longitude,
             DocumentParentId = documentparentId,
             SendDateTime = sendDateTime.Equals(new DateTime()) ? DateTime.Now : sendDateTime
         };
     if (sendDateTime.ToString("dd/MM/yyyy") == "01/01/0001")
     {
         doc.SendDateTime = DateTime.Now;
     }
     doc.IM_DateLastUpdated = DateTime.Now;
     
     return doc;
 }
 string HandleShipTo(tblDocument order)
 {
     var shipTo=string.Empty;
     if (string.IsNullOrEmpty(order.ShipToAddress) || order.ShipToAddress.Contains("--Select Shipto address----"))
     {
        return shipTo;
     }
     var separator = new[] { '[', ']' };
     
     //[name][code][physical] address format=>name is outlet name
     var temp = order.ShipToAddress.Split(separator, StringSplitOptions.RemoveEmptyEntries);
     if (temp.Any())
     {
         //Take only takes shiptocode-nothing else...
         shipTo = temp.Count() >= 2 ? temp[1] : shipTo;
     }
     return shipTo;
 }
 string HandleOutlet(tblDocument order)
 {
     if (order.OrderIssuedOnBehalfOfCC != null && order.OrderIssuedOnBehalfOfCC != Guid.Empty)
     {
         var costCentre = _ctx.tblCostCentre.FirstOrDefault(p => p.Id == order.OrderIssuedOnBehalfOfCC);
         if (costCentre != null)
             return costCentre.Cost_Centre_Code;
     }
     return string.Empty;
 }
Exemplo n.º 10
0
        protected virtual decimal GetOutstandingAmount(tblDocument order)
        {

            decimal salediscount = order.SaleDiscount.HasValue ? order.SaleDiscount.Value : 0;

            var invoiceList = (from d in _ctx.tblDocument
                               where d.DocumentTypeId == (int)DocumentType.Invoice
                               where d.InvoiceOrderId == order.Id
                               from l in d.tblLineItems
                               select new { l.Quantity, l.Value, l.Vat }).ToList();

            var invoiceAmount = invoiceList.Sum(x => ((x.Quantity.Value * x.Value.Value) + (x.Vat.Value * x.Quantity.GetValueOrDefault(0))).GetTruncatedValue()).GetTotalGross();
            //var invoiceAmount = (decimal?) (from d in _ctx.tblDocument
            //                                where d.DocumentTypeId == (int) DocumentType.Invoice
            //                                where d.InvoiceOrderId == order.Id
            //                                from l in d.tblLineItems
            //                                select new {l.Quantity, l.Value, l.Vat})
            //                                   .Sum(x => (x.Quantity*x.Value) + (x.Vat*x.Quantity)) ?? 0;

            var receiptAmount = (decimal?) (from d in _ctx.tblDocument
                                            where d.DocumentTypeId == (int) DocumentType.Receipt
                                            where d.DocumentParentId == order.Id
                                            from l in d.tblLineItems
                                            select new {l.Value})
                                               .Sum(x => x.Value) ?? 0;
            var creditNoteSum = (decimal?) (from d in _ctx.tblDocument
                                            where d.DocumentTypeId == (int) DocumentType.CreditNote
                                            where d.DocumentParentId == order.Id
                                            from l in d.tblLineItems
                                            select new {l.Quantity, l.Value, l.Vat})
                                               .Sum(x => (x.Quantity*x.Value) + (x.Vat*x.Quantity)) ?? 0;

            decimal totalInvoiceAmount = (invoiceAmount - salediscount).GetTotalGross();
            decimal totalPaidAmount = (receiptAmount + creditNoteSum);

            decimal outstandingAmnt = totalInvoiceAmount - totalPaidAmount;

            return outstandingAmnt;
        }
Exemplo n.º 11
0
 private DispatchNote Map(tblDocument tblDoc)
 {
     var dn = new DispatchNote(tblDoc.Id);
     _Map(tblDoc, dn);
     if (tblDoc.OrderOrderTypeId != null)
         dn.DispatchType = (DispatchNoteType)tblDoc.OrderOrderTypeId;
     if (tblDoc.InvoiceOrderId != null)
         dn.OrderId = tblDoc.InvoiceOrderId.Value;
     dn._SetLineItems(tblDoc.tblLineItems.Select(n => MapDNLineItem(n)).ToList());
     return dn;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tblDocument EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblDocument(tblDocument tblDocument)
 {
     base.AddObject("tblDocument", tblDocument);
 }
        private PzCussonsOrderIntegrationDto MapPzDto(tblDocument document)
        {
            if (document != null)
            {
                var orderdateRequired = document.OrderDateRequired.HasValue
                                            ? document.OrderDateRequired.Value.ToString("dd/MM/yy")
                                            : document.DocumentDateIssued.ToString("dd/MM/yy");

                var dto = new PzCussonsOrderIntegrationDto()
                              {
                                  GenericOrderReference = document.DocumentReference,
                                  ExternalOrderReference = document.ExtDocumentReference,
                                  Currency = "KES",
                                  Note = document.Note,
                                  DocumentDateIssued = document.DocumentDateIssued.ToString("dd/MM/yy"),
                                  OrderDateRequired = orderdateRequired,
                                  SalesmanCode = HandleSalesmanCode(document),
                                  ShiptoAddressCode = HandleShipTo(document),
                                  ChequeReferenceNo = GetChequePayment(document),
                                  OutletCode = HandleOutlet(document)
                              };
                int count = 1;

                var lineItems = _ctx.tblLineItems.Where(p => p.DocumentID == document.Id).ToList();
                foreach (var lineItem in lineItems)
                {
                    if (lineItem.ProductID != null && lineItem.ProductID != Guid.Empty)
                    {
                        var product = _ctx.tblProduct.FirstOrDefault(p => p.id == lineItem.ProductID);
                        if(product !=null)
                        {
                            var item = new PzCussonsIntegrationDtoOrderLineItem()
                            {

                                ProductCode = product.ProductCode,
                                ApprovedQuantity = (lineItem.Quantity != null) ? lineItem.Quantity.Value : 0,
                                Count = count,
                                Location = string.Empty,
                                OrderDateRequired = orderdateRequired,
                                Site = string.Empty,
                                Value = lineItem.Value.HasValue ? lineItem.Value.Value : 0m
                            };
                            dto.LineItems.Add(item);
                            count++;
                        }
                    }
                }
                dto.TotalNet = GetOrderNetValue(document);
                return dto;
            }
            return null;
        }
 private decimal GetSaleValue(tblDocument document)
 {
     var lineitems = document.tblLineItems.Where(s => s.LineItemStatusId != (int)MainOrderLineItemStatus.Removed).ToList();
      if (lineitems.Any())
      {
          var totalVat = lineitems.Sum(n => (n.Vat ?? 0) * (n.Quantity ?? 0));
          return (lineitems.Sum(n => (n.Value ?? 0)*(n.Quantity ?? 0)) + totalVat);
      }
     return 0m;
 }
        private List<ShellOrderExportDto> MapSage(tblDocument doc)
        {
            List<ShellOrderExportDto> orders=null;
            if(doc !=null)
            { 
                orders=new List<ShellOrderExportDto>();
                var payments = _ctx.tblOrderPaymentInfo.Where(p => p.DocumentId == doc.Id).ToList();
                var modes = payments.Select(n => ((PaymentMode)n.PaymentMode).ToString());
                var cheque = payments.FirstOrDefault(p => p.PaymentMode == (int) PaymentMode.Cheque);
                var paid = (GetPaidAmount(doc)*-1);
               
                var lineItems = _ctx.tblLineItems.Where(p => p.DocumentID == doc.Id).ToList();
                foreach (var lineItem in lineItems)
                {
                    ShellOrderExportDto orderLineItem = null;
                    if (lineItem.ProductID != null && lineItem.ProductID != Guid.Empty)
                    {
                        var product = _ctx.tblProduct.FirstOrDefault(p => p.id == lineItem.ProductID);
                        if (product != null)
                        {
                            var quantity = (lineItem.Quantity != null) ? lineItem.Quantity.Value : 0;
                            var totalvat = (lineItem.Vat.HasValue ? lineItem.Vat.Value : 0m)*quantity;
                            var totalValue = (lineItem.Value.HasValue ? lineItem.Value.Value : 0m)*quantity;
                            
                            orderLineItem = new ShellOrderExportDto
                            {
                                ExternalOrderReference = doc.ExtDocumentReference,
                                Note = doc.Note,
                                OrderDate = doc.OrderDateRequired.HasValue
                                                ? doc.OrderDateRequired.Value.ToShortDateString()
                                                : string.Empty,
                                OutletCode = HandleOutlet(doc),
                                SalesmanCode = HandleSalesmanCode(doc),
                                AmountPaid = paid < 0 ? (paid = paid * -1).ToString("0.00") : paid.ToString("0.00"),
                                ChequeNo = cheque != null ? cheque.PaymentRefId : string.Empty,
                                ShiptoAddressCode = HandleShipTo(doc),
                                ModeOfpayment = modes != null && modes.Any() ? string.Join(",", modes) : string.Empty,

                                ProductCode = product.ProductCode,
                                Quantity = quantity.ToString(),
                                NetAmountExlVAT = (totalValue).ToString("0.00"),
                                TotalVATAmount = (totalvat).ToString("0.00"),
                                NetAmountIncVAT = (totalValue + totalvat).ToString("0.00")
                            };
                            orderLineItem.PricingTierCode = GetPricingTierCode(orderLineItem.OutletCode);
                            orderLineItem.OrderDateRequired = orderLineItem.OrderDate;
                            orderLineItem.SalesmanCodeTwo = orderLineItem.SalesmanCode;
                        }
                       
                    }
                    orders.Add(orderLineItem);
                }
            }
            return orders;
        }
 private List<SapDocumentExportDto> MapSAP(tblDocument arg)
 {
     if (arg == null) return null;
     return (from line in _ctx.tblLineItems.Where(p => p.DocumentID == arg.Id).ToList()
             where line.ProductID != null && line.ProductID != Guid.Empty
             let product = _ctx.tblProduct.FirstOrDefault(p => p.id == line.ProductID)
             where product != null
             select new SapDocumentExportDto
                        {
                            OrderDate = arg.DocumentDateIssued.ToShortDateString(),
                            OrderDueDate =
                                arg.OrderDateRequired.HasValue
                                    ? arg.OrderDateRequired.Value.ToShortDateString()
                                    : DateTime.Now.ToShortDateString(),
                            OrderRef = arg.ExtDocumentReference,
                            OutletCode = HandleOutlet(arg),
                            ProductCode = product.ProductCode.Trim(),
                            SalesmanCode = HandleSalesmanCode(arg),
                            Quantity = ((line.Quantity != null) ? line.Quantity.Value : 0).ToString("0.0"),
                            VatClass = GetVatClass(product)
                        }).ToList();
 }
Exemplo n.º 17
0
 private GenericDocument Map(tblDocument tblDoc)
 {
     var doc = new GenericDocument(tblDoc.Id);
     _Map(tblDoc, doc);
     return doc;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Create a new tblDocument object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="documentTypeId">Initial value of the DocumentTypeId property.</param>
 /// <param name="iM_DateCreated">Initial value of the IM_DateCreated property.</param>
 /// <param name="iM_DateLastUpdated">Initial value of the IM_DateLastUpdated property.</param>
 /// <param name="iM_IsActive">Initial value of the IM_IsActive property.</param>
 /// <param name="documentIssuerCostCentreId">Initial value of the DocumentIssuerCostCentreId property.</param>
 /// <param name="documentIssuerUserId">Initial value of the DocumentIssuerUserId property.</param>
 /// <param name="documentDateIssued">Initial value of the DocumentDateIssued property.</param>
 /// <param name="documentStatusId">Initial value of the DocumentStatusId property.</param>
 /// <param name="documentRecipientCostCentre">Initial value of the DocumentRecipientCostCentre property.</param>
 public static tblDocument CreatetblDocument(global::System.Guid id, global::System.Int32 documentTypeId, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Boolean iM_IsActive, global::System.Guid documentIssuerCostCentreId, global::System.Guid documentIssuerUserId, global::System.DateTime documentDateIssued, global::System.Int32 documentStatusId, global::System.Guid documentRecipientCostCentre)
 {
     tblDocument tblDocument = new tblDocument();
     tblDocument.Id = id;
     tblDocument.DocumentTypeId = documentTypeId;
     tblDocument.IM_DateCreated = iM_DateCreated;
     tblDocument.IM_DateLastUpdated = iM_DateLastUpdated;
     tblDocument.IM_IsActive = iM_IsActive;
     tblDocument.DocumentIssuerCostCentreId = documentIssuerCostCentreId;
     tblDocument.DocumentIssuerUserId = documentIssuerUserId;
     tblDocument.DocumentDateIssued = documentDateIssued;
     tblDocument.DocumentStatusId = documentStatusId;
     tblDocument.DocumentRecipientCostCentre = documentRecipientCostCentre;
     return tblDocument;
 }
        private FclExportOrderDto MapFCLDTO(tblDocument document,string append)
        {
            if(document !=null)
            {
                var dto = new FclExportOrderDto()
                              {
                                  OrderDate = document.DocumentDateIssued.ToString("dd-MM-yyyy"),
                                  ExternalOrderReference = GetOrderReference(document,append),
                                  GenericOrderReference = document.DocumentReference,
                                  OutletCode =HandleOutlet(document),
                                  SalesmanCode =HandleSalesmanCode(document),
                                  ShiptoAddressCode =HandleShipTo(document)
                              };

                
                foreach (var lineItem in document.tblLineItems)
                {
                    if (lineItem.ProductID != null && lineItem.ProductID != Guid.Empty)
                    {
                        var product = _ctx.tblProduct.FirstOrDefault(p => p.id == lineItem.ProductID);
                        if (product != null)
                        {
                            var item = new FclExportOrderLineItem()
                                           {
                                               ProductCode = product.ProductCode,
                                               ApprovableQuantity =
                                                   (lineItem.Quantity != null) ? lineItem.Quantity.Value : 0,
                                           };
                            dto.LineItems.Add(item);
                        }
                    }
                }
                return dto;
            }
            return null;
        }
 private DisbursementNote Map(tblDocument tblDoc)
 {
     var doc = new DisbursementNote(tblDoc.Id);
     _Map(tblDoc,doc);
     var lineItem = tblDoc.tblLineItems.Select(n => MapDisbursementNoteLineItems(n)).ToList();
     doc._SetLineItems(lineItem);
     return doc;
 }
Exemplo n.º 21
0
        internal MainOrderSummary MapSummary(tblDocument tblDocument, bool calculateOutstanding = false,
                                             bool getapproveddate = false)
        {
            string salesman = "";
            var issuer =
                _ctx.tblCostCentre.Where(s => s.Id == tblDocument.DocumentIssuerCostCentreId).Select(
                    s => new {s.Name, s.CostCentreType.Value, s.Id}).FirstOrDefault();
            var recepient =
                _ctx.tblCostCentre.Where(s => s.Id == tblDocument.DocumentRecipientCostCentre).Select(
                    s => new {s.Name, s.CostCentreType.Value, s.Id}).FirstOrDefault();
            var outlet =
                _ctx.tblCostCentre.Where(s => s.Id == tblDocument.OrderIssuedOnBehalfOfCC).Select(
                    s => new {s.Name, s.CostCentreType.Value, s.Id}).FirstOrDefault();

            var mainOrderSummary = new MainOrderSummary();
            if (issuer != null && recepient != null && (CostCentreType) issuer.Value == CostCentreType.Distributor)
            {
                salesman = recepient.Name + "(" + issuer.Name + ")";
                mainOrderSummary.SalesmanId = recepient.Id;
            }
            else if (issuer != null && recepient != null)
            {
                salesman = issuer.Name + "(" + recepient.Name + ")";
                mainOrderSummary.SalesmanId = issuer.Id;
            }
            if (outlet != null)
            {
                mainOrderSummary.Outlet = outlet.Name;
            }
            if (getapproveddate)
            {
                var invoicedoc = _ctx.tblDocument.FirstOrDefault(s => s.DocumentParentId == tblDocument.Id);
                if (invoicedoc != null)
                    mainOrderSummary.DateProcessed = invoicedoc.DocumentDateIssued;
            }
            var lineitems =
                tblDocument.tblLineItems.Where(s => s.LineItemStatusId != (int) MainOrderLineItemStatus.Removed);

            mainOrderSummary.OrderId = tblDocument.Id;
            mainOrderSummary.Status = (DocumentStatus) tblDocument.DocumentStatusId;
            
            
            mainOrderSummary.TotalVat = lineitems.Sum(n => (n.Vat ?? 0)*(n.Quantity ?? 0));



            mainOrderSummary.GrossAmount = (lineitems.Sum(n => (n.Value ?? 0) * (n.Quantity ?? 0)).GetTruncatedValue() +
                                           mainOrderSummary.TotalVat.GetTruncatedValue()).GetTotalGross();

            //mainOrderSummary.GrossAmount = lineitems.Sum(n => DiscountProWorkflow.GetTruncatedValue((n.Value ?? 0) * (n.Quantity ?? 0))) +
            //                               mainOrderSummary.TotalVat;

            mainOrderSummary.OrderReference = tblDocument.DocumentReference;

            mainOrderSummary.Required = tblDocument.OrderDateRequired != null
                                            ? tblDocument.OrderDateRequired.Value
                                            : DateTime.Now;

            decimal salediscount = tblDocument.SaleDiscount.HasValue ? tblDocument.SaleDiscount.Value : 0;
            mainOrderSummary.SaleDiscount = salediscount;
            mainOrderSummary.NetAmount = (mainOrderSummary.GrossAmount) - mainOrderSummary.SaleDiscount;
            mainOrderSummary.Salesman = salesman;
            mainOrderSummary.ExternalRefNo = tblDocument.ExtDocumentReference ?? "";
            if (tblDocument.OrderIssuedOnBehalfOfCC != null)
                mainOrderSummary.OutletId = tblDocument.OrderIssuedOnBehalfOfCC.Value;
            if (calculateOutstanding)
            {
                var invoiceList = (from d in _ctx.tblDocument
                    where d.DocumentTypeId == (int) DocumentType.Invoice
                    where d.InvoiceOrderId == tblDocument.Id
                    from l in d.tblLineItems
                    select new {l.Quantity, l.Value, l.Vat}).ToList();

                var invoiceAmount =invoiceList.Sum(x => ((x.Quantity.Value * x.Value.Value) + (x.Vat.Value * x.Quantity.GetValueOrDefault(0))).GetTruncatedValue()).GetTotalGross();
                //var invoiceAmount = (decimal?) (from d in _ctx.tblDocument
                //                                where d.DocumentTypeId == (int) DocumentType.Invoice
                //                                where d.InvoiceOrderId == tblDocument.Id
                //                                from l in d.tblLineItems
                //                                select new {l.Quantity, l.Value, l.Vat})
                //                                   .Sum(x => (x.Quantity*x.Value) + (x.Vat*x.Quantity)) ?? 0;

                var receiptAmount = (decimal?) (from d in _ctx.tblDocument
                                                where d.DocumentTypeId == (int) DocumentType.Receipt
                                                where d.DocumentParentId == tblDocument.Id
                                                from l in d.tblLineItems
                                                select new {l.Value})
                                                   .Sum(x => x.Value) ?? 0;
                var creditNoteSum = (decimal?) (from d in _ctx.tblDocument
                                                where d.DocumentTypeId == (int) DocumentType.CreditNote
                                                where d.DocumentParentId == tblDocument.Id
                                                from l in d.tblLineItems
                                                select new {l.Quantity, l.Value, l.Vat})
                                                   .Sum(x => (x.Quantity*x.Value) + (x.Vat*x.Quantity)) ?? 0;

                decimal totalInvoiceAmount =(invoiceAmount - salediscount).GetTotalGross();
                decimal totalPaidAmount = (receiptAmount + creditNoteSum);
                decimal outstandingAmount = totalInvoiceAmount - totalPaidAmount;
                mainOrderSummary.OutstandingAmount = outstandingAmount>0?outstandingAmount:0;
                mainOrderSummary.PaidAmount = receiptAmount;

            }
            return mainOrderSummary;


        }
        private string GetPaymentReference(tblDocument doc, string append)
        {
            var returnValue = string.Empty;
            var counter = string.Empty;
            if (doc.OrderIssuedOnBehalfOfCC != null && doc.OrderIssuedOnBehalfOfCC != Guid.Empty)
            {
                var costcenter = _ctx.tblCostCentre.FirstOrDefault(p => p.Id == doc.OrderIssuedOnBehalfOfCC);

                if (costcenter != null)
                {
                    counter = doc.ExtDocumentReference;
                    var routeId = costcenter.RouteId;
                    if (routeId != null)
                    {
                        var routeName = _routeRepository.GetById((Guid)routeId).Name;
                        returnValue = routeName;
                    }

                }
            }
            return returnValue + append + counter;
        }
Exemplo n.º 23
0
 private Order Map(tblDocument tblDoc)
 {
     var o = new Order(tblDoc.Id);
     _Map(tblDoc, o);
     o.DateRequired = tblDoc.OrderDateRequired.Value;
     o.IssuedOnBehalfOf = _costCentreRepository.GetById(tblDoc.OrderIssuedOnBehalfOfCC.Value);
     o.OrderType = (OrderType)tblDoc.OrderOrderTypeId.Value;
     o.SaleDiscount = tblDoc.SaleDiscount.Value;
     o.Note = tblDoc.Note;
     //tblDoc.tblLineItems.Any();
     o._SetLineItems(tblDoc.tblLineItems.Select(s => MapOrderLineItem(s)).ToList());
     return o;
 }
Exemplo n.º 24
0
        private static void MapPaymentInfo(tblDocument tblMainOrder, MainOrder mo)
        {
            foreach (var paymentInfo in tblMainOrder.tblOrderPaymentInfo)
            {

                var item = new PaymentInfo
                               {
                                   Amount = paymentInfo.Amount,
                                   ConfirmedAmount = paymentInfo.ConfirmedAmount,
                                   Id = paymentInfo.Id,
                                   Description = paymentInfo.Description,
                                   IsConfirmed = paymentInfo.IsConfirmed.Value,
                                   IsProcessed = paymentInfo.IsProcessed.Value,
                                   MMoneyPaymentType = paymentInfo.MMoneyPaymentType,
                                   NotificationId = paymentInfo.NotificationId,
                                   PaymentModeUsed = (PaymentMode) paymentInfo.PaymentMode,
                                   PaymentRefId = paymentInfo.PaymentRefId,
                                   Bank = paymentInfo.BankCode,
                                   BankBranch = paymentInfo.BranchCode,
                                   DueDate = paymentInfo.ChequeDueDate
                               };
                if (paymentInfo.ChequeDueDate.HasValue)
                    paymentInfo.ChequeDueDate = paymentInfo.ChequeDueDate.Value;

                mo.AddPayment(item);
            }
        }
        string GetOrderNetValue(tblDocument order)
        {
            var lineitems =
                _ctx.tblLineItems.Where(
                    s => s.DocumentID == order.Id && s.LineItemStatusId != (int) MainOrderLineItemStatus.Removed).ToList
                    ();
            if (lineitems.Any())
            {
                var totalVat = lineitems.Sum(n => (n.Vat ?? 0)*(n.Quantity ?? 0));
                var grossAmount = lineitems.Sum(n => (n.Value ?? 0)*(n.Quantity ?? 0)) + totalVat;
                decimal salediscount = order.SaleDiscount.HasValue ? order.SaleDiscount.Value : 0;

                return (grossAmount - salediscount).ToString("#0.00");
            }
            return "0.00";
        }
Exemplo n.º 26
0
        protected virtual decimal GetPaidAmount(tblDocument order)
        {
            decimal paidamount =
                _ctx.ExecuteStoreQuery<decimal>(string.Format(MainOrderResource.PaidAmount, order.Id)).FirstOrDefault();
            return paidamount;
            //decimal salediscount = order.SaleDiscount.HasValue ? order.SaleDiscount.Value : 0;
            //var invoiceAmount = (decimal?) (from d in _ctx.tblDocument
            //                                where d.DocumentTypeId == (int) DocumentType.Invoice
            //                                where d.InvoiceOrderId == order.Id
            //                                from l in d.tblLineItems
            //                                select new {l.Quantity, l.Value, l.Vat})
            //                                   .Sum(x => (x.Quantity*x.Value) + (x.Vat*x.Quantity)) ?? 0;

            //var receiptAmount = (decimal?) (from d in _ctx.tblDocument
            //                                where d.DocumentTypeId == (int) DocumentType.Receipt
            //                                where d.DocumentParentId == order.Id
            //                                from l in d.tblLineItems
            //                                select new {l.Value})
            //                                   .Sum(x => x.Value) ?? 0;
            //var creditNoteSum = (decimal?) (from d in _ctx.tblDocument
            //                                where d.DocumentTypeId == (int) DocumentType.CreditNote
            //                                where d.DocumentParentId == order.Id
            //                                from l in d.tblLineItems
            //                                select new {l.Quantity, l.Value, l.Vat})
            //                                   .Sum(x => (x.Quantity*x.Value) + (x.Vat*x.Quantity)) ?? 0;


            //decimal totalPaidAmount = (receiptAmount + creditNoteSum);
           // return totalPaidAmount;
        }
 string GetChequePayment(tblDocument order)
 {
     var payment =_ctx.tblOrderPaymentInfo.Where(p =>p.DocumentId==order.Id && p.PaymentMode == (int) PaymentMode.Cheque).ToList();
     
     if (payment.Any())
     {
         var tblOrderPaymentInfo = payment.FirstOrDefault();
         if (tblOrderPaymentInfo != null) return tblOrderPaymentInfo.PaymentRefId;
     }
     return string.Empty;
 }
Exemplo n.º 28
0
 private Invoice Map(tblDocument tblDoc)
 {
     var inv = PrivateConstruct<Invoice>(tblDoc.Id);
     _Map(tblDoc, inv);
     inv.OrderId = tblDoc.InvoiceOrderId.Value;
     inv.SaleDiscount = tblDoc.SaleDiscount.Value;
     inv._SetLineItems(tblDoc.tblLineItems.Select(n => MapInvoiceLineItem(n)).ToList());
     return inv;
 }
 string HandleSalesmanCode(tblDocument order)
 {
     var issuer = _costCentreRepository.GetById(order.DocumentIssuerCostCentreId);
     if (issuer is Distributor)
     {
         var costCentre = _ctx.tblCostCentre.FirstOrDefault(p => p.Id == order.DocumentRecipientCostCentre);
         if (costCentre != null)
             return costCentre.Cost_Centre_Code;
     }
     else
     {
         var costCentre = _ctx.tblCostCentre.FirstOrDefault(p => p.Id == order.DocumentIssuerCostCentreId);
         if (costCentre != null)
             return costCentre.Cost_Centre_Code;
     }
     return string.Empty;
 }