Exemplo n.º 1
0
func ReadVenaplo(venaploFile string, invoices schema.Szamlak) (schema.Szamlak, error) {
	dbfFile, err := dbf.OpenFile(util.GetDbfFile(venaploFile), new(dbf.Win1250Decoder))
	if err != nil {
		return invoices, err
	}
	defer dbfFile.Close()

	for i := uint32(0); i < dbfFile.NumRecords(); i++ {
		err := dbfFile.GoTo(i)
		if err != nil {
			return invoices, err
		}
		deleted, err := dbfFile.Deleted()
		if err != nil {
			return invoices, err
		}
		if deleted {
			continue
		}

		invoice, err := createInvoice(util.NewNamedDbf(dbfFile))
		if err != nil {
			return invoices, err
		}
		invoices.Szamla = append(invoices.Szamla, invoice)
	}

	return invoices, nil
}
Exemplo n.º 2
0
func ReadAn311(an311File string) (map[int]schema.Vevo, error) {
	customersByNum := map[int]schema.Vevo{}

	dbfFile, err := dbf.OpenFile(util.GetDbfFile(an311File), new(dbf.Win1250Decoder))
	if err != nil {
		return customersByNum, err
	}
	defer dbfFile.Close()

	for i := uint32(0); i < dbfFile.NumRecords(); i++ {
		err := dbfFile.GoTo(i)
		if err != nil {
			return customersByNum, err
		}
		deleted, err := dbfFile.Deleted()
		if err != nil {
			return customersByNum, err
		}
		if deleted {
			continue
		}

		customer, accountNum, err := createCustomer(util.NewNamedDbf(dbfFile))
		if err != nil {
			return customersByNum, err
		}

		customersByNum[accountNum] = customer
	}

	return customersByNum, nil
}
Exemplo n.º 3
0
func ReadCegadat(cegadatFile string, invoices schema.Szamlak) (schema.Szamlak, error) {
	dbfFile, err := dbf.OpenFile(util.GetDbfFile(cegadatFile), new(dbf.Win1250Decoder))
	if err != nil {
		return invoices, err
	}
	defer dbfFile.Close()

	err = dbfFile.GoTo(0)
	if err != nil {
		return invoices, err
	}
	deleted, err := dbfFile.Deleted()
	if err != nil {
		return invoices, err
	}
	if deleted {
		return invoices, errors.New("First data row of cegadat.dbf is deleted.")
	}

	return AddVendor(util.NewNamedDbf(dbfFile), invoices)
}