Esempio n. 1
0
        public SupplierApiMasterModel GetSupplierDetails(decimal businessId)
        {
            SupplierApiMasterModel          result               = new SupplierApiMasterModel();
            List <InvoiceSupplierModel>     SupplierInvoices     = SuppliersApiServices.Instance.getSupplierInvoices(businessId);
            List <TaxCodeModel>             TaxCodes             = SuppliersApiServices.Instance.getTaxCodes(businessId);
            List <TransectionSupplierModel> SupplierTransections = SuppliersApiServices.Instance.getSupplierTransections(businessId);
            List <Supplier>   suppliers   = SuppliersApiServices.Instance.getAllSuppliers(businessId);
            List <Attachment> attachments = CustomersApiServices.Instance.getAttachmentsByBusiness(businessId);

            result.Suppliers = new List <SupplierApiModel>();
            foreach (var item in suppliers.OrderBy(x => x.Name))
            {
                SupplierApiModel                supplierModel        = new SupplierApiModel();
                List <InvoiceSupplierModel>     supplierInvoices     = SupplierInvoices.Where(x => x.SupplierID == item.SupplierID).ToList();
                List <TransectionSupplierModel> supplierTransections = SupplierTransections.Where(x => x.SupplierID == item.SupplierID).ToList();
                supplierModel = SupplierHelper.getSupplierApiModel(supplierInvoices, supplierTransections, TaxCodes, item, attachments);
                result.Suppliers.Add(supplierModel);
            }
            result.TotalInvoices = result.Suppliers.Select(x => x.InvoiceCount).Sum();
            result.TotalAmount   = result.Suppliers.Select(x => x.AccountReceivable).Sum();
            return(result);
        }