From 814a977d1ea7a5fc62c27e5fbf229cb8a7577ff5 Mon Sep 17 00:00:00 2001 From: Rafal Lyzwa Date: Mon, 4 Dec 2023 13:18:58 +0100 Subject: [PATCH] improve party validation for PL regime --- regimes/pl/invoices.go | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/regimes/pl/invoices.go b/regimes/pl/invoices.go index e123d027..c875510f 100644 --- a/regimes/pl/invoices.go +++ b/regimes/pl/invoices.go @@ -29,8 +29,7 @@ func (v *invoiceValidator) validate() error { // Rectification state determined by Preceding value. validation.Field(&inv.Type, validation.In( bill.InvoiceTypeStandard, - bill.InvoiceTypeCorrective, - bill.InvoiceTypeProforma, + // bill.InvoiceTypeCorrective, )), // validation.Field(&inv.Preceding, // validation.Each(validation.By(v.preceding)), @@ -60,7 +59,18 @@ func (v *invoiceValidator) supplier(value interface{}) error { tax.RequireIdentityCode, validation.By(validatePolishTaxIdentity), ), - // TODO check if name exists + validation.Field(&obj.Name, + validation.When( + len(obj.People) == 0, + validation.Required, + ), + ), + validation.Field(&obj.People[0].Name, + validation.When( + obj.Name == "", + validation.Required, + ), + ), ) } @@ -80,7 +90,18 @@ func (v *invoiceValidator) commercialCustomer(value interface{}) error { obj.TaxID.Country.In(l10n.PL), validation.By(validatePolishTaxIdentity), ), // TODO check if id is valid when other entity - // TODO check if name exists + ), + validation.Field(&obj.Name, + validation.When( + len(obj.People) == 0, + validation.Required, + ), + ), + validation.Field(&obj.People[0].Name, + validation.When( + obj.Name == "", + validation.Required, + ), ), ) }