public Document Parse(string file, Document document) { var data = Dbf.Load(file); document.ProviderDocumentId = data.Rows[0]["SERIA"].ToString(); document.DocumentDate = Convert.ToDateTime(data.Rows[0]["SROK_GOD"]); data.Rows.Remove(data.Rows[0]); var parcer = new DbfParser() .Line(l => l.Code, "CODE") .Line(l => l.Product, "TOVAR") .Line(l => l.Producer, "PROIZV") .Line(l => l.Country, "STRANA") .Line(l => l.Period, "SROK_GOD") .Line(l => l.Quantity, "KOLVO") .Line(l => l.ProducerCostWithoutNDS, "CENA_PRB") .Line(l => l.SupplierCostWithoutNDS, "CENA_POB") .Line(l => l.Nds, "ST_NDS") .Line(l => l.RegistryCost, "CENA_GRU") .Line(l => l.Certificates, "SER_NOM") .Line(l => l.SerialNumber, "SERIA") .Line(l => l.BillOfEntryNumber, "GTD") .Line(l => l.Amount, "SUM_SNDS") .Line(l => l.NdsAmount, "SUM_NDS") .Line(l => l.CertificatesDate, "SER_DATE") .Line(l => l.EAN13, "PRV_CODE"); if (data.Columns.Contains("VID")) { data.Rows.Cast <DataRow>().Each(r => { if (r["VID"].ToString() == "ЖВЛС") { r["VID"] = "True"; } else { r["VID"] = "False"; } }); parcer = parcer.Line(l => l.VitallyImportant, "VID"); } parcer.ToDocument(document, data); return(document); }
public override DbfParser GetParser() { var parcer = new DbfParser() .DocumentHeader(d => d.DocumentDate, "DATEDOC") .DocumentHeader(d => d.ProviderDocumentId, "NDOC") .Invoice(i => i.InvoiceNumber, "BILLNUM") .Invoice(i => i.InvoiceDate, "BILLDT") .Invoice(i => i.AmountWithoutNDS, "SUMPAY") .Invoice(i => i.AmountWithoutNDS10, "SUM10") .Invoice(i => i.AmountWithoutNDS18, "SUM20") .Invoice(i => i.AmountWithoutNDS0, "SUM0") .Invoice(i => i.Amount, "SUMPAY") .Line(l => l.Code, "CODEPST") .Line(l => l.Product, "NAME") .Line(l => l.Producer, "FIRM") .Line(l => l.Country, "CNTR") .Line(l => l.SupplierCostWithoutNDS, "PRICE2N") .Line(l => l.SupplierCost, "PRICE2") .Line(l => l.Quantity, "QNT") .Line(l => l.Nds, "NDS") .Line(l => l.Period, "GDATE") .Line(l => l.Certificates, "SERTIF") .Line(l => l.RegistryCost, "REGPRC") .Line(l => l.VitallyImportant, "GNVLS") .Line(l => l.SerialNumber, "SER") .Line(l => l.SupplierPriceMarkup, "PROCNDB") .Line(l => l.EAN13, "EAN13") .Line(l => l.CertificateAuthority, "SERTORG") .Line(l => l.CertificatesDate, "SERTGIVE", "SERTDATE") .Line(l => l.OrderId, "NUMZ") .Line(l => l.CountryCode, "cntrcode") .Line(l => l.UnitCode, "unitcode") .Line(l => l.BillOfEntryNumber, "NUMGTD"); if (Data.Columns.Contains("TSUMNDS")) { parcer = parcer.Invoice(i => i.NDSAmount, "TSUMNDS") .Invoice(i => i.NDSAmount10, "TSUMNDS10") .Invoice(i => i.NDSAmount18, "TSUMNDS20"); } else { parcer = parcer.Invoice(i => i.NDSAmount10, "SUMNDS10") .Invoice(i => i.NDSAmount18, "SUMNDS20"); } if (!Data.Columns.Contains("ADRPOL")) { if (!Data.Columns.Contains("PRICE1N") && !Data.Columns.Contains("PRICEMAN")) { parcer = parcer.Line(l => l.ProducerCostWithoutNDS, "MAKERPRICE", "PRICE1"); } else if (Data.Columns.Contains("PRICE1N")) { parcer = parcer.Line(l => l.ProducerCost, "PRICE1") .Line(l => l.ProducerCostWithoutNDS, "PRICE1N"); } else { parcer = parcer.Line(l => l.ProducerCost, "PRICE1") .Line(l => l.ProducerCostWithoutNDS, "PRICEMAN"); } if (Data.Columns.Contains("SUMMANDS")) { parcer .Line(l => l.NdsAmount, "SUMMANDS"); } else { parcer .Line(l => l.NdsAmount, "SUMSNDS") .Line(l => l.Amount, "SUMS0"); } } else { parcer = parcer.Line(l => l.ProducerCost, "PRICE1N") .Line(l => l.Amount, "SUMSNDS") .Line(l => l.ProducerCostWithoutNDS, "PRICE1"); } if (!Data.Columns.Contains("ADRPOL")) { if (Data.Columns.Contains("PRICEMAN")) { parcer = parcer.Invoice(i => i.RecipientId, "PODRCD"); } else { parcer = parcer.Invoice(i => i.RecipientAddress, "PODRCD"); } } else { parcer = parcer.Invoice(i => i.RecipientAddress, "ADRPOL"); } return(parcer); }