vat.fold: check for errors in insert before updating checked_headers

This commit is contained in:
David Terry 2018-10-10 14:03:37 +03:00
parent 1273acb733
commit 95f1c94bf5

View File

@ -46,6 +46,10 @@ func (repository VatFoldRepository) Create(headerID int64, models []VatFoldModel
VALUES($1, $2, $3, $4::NUMERIC, $5, $6)`,
headerID, model.Ilk, model.Urn, model.Rate, model.TransactionIndex, model.Raw,
)
if err != nil {
tx.Rollback()
return err
}
_, err = tx.Exec(
`INSERT INTO public.checked_headers (header_id, vat_fold_checked)
VALUES($1, $2)