public static Document Create(IRawView receivable, ulong documentId, Company company, DocumentType type) { return new Document() { Company = company, Number = documentId, Reference = receivable.Reference, Type = type, Amount = decimal.Parse(receivable.Amount, Culture), Currency = receivable.Currency, PoundAmount = decimal.Parse(receivable.PoundAmount, Culture) }; }
public static Payables Create(List<RawPayable> rawPayable) { var payables = new Payables(); for (int index = 0; index < rawPayable.Count; index++) { if (rawPayable[index].Col1.Contains(Vendor) && rawPayable[index].Col5 != "*") { var vendor = new Company(); var j = index; var vendorId = ulong.Parse(rawPayable[index].Col5.Trim()); vendor.CompanyId = vendorId; vendor.Code = int.Parse(rawPayable[++j].Col5.Trim()); j = j + 2; vendor.Name = rawPayable[j].Col5.Trim(); for (; j < rawPayable.Count; j++) { if (rawPayable[j].Col1.Contains(Vendor)) { index = j - 1; break; } ulong documentId; if (ulong.TryParse(rawPayable[j].Col5, out documentId)) { var type = rawPayable[j].Type.ParseType(DocumentType.Purchase); var document = DocumentFactory.Create(rawPayable[j], documentId, vendor, type); if(payables.Duplicates.ContainsKey(documentId)) { payables.Duplicates[documentId].Add(document); } else if(payables.Documents.ContainsKey(documentId)) { payables.Duplicates.Add( documentId, new List<Document>() { payables.Documents[documentId], document }); payables.Documents.Remove(documentId); } else { payables.Documents.Add(documentId, document); } } index = j + 1; } payables.Vendors.Add(vendor); } } return payables; }
public static Receivables Create(List<RawReceivable> rawReceivables) { var receivables = new Receivables(); for (int index = 0; index < rawReceivables.Count; index++) { if (rawReceivables[index].Col1.Contains(Customer) && rawReceivables[index].Col5 != "*") { var customer = new Company(); var j = index; var customerId = ulong.Parse(rawReceivables[index].Col5.Trim()); customer.CompanyId = customerId; customer.Code = int.Parse(rawReceivables[++j].Col5.Trim()); j = j + 2; customer.Name = rawReceivables[j].Col5.Trim(); for (; j < rawReceivables.Count; j++) { if (rawReceivables[j].Col1.Contains(Customer)) { index = j - 1; break; } ulong documentId; if (ulong.TryParse(rawReceivables[j].Col6, out documentId)) { var type = rawReceivables[j].Type.ParseType(DocumentType.Sale); var document = DocumentFactory.Create(rawReceivables[j], documentId, customer, type); if (receivables.Duplicates.ContainsKey(documentId)) { receivables.Duplicates[documentId].Add(document); } else if (receivables.Documents.ContainsKey(documentId)) { receivables.Duplicates.Add( documentId, new List<Document>() { receivables.Documents[documentId], document }); receivables.Documents.Remove(documentId); } else { receivables.Documents.Add(documentId, document); } } index = j + 1; } receivables.Customers.Add(customer); } } return receivables; }