Overview
Comment:Invoice module: quotation's items recording strengthened
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | invoice_module
Files: files | file ages | folders
SHA3-256: 370877a7a0ed1d87c3449e634dca50661774f6558c89b6ea54ffa942db80f753
User & Date: alinaar on 2023-02-17 13:48:27
Other Links: branch diff | manifest | tags
Context
2023-02-17
15:23
Invoice module: Quotation details' view implemented check-in: 744cacc7c6 user: alinaar tags: invoice_module
13:48
Invoice module: quotation's items recording strengthened check-in: 370877a7a0 user: alinaar tags: invoice_module
2023-02-07
18:26
Invoice module: dynamic input generation fixed check-in: 1bc3bf31d5 user: alinaar tags: invoice_module
Changes

Modified src/skel-dist/modules/invoice/index.html from [bd9699e432] to [2efea338f7].

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

115
116
117
118
119
120
121
122
123
124
125
<h1>Création d'un devis</h1>

{{if $_POST.quotation_submit}}
	{{:assign computed_total=0}}
	{{:assign errors=null}}
	{{:assign items=null}}
	{{#foreach from=$_POST.items key='index' item='item'}}
		{{:assign var='computed_total' value="%d + %d * %d"|args:$computed_total:$item.unit_price:$item.quantity|math}}

		{{* ToDo: allow zero as unit_price (#d10fbfa243f3cdb8cdf68ac67f5043c199bd44e2) *}}
		
		{{if $item.unit_price < 0 || $item.unit_price != $item.unit_price|floatval|strtolower}} {{* Hack to check the data is a number *}}
			{{:assign var='errors[]' value='Le prix saisi pour "%s" est invalide.'|args:$item.name}}
		{{/if}}
		{{if $item.quantity < 0 || $item.quantity != $item.quantity|floatval|strtolower}}{{:assign var='errors[]' value='La quantité saisie pour "%s" est invalide.'|args:$item.name}}{{/if}}

		{{:assign var='computed_item' value=$item}}
		{{:assign var='computed_item[unit_price]' value=$item.unit_price|floatval}}
		{{:assign var='computed_item[quantity]' value=$item.quantity|floatval}}
		{{:assign var='items[]' value=$computed_item}}

	{{/foreach}}
	
	{{if $computed_total != $_POST.quotation_total || $computed_total < 0}}
		{{:assign error="Erreur de calcul du total.\nEnregistrement du devis refusé."}}
	{{/if}}

	{{if $errors|count}}
		{{#foreach from=$errors item='error'}}
			<p class="error block">{{$error}}</p>
		{{/foreach}}
	{{else}}







<
|
<
<







|

>

|
|
|







95
96
97
98
99
100
101

102


103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<h1>Création d'un devis</h1>

{{if $_POST.quotation_submit}}
	{{:assign computed_total=0}}
	{{:assign errors=null}}
	{{:assign items=null}}
	{{#foreach from=$_POST.items key='index' item='item'}}

		{{if $item.name === ''}}{{:assign var='errors[]' value="Le nom de l'article est requis."}}{{/if}}


		{{if $item.unit_price < 0 || $item.unit_price != $item.unit_price|floatval|strtolower}} {{* Hack to check the data is a number *}}
			{{:assign var='errors[]' value='Le prix saisi pour "%s" est invalide.'|args:$item.name}}
		{{/if}}
		{{if $item.quantity < 0 || $item.quantity != $item.quantity|floatval|strtolower}}{{:assign var='errors[]' value='La quantité saisie pour "%s" est invalide.'|args:$item.name}}{{/if}}

		{{:assign var='computed_item' value=$item}}
		{{:assign var='computed_item[unit_price]' value=$item.unit_price|floatval}}
		{{:assign var='computed_item[quantity]' value=$item.quantity|intval}}
		{{:assign var='items[]' value=$computed_item}}
		{{:assign var='computed_total' value="%d + %d * %d"|args:$computed_total:$item.unit_price:$item.quantity|math}}
	{{/foreach}}

	{{if ($computed_total != $_POST.quotation_total) || ($computed_total < 0)}}
		{{:assign var='errors[]' value='Erreur de calcul du total. Enregistrement du devis refusé.'}}
	{{/if}}

	{{if $errors|count}}
		{{#foreach from=$errors item='error'}}
			<p class="error block">{{$error}}</p>
		{{/foreach}}
	{{else}}
176
177
178
179
180
181
182

183
184
185
186
187
188
189
190
191
192
	</fieldset>
	<fieldset>
		<legend><h2>Liste des articles</h2></legend>
		<p id="item_list_no_item_message">Aucun article pour le moment.</p>
		<table id="item_list" style="display: none;">
			<tr>
				<th>Dénomination</th>

				<th>Prix unitaire</th>
				<th>Quantité</th>
				<th>Total</th>
			</tr>
		</table>
		<p>{{:linkbutton label="Ajouter un article" href="item_form.html" shape="settings" target="_dialog"}}</p>
		<h3>Total des articles</h3>
		<p>
			<span id="quotation_total">0 {{$config.currency|htmlspecialchars}}</span>
			<input type="hidden" name="quotation_total" id="quotation_total_input" label="" value="" />







>


<







174
175
176
177
178
179
180
181
182
183

184
185
186
187
188
189
190
	</fieldset>
	<fieldset>
		<legend><h2>Liste des articles</h2></legend>
		<p id="item_list_no_item_message">Aucun article pour le moment.</p>
		<table id="item_list" style="display: none;">
			<tr>
				<th>Dénomination</th>
				<th>Description</th>
				<th>Prix unitaire</th>
				<th>Quantité</th>

			</tr>
		</table>
		<p>{{:linkbutton label="Ajouter un article" href="item_form.html" shape="settings" target="_dialog"}}</p>
		<h3>Total des articles</h3>
		<p>
			<span id="quotation_total">0 {{$config.currency|htmlspecialchars}}</span>
			<input type="hidden" name="quotation_total" id="quotation_total_input" label="" value="" />

Modified src/skel-dist/modules/invoice/item_form.html from [92a5d026eb] to [2378fa76de].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
<form method="POST" action="" id="item_creation_form">
	<fieldset>
		<legend>Ajouter un article</legend>
		<ul>
			<li><label for="item_name">Dénomination</label><input type="text" name="item_name" id="item_name" label="" placeholder="ex : barnum" value="" /></li>
			<li><label for="item_description">Description</label><textarea name="item_description" id="item_description" label="" placeholder=""></textarea></li>
			<li><label for="item_unit_price">Prix unitaire</label><input type="text" name="item_unit_price" id="item_unit_price" label="" placeholder="" value="" /></li>
			<li><label for="item_quantity">Quantité</label><input type="text" name="item_quantity" id="item_quantity" label="" placeholder="" value="" /></li>
		</ul>
		<input type="button" name="" id="item_addition_button" onclick="add_item()" value="Ajouter l'article au devis" />
	</fieldset>
</form>

{{:admin_footer}}







|






51
52
53
54
55
56
57
58
59
60
61
62
63
64
<form method="POST" action="" id="item_creation_form">
	<fieldset>
		<legend>Ajouter un article</legend>
		<ul>
			<li><label for="item_name">Dénomination</label><input type="text" name="item_name" id="item_name" label="" placeholder="ex : barnum" value="" /></li>
			<li><label for="item_description">Description</label><textarea name="item_description" id="item_description" label="" placeholder=""></textarea></li>
			<li><label for="item_unit_price">Prix unitaire</label><input type="text" name="item_unit_price" id="item_unit_price" label="" placeholder="" value="" /></li>
			<li><label for="item_quantity">Quantité</label><input type="text" name="item_quantity" id="item_quantity" label="" placeholder="" value="1" /></li>
		</ul>
		<input type="button" name="" id="item_addition_button" onclick="add_item()" value="Ajouter l'article au devis" />
	</fieldset>
</form>

{{:admin_footer}}

Modified src/skel-dist/modules/invoice/quotation.schema.json from [d9ca3f4380] to [25734047f4].

25
26
27
28
29
30
31
32










33
34
35
36

37
38
39
40
41
42
43
44
		"status": {
			"description": "Statut",
			"type": "string",
			"enum": ["awaiting", "rejected", "validated", "misc"]
		},
		"items": {
			"description": "Articles",
			"type": ["array", "null"]










		},
		"total": {
			"description": "Total",
			"type": ["float", "integer"]

		},
		"contact_info": {
			"description": "Contact",
			"type": "string"
		}
	},
	"required": [ "recipient_business_name", "recipient_address", "subject", "date", "status", "contact_info" ]
}







|
>
>
>
>
>
>
>
>
>
>



|
>








25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
		"status": {
			"description": "Statut",
			"type": "string",
			"enum": ["awaiting", "rejected", "validated", "misc"]
		},
		"items": {
			"description": "Articles",
			"type": ["array", "null"],
			"items": {
				"type": "object",
				"properties": {
					"name": { "type": "string", "minLength": 1, "maxLength": 128 },
					"description": { "type": "string", "maxLength": 512 },
					"unit_price": { "type": "number", "minimum": 0 },
					"quantity": { "type": "integer", "minimum": 0 }
				},
				"required" : [ "name" ]
			}
		},
		"total": {
			"description": "Total",
			"type": ["number", "integer"],
			"minimum": 0
		},
		"contact_info": {
			"description": "Contact",
			"type": "string"
		}
	},
	"required": [ "recipient_business_name", "recipient_address", "subject", "date", "status", "contact_info" ]
}