示例#1
0
func createInvoice(venaplo util.NamedDbf) (schema.Szamla, error) {
	invoice := schema.Szamla{}

	header, err := createHeader(venaplo)
	if err != nil {
		return invoice, err
	}
	invoice.Fejlec = header

	additional, err := createAdditional(venaplo)
	if err != nil {
		return invoice, err
	}
	invoice.Nem_kotelezo = additional

	clause, err := createAdditionalClause(venaplo)
	if err != nil {
		return invoice, err
	}
	invoice.Zaradekok = &clause

	accountNumField, err := venaplo.FieldByName(FOLYOSZLSZ)
	if err != nil {
		return invoice, err
	}
	invoice.Folyoszamlaszam = int(accountNumField.(int64))

	return invoice, err
}
示例#2
0
func createAdditionalClause(venaplo util.NamedDbf) (schema.Zaradekok, error) {
	clause := schema.Zaradekok{}

	zaradek, err := venaplo.FieldByName(ZARADEK)
	if err != nil {
		return clause, err
	}

	zaradekInt := zaradek.(int)

	clause.Penzforgelsz = (zaradekInt == 3)
	clause.Onszamla = (zaradekInt == 2)
	clause.Ford_ado = (zaradekInt == 5)
	switch zaradekInt {
	case 5:
		clause.Kulonb_szer_szab = 1
		break
	case 6:
		clause.Kulonb_szer_szab = 2
		break
	case 7:
		clause.Kulonb_szer_szab = 3
		break
	case 8:
		clause.Kulonb_szer_szab = 4
		break
	}

	return clause, nil
}
示例#3
0
func createHeader(venaplo util.NamedDbf) (schema.Fejlec, error) {
	header := schema.Fejlec{}

	invoiceNum, err := venaplo.FieldByName(SZAMLASZAM)
	if err != nil {
		return header, err
	}
	header.Szlasorszam = strings.Trim(invoiceNum.(string), util.Whitespace)

	dateline, err := venaplo.FieldByName(SZAMLAKELT)
	if err != nil {
		return header, err
	}
	dl := dateline.(time.Time)
	header.Szladatum = schema.Datum{&dl}

	date, err := venaplo.FieldByName(DATUM)
	if err != nil {
		return header, err
	}
	d := date.(time.Time)
	header.Teljdatum = schema.Datum{&d}

	st, err := venaplo.FieldByName(FIZMODJA)
	if err != nil {
		return header, err
	}
	header.Szlatipus = 1
	if st.(int64) == 6 {
		header.Szlatipus = 4
	}

	return header, nil
}
示例#4
0
func GetVendor(cegadat util.NamedDbf) (schema.Szamlakibocsato, error) {
	vendor := schema.Szamlakibocsato{}

	taxNumber, err := cegadat.FieldByName(EUADOSZAM)
	if err != nil {
		return vendor, err
	}
	vendor.Adoszam = strings.Trim(taxNumber.(string), util.Whitespace)

	additional_clause, err := cegadat.FieldByName(ZARADEK)
	if err != nil {
		return vendor, err
	}
	vendor.Kisadozo = (additional_clause.(int64) == 4)

	name, err := cegadat.FieldByName(NEV)
	if err != nil {
		return vendor, err
	}
	vendor.Nev = strings.Trim(name.(string), util.Whitespace)

	address, err := getVendorAddress(cegadat)
	if err != nil {
		return vendor, err
	}
	vendor.Cim = address

	vendor.Egyeni_vallalkozo = false

	return vendor, nil
}
示例#5
0
func createCustomer(an311 util.NamedDbf) (schema.Vevo, int, error) {
	customer := schema.Vevo{}

	accountNumField, err := an311.FieldByName(FOLYOSZLSZ)
	if err != nil {
		return customer, 0, err
	}
	accountNum := int(accountNumField.(int64))

	nameField, err := an311.FieldByName(NEV)
	if err != nil {
		return customer, accountNum, err
	}
	customer.Nev = strings.Trim(nameField.(string), util.Whitespace)

	name2Field, err := an311.FieldByName(NEV2)
	if err != nil {
		return customer, accountNum, err
	}
	if name2Field.(string) != "" {
		customer.Nev += " " + strings.Trim(name2Field.(string), util.Whitespace)
	}

	customer.Cim, err = getCustomerAddress(an311)
	if err != nil {
		return customer, accountNum, err
	}

	return customer, accountNum, nil
}
示例#6
0
func createAdditional(venaplo util.NamedDbf) (schema.Nem_kotelezo, error) {
	additional := schema.Nem_kotelezo{}

	paymentMethod, err := venaplo.FieldByName(FIZMODJA)
	if err != nil {
		return additional, err
	}

	switch paymentMethod.(int64) {
	case 1:
		additional.Fiz_mod = "Átutalás"
		break
	case 2:
		additional.Fiz_mod = "Készpénz"
		break
	case 3:
		additional.Fiz_mod = "Utalvány"
		break
	case 4:
		additional.Fiz_mod = "Csekk"
		break
	case 5:
		additional.Fiz_mod = "Inkasszó"
		break
	case 6:
		additional.Fiz_mod = "Storno"
		break
	case 7:
		additional.Fiz_mod = "Bankkártya"
		break
	}

	prompt, err := venaplo.FieldByName(FIZHATIDO)
	if err != nil {
		return additional, err
	}
	p := prompt.(time.Time)
	additional.Fiz_hatarido = schema.Datum{&p}

	currency, err := venaplo.FieldByName(DEVNEM)
	if err != nil {
		return additional, err
	}
	additional.Penznem = currency.(string)

	return additional, nil
}
示例#7
0
func getVendorAddress(cegadat util.NamedDbf) (schema.Cim, error) {
	address := schema.Cim{}

	postcode, err := cegadat.FieldByName(IRSZAM)
	if err != nil {
		return address, err
	}
	address.Iranyitoszam = strings.Trim(postcode.(string), util.Whitespace)

	town, err := cegadat.FieldByName(TELEPULES)
	if err != nil {
		return address, err
	}
	address.Telepules = strings.Trim(town.(string), util.Whitespace)

	thoroughfareName, err := cegadat.FieldByName(KOZTERULET)
	if err != nil {
		return address, err
	}
	address.Kozterulet_neve = strings.Trim(thoroughfareName.(string), util.Whitespace)

	thoroughfareType, err := cegadat.FieldByName(JELLEG)
	if err != nil {
		return address, err
	}
	address.Kozterulet_jellege = strings.Trim(thoroughfareType.(string), util.Whitespace)

	houseNumber, err := cegadat.FieldByName(HAZSZAM)
	if err != nil {
		return address, err
	}
	address.Hazszam = strings.Trim(houseNumber.(string), util.Whitespace)

	building, err := cegadat.FieldByName(EPULET)
	if err != nil {
		return address, err
	}
	address.Epulet = strings.Trim(building.(string), util.Whitespace)

	staircase, err := cegadat.FieldByName(LEPCSO)
	if err != nil {
		return address, err
	}
	address.Lepcsohaz = strings.Trim(staircase.(string), util.Whitespace)

	floor, err := cegadat.FieldByName(EMELET)
	if err != nil {
		return address, err
	}
	address.Szint = strings.Trim(floor.(string), util.Whitespace)

	doorNumber, err := cegadat.FieldByName(AJTO)
	if err != nil {
		return address, err
	}
	address.Ajto = strings.Trim(doorNumber.(string), util.Whitespace)

	return address, nil
}
示例#8
0
func getCustomerAddress(an311 util.NamedDbf) (schema.Cim, error) {
	address := schema.Cim{}

	postcode, err := an311.FieldByName(IRSZAM)
	if err != nil {
		return address, err
	}
	address.Iranyitoszam = strings.Trim(postcode.(string), util.Whitespace)

	town, err := an311.FieldByName(TELEPULES)
	if err != nil {
		return address, err
	}
	address.Telepules = strings.Trim(town.(string), util.Whitespace)

	thoroughfareName, err := an311.FieldByName(KOZTERULET)
	if err != nil {
		return address, err
	}
	if s, ok := thoroughfareName.(string); ok {
		address.Kozterulet_neve = strings.Trim(s, util.Whitespace)
	}

	thoroughfareType, err := an311.FieldByName(JELLEG)
	if err != nil {
		return address, err
	}
	if s, ok := thoroughfareType.(string); ok {
		address.Kozterulet_jellege = strings.Trim(s, util.Whitespace)
	}

	houseNumber, err := an311.FieldByName(HAZSZAM)
	if err != nil {
		return address, err
	}
	if s, ok := houseNumber.(string); ok {
		address.Hazszam = strings.Trim(s, util.Whitespace)
	}

	building, err := an311.FieldByName(EPULET)
	if err != nil {
		return address, err
	}
	if s, ok := building.(string); ok {
		address.Epulet = strings.Trim(s, util.Whitespace)
	}

	staircase, err := an311.FieldByName(LEPCSO)
	if err != nil {
		return address, err
	}
	if s, ok := staircase.(string); ok {
		address.Lepcsohaz = strings.Trim(s, util.Whitespace)
	}

	floor, err := an311.FieldByName(EMELET)
	if err != nil {
		return address, err
	}
	if s, ok := floor.(string); ok {
		address.Szint = strings.Trim(s, util.Whitespace)
	}

	doorNumber, err := an311.FieldByName(AJTO)
	if err != nil {
		return address, err
	}
	if s, ok := doorNumber.(string); ok {
		address.Ajto = strings.Trim(s, util.Whitespace)
	}

	return address, nil
}