Compare commits
No commits in common. "32fdab42170c7324191f61afe3b98869c2fca423" and "b3004486f085f9570f62a73d6684f330e9fe0c78" have entirely different histories.
32fdab4217
...
b3004486f0
|
@ -264,12 +264,11 @@ func (form *invoiceForm) Validate() bool {
|
||||||
func (form *invoiceForm) Update() {
|
func (form *invoiceForm) Update() {
|
||||||
products := form.Products
|
products := form.Products
|
||||||
form.Products = nil
|
form.Products = nil
|
||||||
for n, product := range products {
|
index := 0
|
||||||
|
for _, product := range products {
|
||||||
if product.Quantity.Val != "0" {
|
if product.Quantity.Val != "0" {
|
||||||
if n != len(form.Products) {
|
|
||||||
product.Reindex(len(form.Products))
|
|
||||||
}
|
|
||||||
form.Products = append(form.Products, product)
|
form.Products = append(form.Products, product)
|
||||||
|
index++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,24 +290,29 @@ type invoiceProductForm struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInvoiceProductForm(index int, company *Company, locale *Locale, taxOptions []*SelectOption) *invoiceProductForm {
|
func newInvoiceProductForm(index int, company *Company, locale *Locale, taxOptions []*SelectOption) *invoiceProductForm {
|
||||||
form := &invoiceProductForm{
|
suffix := "." + strconv.Itoa(index)
|
||||||
|
return &invoiceProductForm{
|
||||||
locale: locale,
|
locale: locale,
|
||||||
company: company,
|
company: company,
|
||||||
ProductId: &InputField{
|
ProductId: &InputField{
|
||||||
|
Name: "product.id" + suffix,
|
||||||
Label: pgettext("input", "Id", locale),
|
Label: pgettext("input", "Id", locale),
|
||||||
Type: "hidden",
|
Type: "hidden",
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
Name: &InputField{
|
Name: &InputField{
|
||||||
|
Name: "product.name" + suffix,
|
||||||
Label: pgettext("input", "Name", locale),
|
Label: pgettext("input", "Name", locale),
|
||||||
Type: "text",
|
Type: "text",
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
Description: &InputField{
|
Description: &InputField{
|
||||||
|
Name: "product.description" + suffix,
|
||||||
Label: pgettext("input", "Description", locale),
|
Label: pgettext("input", "Description", locale),
|
||||||
Type: "textarea",
|
Type: "textarea",
|
||||||
},
|
},
|
||||||
Price: &InputField{
|
Price: &InputField{
|
||||||
|
Name: "product.price" + suffix,
|
||||||
Label: pgettext("input", "Price", locale),
|
Label: pgettext("input", "Price", locale),
|
||||||
Type: "number",
|
Type: "number",
|
||||||
Required: true,
|
Required: true,
|
||||||
|
@ -318,6 +322,7 @@ func newInvoiceProductForm(index int, company *Company, locale *Locale, taxOptio
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Quantity: &InputField{
|
Quantity: &InputField{
|
||||||
|
Name: "product.quantity" + suffix,
|
||||||
Label: pgettext("input", "Quantity", locale),
|
Label: pgettext("input", "Quantity", locale),
|
||||||
Type: "number",
|
Type: "number",
|
||||||
Required: true,
|
Required: true,
|
||||||
|
@ -326,6 +331,7 @@ func newInvoiceProductForm(index int, company *Company, locale *Locale, taxOptio
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Discount: &InputField{
|
Discount: &InputField{
|
||||||
|
Name: "product.discount" + suffix,
|
||||||
Label: pgettext("input", "Discount (%)", locale),
|
Label: pgettext("input", "Discount (%)", locale),
|
||||||
Type: "number",
|
Type: "number",
|
||||||
Required: true,
|
Required: true,
|
||||||
|
@ -335,24 +341,12 @@ func newInvoiceProductForm(index int, company *Company, locale *Locale, taxOptio
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Tax: &SelectField{
|
Tax: &SelectField{
|
||||||
|
Name: "product.tax" + suffix,
|
||||||
Label: pgettext("input", "Taxes", locale),
|
Label: pgettext("input", "Taxes", locale),
|
||||||
Multiple: true,
|
Multiple: true,
|
||||||
Options: taxOptions,
|
Options: taxOptions,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
form.Reindex(index)
|
|
||||||
return form
|
|
||||||
}
|
|
||||||
|
|
||||||
func (form *invoiceProductForm) Reindex(index int) {
|
|
||||||
suffix := "." + strconv.Itoa(index)
|
|
||||||
form.ProductId.Name = "product.id" + suffix
|
|
||||||
form.Name.Name = "product.name" + suffix
|
|
||||||
form.Description.Name = "product.description" + suffix
|
|
||||||
form.Price.Name = "product.price" + suffix
|
|
||||||
form.Quantity.Name = "product.quantity" + suffix
|
|
||||||
form.Discount.Name = "product.discount" + suffix
|
|
||||||
form.Tax.Name = "product.tax" + suffix
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (form *invoiceProductForm) Parse(r *http.Request) error {
|
func (form *invoiceProductForm) Parse(r *http.Request) error {
|
||||||
|
|
|
@ -494,16 +494,6 @@ main > nav {
|
||||||
margin-bottom: 4rem;
|
margin-bottom: 4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invoice */
|
|
||||||
.new-invoice-product .input:nth-of-type(5) {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.new-invoice-product textarea {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remix Icon */
|
/* Remix Icon */
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
|
|
|
@ -22,13 +22,13 @@
|
||||||
{{ template "input-field" .Notes }}
|
{{ template "input-field" .Notes }}
|
||||||
|
|
||||||
{{- range $product := .Products }}
|
{{- range $product := .Products }}
|
||||||
<fieldset class="new-invoice-product">
|
<fieldset>
|
||||||
{{ template "hidden-field" .ProductId }}
|
{{ template "hidden-field" .ProductId }}
|
||||||
{{ template "input-field" .Name }}
|
{{ template "input-field" .Name }}
|
||||||
|
{{ template "input-field" .Description }}
|
||||||
{{ template "input-field" .Price }}
|
{{ template "input-field" .Price }}
|
||||||
{{ template "input-field" .Quantity }}
|
{{ template "input-field" .Quantity }}
|
||||||
{{ template "input-field" .Discount }}
|
{{ template "input-field" .Discount }}
|
||||||
{{ template "input-field" .Description }}
|
|
||||||
{{ template "select-field" .Tax }}
|
{{ template "select-field" .Tax }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
Loading…
Reference in New Issue