Beispiel #1
0
        public string SubmitInvoice(SupplierInvoiceSubmissionDTO entity)
        {
            //Save the submission and get ID to save invoice
            ITS_Submission subObj = new ITS_Submission();

            subObj = FindByPO(entity.POID);

            var submission = SaveSubmission(subObj, entity);

            //Save invoice

            var invoiceID = invService.SaveInvoices(entity, submission.ID);

            //Update PO to pending payment and due amount.
            ITS_PurchaseOrder poObj = new ITS_PurchaseOrder();

            poObj = orderService.Get(entity.POID);

            orderService.UpdatePO(poObj);

            if (entity.FileUploadType == "") //Check if we are saving for file upload or saving permanantly
            {
                //Finally updated the submission number
                UpdateSubmissionNumber(submission);

                return(submission.SubmissionNumber);
            }
            else
            {
                return(Convert.ToString(invoiceID));
            }
        }
Beispiel #2
0
 public bool ValidEntity(SupplierInvoiceSubmissionDTO entity)
 {
     if (entity.InvoiceDate == Convert.ToDateTime("0001/01/01 12:00:00 AM"))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Beispiel #3
0
        public SupplierInvoiceSubmissionDTO MapDTO(ITS_PurchaseOrder PO)
        {
            System.Globalization.CultureInfo ITSCulture = System.Globalization.CultureInfo.CurrentUICulture;

            string DateFormat = ITSCulture.DateTimeFormat.ShortDatePattern;

            List <ITS_InvoiceCategories> lstCategories = new List <ITS_InvoiceCategories>();

            lstCategories = invCatService.GetAll();

            var Categories = new InvoiceCategoriesCountDTO(invCatService.GetAll());

            List <ITS_POTypeDocTypeLink> obj = potypeService.LinkedDocuments(PO.POTypeID);

            PODocumentTypeDTO        objDocTypeDTO = new PODocumentTypeDTO();
            List <PODocumentTypeDTO> lst           = new List <PODocumentTypeDTO>();

            if (obj != null)
            {
                for (int i = 0; i < obj.Count(); i++)
                {
                    lst.Add(new PODocumentTypeDTO()
                    {
                        DocTypeID = obj[i].DocumentTypeID,
                        DocType   = obj[i].ITS_DocumentType.DocumentType,
                        Mandatory = Convert.ToString(obj[i].MandatoryYN)
                    });
                }
            }

            SupplierInvoiceSubmissionDTO sisDTO = new SupplierInvoiceSubmissionDTO();

            sisDTO.POID      = PO.ID;
            sisDTO.POStatus  = PO.Status;
            sisDTO.PONumber  = PO.PONumber;
            sisDTO.POAmount  = PO.POAmount;
            sisDTO.PODate    = PO.DateCreated.ToString(DateFormat);
            sisDTO.DueAmount = PO.PODueAmount;

            sisDTO.Name       = PO.ITS_Supplier.Name;
            sisDTO.CSDNumber  = PO.ITS_Supplier.CSDNumber;
            sisDTO.VendorCode = PO.ITS_Supplier.VendorCode;

            sisDTO.LinkedDocs = lst;
            if (Categories.Categories.Count != 0)
            {
                sisDTO.InvoiceCat = Categories.Categories;
            }

            // sisDTO.UploadedDocs = lstUpload;

            return(sisDTO);
        }
Beispiel #4
0
        private ITS_Submission SaveSubmission(ITS_Submission submission, SupplierInvoiceSubmissionDTO entity)
        {
            ITS_Submission obj = new ITS_Submission();


            var supplier = suppService.FindByPO(entity.PONumber);

            if (submission != null)
            {
                //Base class and
                //obj = Get(_SubmissionID);
                submission.DateUpdated = System.DateTime.Now;
                submission.UserUpdated = 1;

                submission = Update(submission);
            }
            else
            {
                obj.SubmissionNumber = "";
                obj.PurchaseOrderID  = entity.POID;
                obj.SupplierID       = supplier.ID;
                obj.Status           = EnumService.SubmissionStatus.Saved.ToString();
                obj.PONumber         = entity.PONumber;
                obj.POAmount         = entity.POAmount;
                obj.DateCreated      = System.DateTime.Now;
                obj.UserCreated      = "Bongani"; //Get user from session
                obj.UserUpdated      = 1;         //Get user from session
                obj.DateUpdated      = System.DateTime.Now;



                try
                {
                    submission = Add(obj);
                    SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }


            return(submission);
        }
        public IHttpActionResult Post([FromBody] SupplierInvoiceSubmissionDTO entity)
        {
            string subNumber;

            if (svr.ValidEntity(entity) == true)
            {
                if (svr.InvoiceNumberUnique(entity.InvoiceNumber, entity.VendorCode) == true)
                {
                    try
                    {
                        subNumber = svr.SubmitInvoice(entity);
                        return(Ok(subNumber));
                    }
                    catch (Exception ex)
                    {
                        string ContentMessage = helper.ExceptionHelper(ex);

                        HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                        httpResponseMessage.Content = new StringContent(ContentMessage);
                        throw new HttpResponseException(httpResponseMessage);
                    }
                }
                else
                {
                    string ContentMessage = "Invoice number *" + entity.InvoiceNumber + " already been used.";

                    HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                    httpResponseMessage.Content = new StringContent(ContentMessage);
                    throw new HttpResponseException(httpResponseMessage);
                }
            }
            else
            {
                HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                httpResponseMessage.Content = new StringContent("Invalid Entity");
                throw new HttpResponseException(httpResponseMessage);
            }
        }
Beispiel #6
0
        public int  SaveInvoices(SupplierInvoiceSubmissionDTO entity, int submissionid)
        {
            ITS_SupplierInvoice invoice = new ITS_SupplierInvoice();


            invoice.SubmissionID  = submissionid;
            invoice.Status        = EnumService.SubmissionStatus.Saved.ToString();
            invoice.InvoiceNumber = entity.InvoiceNumber;
            invoice.InvoiceAmount = entity.InvoiceAmount;
            invoice.InvoiceDate   = Convert.ToDateTime(entity.InvoiceDate);
            invoice.Description   = entity.Description;
            invoice.DateCreated   = System.DateTime.Now;
            invoice.UserCreated   = "Bongani"; //Get user from session
            invoice.UserUpdated   = 1;         //Get UserID
            invoice.DateUpdated   = System.DateTime.Now;


            var subInvoice = Add(invoice);

            SaveChanges();

            return(subInvoice.ID);
        }