id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
30,400
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.setProperty
public function setProperty($property, $value) { if (property_exists($this, $property) && $property !== 'form') { $this->$property = $value; } return $this; }
php
public function setProperty($property, $value) { if (property_exists($this, $property) && $property !== 'form') { $this->$property = $value; } return $this; }
[ "public", "function", "setProperty", "(", "$", "property", ",", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "property", ")", "&&", "$", "property", "!==", "'form'", ")", "{", "$", "this", "->", "$", "property", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Sets the value of a property of this object. The property must exist as property @param string $property @param mixed $value @return $this
[ "Sets", "the", "value", "of", "a", "property", "of", "this", "object", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L171-L177
30,401
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderFields
protected function renderFields(array $fields) { $output = ''; foreach ($fields as $id => $field) { // Add defaults. $field += array( 'id' => $id, 'name' => $id, 'label' => '', 'value' => '', 'description' => '', 'attributes' => array(), 'options' => array(), ); $output .= $this->renderField($field); } return $output; }
php
protected function renderFields(array $fields) { $output = ''; foreach ($fields as $id => $field) { // Add defaults. $field += array( 'id' => $id, 'name' => $id, 'label' => '', 'value' => '', 'description' => '', 'attributes' => array(), 'options' => array(), ); $output .= $this->renderField($field); } return $output; }
[ "protected", "function", "renderFields", "(", "array", "$", "fields", ")", "{", "$", "output", "=", "''", ";", "foreach", "(", "$", "fields", "as", "$", "id", "=>", "$", "field", ")", "{", "// Add defaults.", "$", "field", "+=", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "$", "id", ",", "'label'", "=>", "''", ",", "'value'", "=>", "''", ",", "'description'", "=>", "''", ",", "'attributes'", "=>", "array", "(", ")", ",", "'options'", "=>", "array", "(", ")", ",", ")", ";", "$", "output", ".=", "$", "this", "->", "renderField", "(", "$", "field", ")", ";", "}", "return", "$", "output", ";", "}" ]
Renders a set of field definitions. @param array[] $fields @return string
[ "Renders", "a", "set", "of", "field", "definitions", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L204-L221
30,402
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderFieldset
protected function renderFieldset(array $field) { $output = ''; $output .= $this->fieldsetBegin($field); $output .= $this->renderFields($field['fields']); $output .= $this->fieldsetEnd($field); return $output; }
php
protected function renderFieldset(array $field) { $output = ''; $output .= $this->fieldsetBegin($field); $output .= $this->renderFields($field['fields']); $output .= $this->fieldsetEnd($field); return $output; }
[ "protected", "function", "renderFieldset", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "fieldsetBegin", "(", "$", "field", ")", ";", "$", "output", ".=", "$", "this", "->", "renderFields", "(", "$", "field", "[", "'fields'", "]", ")", ";", "$", "output", ".=", "$", "this", "->", "fieldsetEnd", "(", "$", "field", ")", ";", "return", "$", "output", ";", "}" ]
Renders a fieldset or details form element. @param array $field @return string The rendered fieldset or details form element.
[ "Renders", "a", "fieldset", "or", "details", "form", "element", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L248-L255
30,403
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.fieldsetBegin
protected function fieldsetBegin(array $field) { $output = ''; $output .= $this->getWrapper($field['type'], $field['attributes']); $titleTag = $field['type'] === 'fieldset' ? 'legend' : 'summary'; if (!empty($field[$titleTag])) { $output .= $this->getWrapper($titleTag, $field['attributes']); $output .= $field[$titleTag]; $output .= $this->getWrapperEnd($titleTag); } $output .= $this->getWrapper('fieldsetContent'); if (!empty($field['description'])) { $output .= $this->renderDescription($field['description'], true); } return $output; }
php
protected function fieldsetBegin(array $field) { $output = ''; $output .= $this->getWrapper($field['type'], $field['attributes']); $titleTag = $field['type'] === 'fieldset' ? 'legend' : 'summary'; if (!empty($field[$titleTag])) { $output .= $this->getWrapper($titleTag, $field['attributes']); $output .= $field[$titleTag]; $output .= $this->getWrapperEnd($titleTag); } $output .= $this->getWrapper('fieldsetContent'); if (!empty($field['description'])) { $output .= $this->renderDescription($field['description'], true); } return $output; }
[ "protected", "function", "fieldsetBegin", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "$", "field", "[", "'type'", "]", ",", "$", "field", "[", "'attributes'", "]", ")", ";", "$", "titleTag", "=", "$", "field", "[", "'type'", "]", "===", "'fieldset'", "?", "'legend'", ":", "'summary'", ";", "if", "(", "!", "empty", "(", "$", "field", "[", "$", "titleTag", "]", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "$", "titleTag", ",", "$", "field", "[", "'attributes'", "]", ")", ";", "$", "output", ".=", "$", "field", "[", "$", "titleTag", "]", ";", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "$", "titleTag", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'fieldsetContent'", ")", ";", "if", "(", "!", "empty", "(", "$", "field", "[", "'description'", "]", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "renderDescription", "(", "$", "field", "[", "'description'", "]", ",", "true", ")", ";", "}", "return", "$", "output", ";", "}" ]
Outputs the beginning of a fieldset. @param array $field @return string
[ "Outputs", "the", "beginning", "of", "a", "fieldset", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L264-L279
30,404
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.fieldsetEnd
protected function fieldsetEnd(array $field) { $output = ''; $output .= $this->getWrapperEnd('fieldsetContent'); $output .= $this->getWrapperEnd($field['type']); return $output; }
php
protected function fieldsetEnd(array $field) { $output = ''; $output .= $this->getWrapperEnd('fieldsetContent'); $output .= $this->getWrapperEnd($field['type']); return $output; }
[ "protected", "function", "fieldsetEnd", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'fieldsetContent'", ")", ";", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "$", "field", "[", "'type'", "]", ")", ";", "return", "$", "output", ";", "}" ]
Outputs the end of a fieldset. @param array $field @return string
[ "Outputs", "the", "end", "of", "a", "fieldset", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L288-L294
30,405
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderSimpleField
protected function renderSimpleField(array $field) { if (!empty($field['ajax'])) { $field = $this->addAjax($field); } $output = ''; // Split attributes over label and element. $attributes = $field['attributes']; $labelAttributes = array(); if (!empty($attributes['label'])) { $labelAttributes = $attributes['label']; unset($attributes['label']); } if (!empty($attributes['required'])) { $labelAttributes['required'] = $attributes['required']; } $field['attributes'] = $attributes; if ($field['type'] !== 'hidden') { $output .= $this->getWrapper('element'); // Do not use a <label> with an "id" attribute on the label for a // set of radio buttons, a set of checkboxes, or on markup. $id = in_array($field['type'], array('radio', 'checkbox', 'markup')) ? '' : $field['id']; $output .= $this->renderLabel($field['label'], $id, $labelAttributes, true); $output .= $this->getWrapper('inputDescription'); } $output .= $this->renderElement($field); if ($field['type'] !== 'hidden') { $output .= $this->renderDescription($field['description']); $output .= $this->getWrapperEnd('inputDescription'); $output .= $this->getWrapperEnd('element'); } return $output; }
php
protected function renderSimpleField(array $field) { if (!empty($field['ajax'])) { $field = $this->addAjax($field); } $output = ''; // Split attributes over label and element. $attributes = $field['attributes']; $labelAttributes = array(); if (!empty($attributes['label'])) { $labelAttributes = $attributes['label']; unset($attributes['label']); } if (!empty($attributes['required'])) { $labelAttributes['required'] = $attributes['required']; } $field['attributes'] = $attributes; if ($field['type'] !== 'hidden') { $output .= $this->getWrapper('element'); // Do not use a <label> with an "id" attribute on the label for a // set of radio buttons, a set of checkboxes, or on markup. $id = in_array($field['type'], array('radio', 'checkbox', 'markup')) ? '' : $field['id']; $output .= $this->renderLabel($field['label'], $id, $labelAttributes, true); $output .= $this->getWrapper('inputDescription'); } $output .= $this->renderElement($field); if ($field['type'] !== 'hidden') { $output .= $this->renderDescription($field['description']); $output .= $this->getWrapperEnd('inputDescription'); $output .= $this->getWrapperEnd('element'); } return $output; }
[ "protected", "function", "renderSimpleField", "(", "array", "$", "field", ")", "{", "if", "(", "!", "empty", "(", "$", "field", "[", "'ajax'", "]", ")", ")", "{", "$", "field", "=", "$", "this", "->", "addAjax", "(", "$", "field", ")", ";", "}", "$", "output", "=", "''", ";", "// Split attributes over label and element.", "$", "attributes", "=", "$", "field", "[", "'attributes'", "]", ";", "$", "labelAttributes", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "attributes", "[", "'label'", "]", ")", ")", "{", "$", "labelAttributes", "=", "$", "attributes", "[", "'label'", "]", ";", "unset", "(", "$", "attributes", "[", "'label'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "attributes", "[", "'required'", "]", ")", ")", "{", "$", "labelAttributes", "[", "'required'", "]", "=", "$", "attributes", "[", "'required'", "]", ";", "}", "$", "field", "[", "'attributes'", "]", "=", "$", "attributes", ";", "if", "(", "$", "field", "[", "'type'", "]", "!==", "'hidden'", ")", "{", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'element'", ")", ";", "// Do not use a <label> with an \"id\" attribute on the label for a", "// set of radio buttons, a set of checkboxes, or on markup.", "$", "id", "=", "in_array", "(", "$", "field", "[", "'type'", "]", ",", "array", "(", "'radio'", ",", "'checkbox'", ",", "'markup'", ")", ")", "?", "''", ":", "$", "field", "[", "'id'", "]", ";", "$", "output", ".=", "$", "this", "->", "renderLabel", "(", "$", "field", "[", "'label'", "]", ",", "$", "id", ",", "$", "labelAttributes", ",", "true", ")", ";", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'inputDescription'", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "renderElement", "(", "$", "field", ")", ";", "if", "(", "$", "field", "[", "'type'", "]", "!==", "'hidden'", ")", "{", "$", "output", ".=", "$", "this", "->", "renderDescription", "(", "$", "field", "[", "'description'", "]", ")", ";", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'inputDescription'", ")", ";", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'element'", ")", ";", "}", "return", "$", "output", ";", "}" ]
Renders a form field including its label and description. @param array $field @return string Html for this form field.
[ "Renders", "a", "form", "field", "including", "its", "label", "and", "description", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L304-L339
30,406
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderElement
protected function renderElement($field) { $type = $field['type']; switch ($type) { case 'textarea': case 'markup': case 'select': case 'radio': case 'checkbox': return $this->$type($field); default: return $this->input($field); } }
php
protected function renderElement($field) { $type = $field['type']; switch ($type) { case 'textarea': case 'markup': case 'select': case 'radio': case 'checkbox': return $this->$type($field); default: return $this->input($field); } }
[ "protected", "function", "renderElement", "(", "$", "field", ")", "{", "$", "type", "=", "$", "field", "[", "'type'", "]", ";", "switch", "(", "$", "type", ")", "{", "case", "'textarea'", ":", "case", "'markup'", ":", "case", "'select'", ":", "case", "'radio'", ":", "case", "'checkbox'", ":", "return", "$", "this", "->", "$", "type", "(", "$", "field", ")", ";", "default", ":", "return", "$", "this", "->", "input", "(", "$", "field", ")", ";", "}", "}" ]
Renders a form field itself, ie without label and description. @param $field @return string The html for the form element.
[ "Renders", "a", "form", "field", "itself", "ie", "without", "label", "and", "description", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L349-L362
30,407
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderDescription
protected function renderDescription($text, $isFieldset = false) { $output = ''; // Help text. if (!empty($text)) { // Allow for links in the help text, so no filtering anymore. $wrapperType = $isFieldset ? 'fieldsetDescription' : 'description'; $output .= $this->getWrapper($wrapperType); $output .= $text; $output .= $this->getWrapperEnd($wrapperType); } return $output; }
php
protected function renderDescription($text, $isFieldset = false) { $output = ''; // Help text. if (!empty($text)) { // Allow for links in the help text, so no filtering anymore. $wrapperType = $isFieldset ? 'fieldsetDescription' : 'description'; $output .= $this->getWrapper($wrapperType); $output .= $text; $output .= $this->getWrapperEnd($wrapperType); } return $output; }
[ "protected", "function", "renderDescription", "(", "$", "text", ",", "$", "isFieldset", "=", "false", ")", "{", "$", "output", "=", "''", ";", "// Help text.", "if", "(", "!", "empty", "(", "$", "text", ")", ")", "{", "// Allow for links in the help text, so no filtering anymore.", "$", "wrapperType", "=", "$", "isFieldset", "?", "'fieldsetDescription'", ":", "'description'", ";", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "$", "wrapperType", ")", ";", "$", "output", ".=", "$", "text", ";", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "$", "wrapperType", ")", ";", "}", "return", "$", "output", ";", "}" ]
Renders a descriptive help text. @param string $text @param bool $isFieldset @return string The rendered description.
[ "Renders", "a", "descriptive", "help", "text", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L373-L387
30,408
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderLabel
protected function renderLabel($text, $id, array $attributes, $wrapLabel, $prefix = '', $postfix = '') { $output = ''; // Split attributes over label and wrapper. $wrapperAttributes = array(); if (!empty($attributes['wrapper'])) { $wrapperAttributes = $attributes['wrapper']; unset($attributes['wrapper']); } if (!empty($attributes['required'])) { $wrapperAttributes['required'] = $attributes['required']; } // Tag around main labels. if ($wrapLabel) { $output .= $this->getWrapper('label', $wrapperAttributes); } // Label. $attributes = $this->addLabelAttributes($attributes, $id); $postfix .= !empty($attributes['required']) ? $this->requiredMarkup : ''; $tag = empty($id) ? $this->multiLabelTag : 'label'; $output .= $this->getOpenTag($tag, $attributes); $output .= $prefix . htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8') . $postfix; $output .= $this->getCloseTag($tag); // Tag around labels. if ($wrapLabel) { $output .= $this->getWrapperEnd('label'); } return $output; }
php
protected function renderLabel($text, $id, array $attributes, $wrapLabel, $prefix = '', $postfix = '') { $output = ''; // Split attributes over label and wrapper. $wrapperAttributes = array(); if (!empty($attributes['wrapper'])) { $wrapperAttributes = $attributes['wrapper']; unset($attributes['wrapper']); } if (!empty($attributes['required'])) { $wrapperAttributes['required'] = $attributes['required']; } // Tag around main labels. if ($wrapLabel) { $output .= $this->getWrapper('label', $wrapperAttributes); } // Label. $attributes = $this->addLabelAttributes($attributes, $id); $postfix .= !empty($attributes['required']) ? $this->requiredMarkup : ''; $tag = empty($id) ? $this->multiLabelTag : 'label'; $output .= $this->getOpenTag($tag, $attributes); $output .= $prefix . htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8') . $postfix; $output .= $this->getCloseTag($tag); // Tag around labels. if ($wrapLabel) { $output .= $this->getWrapperEnd('label'); } return $output; }
[ "protected", "function", "renderLabel", "(", "$", "text", ",", "$", "id", ",", "array", "$", "attributes", ",", "$", "wrapLabel", ",", "$", "prefix", "=", "''", ",", "$", "postfix", "=", "''", ")", "{", "$", "output", "=", "''", ";", "// Split attributes over label and wrapper.", "$", "wrapperAttributes", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "attributes", "[", "'wrapper'", "]", ")", ")", "{", "$", "wrapperAttributes", "=", "$", "attributes", "[", "'wrapper'", "]", ";", "unset", "(", "$", "attributes", "[", "'wrapper'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "attributes", "[", "'required'", "]", ")", ")", "{", "$", "wrapperAttributes", "[", "'required'", "]", "=", "$", "attributes", "[", "'required'", "]", ";", "}", "// Tag around main labels.", "if", "(", "$", "wrapLabel", ")", "{", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'label'", ",", "$", "wrapperAttributes", ")", ";", "}", "// Label.", "$", "attributes", "=", "$", "this", "->", "addLabelAttributes", "(", "$", "attributes", ",", "$", "id", ")", ";", "$", "postfix", ".=", "!", "empty", "(", "$", "attributes", "[", "'required'", "]", ")", "?", "$", "this", "->", "requiredMarkup", ":", "''", ";", "$", "tag", "=", "empty", "(", "$", "id", ")", "?", "$", "this", "->", "multiLabelTag", ":", "'label'", ";", "$", "output", ".=", "$", "this", "->", "getOpenTag", "(", "$", "tag", ",", "$", "attributes", ")", ";", "$", "output", ".=", "$", "prefix", ".", "htmlspecialchars", "(", "$", "text", ",", "$", "this", "->", "htmlSpecialCharsFlag", ",", "'UTF-8'", ")", ".", "$", "postfix", ";", "$", "output", ".=", "$", "this", "->", "getCloseTag", "(", "$", "tag", ")", ";", "// Tag around labels.", "if", "(", "$", "wrapLabel", ")", "{", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'label'", ")", ";", "}", "return", "$", "output", ";", "}" ]
Renders a label. @param string $text The label text. @param string $id The value of the for attribute. If the empty string, not a label tag but a span with a class="label" will be rendered. @param array $attributes Any additional attributes to render for the label. The array is a keyed array, the keys being the attribute names, the values being the value of that attribute. If that value is an array it is rendered as a joined string of the values separated by a space (e.g. multiple classes). @param bool $wrapLabel Whether to wrap this label within the defined label wrapper tag. @param string $prefix Prefix to prepend to the label text, may contain html, so don't escape. Will come from code not users. @param string $postfix Postfix to append to the label text, may contain html, so don't escape. Will come from code not users. @return string The rendered label. The rendered label.
[ "Renders", "a", "label", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L414-L446
30,409
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.input
protected function input(array $field) { $output = ''; // Tag around input element. $output .= $this->getWrapper('input'); $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'type', $field['type']); $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $attributes = $this->addAttribute($attributes, 'value', $field['value']); $output .= $this->getOpenTag('input', $attributes, true); // Tag around input element. $output .= $this->getWrapperEnd('input'); return $output; }
php
protected function input(array $field) { $output = ''; // Tag around input element. $output .= $this->getWrapper('input'); $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'type', $field['type']); $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $attributes = $this->addAttribute($attributes, 'value', $field['value']); $output .= $this->getOpenTag('input', $attributes, true); // Tag around input element. $output .= $this->getWrapperEnd('input'); return $output; }
[ "protected", "function", "input", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "// Tag around input element.", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'input'", ")", ";", "$", "attributes", "=", "$", "field", "[", "'attributes'", "]", ";", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'type'", ",", "$", "field", "[", "'type'", "]", ")", ";", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'id'", ",", "$", "field", "[", "'id'", "]", ")", ";", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'name'", ",", "$", "field", "[", "'name'", "]", ")", ";", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'value'", ",", "$", "field", "[", "'value'", "]", ")", ";", "$", "output", ".=", "$", "this", "->", "getOpenTag", "(", "'input'", ",", "$", "attributes", ",", "true", ")", ";", "// Tag around input element.", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'input'", ")", ";", "return", "$", "output", ";", "}" ]
Renders an input field. @param array $field @return string The rendered input field.
[ "Renders", "an", "input", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L456-L474
30,410
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.textarea
protected function textarea(array $field) { $output = ''; // Tag around input element. $output .= $this->getWrapper('input'); $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $output .= $this->getOpenTag('textarea', $attributes); $output .= htmlspecialchars($field['value'], $this->htmlSpecialCharsFlag, 'UTF-8'); $output .= $this->getCloseTag('textarea'); // Tag around input element. $output .= $this->getWrapperEnd('input'); return $output; }
php
protected function textarea(array $field) { $output = ''; // Tag around input element. $output .= $this->getWrapper('input'); $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $output .= $this->getOpenTag('textarea', $attributes); $output .= htmlspecialchars($field['value'], $this->htmlSpecialCharsFlag, 'UTF-8'); $output .= $this->getCloseTag('textarea'); // Tag around input element. $output .= $this->getWrapperEnd('input'); return $output; }
[ "protected", "function", "textarea", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "// Tag around input element.", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'input'", ")", ";", "$", "attributes", "=", "$", "field", "[", "'attributes'", "]", ";", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'id'", ",", "$", "field", "[", "'id'", "]", ")", ";", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'name'", ",", "$", "field", "[", "'name'", "]", ")", ";", "$", "output", ".=", "$", "this", "->", "getOpenTag", "(", "'textarea'", ",", "$", "attributes", ")", ";", "$", "output", ".=", "htmlspecialchars", "(", "$", "field", "[", "'value'", "]", ",", "$", "this", "->", "htmlSpecialCharsFlag", ",", "'UTF-8'", ")", ";", "$", "output", ".=", "$", "this", "->", "getCloseTag", "(", "'textarea'", ")", ";", "// Tag around input element.", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'input'", ")", ";", "return", "$", "output", ";", "}" ]
Renders a textarea field. @param $field @return string The rendered textarea field.
[ "Renders", "a", "textarea", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L484-L501
30,411
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.select
protected function select(array $field) { $output = ''; // Tag around select element: same as for an input element. $output .= $this->getWrapper('input'); // Select tag. $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $output .= $this->getOpenTag('select', $attributes); // Options. foreach ($field['options'] as $value => $text) { $optionAttributes = array('value' => $value); if ($this->isOptionSelected($field['value'], $value)) { $optionAttributes['selected'] = true; } $output .= $this->getOpenTag('option', $optionAttributes); $output .= htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8'); $output .= $this->getCloseTag('option'); } // End tag. $output .= $this->getCloseTag('select'); // Tag around select element. $output .= $this->getWrapperEnd('input'); return $output; }
php
protected function select(array $field) { $output = ''; // Tag around select element: same as for an input element. $output .= $this->getWrapper('input'); // Select tag. $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $output .= $this->getOpenTag('select', $attributes); // Options. foreach ($field['options'] as $value => $text) { $optionAttributes = array('value' => $value); if ($this->isOptionSelected($field['value'], $value)) { $optionAttributes['selected'] = true; } $output .= $this->getOpenTag('option', $optionAttributes); $output .= htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8'); $output .= $this->getCloseTag('option'); } // End tag. $output .= $this->getCloseTag('select'); // Tag around select element. $output .= $this->getWrapperEnd('input'); return $output; }
[ "protected", "function", "select", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "// Tag around select element: same as for an input element.", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'input'", ")", ";", "// Select tag.", "$", "attributes", "=", "$", "field", "[", "'attributes'", "]", ";", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'id'", ",", "$", "field", "[", "'id'", "]", ")", ";", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'name'", ",", "$", "field", "[", "'name'", "]", ")", ";", "$", "output", ".=", "$", "this", "->", "getOpenTag", "(", "'select'", ",", "$", "attributes", ")", ";", "// Options.", "foreach", "(", "$", "field", "[", "'options'", "]", "as", "$", "value", "=>", "$", "text", ")", "{", "$", "optionAttributes", "=", "array", "(", "'value'", "=>", "$", "value", ")", ";", "if", "(", "$", "this", "->", "isOptionSelected", "(", "$", "field", "[", "'value'", "]", ",", "$", "value", ")", ")", "{", "$", "optionAttributes", "[", "'selected'", "]", "=", "true", ";", "}", "$", "output", ".=", "$", "this", "->", "getOpenTag", "(", "'option'", ",", "$", "optionAttributes", ")", ";", "$", "output", ".=", "htmlspecialchars", "(", "$", "text", ",", "$", "this", "->", "htmlSpecialCharsFlag", ",", "'UTF-8'", ")", ";", "$", "output", ".=", "$", "this", "->", "getCloseTag", "(", "'option'", ")", ";", "}", "// End tag.", "$", "output", ".=", "$", "this", "->", "getCloseTag", "(", "'select'", ")", ";", "// Tag around select element.", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'input'", ")", ";", "return", "$", "output", ";", "}" ]
Renders a select element. @param array $field @return string The rendered select element.
[ "Renders", "a", "select", "element", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L531-L561
30,412
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.checkbox
protected function checkbox(array $field) { $output = ''; // Div tag. $attributes = $field['attributes']; //? unset($attributes['required']); $output .= $this->getWrapper('input', $attributes); $output .= $this->getWrapper('checkbox', $attributes); // Checkboxes. foreach ($field['options'] as $value => $text) { $checkboxAttributes = $this->getCheckboxAttributes($field['id'], $field['name'], $value); if (in_array($value, $field['value'], false)) { $checkboxAttributes['checked'] = true; } $output .= $this->getWrapper('checkbox1'); $checkboxInput = $this->getOpenTag('input', $checkboxAttributes); if ($this->checkboxInputInLabel) { $output .= $this->renderLabel($text, $checkboxAttributes['id'], array(), false, $checkboxInput); } else { $output .= $checkboxInput; $output .= $this->renderLabel($text, $checkboxAttributes['id'], array(), false); } $output .= $this->getWrapperEnd('checkbox1'); } // End tag. $output .= $this->getWrapperEnd('checkbox'); $output .= $this->getWrapperEnd('input'); return $output; }
php
protected function checkbox(array $field) { $output = ''; // Div tag. $attributes = $field['attributes']; //? unset($attributes['required']); $output .= $this->getWrapper('input', $attributes); $output .= $this->getWrapper('checkbox', $attributes); // Checkboxes. foreach ($field['options'] as $value => $text) { $checkboxAttributes = $this->getCheckboxAttributes($field['id'], $field['name'], $value); if (in_array($value, $field['value'], false)) { $checkboxAttributes['checked'] = true; } $output .= $this->getWrapper('checkbox1'); $checkboxInput = $this->getOpenTag('input', $checkboxAttributes); if ($this->checkboxInputInLabel) { $output .= $this->renderLabel($text, $checkboxAttributes['id'], array(), false, $checkboxInput); } else { $output .= $checkboxInput; $output .= $this->renderLabel($text, $checkboxAttributes['id'], array(), false); } $output .= $this->getWrapperEnd('checkbox1'); } // End tag. $output .= $this->getWrapperEnd('checkbox'); $output .= $this->getWrapperEnd('input'); return $output; }
[ "protected", "function", "checkbox", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "// Div tag.", "$", "attributes", "=", "$", "field", "[", "'attributes'", "]", ";", "//? unset($attributes['required']);", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'input'", ",", "$", "attributes", ")", ";", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'checkbox'", ",", "$", "attributes", ")", ";", "// Checkboxes.", "foreach", "(", "$", "field", "[", "'options'", "]", "as", "$", "value", "=>", "$", "text", ")", "{", "$", "checkboxAttributes", "=", "$", "this", "->", "getCheckboxAttributes", "(", "$", "field", "[", "'id'", "]", ",", "$", "field", "[", "'name'", "]", ",", "$", "value", ")", ";", "if", "(", "in_array", "(", "$", "value", ",", "$", "field", "[", "'value'", "]", ",", "false", ")", ")", "{", "$", "checkboxAttributes", "[", "'checked'", "]", "=", "true", ";", "}", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'checkbox1'", ")", ";", "$", "checkboxInput", "=", "$", "this", "->", "getOpenTag", "(", "'input'", ",", "$", "checkboxAttributes", ")", ";", "if", "(", "$", "this", "->", "checkboxInputInLabel", ")", "{", "$", "output", ".=", "$", "this", "->", "renderLabel", "(", "$", "text", ",", "$", "checkboxAttributes", "[", "'id'", "]", ",", "array", "(", ")", ",", "false", ",", "$", "checkboxInput", ")", ";", "}", "else", "{", "$", "output", ".=", "$", "checkboxInput", ";", "$", "output", ".=", "$", "this", "->", "renderLabel", "(", "$", "text", ",", "$", "checkboxAttributes", "[", "'id'", "]", ",", "array", "(", ")", ",", "false", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'checkbox1'", ")", ";", "}", "// End tag.", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'checkbox'", ")", ";", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'input'", ")", ";", "return", "$", "output", ";", "}" ]
Renders a list of checkboxes. @param array $field @return string The rendered checkboxes.
[ "Renders", "a", "list", "of", "checkboxes", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L619-L652
30,413
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.getWrapper
protected function getWrapper($type, array $attributes = array()) { $tag = "{$type}WrapperTag"; $class = "{$type}WrapperClass"; $output = ''; if (!empty($this->$tag)) { if (!empty($this->$class)) { $attributes = $this->addAttribute($attributes, 'class', $this->$class); } $output .= $this->getOpenTag($this->$tag, $attributes); } return $output; }
php
protected function getWrapper($type, array $attributes = array()) { $tag = "{$type}WrapperTag"; $class = "{$type}WrapperClass"; $output = ''; if (!empty($this->$tag)) { if (!empty($this->$class)) { $attributes = $this->addAttribute($attributes, 'class', $this->$class); } $output .= $this->getOpenTag($this->$tag, $attributes); } return $output; }
[ "protected", "function", "getWrapper", "(", "$", "type", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "tag", "=", "\"{$type}WrapperTag\"", ";", "$", "class", "=", "\"{$type}WrapperClass\"", ";", "$", "output", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "$", "tag", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "$", "class", ")", ")", "{", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'class'", ",", "$", "this", "->", "$", "class", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "getOpenTag", "(", "$", "this", "->", "$", "tag", ",", "$", "attributes", ")", ";", "}", "return", "$", "output", ";", "}" ]
Returns the open tag for a wrapper element. @param string $type @param array $attributes @return string
[ "Returns", "the", "open", "tag", "for", "a", "wrapper", "element", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L662-L674
30,414
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.getWrapperEnd
protected function getWrapperEnd($type) { $tag = "{$type}WrapperTag"; $output = ''; if (!empty($this->$tag)) { $output .= $this->getCloseTag($this->$tag); } return $output; }
php
protected function getWrapperEnd($type) { $tag = "{$type}WrapperTag"; $output = ''; if (!empty($this->$tag)) { $output .= $this->getCloseTag($this->$tag); } return $output; }
[ "protected", "function", "getWrapperEnd", "(", "$", "type", ")", "{", "$", "tag", "=", "\"{$type}WrapperTag\"", ";", "$", "output", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "$", "tag", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "getCloseTag", "(", "$", "this", "->", "$", "tag", ")", ";", "}", "return", "$", "output", ";", "}" ]
Returns the closing tag for a wrapper element. @param string $type @return string
[ "Returns", "the", "closing", "tag", "for", "a", "wrapper", "element", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L683-L691
30,415
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.getOpenTag
protected function getOpenTag($tag, array $attributes = array(), $selfClosing = false) { return '<' . htmlspecialchars($tag, ENT_QUOTES, 'ISO-8859-1') . $this->renderAttributes($attributes) . ($selfClosing && !$this->html5 ? '/' : '') . '>'; }
php
protected function getOpenTag($tag, array $attributes = array(), $selfClosing = false) { return '<' . htmlspecialchars($tag, ENT_QUOTES, 'ISO-8859-1') . $this->renderAttributes($attributes) . ($selfClosing && !$this->html5 ? '/' : '') . '>'; }
[ "protected", "function", "getOpenTag", "(", "$", "tag", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "selfClosing", "=", "false", ")", "{", "return", "'<'", ".", "htmlspecialchars", "(", "$", "tag", ",", "ENT_QUOTES", ",", "'ISO-8859-1'", ")", ".", "$", "this", "->", "renderAttributes", "(", "$", "attributes", ")", ".", "(", "$", "selfClosing", "&&", "!", "$", "this", "->", "html5", "?", "'/'", ":", "''", ")", ".", "'>'", ";", "}" ]
Returns a secured html open tag string. @param string $tag The html tag. @param array $attributes The attributes to render. @param bool $selfClosing Whether the tag is self closing. Only in html4 this will add a / character before the closing > character. @return string The rendered open tag.
[ "Returns", "a", "secured", "html", "open", "tag", "string", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L707-L710
30,416
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderAttributes
protected function renderAttributes(array $attributes) { $attributeString = ''; foreach ($attributes as $key => $value) { if (is_array($value)) { $value = implode(' ', $value); } // Skip attributes that are not to be set (required, disabled, ...). if ($value !== false && $value !== '') { $attributeString .= ' ' . htmlspecialchars($key, ENT_QUOTES, 'UTF-8'); // HTML5: do not add a value to boolean attributes. // HTML4: add the name of the key as value for the attribute. if (!$this->html5 && $value === true) { $value = $key; } if ($value !== true) { $attributeString .= '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"'; } } } return $attributeString; }
php
protected function renderAttributes(array $attributes) { $attributeString = ''; foreach ($attributes as $key => $value) { if (is_array($value)) { $value = implode(' ', $value); } // Skip attributes that are not to be set (required, disabled, ...). if ($value !== false && $value !== '') { $attributeString .= ' ' . htmlspecialchars($key, ENT_QUOTES, 'UTF-8'); // HTML5: do not add a value to boolean attributes. // HTML4: add the name of the key as value for the attribute. if (!$this->html5 && $value === true) { $value = $key; } if ($value !== true) { $attributeString .= '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"'; } } } return $attributeString; }
[ "protected", "function", "renderAttributes", "(", "array", "$", "attributes", ")", "{", "$", "attributeString", "=", "''", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "implode", "(", "' '", ",", "$", "value", ")", ";", "}", "// Skip attributes that are not to be set (required, disabled, ...).", "if", "(", "$", "value", "!==", "false", "&&", "$", "value", "!==", "''", ")", "{", "$", "attributeString", ".=", "' '", ".", "htmlspecialchars", "(", "$", "key", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "// HTML5: do not add a value to boolean attributes.", "// HTML4: add the name of the key as value for the attribute.", "if", "(", "!", "$", "this", "->", "html5", "&&", "$", "value", "===", "true", ")", "{", "$", "value", "=", "$", "key", ";", "}", "if", "(", "$", "value", "!==", "true", ")", "{", "$", "attributeString", ".=", "'=\"'", ".", "htmlspecialchars", "(", "$", "value", ",", "ENT_COMPAT", ",", "'UTF-8'", ")", ".", "'\"'", ";", "}", "}", "}", "return", "$", "attributeString", ";", "}" ]
Renders a list of attributes. @param array $attributes @return string html string with the rendered attributes and 1 space in front of it.
[ "Renders", "a", "list", "of", "attributes", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L734-L755
30,417
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.addLabelAttributes
protected function addLabelAttributes(array $attributes, $id) { $attributes = $this->addAttribute($attributes, 'for', $id); if (empty($id)) { $attributes = $this->addAttribute($attributes, 'class', $this->multiLabelClass); } return $attributes; }
php
protected function addLabelAttributes(array $attributes, $id) { $attributes = $this->addAttribute($attributes, 'for', $id); if (empty($id)) { $attributes = $this->addAttribute($attributes, 'class', $this->multiLabelClass); } return $attributes; }
[ "protected", "function", "addLabelAttributes", "(", "array", "$", "attributes", ",", "$", "id", ")", "{", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'for'", ",", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'class'", ",", "$", "this", "->", "multiLabelClass", ")", ";", "}", "return", "$", "attributes", ";", "}" ]
Adds a set of attributes specific for a label. @param array $attributes @param string $id @return array
[ "Adds", "a", "set", "of", "attributes", "specific", "for", "a", "label", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L812-L819
30,418
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.isOptionSelected
protected function isOptionSelected($selectedValues, $option) { return is_array($selectedValues) ? in_array((string) $option, $selectedValues,false) : (string) $option === (string) $selectedValues; }
php
protected function isOptionSelected($selectedValues, $option) { return is_array($selectedValues) ? in_array((string) $option, $selectedValues,false) : (string) $option === (string) $selectedValues; }
[ "protected", "function", "isOptionSelected", "(", "$", "selectedValues", ",", "$", "option", ")", "{", "return", "is_array", "(", "$", "selectedValues", ")", "?", "in_array", "(", "(", "string", ")", "$", "option", ",", "$", "selectedValues", ",", "false", ")", ":", "(", "string", ")", "$", "option", "===", "(", "string", ")", "$", "selectedValues", ";", "}" ]
Returns whether an option is part of a set of selected values. @param string|int|array $selectedValues The set of selected values, may be just 1 scalar value. @param string|int $option The option to search for in the set of selected values. @return bool If this option is part of the selected values.
[ "Returns", "whether", "an", "option", "is", "part", "of", "a", "set", "of", "selected", "values", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L872-L875
30,419
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.addAjax
protected function addAjax(array $field) { // We add a class so this element can be recognised by js as having an // ajax action. $field['attributes'] = $this->addAttribute($field['attributes'], 'class', 'acumulus-ajax'); // Add the data`-* attributes. if (!empty($field['ajax']) && is_array($field['ajax'])) { foreach ($field['ajax'] as $dataName => $dataValue) { $field['attributes'] = $this->addAttribute($field['attributes'], 'data-acumulus-' . $dataName, $dataValue); } } return $field; }
php
protected function addAjax(array $field) { // We add a class so this element can be recognised by js as having an // ajax action. $field['attributes'] = $this->addAttribute($field['attributes'], 'class', 'acumulus-ajax'); // Add the data`-* attributes. if (!empty($field['ajax']) && is_array($field['ajax'])) { foreach ($field['ajax'] as $dataName => $dataValue) { $field['attributes'] = $this->addAttribute($field['attributes'], 'data-acumulus-' . $dataName, $dataValue); } } return $field; }
[ "protected", "function", "addAjax", "(", "array", "$", "field", ")", "{", "// We add a class so this element can be recognised by js as having an", "// ajax action.", "$", "field", "[", "'attributes'", "]", "=", "$", "this", "->", "addAttribute", "(", "$", "field", "[", "'attributes'", "]", ",", "'class'", ",", "'acumulus-ajax'", ")", ";", "// Add the data`-* attributes.", "if", "(", "!", "empty", "(", "$", "field", "[", "'ajax'", "]", ")", "&&", "is_array", "(", "$", "field", "[", "'ajax'", "]", ")", ")", "{", "foreach", "(", "$", "field", "[", "'ajax'", "]", "as", "$", "dataName", "=>", "$", "dataValue", ")", "{", "$", "field", "[", "'attributes'", "]", "=", "$", "this", "->", "addAttribute", "(", "$", "field", "[", "'attributes'", "]", ",", "'data-acumulus-'", ".", "$", "dataName", ",", "$", "dataValue", ")", ";", "}", "}", "return", "$", "field", ";", "}" ]
Processes the ajax setting on a field. The ajax setting is typically an array with data values to be added as data-* attributes tot he fom element. @param array $field The field for which an ajax action is to be enabled. @return array The field with ajax settings mapped to additional attributes.
[ "Processes", "the", "ajax", "setting", "on", "a", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L889-L903
30,420
SIELOnline/libAcumulus
src/Invoice/CompletorStrategy/ApplySameVatRate.php
ApplySameVatRate.tryVatRate
protected function tryVatRate($vatRate) { $this->description = "ApplySameVatRate($vatRate)"; $this->replacingLines = array(); $vatAmount = 0.0; foreach ($this->lines2Complete as $line2Complete) { $vatAmount += $this->completeLine($line2Complete, $vatRate); } $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategy . $this->getName()] = "tryVatRate($vatRate): $vatAmount"; // If the vat totals are equal, the strategy worked. // We allow for a reasonable margin, as rounding errors may add up. return Number::floatsAreEqual($vatAmount, $this->vat2Divide, 0.04); }
php
protected function tryVatRate($vatRate) { $this->description = "ApplySameVatRate($vatRate)"; $this->replacingLines = array(); $vatAmount = 0.0; foreach ($this->lines2Complete as $line2Complete) { $vatAmount += $this->completeLine($line2Complete, $vatRate); } $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategy . $this->getName()] = "tryVatRate($vatRate): $vatAmount"; // If the vat totals are equal, the strategy worked. // We allow for a reasonable margin, as rounding errors may add up. return Number::floatsAreEqual($vatAmount, $this->vat2Divide, 0.04); }
[ "protected", "function", "tryVatRate", "(", "$", "vatRate", ")", "{", "$", "this", "->", "description", "=", "\"ApplySameVatRate($vatRate)\"", ";", "$", "this", "->", "replacingLines", "=", "array", "(", ")", ";", "$", "vatAmount", "=", "0.0", ";", "foreach", "(", "$", "this", "->", "lines2Complete", "as", "$", "line2Complete", ")", "{", "$", "vatAmount", "+=", "$", "this", "->", "completeLine", "(", "$", "line2Complete", ",", "$", "vatRate", ")", ";", "}", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "CompletorStrategy", ".", "$", "this", "->", "getName", "(", ")", "]", "=", "\"tryVatRate($vatRate): $vatAmount\"", ";", "// If the vat totals are equal, the strategy worked.", "// We allow for a reasonable margin, as rounding errors may add up.", "return", "Number", "::", "floatsAreEqual", "(", "$", "vatAmount", ",", "$", "this", "->", "vat2Divide", ",", "0.04", ")", ";", "}" ]
Tries 1 of the possible vat rates. @param float $vatRate @return bool
[ "Tries", "1", "of", "the", "possible", "vat", "rates", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategy/ApplySameVatRate.php#L58-L71
30,421
SIELOnline/libAcumulus
src/WooCommerce/Helpers/Token.php
Token.getDataValue
protected function getDataValue(array $data, $property) { $value = null; if (array_key_exists($property, $data)) { // Found: return the value. $value = $data[$property]; } else { // Not found: check in meta data or descend recursively. if (isset($data['meta_data'])) { $value = $this->getMetaDataValue($data['meta_data'], $property); } if ($value === null) { // Not found in meta_data: check if we should descend a level. $propertyParts = explode('_', $property, 2); if (count($propertyParts) === 2 && array_key_exists($propertyParts[0], $data) && is_array($data[$propertyParts[0]])) { $value = $this->getDataValue($data[$propertyParts[0]], $propertyParts[1]); } } } return $value; }
php
protected function getDataValue(array $data, $property) { $value = null; if (array_key_exists($property, $data)) { // Found: return the value. $value = $data[$property]; } else { // Not found: check in meta data or descend recursively. if (isset($data['meta_data'])) { $value = $this->getMetaDataValue($data['meta_data'], $property); } if ($value === null) { // Not found in meta_data: check if we should descend a level. $propertyParts = explode('_', $property, 2); if (count($propertyParts) === 2 && array_key_exists($propertyParts[0], $data) && is_array($data[$propertyParts[0]])) { $value = $this->getDataValue($data[$propertyParts[0]], $propertyParts[1]); } } } return $value; }
[ "protected", "function", "getDataValue", "(", "array", "$", "data", ",", "$", "property", ")", "{", "$", "value", "=", "null", ";", "if", "(", "array_key_exists", "(", "$", "property", ",", "$", "data", ")", ")", "{", "// Found: return the value.", "$", "value", "=", "$", "data", "[", "$", "property", "]", ";", "}", "else", "{", "// Not found: check in meta data or descend recursively.", "if", "(", "isset", "(", "$", "data", "[", "'meta_data'", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "getMetaDataValue", "(", "$", "data", "[", "'meta_data'", "]", ",", "$", "property", ")", ";", "}", "if", "(", "$", "value", "===", "null", ")", "{", "// Not found in meta_data: check if we should descend a level.", "$", "propertyParts", "=", "explode", "(", "'_'", ",", "$", "property", ",", "2", ")", ";", "if", "(", "count", "(", "$", "propertyParts", ")", "===", "2", "&&", "array_key_exists", "(", "$", "propertyParts", "[", "0", "]", ",", "$", "data", ")", "&&", "is_array", "(", "$", "data", "[", "$", "propertyParts", "[", "0", "]", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "getDataValue", "(", "$", "data", "[", "$", "propertyParts", "[", "0", "]", "]", ",", "$", "propertyParts", "[", "1", "]", ")", ";", "}", "}", "}", "return", "$", "value", ";", "}" ]
Extracts a value from a WooCommerce data object data array. A WooCommerce data array (array with key value pairs returned from the WC_Data::get_data() method may contain recursive data sets, e.g. 'billing' for the billing address, and a separate meta_data set. This method recursively searches for the property by stripping it into separate pieces delimited by underscores. E.g. billing_email may be found in $data['billing']['email']. @param array $data The key value data set to search in. @param string $property The name of the property to search for. @return null|string The value for the property of the given name, or null or the empty string if not available (or the property really equals null or the empty string). The return value may be a scalar (numeric type) that can be converted to a string.
[ "Extracts", "a", "value", "from", "a", "WooCommerce", "data", "object", "data", "array", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Helpers/Token.php#L58-L78
30,422
SIELOnline/libAcumulus
src/WooCommerce/Helpers/Token.php
Token.getMetaDataValue
protected function getMetaDataValue(array $metaData, $property) { $property = ltrim($property, '_'); $value = null; foreach ($metaData as $metaItem) { $key = ltrim($metaItem->key, '_'); if ($property === $key) { $value = $metaItem->value; break; } } return $value; }
php
protected function getMetaDataValue(array $metaData, $property) { $property = ltrim($property, '_'); $value = null; foreach ($metaData as $metaItem) { $key = ltrim($metaItem->key, '_'); if ($property === $key) { $value = $metaItem->value; break; } } return $value; }
[ "protected", "function", "getMetaDataValue", "(", "array", "$", "metaData", ",", "$", "property", ")", "{", "$", "property", "=", "ltrim", "(", "$", "property", ",", "'_'", ")", ";", "$", "value", "=", "null", ";", "foreach", "(", "$", "metaData", "as", "$", "metaItem", ")", "{", "$", "key", "=", "ltrim", "(", "$", "metaItem", "->", "key", ",", "'_'", ")", ";", "if", "(", "$", "property", "===", "$", "key", ")", "{", "$", "value", "=", "$", "metaItem", "->", "value", ";", "break", ";", "}", "}", "return", "$", "value", ";", "}" ]
Extracts a value from a set of WooCommerce meta data objects. WooCommerce meta data is stored in objects having twice the set of properties id, key, and value, once in the property current_value and once in the property data. If 1 of the properties id, key or value is retrieved, its value from the current_value set is returned. @param object[] $metaData The meta data set to search in. @param string $property The name of the property to search for. May be with or without a leading underscore. @return null|string The value for the property of the given name, or null or the empty string if not available (or the property really equals null or the empty string). The return value may be a scalar (numeric type) that can be converted to a string.
[ "Extracts", "a", "value", "from", "a", "set", "of", "WooCommerce", "meta", "data", "objects", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Helpers/Token.php#L100-L112
30,423
SIELOnline/libAcumulus
src/Shop/AcumulusEntry.php
AcumulusEntry.getEntryId
public function getEntryId() { $entryId = $this->get(static::$keyEntryId); if (!empty($entryId)) { $entryId = (int) $entryId; } return $entryId; }
php
public function getEntryId() { $entryId = $this->get(static::$keyEntryId); if (!empty($entryId)) { $entryId = (int) $entryId; } return $entryId; }
[ "public", "function", "getEntryId", "(", ")", "{", "$", "entryId", "=", "$", "this", "->", "get", "(", "static", "::", "$", "keyEntryId", ")", ";", "if", "(", "!", "empty", "(", "$", "entryId", ")", ")", "{", "$", "entryId", "=", "(", "int", ")", "$", "entryId", ";", "}", "return", "$", "entryId", ";", "}" ]
Returns the entry id for this Acumulus entry. @return int|null The entry id of this Acumulus entry or null if it was stored as a concept.
[ "Returns", "the", "entry", "id", "for", "this", "Acumulus", "entry", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntry.php#L76-L83
30,424
SIELOnline/libAcumulus
src/Shop/AcumulusEntry.php
AcumulusEntry.getCreated
public function getCreated($raw = false) { $result = $this->get(static::$keyCreated); if (!$raw) { $result = $this->toDateTime($result); } return $result; }
php
public function getCreated($raw = false) { $result = $this->get(static::$keyCreated); if (!$raw) { $result = $this->toDateTime($result); } return $result; }
[ "public", "function", "getCreated", "(", "$", "raw", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "get", "(", "static", "::", "$", "keyCreated", ")", ";", "if", "(", "!", "$", "raw", ")", "{", "$", "result", "=", "$", "this", "->", "toDateTime", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the time when this record was created. @param bool $raw Whether to return the raw value as stored in the database, or a Datetime object. The raw value will differ per webshop. @return string|int|\DateTime The timestamp when this record was created.
[ "Returns", "the", "time", "when", "this", "record", "was", "created", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntry.php#L129-L136
30,425
SIELOnline/libAcumulus
src/Shop/AcumulusEntry.php
AcumulusEntry.getUpdated
public function getUpdated($raw = false) { $result = $this->get(static::$keyUpdated); if (!$raw) { $result = $this->toDateTime($result); } return $result; }
php
public function getUpdated($raw = false) { $result = $this->get(static::$keyUpdated); if (!$raw) { $result = $this->toDateTime($result); } return $result; }
[ "public", "function", "getUpdated", "(", "$", "raw", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "get", "(", "static", "::", "$", "keyUpdated", ")", ";", "if", "(", "!", "$", "raw", ")", "{", "$", "result", "=", "$", "this", "->", "toDateTime", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the time when this record was last updated. @param bool $raw Whether to return the raw value as stored in the database, or a Datetime object. The raw value will differ per webshop. @return string|int|\DateTime The timestamp when this record was last updated.
[ "Returns", "the", "time", "when", "this", "record", "was", "last", "updated", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntry.php#L148-L155
30,426
SIELOnline/libAcumulus
src/Shop/AcumulusEntry.php
AcumulusEntry.get
protected function get($field) { $value = null; if (is_array($this->record)) { // Value may be null: use array_key_exists(), not isset(). if (array_key_exists($field, $this->record)) { $value = $this->record[$field]; } } elseif (is_object($this->record)) { // It's an object: try to get the property. // Safest way is via the get_object_vars() function. $properties = get_object_vars($this->record); if (!empty($properties) && array_key_exists($field, $properties)) { $value = $properties[$field]; } elseif (method_exists($this->record, $field)) { $value = call_user_func(array($this->record, $field)); } elseif (method_exists($this->record, '__get')) { @$value = $this->record->$field; } elseif (method_exists($this->record, '__call')) { @$value = $this->record->$field(); } } return $value; }
php
protected function get($field) { $value = null; if (is_array($this->record)) { // Value may be null: use array_key_exists(), not isset(). if (array_key_exists($field, $this->record)) { $value = $this->record[$field]; } } elseif (is_object($this->record)) { // It's an object: try to get the property. // Safest way is via the get_object_vars() function. $properties = get_object_vars($this->record); if (!empty($properties) && array_key_exists($field, $properties)) { $value = $properties[$field]; } elseif (method_exists($this->record, $field)) { $value = call_user_func(array($this->record, $field)); } elseif (method_exists($this->record, '__get')) { @$value = $this->record->$field; } elseif (method_exists($this->record, '__call')) { @$value = $this->record->$field(); } } return $value; }
[ "protected", "function", "get", "(", "$", "field", ")", "{", "$", "value", "=", "null", ";", "if", "(", "is_array", "(", "$", "this", "->", "record", ")", ")", "{", "// Value may be null: use array_key_exists(), not isset().", "if", "(", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "record", ")", ")", "{", "$", "value", "=", "$", "this", "->", "record", "[", "$", "field", "]", ";", "}", "}", "elseif", "(", "is_object", "(", "$", "this", "->", "record", ")", ")", "{", "// It's an object: try to get the property.", "// Safest way is via the get_object_vars() function.", "$", "properties", "=", "get_object_vars", "(", "$", "this", "->", "record", ")", ";", "if", "(", "!", "empty", "(", "$", "properties", ")", "&&", "array_key_exists", "(", "$", "field", ",", "$", "properties", ")", ")", "{", "$", "value", "=", "$", "properties", "[", "$", "field", "]", ";", "}", "elseif", "(", "method_exists", "(", "$", "this", "->", "record", ",", "$", "field", ")", ")", "{", "$", "value", "=", "call_user_func", "(", "array", "(", "$", "this", "->", "record", ",", "$", "field", ")", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "this", "->", "record", ",", "'__get'", ")", ")", "{", "@", "$", "value", "=", "$", "this", "->", "record", "->", "$", "field", ";", "}", "elseif", "(", "method_exists", "(", "$", "this", "->", "record", ",", "'__call'", ")", ")", "{", "@", "$", "value", "=", "$", "this", "->", "record", "->", "$", "field", "(", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Returns the value of the given field in the given acumulus entry record. As different webshops may use different field and property names in their tables and models, we abstracted accessing a field of a record into this method. @param string $field The field to search for. @return mixed|null The value of the given field in this acumulus entry record.
[ "Returns", "the", "value", "of", "the", "given", "field", "in", "the", "given", "acumulus", "entry", "record", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntry.php#L204-L227
30,427
SIELOnline/libAcumulus
SielAcumulusAutoloader.php
SielAcumulusAutoloader.register
public static function register() { // In some shops (OpenCart1) there's not one central entry point and // we may risk registering twice. static $hasBeenRegistered = false; if (!$hasBeenRegistered) { $dir = __DIR__ . '/src/'; $ourNamespace = 'Siel\\Acumulus\\'; $ourNamespaceLen = strlen($ourNamespace); $autoloadFunction = function ($class) use ($ourNamespace, $ourNamespaceLen, $dir) { if (strncmp($class, $ourNamespace, $ourNamespaceLen) === 0) { $fileName = $dir . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $ourNamespaceLen)) . '.php'; if (is_readable($fileName)) { /** @noinspection PhpIncludeInspection */ include($fileName); } } }; // Prepend this autoloader: it will not throw, nor warn, while the // shop specific autoloader might do so. spl_autoload_register($autoloadFunction, true, true); $hasBeenRegistered = true; } }
php
public static function register() { // In some shops (OpenCart1) there's not one central entry point and // we may risk registering twice. static $hasBeenRegistered = false; if (!$hasBeenRegistered) { $dir = __DIR__ . '/src/'; $ourNamespace = 'Siel\\Acumulus\\'; $ourNamespaceLen = strlen($ourNamespace); $autoloadFunction = function ($class) use ($ourNamespace, $ourNamespaceLen, $dir) { if (strncmp($class, $ourNamespace, $ourNamespaceLen) === 0) { $fileName = $dir . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $ourNamespaceLen)) . '.php'; if (is_readable($fileName)) { /** @noinspection PhpIncludeInspection */ include($fileName); } } }; // Prepend this autoloader: it will not throw, nor warn, while the // shop specific autoloader might do so. spl_autoload_register($autoloadFunction, true, true); $hasBeenRegistered = true; } }
[ "public", "static", "function", "register", "(", ")", "{", "// In some shops (OpenCart1) there's not one central entry point and", "// we may risk registering twice.", "static", "$", "hasBeenRegistered", "=", "false", ";", "if", "(", "!", "$", "hasBeenRegistered", ")", "{", "$", "dir", "=", "__DIR__", ".", "'/src/'", ";", "$", "ourNamespace", "=", "'Siel\\\\Acumulus\\\\'", ";", "$", "ourNamespaceLen", "=", "strlen", "(", "$", "ourNamespace", ")", ";", "$", "autoloadFunction", "=", "function", "(", "$", "class", ")", "use", "(", "$", "ourNamespace", ",", "$", "ourNamespaceLen", ",", "$", "dir", ")", "{", "if", "(", "strncmp", "(", "$", "class", ",", "$", "ourNamespace", ",", "$", "ourNamespaceLen", ")", "===", "0", ")", "{", "$", "fileName", "=", "$", "dir", ".", "str_replace", "(", "'\\\\'", ",", "DIRECTORY_SEPARATOR", ",", "substr", "(", "$", "class", ",", "$", "ourNamespaceLen", ")", ")", ".", "'.php'", ";", "if", "(", "is_readable", "(", "$", "fileName", ")", ")", "{", "/** @noinspection PhpIncludeInspection */", "include", "(", "$", "fileName", ")", ";", "}", "}", "}", ";", "// Prepend this autoloader: it will not throw, nor warn, while the", "// shop specific autoloader might do so.", "spl_autoload_register", "(", "$", "autoloadFunction", ",", "true", ",", "true", ")", ";", "$", "hasBeenRegistered", "=", "true", ";", "}", "}" ]
Registers an autoloader for the Siel\Acumulus namespace. As not all web shops support auto-loading based on namespaces or have other glitches, eg. expecting lower cased file names, we define our own autoloader. If the module cannot use the autoloader of the web shop, this method should be called during bootstrapping of the module. Thanks to https://gist.github.com/mageekguy/8300961
[ "Registers", "an", "autoloader", "for", "the", "Siel", "\\", "Acumulus", "namespace", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/SielAcumulusAutoloader.php#L20-L44
30,428
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.setStatus
private function setStatus($status, $message = '') { if ($status > $this->status) { $this->status = $status; // Save the message belonging to this worse state. if (!empty($message)) { $this->statusMessage = $message; } } }
php
private function setStatus($status, $message = '') { if ($status > $this->status) { $this->status = $status; // Save the message belonging to this worse state. if (!empty($message)) { $this->statusMessage = $message; } } }
[ "private", "function", "setStatus", "(", "$", "status", ",", "$", "message", "=", "''", ")", "{", "if", "(", "$", "status", ">", "$", "this", "->", "status", ")", "{", "$", "this", "->", "status", "=", "$", "status", ";", "// Save the message belonging to this worse state.", "if", "(", "!", "empty", "(", "$", "message", ")", ")", "{", "$", "this", "->", "statusMessage", "=", "$", "message", ";", "}", "}", "}" ]
Sets the status, but only if it is "worse" than the current status. @param int $status The status to set. @param string $message Optionally, a message indicating what is wrong may be given.
[ "Sets", "the", "status", "but", "only", "if", "it", "is", "worse", "than", "the", "current", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L142-L151
30,429
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getStatusClass
public function getStatusClass($status) { switch ($status) { case static::Status_Success: $result = 'success'; break; case static::Status_Info: $result = 'info'; break; case static::Status_Warning: $result = 'warning'; break; case static::Status_Error: default: $result = 'error'; break; } return $result; }
php
public function getStatusClass($status) { switch ($status) { case static::Status_Success: $result = 'success'; break; case static::Status_Info: $result = 'info'; break; case static::Status_Warning: $result = 'warning'; break; case static::Status_Error: default: $result = 'error'; break; } return $result; }
[ "public", "function", "getStatusClass", "(", "$", "status", ")", "{", "switch", "(", "$", "status", ")", "{", "case", "static", "::", "Status_Success", ":", "$", "result", "=", "'success'", ";", "break", ";", "case", "static", "::", "Status_Info", ":", "$", "result", "=", "'info'", ";", "break", ";", "case", "static", "::", "Status_Warning", ":", "$", "result", "=", "'warning'", ";", "break", ";", "case", "static", "::", "Status_Error", ":", "default", ":", "$", "result", "=", "'error'", ";", "break", ";", "}", "return", "$", "result", ";", "}" ]
Returns a string to use as css class for the current status. @param int $status @return string
[ "Returns", "a", "string", "to", "use", "as", "css", "class", "for", "the", "current", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L169-L187
30,430
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getStatusIcon
private function getStatusIcon($status) { switch ($status) { case static::Status_Success: $result = json_decode('"\u2714"'); break; case static::Status_Info: case static::Status_Warning: $result = '!'; break; case static::Status_Error: default: $result = json_decode('"\u2716"'); break; } return $result; }
php
private function getStatusIcon($status) { switch ($status) { case static::Status_Success: $result = json_decode('"\u2714"'); break; case static::Status_Info: case static::Status_Warning: $result = '!'; break; case static::Status_Error: default: $result = json_decode('"\u2716"'); break; } return $result; }
[ "private", "function", "getStatusIcon", "(", "$", "status", ")", "{", "switch", "(", "$", "status", ")", "{", "case", "static", "::", "Status_Success", ":", "$", "result", "=", "json_decode", "(", "'\"\\u2714\"'", ")", ";", "break", ";", "case", "static", "::", "Status_Info", ":", "case", "static", "::", "Status_Warning", ":", "$", "result", "=", "'!'", ";", "break", ";", "case", "static", "::", "Status_Error", ":", "default", ":", "$", "result", "=", "json_decode", "(", "'\"\\u2716\"'", ")", ";", "break", ";", "}", "return", "$", "result", ";", "}" ]
Returns an icon character that represents the current status. @param int $status @return string An icon character that represents the status.
[ "Returns", "an", "icon", "character", "that", "represents", "the", "current", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L197-L213
30,431
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getStatusLabelAttributes
private function getStatusLabelAttributes($status, $statusMessage) { $statusClass = $this->getStatusClass($status); $attributes = array( 'class' => array('notice', 'notice-' . $statusClass), 'wrapper' => array( 'class' => array('notice', 'notice-' . $statusClass), ), ); if (!empty($statusMessage)) { $attributes['title'] = $statusMessage; } return $attributes; }
php
private function getStatusLabelAttributes($status, $statusMessage) { $statusClass = $this->getStatusClass($status); $attributes = array( 'class' => array('notice', 'notice-' . $statusClass), 'wrapper' => array( 'class' => array('notice', 'notice-' . $statusClass), ), ); if (!empty($statusMessage)) { $attributes['title'] = $statusMessage; } return $attributes; }
[ "private", "function", "getStatusLabelAttributes", "(", "$", "status", ",", "$", "statusMessage", ")", "{", "$", "statusClass", "=", "$", "this", "->", "getStatusClass", "(", "$", "status", ")", ";", "$", "attributes", "=", "array", "(", "'class'", "=>", "array", "(", "'notice'", ",", "'notice-'", ".", "$", "statusClass", ")", ",", "'wrapper'", "=>", "array", "(", "'class'", "=>", "array", "(", "'notice'", ",", "'notice-'", ".", "$", "statusClass", ")", ",", ")", ",", ")", ";", "if", "(", "!", "empty", "(", "$", "statusMessage", ")", ")", "{", "$", "attributes", "[", "'title'", "]", "=", "$", "statusMessage", ";", "}", "return", "$", "attributes", ";", "}" ]
Returns a set of label attributes for the current status. @param int $status @param string $statusMessage @return array A set of attributes to add to the label.
[ "Returns", "a", "set", "of", "label", "attributes", "for", "the", "current", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L224-L237
30,432
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getAmountStatusTitle
private function getAmountStatusTitle($status) { $result = ''; if ($status > static::Status_Success) { $result = $this->t('amount_status_' . $status); } return $result; }
php
private function getAmountStatusTitle($status) { $result = ''; if ($status > static::Status_Success) { $result = $this->t('amount_status_' . $status); } return $result; }
[ "private", "function", "getAmountStatusTitle", "(", "$", "status", ")", "{", "$", "result", "=", "''", ";", "if", "(", "$", "status", ">", "static", "::", "Status_Success", ")", "{", "$", "result", "=", "$", "this", "->", "t", "(", "'amount_status_'", ".", "$", "status", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns a description of the amount status. @param int $status @return string A description of the amount status.
[ "Returns", "a", "description", "of", "the", "amount", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L247-L254
30,433
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.setSubmittedSource
private function setSubmittedSource() { // Get actual source ($this->source may be the parent, not the source to // execute on). Do so without trusting the input. $sourceType = $this->getSubmittedValue('type') === Source::Order ? Source::Order : Source::CreditNote; $sourceId = (int) $this->getSubmittedValue('source'); $this->submittedSource = null; if ($this->source->getType() === $sourceType && $this->source->getId() === $sourceId) { $this->submittedSource = $this->source; } else { $creditNotes = $this->source->getCreditNotes(); foreach ($creditNotes as $creditNote) { if ($creditNote->getType() === $sourceType && $creditNote->getId() === $sourceId) { $this->submittedSource = $creditNote; } } } }
php
private function setSubmittedSource() { // Get actual source ($this->source may be the parent, not the source to // execute on). Do so without trusting the input. $sourceType = $this->getSubmittedValue('type') === Source::Order ? Source::Order : Source::CreditNote; $sourceId = (int) $this->getSubmittedValue('source'); $this->submittedSource = null; if ($this->source->getType() === $sourceType && $this->source->getId() === $sourceId) { $this->submittedSource = $this->source; } else { $creditNotes = $this->source->getCreditNotes(); foreach ($creditNotes as $creditNote) { if ($creditNote->getType() === $sourceType && $creditNote->getId() === $sourceId) { $this->submittedSource = $creditNote; } } } }
[ "private", "function", "setSubmittedSource", "(", ")", "{", "// Get actual source ($this->source may be the parent, not the source to", "// execute on). Do so without trusting the input.", "$", "sourceType", "=", "$", "this", "->", "getSubmittedValue", "(", "'type'", ")", "===", "Source", "::", "Order", "?", "Source", "::", "Order", ":", "Source", "::", "CreditNote", ";", "$", "sourceId", "=", "(", "int", ")", "$", "this", "->", "getSubmittedValue", "(", "'source'", ")", ";", "$", "this", "->", "submittedSource", "=", "null", ";", "if", "(", "$", "this", "->", "source", "->", "getType", "(", ")", "===", "$", "sourceType", "&&", "$", "this", "->", "source", "->", "getId", "(", ")", "===", "$", "sourceId", ")", "{", "$", "this", "->", "submittedSource", "=", "$", "this", "->", "source", ";", "}", "else", "{", "$", "creditNotes", "=", "$", "this", "->", "source", "->", "getCreditNotes", "(", ")", ";", "foreach", "(", "$", "creditNotes", "as", "$", "creditNote", ")", "{", "if", "(", "$", "creditNote", "->", "getType", "(", ")", "===", "$", "sourceType", "&&", "$", "creditNote", "->", "getId", "(", ")", "===", "$", "sourceId", ")", "{", "$", "this", "->", "submittedSource", "=", "$", "creditNote", ";", "}", "}", "}", "}" ]
Extracts the source on which the submitted action is targeted.
[ "Extracts", "the", "source", "on", "which", "the", "submitted", "action", "is", "targeted", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L275-L292
30,434
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getFields1Source
private function getFields1Source(Source $source, $localEntryInfo) { $this->resetStatus(); // Get invoice status field and other invoice status related info. $statusInfo = $this->getInvoiceStatusInfo($localEntryInfo); $this->setStatus($statusInfo['severity'], $statusInfo['severity-message']); /** @var string $invoiceStatus */ $invoiceStatus = $statusInfo['status']; /** @var string $statusText */ $statusText = $statusInfo['text']; /** @var string $statusDescription */ $statusDescription = $statusInfo['description']; /** @var Result|null $result */ $result = $statusInfo['result']; /** @var array $entry */ $entry = $statusInfo['entry']; // Create and add additional fields based on invoice status. switch ($invoiceStatus) { case static::Invoice_NotSent: $additionalFields = $this->getNotSentFields($source); break; case static::Invoice_SentConcept: $additionalFields = $this->getConceptFields($source); break; case static::Invoice_CommunicationError: /** @noinspection PhpUndefinedVariableInspection */ $additionalFields = $this->getCommunicationErrorFields($result); break; case static::Invoice_NonExisting: $additionalFields = $this->getNonExistingFields($source); break; case static::Invoice_Deleted: $additionalFields = $this->getDeletedFields($source); break; case static::Invoice_Sent: $additionalFields = $this->getEntryFields($source, $localEntryInfo, $entry); break; default: $additionalFields = array( 'unknown' => array( 'type' => 'markup', 'value' => sprintf($this->t('invoice_status_unknown'), $invoiceStatus), ) ); break; } // Create main status field after we have the other fields, so we can // use the results in rendering the overall status. $fields = array( 'status' => array( 'type' => 'markup', 'label' => $this->getStatusIcon($this->status), 'attributes' => array( 'class' => str_replace('_', '-', $invoiceStatus), 'label' => $this->getStatusLabelAttributes($this->status, $this->statusMessage), ), 'value' => $statusText, 'description' => $statusDescription, ), ) + $additionalFields; return $fields; }
php
private function getFields1Source(Source $source, $localEntryInfo) { $this->resetStatus(); // Get invoice status field and other invoice status related info. $statusInfo = $this->getInvoiceStatusInfo($localEntryInfo); $this->setStatus($statusInfo['severity'], $statusInfo['severity-message']); /** @var string $invoiceStatus */ $invoiceStatus = $statusInfo['status']; /** @var string $statusText */ $statusText = $statusInfo['text']; /** @var string $statusDescription */ $statusDescription = $statusInfo['description']; /** @var Result|null $result */ $result = $statusInfo['result']; /** @var array $entry */ $entry = $statusInfo['entry']; // Create and add additional fields based on invoice status. switch ($invoiceStatus) { case static::Invoice_NotSent: $additionalFields = $this->getNotSentFields($source); break; case static::Invoice_SentConcept: $additionalFields = $this->getConceptFields($source); break; case static::Invoice_CommunicationError: /** @noinspection PhpUndefinedVariableInspection */ $additionalFields = $this->getCommunicationErrorFields($result); break; case static::Invoice_NonExisting: $additionalFields = $this->getNonExistingFields($source); break; case static::Invoice_Deleted: $additionalFields = $this->getDeletedFields($source); break; case static::Invoice_Sent: $additionalFields = $this->getEntryFields($source, $localEntryInfo, $entry); break; default: $additionalFields = array( 'unknown' => array( 'type' => 'markup', 'value' => sprintf($this->t('invoice_status_unknown'), $invoiceStatus), ) ); break; } // Create main status field after we have the other fields, so we can // use the results in rendering the overall status. $fields = array( 'status' => array( 'type' => 'markup', 'label' => $this->getStatusIcon($this->status), 'attributes' => array( 'class' => str_replace('_', '-', $invoiceStatus), 'label' => $this->getStatusLabelAttributes($this->status, $this->statusMessage), ), 'value' => $statusText, 'description' => $statusDescription, ), ) + $additionalFields; return $fields; }
[ "private", "function", "getFields1Source", "(", "Source", "$", "source", ",", "$", "localEntryInfo", ")", "{", "$", "this", "->", "resetStatus", "(", ")", ";", "// Get invoice status field and other invoice status related info.", "$", "statusInfo", "=", "$", "this", "->", "getInvoiceStatusInfo", "(", "$", "localEntryInfo", ")", ";", "$", "this", "->", "setStatus", "(", "$", "statusInfo", "[", "'severity'", "]", ",", "$", "statusInfo", "[", "'severity-message'", "]", ")", ";", "/** @var string $invoiceStatus */", "$", "invoiceStatus", "=", "$", "statusInfo", "[", "'status'", "]", ";", "/** @var string $statusText */", "$", "statusText", "=", "$", "statusInfo", "[", "'text'", "]", ";", "/** @var string $statusDescription */", "$", "statusDescription", "=", "$", "statusInfo", "[", "'description'", "]", ";", "/** @var Result|null $result */", "$", "result", "=", "$", "statusInfo", "[", "'result'", "]", ";", "/** @var array $entry */", "$", "entry", "=", "$", "statusInfo", "[", "'entry'", "]", ";", "// Create and add additional fields based on invoice status.", "switch", "(", "$", "invoiceStatus", ")", "{", "case", "static", "::", "Invoice_NotSent", ":", "$", "additionalFields", "=", "$", "this", "->", "getNotSentFields", "(", "$", "source", ")", ";", "break", ";", "case", "static", "::", "Invoice_SentConcept", ":", "$", "additionalFields", "=", "$", "this", "->", "getConceptFields", "(", "$", "source", ")", ";", "break", ";", "case", "static", "::", "Invoice_CommunicationError", ":", "/** @noinspection PhpUndefinedVariableInspection */", "$", "additionalFields", "=", "$", "this", "->", "getCommunicationErrorFields", "(", "$", "result", ")", ";", "break", ";", "case", "static", "::", "Invoice_NonExisting", ":", "$", "additionalFields", "=", "$", "this", "->", "getNonExistingFields", "(", "$", "source", ")", ";", "break", ";", "case", "static", "::", "Invoice_Deleted", ":", "$", "additionalFields", "=", "$", "this", "->", "getDeletedFields", "(", "$", "source", ")", ";", "break", ";", "case", "static", "::", "Invoice_Sent", ":", "$", "additionalFields", "=", "$", "this", "->", "getEntryFields", "(", "$", "source", ",", "$", "localEntryInfo", ",", "$", "entry", ")", ";", "break", ";", "default", ":", "$", "additionalFields", "=", "array", "(", "'unknown'", "=>", "array", "(", "'type'", "=>", "'markup'", ",", "'value'", "=>", "sprintf", "(", "$", "this", "->", "t", "(", "'invoice_status_unknown'", ")", ",", "$", "invoiceStatus", ")", ",", ")", ")", ";", "break", ";", "}", "// Create main status field after we have the other fields, so we can", "// use the results in rendering the overall status.", "$", "fields", "=", "array", "(", "'status'", "=>", "array", "(", "'type'", "=>", "'markup'", ",", "'label'", "=>", "$", "this", "->", "getStatusIcon", "(", "$", "this", "->", "status", ")", ",", "'attributes'", "=>", "array", "(", "'class'", "=>", "str_replace", "(", "'_'", ",", "'-'", ",", "$", "invoiceStatus", ")", ",", "'label'", "=>", "$", "this", "->", "getStatusLabelAttributes", "(", "$", "this", "->", "status", ",", "$", "this", "->", "statusMessage", ")", ",", ")", ",", "'value'", "=>", "$", "statusText", ",", "'description'", "=>", "$", "statusDescription", ",", ")", ",", ")", "+", "$", "additionalFields", ";", "return", "$", "fields", ";", "}" ]
Returns the overview for 1 source. @param \Siel\Acumulus\Invoice\Source $source @param \Siel\Acumulus\Shop\AcumulusEntry|null $localEntryInfo @return array[] The fields that describe the status for 1 source.
[ "Returns", "the", "overview", "for", "1", "source", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L414-L478
30,435
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getInvoiceStatusInfo
private function getInvoiceStatusInfo($localEntryInfo) { $result = null; $entry = null; $arg1 = null; $arg2 = null; $description = ''; $statusMessage = null; if ($localEntryInfo === null) { $invoiceStatus = static::Invoice_NotSent; $statusSeverity = static::Status_Info; } else { $arg1 = $this->getDate($localEntryInfo->getUpdated()); if ($localEntryInfo->getEntryId() === null) { $invoiceStatus = static::Invoice_SentConcept; $description = 'concept_description'; $statusSeverity = static::Status_Warning; } else { $result = $this->service->getEntry($localEntryInfo->getEntryId()); $entry = $this->sanitizeEntry($result->getResponse()); if ($result->hasCodeTag('XGYBSN000')) { $invoiceStatus = static::Invoice_NonExisting; $statusSeverity = static::Status_Error; // To prevent this error in the future, we delete the local // entry. $this->acumulusEntryManager->delete($localEntryInfo); } elseif (empty($entry)) { $invoiceStatus = static::Invoice_CommunicationError; $statusSeverity = static::Status_Error; } elseif (!empty($entry['deleted'])) { $invoiceStatus = static::Invoice_Deleted; $statusSeverity = static::Status_Warning; $arg2 = $entry['deleted']; } else { $invoiceStatus = static::Invoice_Sent; $arg1 = $entry['invoicenumber']; $arg2 = $entry['entrydate']; $statusSeverity = static::Status_Success; $statusMessage = $this->t('invoice_status_ok'); } } } return array( 'severity' => $statusSeverity, 'severity-message' => $statusMessage, 'status' => $invoiceStatus, 'result' => $result, 'entry' => $entry, 'text' => sprintf($this->t($invoiceStatus), $arg1, $arg2), 'description' => $this->t($description), ); }
php
private function getInvoiceStatusInfo($localEntryInfo) { $result = null; $entry = null; $arg1 = null; $arg2 = null; $description = ''; $statusMessage = null; if ($localEntryInfo === null) { $invoiceStatus = static::Invoice_NotSent; $statusSeverity = static::Status_Info; } else { $arg1 = $this->getDate($localEntryInfo->getUpdated()); if ($localEntryInfo->getEntryId() === null) { $invoiceStatus = static::Invoice_SentConcept; $description = 'concept_description'; $statusSeverity = static::Status_Warning; } else { $result = $this->service->getEntry($localEntryInfo->getEntryId()); $entry = $this->sanitizeEntry($result->getResponse()); if ($result->hasCodeTag('XGYBSN000')) { $invoiceStatus = static::Invoice_NonExisting; $statusSeverity = static::Status_Error; // To prevent this error in the future, we delete the local // entry. $this->acumulusEntryManager->delete($localEntryInfo); } elseif (empty($entry)) { $invoiceStatus = static::Invoice_CommunicationError; $statusSeverity = static::Status_Error; } elseif (!empty($entry['deleted'])) { $invoiceStatus = static::Invoice_Deleted; $statusSeverity = static::Status_Warning; $arg2 = $entry['deleted']; } else { $invoiceStatus = static::Invoice_Sent; $arg1 = $entry['invoicenumber']; $arg2 = $entry['entrydate']; $statusSeverity = static::Status_Success; $statusMessage = $this->t('invoice_status_ok'); } } } return array( 'severity' => $statusSeverity, 'severity-message' => $statusMessage, 'status' => $invoiceStatus, 'result' => $result, 'entry' => $entry, 'text' => sprintf($this->t($invoiceStatus), $arg1, $arg2), 'description' => $this->t($description), ); }
[ "private", "function", "getInvoiceStatusInfo", "(", "$", "localEntryInfo", ")", "{", "$", "result", "=", "null", ";", "$", "entry", "=", "null", ";", "$", "arg1", "=", "null", ";", "$", "arg2", "=", "null", ";", "$", "description", "=", "''", ";", "$", "statusMessage", "=", "null", ";", "if", "(", "$", "localEntryInfo", "===", "null", ")", "{", "$", "invoiceStatus", "=", "static", "::", "Invoice_NotSent", ";", "$", "statusSeverity", "=", "static", "::", "Status_Info", ";", "}", "else", "{", "$", "arg1", "=", "$", "this", "->", "getDate", "(", "$", "localEntryInfo", "->", "getUpdated", "(", ")", ")", ";", "if", "(", "$", "localEntryInfo", "->", "getEntryId", "(", ")", "===", "null", ")", "{", "$", "invoiceStatus", "=", "static", "::", "Invoice_SentConcept", ";", "$", "description", "=", "'concept_description'", ";", "$", "statusSeverity", "=", "static", "::", "Status_Warning", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "service", "->", "getEntry", "(", "$", "localEntryInfo", "->", "getEntryId", "(", ")", ")", ";", "$", "entry", "=", "$", "this", "->", "sanitizeEntry", "(", "$", "result", "->", "getResponse", "(", ")", ")", ";", "if", "(", "$", "result", "->", "hasCodeTag", "(", "'XGYBSN000'", ")", ")", "{", "$", "invoiceStatus", "=", "static", "::", "Invoice_NonExisting", ";", "$", "statusSeverity", "=", "static", "::", "Status_Error", ";", "// To prevent this error in the future, we delete the local", "// entry.", "$", "this", "->", "acumulusEntryManager", "->", "delete", "(", "$", "localEntryInfo", ")", ";", "}", "elseif", "(", "empty", "(", "$", "entry", ")", ")", "{", "$", "invoiceStatus", "=", "static", "::", "Invoice_CommunicationError", ";", "$", "statusSeverity", "=", "static", "::", "Status_Error", ";", "}", "elseif", "(", "!", "empty", "(", "$", "entry", "[", "'deleted'", "]", ")", ")", "{", "$", "invoiceStatus", "=", "static", "::", "Invoice_Deleted", ";", "$", "statusSeverity", "=", "static", "::", "Status_Warning", ";", "$", "arg2", "=", "$", "entry", "[", "'deleted'", "]", ";", "}", "else", "{", "$", "invoiceStatus", "=", "static", "::", "Invoice_Sent", ";", "$", "arg1", "=", "$", "entry", "[", "'invoicenumber'", "]", ";", "$", "arg2", "=", "$", "entry", "[", "'entrydate'", "]", ";", "$", "statusSeverity", "=", "static", "::", "Status_Success", ";", "$", "statusMessage", "=", "$", "this", "->", "t", "(", "'invoice_status_ok'", ")", ";", "}", "}", "}", "return", "array", "(", "'severity'", "=>", "$", "statusSeverity", ",", "'severity-message'", "=>", "$", "statusMessage", ",", "'status'", "=>", "$", "invoiceStatus", ",", "'result'", "=>", "$", "result", ",", "'entry'", "=>", "$", "entry", ",", "'text'", "=>", "sprintf", "(", "$", "this", "->", "t", "(", "$", "invoiceStatus", ")", ",", "$", "arg1", ",", "$", "arg2", ")", ",", "'description'", "=>", "$", "this", "->", "t", "(", "$", "description", ")", ",", ")", ";", "}" ]
Returns status related information. @param \Siel\Acumulus\Shop\AcumulusEntry|null $localEntryInfo @return array Keyed array with keys: - status (string): 1 of the ShopOrderOverviewForm::Status_ constants. - send-status (string): 1 of the ShopOrderOverviewForm::Invoice_ constants. - result (\Siel\Acumulus\Web\Result?): result of the getEntry API call. - entry (array|null): the <entry> part of the getEntry API call. - statusField (array): a form field array representing the status.
[ "Returns", "status", "related", "information", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L493-L545
30,436
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getNotSentFields
private function getNotSentFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 0, ), 'value' => $this->t('send_now'), ), ); return $fields; }
php
private function getNotSentFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 0, ), 'value' => $this->t('send_now'), ), ); return $fields; }
[ "private", "function", "getNotSentFields", "(", "Source", "$", "source", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'send'", "=>", "array", "(", "'type'", "=>", "'button'", ",", "'ajax'", "=>", "array", "(", "'service'", "=>", "'invoice_add'", ",", "'parent_type'", "=>", "$", "this", "->", "source", "->", "getType", "(", ")", ",", "'parent_source'", "=>", "$", "this", "->", "source", "->", "getId", "(", ")", ",", "'type'", "=>", "$", "source", "->", "getType", "(", ")", ",", "'source'", "=>", "$", "source", "->", "getId", "(", ")", ",", "'value'", "=>", "0", ",", ")", ",", "'value'", "=>", "$", "this", "->", "t", "(", "'send_now'", ")", ",", ")", ",", ")", ";", "return", "$", "fields", ";", "}" ]
Returns additional form fields to show when the invoice has not yet been sent. @param \Siel\Acumulus\Invoice\Source $source The Source for which the invoice has not yet been sent. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "not", "yet", "been", "sent", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L557-L576
30,437
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getConceptFields
private function getConceptFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
php
private function getConceptFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
[ "private", "function", "getConceptFields", "(", "Source", "$", "source", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'send'", "=>", "array", "(", "'type'", "=>", "'button'", ",", "'value'", "=>", "$", "this", "->", "t", "(", "'send_again'", ")", ",", "'ajax'", "=>", "array", "(", "'service'", "=>", "'invoice_add'", ",", "'parent_type'", "=>", "$", "this", "->", "source", "->", "getType", "(", ")", ",", "'parent_source'", "=>", "$", "this", "->", "source", "->", "getId", "(", ")", ",", "'type'", "=>", "$", "source", "->", "getType", "(", ")", ",", "'source'", "=>", "$", "source", "->", "getId", "(", ")", ",", "'value'", "=>", "1", ",", ")", ",", ")", ",", ")", ";", "return", "$", "fields", ";", "}" ]
Returns additional form fields to show when the invoice has been sent as concept. @param \Siel\Acumulus\Invoice\Source $source The Source for which the invoice was sent as concept. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "been", "sent", "as", "concept", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L588-L606
30,438
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getCommunicationErrorFields
private function getCommunicationErrorFields(Result $result) { $fields = array(); $fields += array( 'messages' => array( 'type' => 'markup', 'label' => $this->t('messages'), 'value' => $result->getMessages(Result::Format_FormattedText), ), ); return $fields; }
php
private function getCommunicationErrorFields(Result $result) { $fields = array(); $fields += array( 'messages' => array( 'type' => 'markup', 'label' => $this->t('messages'), 'value' => $result->getMessages(Result::Format_FormattedText), ), ); return $fields; }
[ "private", "function", "getCommunicationErrorFields", "(", "Result", "$", "result", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'messages'", "=>", "array", "(", "'type'", "=>", "'markup'", ",", "'label'", "=>", "$", "this", "->", "t", "(", "'messages'", ")", ",", "'value'", "=>", "$", "result", "->", "getMessages", "(", "Result", "::", "Format_FormattedText", ")", ",", ")", ",", ")", ";", "return", "$", "fields", ";", "}" ]
Returns additional form fields to show when the invoice has been sent but a communication error occurred in retrieving the entry. @param \Siel\Acumulus\Web\Result $result The result that details the error. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "been", "sent", "but", "a", "communication", "error", "occurred", "in", "retrieving", "the", "entry", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L618-L629
30,439
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getNonExistingFields
private function getNonExistingFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
php
private function getNonExistingFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
[ "private", "function", "getNonExistingFields", "(", "Source", "$", "source", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'send'", "=>", "array", "(", "'type'", "=>", "'button'", ",", "'value'", "=>", "$", "this", "->", "t", "(", "'send_again'", ")", ",", "'ajax'", "=>", "array", "(", "'service'", "=>", "'invoice_add'", ",", "'parent_type'", "=>", "$", "this", "->", "source", "->", "getType", "(", ")", ",", "'parent_source'", "=>", "$", "this", "->", "source", "->", "getId", "(", ")", ",", "'type'", "=>", "$", "source", "->", "getType", "(", ")", ",", "'source'", "=>", "$", "source", "->", "getId", "(", ")", ",", "'value'", "=>", "1", ",", ")", ",", ")", ",", ")", ";", "return", "$", "fields", ";", "}" ]
Returns additional form fields to show when the invoice has been sent but does no longer exist. @param \Siel\Acumulus\Invoice\Source $source The Source for which the invoice does no longer exist. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "been", "sent", "but", "does", "no", "longer", "exist", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L641-L659
30,440
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getDeletedFields
private function getDeletedFields(Source $source) { $fields = array(); $fields += array( 'undelete' => array( 'type' => 'button', 'value' => $this->t('undelete'), 'ajax' => array( 'service' => 'entry_deletestatus_set', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => API::Entry_Delete, ), ), 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
php
private function getDeletedFields(Source $source) { $fields = array(); $fields += array( 'undelete' => array( 'type' => 'button', 'value' => $this->t('undelete'), 'ajax' => array( 'service' => 'entry_deletestatus_set', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => API::Entry_Delete, ), ), 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
[ "private", "function", "getDeletedFields", "(", "Source", "$", "source", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'undelete'", "=>", "array", "(", "'type'", "=>", "'button'", ",", "'value'", "=>", "$", "this", "->", "t", "(", "'undelete'", ")", ",", "'ajax'", "=>", "array", "(", "'service'", "=>", "'entry_deletestatus_set'", ",", "'parent_type'", "=>", "$", "this", "->", "source", "->", "getType", "(", ")", ",", "'parent_source'", "=>", "$", "this", "->", "source", "->", "getId", "(", ")", ",", "'type'", "=>", "$", "source", "->", "getType", "(", ")", ",", "'source'", "=>", "$", "source", "->", "getId", "(", ")", ",", "'value'", "=>", "API", "::", "Entry_Delete", ",", ")", ",", ")", ",", "'send'", "=>", "array", "(", "'type'", "=>", "'button'", ",", "'value'", "=>", "$", "this", "->", "t", "(", "'send_again'", ")", ",", "'ajax'", "=>", "array", "(", "'service'", "=>", "'invoice_add'", ",", "'parent_type'", "=>", "$", "this", "->", "source", "->", "getType", "(", ")", ",", "'parent_source'", "=>", "$", "this", "->", "source", "->", "getId", "(", ")", ",", "'type'", "=>", "$", "source", "->", "getType", "(", ")", ",", "'source'", "=>", "$", "source", "->", "getId", "(", ")", ",", "'value'", "=>", "1", ",", ")", ",", ")", ",", ")", ";", "return", "$", "fields", ";", "}" ]
Returns additional form fields to show when the invoice has been sent but subsequently has been deleted in Acumulus. @param \Siel\Acumulus\Invoice\Source $source The Source for which the invoice has been deleted. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "been", "sent", "but", "subsequently", "has", "been", "deleted", "in", "Acumulus", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L671-L701
30,441
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getEntryFields
private function getEntryFields(Source $source, BaseAcumulusEntry $localEntryInfo, array $entry) { /* keys in $entry array: * - entryid * * entrydate: yy-mm-dd * - entrytype * - entrydescription * - entrynote * - fiscaltype * * vatreversecharge: 0 or 1 * * foreigneu: 0 or 1 * * foreignnoneu: 0 or 1 * * marginscheme: 0 or 1 * * foreignvat: 0 or 1 * - contactid * - accountnumber * - costcenterid * - costtypeid * * invoicenumber * - invoicenote * - descriptiontext * - invoicelayoutid * - totalvalueexclvat * - totalvalue * - paymenttermdays * * paymentdate: yy-mm-dd * * paymentstatus: 1 or 2 * * deleted: timestamp */ $fields = $this->getVatTypeField($entry) + $this->getAmountFields($source, $entry) + $this->getPaymentStatusFields($source, $entry) + $this->getLinksField($localEntryInfo->getToken()); return $fields; }
php
private function getEntryFields(Source $source, BaseAcumulusEntry $localEntryInfo, array $entry) { /* keys in $entry array: * - entryid * * entrydate: yy-mm-dd * - entrytype * - entrydescription * - entrynote * - fiscaltype * * vatreversecharge: 0 or 1 * * foreigneu: 0 or 1 * * foreignnoneu: 0 or 1 * * marginscheme: 0 or 1 * * foreignvat: 0 or 1 * - contactid * - accountnumber * - costcenterid * - costtypeid * * invoicenumber * - invoicenote * - descriptiontext * - invoicelayoutid * - totalvalueexclvat * - totalvalue * - paymenttermdays * * paymentdate: yy-mm-dd * * paymentstatus: 1 or 2 * * deleted: timestamp */ $fields = $this->getVatTypeField($entry) + $this->getAmountFields($source, $entry) + $this->getPaymentStatusFields($source, $entry) + $this->getLinksField($localEntryInfo->getToken()); return $fields; }
[ "private", "function", "getEntryFields", "(", "Source", "$", "source", ",", "BaseAcumulusEntry", "$", "localEntryInfo", ",", "array", "$", "entry", ")", "{", "/* keys in $entry array:\n * - entryid\n * * entrydate: yy-mm-dd\n * - entrytype\n * - entrydescription\n * - entrynote\n * - fiscaltype\n * * vatreversecharge: 0 or 1\n * * foreigneu: 0 or 1\n * * foreignnoneu: 0 or 1\n * * marginscheme: 0 or 1\n * * foreignvat: 0 or 1\n * - contactid\n * - accountnumber\n * - costcenterid\n * - costtypeid\n * * invoicenumber\n * - invoicenote\n * - descriptiontext\n * - invoicelayoutid\n * - totalvalueexclvat\n * - totalvalue\n * - paymenttermdays\n * * paymentdate: yy-mm-dd\n * * paymentstatus: 1 or 2\n * * deleted: timestamp\n */", "$", "fields", "=", "$", "this", "->", "getVatTypeField", "(", "$", "entry", ")", "+", "$", "this", "->", "getAmountFields", "(", "$", "source", ",", "$", "entry", ")", "+", "$", "this", "->", "getPaymentStatusFields", "(", "$", "source", ",", "$", "entry", ")", "+", "$", "this", "->", "getLinksField", "(", "$", "localEntryInfo", "->", "getToken", "(", ")", ")", ";", "return", "$", "fields", ";", "}" ]
Returns additional form fields to show when the invoice is still there. @param \Siel\Acumulus\Invoice\Source $source @param \Siel\Acumulus\Shop\AcumulusEntry $localEntryInfo @param array $entry @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "is", "still", "there", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L713-L748
30,442
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getVatTypeField
private function getVatTypeField(array $entry) { if (!empty($entry['vatreversecharge'])) { if (!empty($entry['foreigneu'])) { $vatType = API::VatType_EuReversed; } else { $vatType = API::VatType_NationalReversed; } } elseif (!empty($entry['marginscheme'])) { $vatType = API::VatType_MarginScheme; } elseif (!empty($entry['foreignvat'])) { $vatType = API::VatType_ForeignVat; } elseif (!empty($entry['foreignnoneu'])) { $vatType = API::VatType_RestOfWorld; } else { $vatType = API::VatType_National; } return array( 'vat_type' => array( 'type' => 'markup', 'label' => $this->t('vat_type'), 'value' => $this->t('vat_type_' . $vatType), ), ); }
php
private function getVatTypeField(array $entry) { if (!empty($entry['vatreversecharge'])) { if (!empty($entry['foreigneu'])) { $vatType = API::VatType_EuReversed; } else { $vatType = API::VatType_NationalReversed; } } elseif (!empty($entry['marginscheme'])) { $vatType = API::VatType_MarginScheme; } elseif (!empty($entry['foreignvat'])) { $vatType = API::VatType_ForeignVat; } elseif (!empty($entry['foreignnoneu'])) { $vatType = API::VatType_RestOfWorld; } else { $vatType = API::VatType_National; } return array( 'vat_type' => array( 'type' => 'markup', 'label' => $this->t('vat_type'), 'value' => $this->t('vat_type_' . $vatType), ), ); }
[ "private", "function", "getVatTypeField", "(", "array", "$", "entry", ")", "{", "if", "(", "!", "empty", "(", "$", "entry", "[", "'vatreversecharge'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "entry", "[", "'foreigneu'", "]", ")", ")", "{", "$", "vatType", "=", "API", "::", "VatType_EuReversed", ";", "}", "else", "{", "$", "vatType", "=", "API", "::", "VatType_NationalReversed", ";", "}", "}", "elseif", "(", "!", "empty", "(", "$", "entry", "[", "'marginscheme'", "]", ")", ")", "{", "$", "vatType", "=", "API", "::", "VatType_MarginScheme", ";", "}", "elseif", "(", "!", "empty", "(", "$", "entry", "[", "'foreignvat'", "]", ")", ")", "{", "$", "vatType", "=", "API", "::", "VatType_ForeignVat", ";", "}", "elseif", "(", "!", "empty", "(", "$", "entry", "[", "'foreignnoneu'", "]", ")", ")", "{", "$", "vatType", "=", "API", "::", "VatType_RestOfWorld", ";", "}", "else", "{", "$", "vatType", "=", "API", "::", "VatType_National", ";", "}", "return", "array", "(", "'vat_type'", "=>", "array", "(", "'type'", "=>", "'markup'", ",", "'label'", "=>", "$", "this", "->", "t", "(", "'vat_type'", ")", ",", "'value'", "=>", "$", "this", "->", "t", "(", "'vat_type_'", ".", "$", "vatType", ")", ",", ")", ",", ")", ";", "}" ]
Returns the vat type field. @param array $entry @return array The vattype field.
[ "Returns", "the", "vat", "type", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L758-L782
30,443
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getAmountFields
private function getAmountFields(Source $source, array $entry) { $fields = array(); if (!empty($entry['totalvalue']) && !empty($entry['totalvalueexclvat'])) { // Get Acumulus amounts. $amountExAcumulus = $entry['totalvalueexclvat']; $amountIncAcumulus = $entry['totalvalue']; $amountVatAcumulus = $amountIncAcumulus - $amountExAcumulus; // Get local amounts. $localTotals = $source->getTotals(); // Compare. $amountExStatus = $this->getAmountStatus($amountExAcumulus, $localTotals[Meta::InvoiceAmount]); $amountIncStatus = $this->getAmountStatus($amountIncAcumulus, $localTotals[Meta::InvoiceAmountInc]); $amountVatStatus = $this->getAmountStatus($amountVatAcumulus, $localTotals[Meta::InvoiceVatAmount]); $amountEx = $this->getFormattedAmount($amountExAcumulus, $amountExStatus); $amountInc = $this->getFormattedAmount($amountIncAcumulus, $amountIncStatus); $amountVat = $this->getFormattedAmount($amountVatAcumulus, $amountVatStatus); $fields['invoice_amount'] = array( 'type' => 'markup', 'label' => $this->t('invoice_amount'), 'value' => sprintf('<div class="acumulus-amount">%1$s%2$s %4$s%3$s</div>', $amountEx, $amountVat, $amountInc, $this->t('vat')), ); } return $fields; }
php
private function getAmountFields(Source $source, array $entry) { $fields = array(); if (!empty($entry['totalvalue']) && !empty($entry['totalvalueexclvat'])) { // Get Acumulus amounts. $amountExAcumulus = $entry['totalvalueexclvat']; $amountIncAcumulus = $entry['totalvalue']; $amountVatAcumulus = $amountIncAcumulus - $amountExAcumulus; // Get local amounts. $localTotals = $source->getTotals(); // Compare. $amountExStatus = $this->getAmountStatus($amountExAcumulus, $localTotals[Meta::InvoiceAmount]); $amountIncStatus = $this->getAmountStatus($amountIncAcumulus, $localTotals[Meta::InvoiceAmountInc]); $amountVatStatus = $this->getAmountStatus($amountVatAcumulus, $localTotals[Meta::InvoiceVatAmount]); $amountEx = $this->getFormattedAmount($amountExAcumulus, $amountExStatus); $amountInc = $this->getFormattedAmount($amountIncAcumulus, $amountIncStatus); $amountVat = $this->getFormattedAmount($amountVatAcumulus, $amountVatStatus); $fields['invoice_amount'] = array( 'type' => 'markup', 'label' => $this->t('invoice_amount'), 'value' => sprintf('<div class="acumulus-amount">%1$s%2$s %4$s%3$s</div>', $amountEx, $amountVat, $amountInc, $this->t('vat')), ); } return $fields; }
[ "private", "function", "getAmountFields", "(", "Source", "$", "source", ",", "array", "$", "entry", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "entry", "[", "'totalvalue'", "]", ")", "&&", "!", "empty", "(", "$", "entry", "[", "'totalvalueexclvat'", "]", ")", ")", "{", "// Get Acumulus amounts.", "$", "amountExAcumulus", "=", "$", "entry", "[", "'totalvalueexclvat'", "]", ";", "$", "amountIncAcumulus", "=", "$", "entry", "[", "'totalvalue'", "]", ";", "$", "amountVatAcumulus", "=", "$", "amountIncAcumulus", "-", "$", "amountExAcumulus", ";", "// Get local amounts.", "$", "localTotals", "=", "$", "source", "->", "getTotals", "(", ")", ";", "// Compare.", "$", "amountExStatus", "=", "$", "this", "->", "getAmountStatus", "(", "$", "amountExAcumulus", ",", "$", "localTotals", "[", "Meta", "::", "InvoiceAmount", "]", ")", ";", "$", "amountIncStatus", "=", "$", "this", "->", "getAmountStatus", "(", "$", "amountIncAcumulus", ",", "$", "localTotals", "[", "Meta", "::", "InvoiceAmountInc", "]", ")", ";", "$", "amountVatStatus", "=", "$", "this", "->", "getAmountStatus", "(", "$", "amountVatAcumulus", ",", "$", "localTotals", "[", "Meta", "::", "InvoiceVatAmount", "]", ")", ";", "$", "amountEx", "=", "$", "this", "->", "getFormattedAmount", "(", "$", "amountExAcumulus", ",", "$", "amountExStatus", ")", ";", "$", "amountInc", "=", "$", "this", "->", "getFormattedAmount", "(", "$", "amountIncAcumulus", ",", "$", "amountIncStatus", ")", ";", "$", "amountVat", "=", "$", "this", "->", "getFormattedAmount", "(", "$", "amountVatAcumulus", ",", "$", "amountVatStatus", ")", ";", "$", "fields", "[", "'invoice_amount'", "]", "=", "array", "(", "'type'", "=>", "'markup'", ",", "'label'", "=>", "$", "this", "->", "t", "(", "'invoice_amount'", ")", ",", "'value'", "=>", "sprintf", "(", "'<div class=\"acumulus-amount\">%1$s%2$s %4$s%3$s</div>'", ",", "$", "amountEx", ",", "$", "amountVat", ",", "$", "amountInc", ",", "$", "this", "->", "t", "(", "'vat'", ")", ")", ",", ")", ";", "}", "return", "$", "fields", ";", "}" ]
Returns the amounts of this invoice. @param \Siel\Acumulus\Invoice\Source $source @param array $entry @return array[] Array with form fields with the payment status and date (if paid) of the invoice.
[ "Returns", "the", "amounts", "of", "this", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L881-L909
30,444
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getAmountStatus
private function getAmountStatus($amount, $amountLocal) { if (Number::floatsAreEqual($amount, $amountLocal)) { $status = static::Status_Success; } elseif (Number::floatsAreEqual($amount, $amountLocal, 0.02)) { $status = static::Status_Info; } elseif (Number::floatsAreEqual($amount, $amountLocal, 0.05)) { $status = static::Status_Warning; } else { $status = static::Status_Error; } return $status; }
php
private function getAmountStatus($amount, $amountLocal) { if (Number::floatsAreEqual($amount, $amountLocal)) { $status = static::Status_Success; } elseif (Number::floatsAreEqual($amount, $amountLocal, 0.02)) { $status = static::Status_Info; } elseif (Number::floatsAreEqual($amount, $amountLocal, 0.05)) { $status = static::Status_Warning; } else { $status = static::Status_Error; } return $status; }
[ "private", "function", "getAmountStatus", "(", "$", "amount", ",", "$", "amountLocal", ")", "{", "if", "(", "Number", "::", "floatsAreEqual", "(", "$", "amount", ",", "$", "amountLocal", ")", ")", "{", "$", "status", "=", "static", "::", "Status_Success", ";", "}", "elseif", "(", "Number", "::", "floatsAreEqual", "(", "$", "amount", ",", "$", "amountLocal", ",", "0.02", ")", ")", "{", "$", "status", "=", "static", "::", "Status_Info", ";", "}", "elseif", "(", "Number", "::", "floatsAreEqual", "(", "$", "amount", ",", "$", "amountLocal", ",", "0.05", ")", ")", "{", "$", "status", "=", "static", "::", "Status_Warning", ";", "}", "else", "{", "$", "status", "=", "static", "::", "Status_Error", ";", "}", "return", "$", "status", ";", "}" ]
Returns the status of an amount by comparing it with its local value. If the amounts differ: - < 0.5 cent, they are considered equal and 'success' will be returned. - < 2 cents, it is considered a mere rounding error and 'info' will be returned. - < 5 cents, it is considered a probable error and 'warning' will be returned. - >= 5 cents, it is considered an error and 'error' will be returned. @param float $amount @param float $amountLocal @return int One of the Status_... constants.
[ "Returns", "the", "status", "of", "an", "amount", "by", "comparing", "it", "with", "its", "local", "value", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L926-L938
30,445
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getLinksField
private function getLinksField($token) { $uri = $this->service->getInvoicePdfUri($token); $text = ucfirst($this->t('invoice')); $title = sprintf($this->t('open_as_pdf'), $text); /** @noinspection HtmlUnknownTarget */ $invoiceLink = sprintf('<a class="%4$s" href="%1$s" title="%3$s">%2$s</a>', $uri, $text, $title, 'pdf'); $uri = $this->service->getPackingSlipUri($token); $text = ucfirst($this->t('packing_slip')); $title = sprintf($this->t('open_as_pdf'), $text); /** @noinspection HtmlUnknownTarget */ $packingSlipLink = sprintf('<a class="%4$s" href="%1$s" title="%3$s">%2$s</a>', $uri, $text, $title, 'pdf'); $fields = array( 'links' => array( 'type' => 'markup', 'label' => $this->t('documents'), 'value' => "$invoiceLink $packingSlipLink", ), ); return $fields; }
php
private function getLinksField($token) { $uri = $this->service->getInvoicePdfUri($token); $text = ucfirst($this->t('invoice')); $title = sprintf($this->t('open_as_pdf'), $text); /** @noinspection HtmlUnknownTarget */ $invoiceLink = sprintf('<a class="%4$s" href="%1$s" title="%3$s">%2$s</a>', $uri, $text, $title, 'pdf'); $uri = $this->service->getPackingSlipUri($token); $text = ucfirst($this->t('packing_slip')); $title = sprintf($this->t('open_as_pdf'), $text); /** @noinspection HtmlUnknownTarget */ $packingSlipLink = sprintf('<a class="%4$s" href="%1$s" title="%3$s">%2$s</a>', $uri, $text, $title, 'pdf'); $fields = array( 'links' => array( 'type' => 'markup', 'label' => $this->t('documents'), 'value' => "$invoiceLink $packingSlipLink", ), ); return $fields; }
[ "private", "function", "getLinksField", "(", "$", "token", ")", "{", "$", "uri", "=", "$", "this", "->", "service", "->", "getInvoicePdfUri", "(", "$", "token", ")", ";", "$", "text", "=", "ucfirst", "(", "$", "this", "->", "t", "(", "'invoice'", ")", ")", ";", "$", "title", "=", "sprintf", "(", "$", "this", "->", "t", "(", "'open_as_pdf'", ")", ",", "$", "text", ")", ";", "/** @noinspection HtmlUnknownTarget */", "$", "invoiceLink", "=", "sprintf", "(", "'<a class=\"%4$s\" href=\"%1$s\" title=\"%3$s\">%2$s</a>'", ",", "$", "uri", ",", "$", "text", ",", "$", "title", ",", "'pdf'", ")", ";", "$", "uri", "=", "$", "this", "->", "service", "->", "getPackingSlipUri", "(", "$", "token", ")", ";", "$", "text", "=", "ucfirst", "(", "$", "this", "->", "t", "(", "'packing_slip'", ")", ")", ";", "$", "title", "=", "sprintf", "(", "$", "this", "->", "t", "(", "'open_as_pdf'", ")", ",", "$", "text", ")", ";", "/** @noinspection HtmlUnknownTarget */", "$", "packingSlipLink", "=", "sprintf", "(", "'<a class=\"%4$s\" href=\"%1$s\" title=\"%3$s\">%2$s</a>'", ",", "$", "uri", ",", "$", "text", ",", "$", "title", ",", "'pdf'", ")", ";", "$", "fields", "=", "array", "(", "'links'", "=>", "array", "(", "'type'", "=>", "'markup'", ",", "'label'", "=>", "$", "this", "->", "t", "(", "'documents'", ")", ",", "'value'", "=>", "\"$invoiceLink $packingSlipLink\"", ",", ")", ",", ")", ";", "return", "$", "fields", ";", "}" ]
Returns links to the invoice and packing slip documents. @param string $token @return array[] Array with form field that contains links to documents related to this invoice.
[ "Returns", "links", "to", "the", "invoice", "and", "packing", "slip", "documents", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L982-L1004
30,446
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.sanitizeEntry
private function sanitizeEntry($entry) { if (!empty($entry)) { /* @todo: keys in $entry array that are not yet used and not yet sanitized: * - entrytype * - entrydescription * - entrynote * - fiscaltype * - contactid * - accountnumber * - costcenterid * - costtypeid * - invoicenote * - descriptiontext * - invoicelayoutid * - token * - paymenttermdays */ $result['entryid'] = $this->sanitizeEntryIntValue($entry, 'entryid'); $result['entrydate'] = $this->sanitizeEntryDateValue($entry, 'entrydate'); $result['vatreversecharge'] = $this->sanitizeEntryBoolValue($entry, 'vatreversecharge'); $result['foreigneu'] = $this->sanitizeEntryBoolValue($entry, 'foreigneu'); $result['foreignnoneu'] = $this->sanitizeEntryBoolValue($entry, 'foreignnoneu'); $result['marginscheme'] = $this->sanitizeEntryBoolValue($entry, 'marginscheme'); $result['foreignvat'] = $this->sanitizeEntryBoolValue($entry, 'foreignvat'); $result['invoicenumber'] = $this->sanitizeEntryIntValue($entry, 'invoicenumber'); $result['totalvalueexclvat'] = $this->sanitizeEntryFloatValue($entry, 'totalvalueexclvat'); $result['totalvalue'] = $this->sanitizeEntryFloatValue($entry, 'totalvalue'); $result['paymentstatus'] = $this->sanitizeEntryIntValue($entry, 'paymentstatus'); $result['paymentdate'] = $this->sanitizeEntryDateValue($entry, 'paymentdate'); $result['deleted'] = $this->sanitizeEntryStringValue($entry, 'deleted'); } else { $result = null; } return $result; }
php
private function sanitizeEntry($entry) { if (!empty($entry)) { /* @todo: keys in $entry array that are not yet used and not yet sanitized: * - entrytype * - entrydescription * - entrynote * - fiscaltype * - contactid * - accountnumber * - costcenterid * - costtypeid * - invoicenote * - descriptiontext * - invoicelayoutid * - token * - paymenttermdays */ $result['entryid'] = $this->sanitizeEntryIntValue($entry, 'entryid'); $result['entrydate'] = $this->sanitizeEntryDateValue($entry, 'entrydate'); $result['vatreversecharge'] = $this->sanitizeEntryBoolValue($entry, 'vatreversecharge'); $result['foreigneu'] = $this->sanitizeEntryBoolValue($entry, 'foreigneu'); $result['foreignnoneu'] = $this->sanitizeEntryBoolValue($entry, 'foreignnoneu'); $result['marginscheme'] = $this->sanitizeEntryBoolValue($entry, 'marginscheme'); $result['foreignvat'] = $this->sanitizeEntryBoolValue($entry, 'foreignvat'); $result['invoicenumber'] = $this->sanitizeEntryIntValue($entry, 'invoicenumber'); $result['totalvalueexclvat'] = $this->sanitizeEntryFloatValue($entry, 'totalvalueexclvat'); $result['totalvalue'] = $this->sanitizeEntryFloatValue($entry, 'totalvalue'); $result['paymentstatus'] = $this->sanitizeEntryIntValue($entry, 'paymentstatus'); $result['paymentdate'] = $this->sanitizeEntryDateValue($entry, 'paymentdate'); $result['deleted'] = $this->sanitizeEntryStringValue($entry, 'deleted'); } else { $result = null; } return $result; }
[ "private", "function", "sanitizeEntry", "(", "$", "entry", ")", "{", "if", "(", "!", "empty", "(", "$", "entry", ")", ")", "{", "/* @todo: keys in $entry array that are not yet used and not yet sanitized:\n * - entrytype\n * - entrydescription\n * - entrynote\n * - fiscaltype\n * - contactid\n * - accountnumber\n * - costcenterid\n * - costtypeid\n * - invoicenote\n * - descriptiontext\n * - invoicelayoutid\n * - token\n * - paymenttermdays\n */", "$", "result", "[", "'entryid'", "]", "=", "$", "this", "->", "sanitizeEntryIntValue", "(", "$", "entry", ",", "'entryid'", ")", ";", "$", "result", "[", "'entrydate'", "]", "=", "$", "this", "->", "sanitizeEntryDateValue", "(", "$", "entry", ",", "'entrydate'", ")", ";", "$", "result", "[", "'vatreversecharge'", "]", "=", "$", "this", "->", "sanitizeEntryBoolValue", "(", "$", "entry", ",", "'vatreversecharge'", ")", ";", "$", "result", "[", "'foreigneu'", "]", "=", "$", "this", "->", "sanitizeEntryBoolValue", "(", "$", "entry", ",", "'foreigneu'", ")", ";", "$", "result", "[", "'foreignnoneu'", "]", "=", "$", "this", "->", "sanitizeEntryBoolValue", "(", "$", "entry", ",", "'foreignnoneu'", ")", ";", "$", "result", "[", "'marginscheme'", "]", "=", "$", "this", "->", "sanitizeEntryBoolValue", "(", "$", "entry", ",", "'marginscheme'", ")", ";", "$", "result", "[", "'foreignvat'", "]", "=", "$", "this", "->", "sanitizeEntryBoolValue", "(", "$", "entry", ",", "'foreignvat'", ")", ";", "$", "result", "[", "'invoicenumber'", "]", "=", "$", "this", "->", "sanitizeEntryIntValue", "(", "$", "entry", ",", "'invoicenumber'", ")", ";", "$", "result", "[", "'totalvalueexclvat'", "]", "=", "$", "this", "->", "sanitizeEntryFloatValue", "(", "$", "entry", ",", "'totalvalueexclvat'", ")", ";", "$", "result", "[", "'totalvalue'", "]", "=", "$", "this", "->", "sanitizeEntryFloatValue", "(", "$", "entry", ",", "'totalvalue'", ")", ";", "$", "result", "[", "'paymentstatus'", "]", "=", "$", "this", "->", "sanitizeEntryIntValue", "(", "$", "entry", ",", "'paymentstatus'", ")", ";", "$", "result", "[", "'paymentdate'", "]", "=", "$", "this", "->", "sanitizeEntryDateValue", "(", "$", "entry", ",", "'paymentdate'", ")", ";", "$", "result", "[", "'deleted'", "]", "=", "$", "this", "->", "sanitizeEntryStringValue", "(", "$", "entry", ",", "'deleted'", ")", ";", "}", "else", "{", "$", "result", "=", "null", ";", "}", "return", "$", "result", ";", "}" ]
Sanitizes an entry struct received via an getEntry API call. The info received from an external API call must not be trusted, so it should be sanitized. As most info from this API call is placed in markup fields we cannot rely on the FormRenderer or the webshop's form API (which do not sanitize markup fields). So we sanitize the values in the struct itself before using them: - Int, float, and bool fields are cast to their proper type. - Date strings are parsed to a DateTime and formatted back to a date string. - Strings that can only contain a restricted set of values are checked against that set and emptied if not part of it. - Free string values are escaped to save html. - Keys we don't use are not returned. This keeps the output safe when a future API version returns additional fields and we forget to sanitize it and thus use it non sanitised. @param $entry @return mixed The sanitized entry struct.
[ "Sanitizes", "an", "entry", "struct", "received", "via", "an", "getEntry", "API", "call", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L1079-L1114
30,447
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.sanitizeEntryStringValue
private function sanitizeEntryStringValue(array $entry, $key) { return !empty($entry[$key]) ? htmlspecialchars($entry[$key], ENT_NOQUOTES) : ''; }
php
private function sanitizeEntryStringValue(array $entry, $key) { return !empty($entry[$key]) ? htmlspecialchars($entry[$key], ENT_NOQUOTES) : ''; }
[ "private", "function", "sanitizeEntryStringValue", "(", "array", "$", "entry", ",", "$", "key", ")", "{", "return", "!", "empty", "(", "$", "entry", "[", "$", "key", "]", ")", "?", "htmlspecialchars", "(", "$", "entry", "[", "$", "key", "]", ",", "ENT_NOQUOTES", ")", ":", "''", ";", "}" ]
Returns a html safe version of a string in an entry record. @param array $entry @param string $key @return string The html safe version of the value under this key or the empty string if not set.
[ "Returns", "a", "html", "safe", "version", "of", "a", "string", "in", "an", "entry", "record", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L1126-L1129
30,448
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.sanitizeEntryDateValue
private function sanitizeEntryDateValue(array $entry, $key) { $date = ''; if (!empty($entry[$key])) { $date = DateTime::createFromFormat(API::DateFormat_Iso, $entry[$key]); if ($date instanceof DateTime) { $date = $date->format(Api::DateFormat_Iso); } else { $date = ''; } } return $date; }
php
private function sanitizeEntryDateValue(array $entry, $key) { $date = ''; if (!empty($entry[$key])) { $date = DateTime::createFromFormat(API::DateFormat_Iso, $entry[$key]); if ($date instanceof DateTime) { $date = $date->format(Api::DateFormat_Iso); } else { $date = ''; } } return $date; }
[ "private", "function", "sanitizeEntryDateValue", "(", "array", "$", "entry", ",", "$", "key", ")", "{", "$", "date", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "entry", "[", "$", "key", "]", ")", ")", "{", "$", "date", "=", "DateTime", "::", "createFromFormat", "(", "API", "::", "DateFormat_Iso", ",", "$", "entry", "[", "$", "key", "]", ")", ";", "if", "(", "$", "date", "instanceof", "DateTime", ")", "{", "$", "date", "=", "$", "date", "->", "format", "(", "Api", "::", "DateFormat_Iso", ")", ";", "}", "else", "{", "$", "date", "=", "''", ";", "}", "}", "return", "$", "date", ";", "}" ]
Returns a sanitized date value of an entry record. @param array $entry @param string $key @return string The date value (yyyy-mm-dd) of the value under this key or the empty string, if the string is not in the valid date format (yyyy-mm-dd).
[ "Returns", "a", "sanitized", "date", "value", "of", "an", "entry", "record", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L1185-L1197
30,449
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.initPossibleVatTypes
protected function initPossibleVatTypes() { $possibleVatTypes = array(); $shopSettings = $this->config->getShopSettings(); $nature = $shopSettings['nature_shop']; $margin = $shopSettings['marginProducts']; $foreignVat = $shopSettings['foreignVat']; if (!empty($this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType])) { // If shop specific code or an event handler has already set the vat // type, we obey so. $possibleVatTypes[] = $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType]; } else { if ($this->isNl()) { $possibleVatTypes[] = Api::VatType_National; // Can it be national reversed VAT: not really supported but // possible. if ($this->isCompany()) { $possibleVatTypes[] = Api::VatType_NationalReversed; } } elseif ($this->isEu()) { // Can it be normal vat? if ($foreignVat !== PluginConfig::ForeignVat_Only) { $possibleVatTypes[] = Api::VatType_National; } // Can it be foreign vat? if ($foreignVat !== PluginConfig::ForeignVat_No) { $possibleVatTypes[] = Api::VatType_ForeignVat; } // Can it be EU reversed VAT. if ($this->isCompany()) { $possibleVatTypes[] = Api::VatType_EuReversed; } } elseif ($this->isOutsideEu()) { // Can it be national vat (possibly vat free)? Services should // use vattype = 1. if ($nature !== PluginConfig::Nature_Products) { $possibleVatTypes[] = Api::VatType_National; } // Can it be rest of world (0%)? Goods should use vat type = 4 // unless you can't or don't want to prove that the goods will // leave the EU (see // https://www.belastingdienst.nl/rekenhulpen/leveren_van_goederen_naar_het_buitenland/), // in which case we should use vat type = 1. if ($nature !== PluginConfig::Nature_Services) { $possibleVatTypes[] = Api::VatType_National; $possibleVatTypes[] = Api::VatType_RestOfWorld; } } // Can it be a margin invoice? if ($margin !== PluginConfig::MarginProducts_No) { $possibleVatTypes[] = Api::VatType_MarginScheme; } } $this->possibleVatTypes = array_unique($possibleVatTypes, SORT_NUMERIC); }
php
protected function initPossibleVatTypes() { $possibleVatTypes = array(); $shopSettings = $this->config->getShopSettings(); $nature = $shopSettings['nature_shop']; $margin = $shopSettings['marginProducts']; $foreignVat = $shopSettings['foreignVat']; if (!empty($this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType])) { // If shop specific code or an event handler has already set the vat // type, we obey so. $possibleVatTypes[] = $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType]; } else { if ($this->isNl()) { $possibleVatTypes[] = Api::VatType_National; // Can it be national reversed VAT: not really supported but // possible. if ($this->isCompany()) { $possibleVatTypes[] = Api::VatType_NationalReversed; } } elseif ($this->isEu()) { // Can it be normal vat? if ($foreignVat !== PluginConfig::ForeignVat_Only) { $possibleVatTypes[] = Api::VatType_National; } // Can it be foreign vat? if ($foreignVat !== PluginConfig::ForeignVat_No) { $possibleVatTypes[] = Api::VatType_ForeignVat; } // Can it be EU reversed VAT. if ($this->isCompany()) { $possibleVatTypes[] = Api::VatType_EuReversed; } } elseif ($this->isOutsideEu()) { // Can it be national vat (possibly vat free)? Services should // use vattype = 1. if ($nature !== PluginConfig::Nature_Products) { $possibleVatTypes[] = Api::VatType_National; } // Can it be rest of world (0%)? Goods should use vat type = 4 // unless you can't or don't want to prove that the goods will // leave the EU (see // https://www.belastingdienst.nl/rekenhulpen/leveren_van_goederen_naar_het_buitenland/), // in which case we should use vat type = 1. if ($nature !== PluginConfig::Nature_Services) { $possibleVatTypes[] = Api::VatType_National; $possibleVatTypes[] = Api::VatType_RestOfWorld; } } // Can it be a margin invoice? if ($margin !== PluginConfig::MarginProducts_No) { $possibleVatTypes[] = Api::VatType_MarginScheme; } } $this->possibleVatTypes = array_unique($possibleVatTypes, SORT_NUMERIC); }
[ "protected", "function", "initPossibleVatTypes", "(", ")", "{", "$", "possibleVatTypes", "=", "array", "(", ")", ";", "$", "shopSettings", "=", "$", "this", "->", "config", "->", "getShopSettings", "(", ")", ";", "$", "nature", "=", "$", "shopSettings", "[", "'nature_shop'", "]", ";", "$", "margin", "=", "$", "shopSettings", "[", "'marginProducts'", "]", ";", "$", "foreignVat", "=", "$", "shopSettings", "[", "'foreignVat'", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", ")", ")", "{", "// If shop specific code or an event handler has already set the vat", "// type, we obey so.", "$", "possibleVatTypes", "[", "]", "=", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", ";", "}", "else", "{", "if", "(", "$", "this", "->", "isNl", "(", ")", ")", "{", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_National", ";", "// Can it be national reversed VAT: not really supported but", "// possible.", "if", "(", "$", "this", "->", "isCompany", "(", ")", ")", "{", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_NationalReversed", ";", "}", "}", "elseif", "(", "$", "this", "->", "isEu", "(", ")", ")", "{", "// Can it be normal vat?", "if", "(", "$", "foreignVat", "!==", "PluginConfig", "::", "ForeignVat_Only", ")", "{", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_National", ";", "}", "// Can it be foreign vat?", "if", "(", "$", "foreignVat", "!==", "PluginConfig", "::", "ForeignVat_No", ")", "{", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_ForeignVat", ";", "}", "// Can it be EU reversed VAT.", "if", "(", "$", "this", "->", "isCompany", "(", ")", ")", "{", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_EuReversed", ";", "}", "}", "elseif", "(", "$", "this", "->", "isOutsideEu", "(", ")", ")", "{", "// Can it be national vat (possibly vat free)? Services should", "// use vattype = 1.", "if", "(", "$", "nature", "!==", "PluginConfig", "::", "Nature_Products", ")", "{", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_National", ";", "}", "// Can it be rest of world (0%)? Goods should use vat type = 4", "// unless you can't or don't want to prove that the goods will", "// leave the EU (see", "// https://www.belastingdienst.nl/rekenhulpen/leveren_van_goederen_naar_het_buitenland/),", "// in which case we should use vat type = 1.", "if", "(", "$", "nature", "!==", "PluginConfig", "::", "Nature_Services", ")", "{", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_National", ";", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_RestOfWorld", ";", "}", "}", "// Can it be a margin invoice?", "if", "(", "$", "margin", "!==", "PluginConfig", "::", "MarginProducts_No", ")", "{", "$", "possibleVatTypes", "[", "]", "=", "Api", "::", "VatType_MarginScheme", ";", "}", "}", "$", "this", "->", "possibleVatTypes", "=", "array_unique", "(", "$", "possibleVatTypes", ",", "SORT_NUMERIC", ")", ";", "}" ]
Initializes the list of possible vat types for this invoice. The list of possible vat types depends on: - Whether the vat type already has been set. - Whether there is at least 1 line with a costprice. - The country of the client. - Whether the client is a company. - The shop settings (selling foreign vat or vat free products). - Optionally, the date of the invoice. See also: {@see https://wiki.acumulus.nl/index.php?page=facturen-naar-het-buitenland}.
[ "Initializes", "the", "list", "of", "possible", "vat", "types", "for", "this", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L263-L319
30,450
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.initPossibleVatRates
protected function initPossibleVatRates() { $possibleVatRates = array(); $shopSettings = $this->config->getShopSettings(); $nature = $shopSettings['nature_shop']; $vatFreeProducts = $shopSettings['vatFreeProducts']; foreach ($this->possibleVatTypes as $vatType) { switch ($vatType) { case Api::VatType_National: case Api::VatType_MarginScheme: $vatTypeVatRates = $this->getVatRatesByCountryAndDate('nl'); // Add vat free (-1): // - if selling vat free products/services // - OR if outside EU AND (services OR company). if ($vatFreeProducts != PluginConfig::VatFreeProducts_No) { $vatTypeVatRates[] = -1; } elseif ($this->isOutsideEu() && ($nature !== PluginConfig::Nature_Products || $this->isCompany())) { $vatTypeVatRates[] = -1; } break; case Api::VatType_NationalReversed: case Api::VatType_EuReversed: case Api::VatType_RestOfWorld: $vatTypeVatRates = array(0); break; case Api::VatType_ForeignVat: $vatTypeVatRates = $this->getVatRatesByCountryAndDate($this->invoice[Tag::Customer][Tag::CountryCode]); break; default: $vatTypeVatRates = array(); $this->log->error('Completor::initPossibleVatRates(): unknown vat type %d', $vatType); break; } // convert the list of vat rates to a list of vat rate infos. foreach ($vatTypeVatRates as &$vatRate) { $vatRate = array(Tag::VatRate => $vatRate, Tag::VatType => $vatType); } $possibleVatRates = array_merge($possibleVatRates, $vatTypeVatRates); } $this->possibleVatRates = $possibleVatRates; }
php
protected function initPossibleVatRates() { $possibleVatRates = array(); $shopSettings = $this->config->getShopSettings(); $nature = $shopSettings['nature_shop']; $vatFreeProducts = $shopSettings['vatFreeProducts']; foreach ($this->possibleVatTypes as $vatType) { switch ($vatType) { case Api::VatType_National: case Api::VatType_MarginScheme: $vatTypeVatRates = $this->getVatRatesByCountryAndDate('nl'); // Add vat free (-1): // - if selling vat free products/services // - OR if outside EU AND (services OR company). if ($vatFreeProducts != PluginConfig::VatFreeProducts_No) { $vatTypeVatRates[] = -1; } elseif ($this->isOutsideEu() && ($nature !== PluginConfig::Nature_Products || $this->isCompany())) { $vatTypeVatRates[] = -1; } break; case Api::VatType_NationalReversed: case Api::VatType_EuReversed: case Api::VatType_RestOfWorld: $vatTypeVatRates = array(0); break; case Api::VatType_ForeignVat: $vatTypeVatRates = $this->getVatRatesByCountryAndDate($this->invoice[Tag::Customer][Tag::CountryCode]); break; default: $vatTypeVatRates = array(); $this->log->error('Completor::initPossibleVatRates(): unknown vat type %d', $vatType); break; } // convert the list of vat rates to a list of vat rate infos. foreach ($vatTypeVatRates as &$vatRate) { $vatRate = array(Tag::VatRate => $vatRate, Tag::VatType => $vatType); } $possibleVatRates = array_merge($possibleVatRates, $vatTypeVatRates); } $this->possibleVatRates = $possibleVatRates; }
[ "protected", "function", "initPossibleVatRates", "(", ")", "{", "$", "possibleVatRates", "=", "array", "(", ")", ";", "$", "shopSettings", "=", "$", "this", "->", "config", "->", "getShopSettings", "(", ")", ";", "$", "nature", "=", "$", "shopSettings", "[", "'nature_shop'", "]", ";", "$", "vatFreeProducts", "=", "$", "shopSettings", "[", "'vatFreeProducts'", "]", ";", "foreach", "(", "$", "this", "->", "possibleVatTypes", "as", "$", "vatType", ")", "{", "switch", "(", "$", "vatType", ")", "{", "case", "Api", "::", "VatType_National", ":", "case", "Api", "::", "VatType_MarginScheme", ":", "$", "vatTypeVatRates", "=", "$", "this", "->", "getVatRatesByCountryAndDate", "(", "'nl'", ")", ";", "// Add vat free (-1):", "// - if selling vat free products/services", "// - OR if outside EU AND (services OR company).", "if", "(", "$", "vatFreeProducts", "!=", "PluginConfig", "::", "VatFreeProducts_No", ")", "{", "$", "vatTypeVatRates", "[", "]", "=", "-", "1", ";", "}", "elseif", "(", "$", "this", "->", "isOutsideEu", "(", ")", "&&", "(", "$", "nature", "!==", "PluginConfig", "::", "Nature_Products", "||", "$", "this", "->", "isCompany", "(", ")", ")", ")", "{", "$", "vatTypeVatRates", "[", "]", "=", "-", "1", ";", "}", "break", ";", "case", "Api", "::", "VatType_NationalReversed", ":", "case", "Api", "::", "VatType_EuReversed", ":", "case", "Api", "::", "VatType_RestOfWorld", ":", "$", "vatTypeVatRates", "=", "array", "(", "0", ")", ";", "break", ";", "case", "Api", "::", "VatType_ForeignVat", ":", "$", "vatTypeVatRates", "=", "$", "this", "->", "getVatRatesByCountryAndDate", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "CountryCode", "]", ")", ";", "break", ";", "default", ":", "$", "vatTypeVatRates", "=", "array", "(", ")", ";", "$", "this", "->", "log", "->", "error", "(", "'Completor::initPossibleVatRates(): unknown vat type %d'", ",", "$", "vatType", ")", ";", "break", ";", "}", "// convert the list of vat rates to a list of vat rate infos.", "foreach", "(", "$", "vatTypeVatRates", "as", "&", "$", "vatRate", ")", "{", "$", "vatRate", "=", "array", "(", "Tag", "::", "VatRate", "=>", "$", "vatRate", ",", "Tag", "::", "VatType", "=>", "$", "vatType", ")", ";", "}", "$", "possibleVatRates", "=", "array_merge", "(", "$", "possibleVatRates", ",", "$", "vatTypeVatRates", ")", ";", "}", "$", "this", "->", "possibleVatRates", "=", "$", "possibleVatRates", ";", "}" ]
Initializes the list of possible vat rates. The possible vat rates depend on: - the possible vat types. - optionally, the date of the invoice. - optionally, the country of the client. - optionally, the nature of the articles sold. On finishing, $this->possibleVatRates will contain an array with possible vat rates. A vat rate being an array with keys vatrate and vattype. This is done so to be able to determine to which vat type(s) a vat rate belongs.
[ "Initializes", "the", "list", "of", "possible", "vat", "rates", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L335-L377
30,451
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.fictitiousClient
protected function fictitiousClient() { $customerSettings = $this->config->getCustomerSettings(); if (!$customerSettings['sendCustomer'] && !$this->isCompany()) { $keysToKeep = array(Tag::CountryCode, Tag::Invoice); foreach ($this->invoice[Tag::Customer] as $key => $value) { if (!in_array($key, $keysToKeep)) { unset($this->invoice[Tag::Customer][$key]); } } $this->invoice[Tag::Customer][Tag::Email] = $customerSettings['genericCustomerEmail']; $this->invoice[Tag::Customer][Tag::ContactStatus] = Api::ContactStatus_Disabled; $this->invoice[Tag::Customer][Tag::OverwriteIfExists] = Api::OverwriteIfExists_No; } }
php
protected function fictitiousClient() { $customerSettings = $this->config->getCustomerSettings(); if (!$customerSettings['sendCustomer'] && !$this->isCompany()) { $keysToKeep = array(Tag::CountryCode, Tag::Invoice); foreach ($this->invoice[Tag::Customer] as $key => $value) { if (!in_array($key, $keysToKeep)) { unset($this->invoice[Tag::Customer][$key]); } } $this->invoice[Tag::Customer][Tag::Email] = $customerSettings['genericCustomerEmail']; $this->invoice[Tag::Customer][Tag::ContactStatus] = Api::ContactStatus_Disabled; $this->invoice[Tag::Customer][Tag::OverwriteIfExists] = Api::OverwriteIfExists_No; } }
[ "protected", "function", "fictitiousClient", "(", ")", "{", "$", "customerSettings", "=", "$", "this", "->", "config", "->", "getCustomerSettings", "(", ")", ";", "if", "(", "!", "$", "customerSettings", "[", "'sendCustomer'", "]", "&&", "!", "$", "this", "->", "isCompany", "(", ")", ")", "{", "$", "keysToKeep", "=", "array", "(", "Tag", "::", "CountryCode", ",", "Tag", "::", "Invoice", ")", ";", "foreach", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "keysToKeep", ")", ")", "{", "unset", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "$", "key", "]", ")", ";", "}", "}", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Email", "]", "=", "$", "customerSettings", "[", "'genericCustomerEmail'", "]", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "ContactStatus", "]", "=", "Api", "::", "ContactStatus_Disabled", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "OverwriteIfExists", "]", "=", "Api", "::", "OverwriteIfExists_No", ";", "}", "}" ]
Anonymize customer if set so. - We don't do this for business clients, only consumers. - We keep the country code as it is needed to determine the vat type.
[ "Anonymize", "customer", "if", "set", "so", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L385-L399
30,452
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.validateEmail
protected function validateEmail() { // Check email address. if (empty($this->invoice[Tag::Customer][Tag::Email])) { $customerSettings = $this->config->getCustomerSettings(); $this->invoice[Tag::Customer][Tag::Email] = $customerSettings['emailIfAbsent']; $this->result->addWarning(801,'', $this->t('message_warning_no_email')); } else { $email = $this->invoice[Tag::Customer][Tag::Email]; $at = strpos($email, '@'); // Comma (,) used as separator? $comma = strpos($email, ',', $at); if ($at < $comma) { $email = trim(substr($email, 0, $comma)); } // Semicolon (;) used as separator? $semicolon = strpos($email, ';', $at); if ($at < $semicolon) { $email = trim(substr($email, 0, $semicolon)); } // Display name used in single remaining address? if (preg_match('/^(.+?)<([^>]+)>$/', $email, $matches)) { $email = trim($matches[2]); } $this->invoice[Tag::Customer][Tag::Email] = $email; } }
php
protected function validateEmail() { // Check email address. if (empty($this->invoice[Tag::Customer][Tag::Email])) { $customerSettings = $this->config->getCustomerSettings(); $this->invoice[Tag::Customer][Tag::Email] = $customerSettings['emailIfAbsent']; $this->result->addWarning(801,'', $this->t('message_warning_no_email')); } else { $email = $this->invoice[Tag::Customer][Tag::Email]; $at = strpos($email, '@'); // Comma (,) used as separator? $comma = strpos($email, ',', $at); if ($at < $comma) { $email = trim(substr($email, 0, $comma)); } // Semicolon (;) used as separator? $semicolon = strpos($email, ';', $at); if ($at < $semicolon) { $email = trim(substr($email, 0, $semicolon)); } // Display name used in single remaining address? if (preg_match('/^(.+?)<([^>]+)>$/', $email, $matches)) { $email = trim($matches[2]); } $this->invoice[Tag::Customer][Tag::Email] = $email; } }
[ "protected", "function", "validateEmail", "(", ")", "{", "// Check email address.", "if", "(", "empty", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Email", "]", ")", ")", "{", "$", "customerSettings", "=", "$", "this", "->", "config", "->", "getCustomerSettings", "(", ")", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Email", "]", "=", "$", "customerSettings", "[", "'emailIfAbsent'", "]", ";", "$", "this", "->", "result", "->", "addWarning", "(", "801", ",", "''", ",", "$", "this", "->", "t", "(", "'message_warning_no_email'", ")", ")", ";", "}", "else", "{", "$", "email", "=", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Email", "]", ";", "$", "at", "=", "strpos", "(", "$", "email", ",", "'@'", ")", ";", "// Comma (,) used as separator?", "$", "comma", "=", "strpos", "(", "$", "email", ",", "','", ",", "$", "at", ")", ";", "if", "(", "$", "at", "<", "$", "comma", ")", "{", "$", "email", "=", "trim", "(", "substr", "(", "$", "email", ",", "0", ",", "$", "comma", ")", ")", ";", "}", "// Semicolon (;) used as separator?", "$", "semicolon", "=", "strpos", "(", "$", "email", ",", "';'", ",", "$", "at", ")", ";", "if", "(", "$", "at", "<", "$", "semicolon", ")", "{", "$", "email", "=", "trim", "(", "substr", "(", "$", "email", ",", "0", ",", "$", "semicolon", ")", ")", ";", "}", "// Display name used in single remaining address?", "if", "(", "preg_match", "(", "'/^(.+?)<([^>]+)>$/'", ",", "$", "email", ",", "$", "matches", ")", ")", "{", "$", "email", "=", "trim", "(", "$", "matches", "[", "2", "]", ")", ";", "}", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Email", "]", "=", "$", "email", ";", "}", "}" ]
Validates the email address of the invoice. Validations performed: - Multiple, comma separated, email addresses are not allowed. - Display names (My Name <my.name@example.com>) are not allowed. - The email address may not be empty but may be left out though in which case a new relation will be created. To prevent both, we use a fake address and we will set a warning.
[ "Validates", "the", "email", "address", "of", "the", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L411-L438
30,453
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.invoiceTemplate
protected function invoiceTemplate() { $invoiceSettings = $this->config->getInvoiceSettings(); // Acumulus invoice template to use. $settingToUse = isset($this->invoice[Tag::Customer][Tag::Invoice][Tag::PaymentStatus]) && $this->invoice[Tag::Customer][Tag::Invoice][Tag::PaymentStatus] == Api::PaymentStatus_Paid // 0 (= empty) = use same invoice template as for non paid invoices. && $invoiceSettings['defaultInvoicePaidTemplate'] != 0 ? 'defaultInvoicePaidTemplate' : 'defaultInvoiceTemplate'; $this->addDefault($this->invoice[Tag::Customer][Tag::Invoice], Tag::Template, $invoiceSettings[$settingToUse]); }
php
protected function invoiceTemplate() { $invoiceSettings = $this->config->getInvoiceSettings(); // Acumulus invoice template to use. $settingToUse = isset($this->invoice[Tag::Customer][Tag::Invoice][Tag::PaymentStatus]) && $this->invoice[Tag::Customer][Tag::Invoice][Tag::PaymentStatus] == Api::PaymentStatus_Paid // 0 (= empty) = use same invoice template as for non paid invoices. && $invoiceSettings['defaultInvoicePaidTemplate'] != 0 ? 'defaultInvoicePaidTemplate' : 'defaultInvoiceTemplate'; $this->addDefault($this->invoice[Tag::Customer][Tag::Invoice], Tag::Template, $invoiceSettings[$settingToUse]); }
[ "protected", "function", "invoiceTemplate", "(", ")", "{", "$", "invoiceSettings", "=", "$", "this", "->", "config", "->", "getInvoiceSettings", "(", ")", ";", "// Acumulus invoice template to use.", "$", "settingToUse", "=", "isset", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "PaymentStatus", "]", ")", "&&", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "PaymentStatus", "]", "==", "Api", "::", "PaymentStatus_Paid", "// 0 (= empty) = use same invoice template as for non paid invoices.", "&&", "$", "invoiceSettings", "[", "'defaultInvoicePaidTemplate'", "]", "!=", "0", "?", "'defaultInvoicePaidTemplate'", ":", "'defaultInvoiceTemplate'", ";", "$", "this", "->", "addDefault", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", ",", "Tag", "::", "Template", ",", "$", "invoiceSettings", "[", "$", "settingToUse", "]", ")", ";", "}" ]
Fills the invoice template to use when sending an invoice from Acumulus. As getting the payment status right is notoriously hard, we fill this value only here in the completor phase to give users the chance to change the payment status in the acumulus invoice created event.
[ "Fills", "the", "invoice", "template", "to", "use", "when", "sending", "an", "invoice", "from", "Acumulus", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L447-L459
30,454
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.checkMissingAmount
protected function checkMissingAmount() { // Check if we are missing an amount and, if so, add a line for it. $this->completeLineTotals(); $areTotalsEqual = $this->areTotalsEqual(); if ($areTotalsEqual === false) { $this->addMissingAmountLine(); } }
php
protected function checkMissingAmount() { // Check if we are missing an amount and, if so, add a line for it. $this->completeLineTotals(); $areTotalsEqual = $this->areTotalsEqual(); if ($areTotalsEqual === false) { $this->addMissingAmountLine(); } }
[ "protected", "function", "checkMissingAmount", "(", ")", "{", "// Check if we are missing an amount and, if so, add a line for it.", "$", "this", "->", "completeLineTotals", "(", ")", ";", "$", "areTotalsEqual", "=", "$", "this", "->", "areTotalsEqual", "(", ")", ";", "if", "(", "$", "areTotalsEqual", "===", "false", ")", "{", "$", "this", "->", "addMissingAmountLine", "(", ")", ";", "}", "}" ]
Checks for a missing amount and handles it.
[ "Checks", "for", "a", "missing", "amount", "and", "handles", "it", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L486-L494
30,455
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.completeLineTotals
protected function completeLineTotals() { $linesAmount = 0.0; $linesAmountInc = 0.0; $linesVatAmount = 0.0; $this->lineTotalsStates = array( 'incomplete' => array(), 'equal' => array(), 'differ' => array(), ); $invoiceLines = $this->invoice[Tag::Customer][Tag::Invoice][Tag::Line]; foreach ($invoiceLines as $line) { if (isset($line[Meta::LineAmount])) { $linesAmount += $line[Meta::LineAmount]; } elseif (isset($line[Tag::UnitPrice])) { $linesAmount += $line[Tag::Quantity] * $line[Tag::UnitPrice]; } else { $this->lineTotalsStates['incomplete'][Meta::LinesAmount] = Meta::LinesAmount; } if (isset($line[Meta::LineAmountInc])) { $linesAmountInc += $line[Meta::LineAmountInc]; } elseif (isset($line[Meta::UnitPriceInc])) { $linesAmountInc += $line[Tag::Quantity] * $line[Meta::UnitPriceInc]; } else { $this->lineTotalsStates['incomplete'][Meta::LinesAmountInc] = Meta::LinesAmountInc; } if (isset($line[Meta::LineVatAmount])) { $linesVatAmount += $line[Meta::LineVatAmount]; } elseif (isset($line[Meta::VatAmount])) { $linesVatAmount += $line[Tag::Quantity] * $line[Meta::VatAmount]; } else { $this->lineTotalsStates['incomplete'][Meta::LinesVatAmount] = Meta::LinesVatAmount; } } $this->invoice[Tag::Customer][Tag::Invoice][Meta::LinesAmount ] = $linesAmount; $this->invoice[Tag::Customer][Tag::Invoice][Meta::LinesAmountInc] = $linesAmountInc; $this->invoice[Tag::Customer][Tag::Invoice][Meta::LinesVatAmount] = $linesVatAmount; if (!empty($this->lineTotalsStates['incomplete'])) { sort($this->lineTotalsStates['incomplete']); $this->invoice[Tag::Customer][Tag::Invoice][Meta::LinesIncomplete] = implode(',', $this->lineTotalsStates['incomplete']); } }
php
protected function completeLineTotals() { $linesAmount = 0.0; $linesAmountInc = 0.0; $linesVatAmount = 0.0; $this->lineTotalsStates = array( 'incomplete' => array(), 'equal' => array(), 'differ' => array(), ); $invoiceLines = $this->invoice[Tag::Customer][Tag::Invoice][Tag::Line]; foreach ($invoiceLines as $line) { if (isset($line[Meta::LineAmount])) { $linesAmount += $line[Meta::LineAmount]; } elseif (isset($line[Tag::UnitPrice])) { $linesAmount += $line[Tag::Quantity] * $line[Tag::UnitPrice]; } else { $this->lineTotalsStates['incomplete'][Meta::LinesAmount] = Meta::LinesAmount; } if (isset($line[Meta::LineAmountInc])) { $linesAmountInc += $line[Meta::LineAmountInc]; } elseif (isset($line[Meta::UnitPriceInc])) { $linesAmountInc += $line[Tag::Quantity] * $line[Meta::UnitPriceInc]; } else { $this->lineTotalsStates['incomplete'][Meta::LinesAmountInc] = Meta::LinesAmountInc; } if (isset($line[Meta::LineVatAmount])) { $linesVatAmount += $line[Meta::LineVatAmount]; } elseif (isset($line[Meta::VatAmount])) { $linesVatAmount += $line[Tag::Quantity] * $line[Meta::VatAmount]; } else { $this->lineTotalsStates['incomplete'][Meta::LinesVatAmount] = Meta::LinesVatAmount; } } $this->invoice[Tag::Customer][Tag::Invoice][Meta::LinesAmount ] = $linesAmount; $this->invoice[Tag::Customer][Tag::Invoice][Meta::LinesAmountInc] = $linesAmountInc; $this->invoice[Tag::Customer][Tag::Invoice][Meta::LinesVatAmount] = $linesVatAmount; if (!empty($this->lineTotalsStates['incomplete'])) { sort($this->lineTotalsStates['incomplete']); $this->invoice[Tag::Customer][Tag::Invoice][Meta::LinesIncomplete] = implode(',', $this->lineTotalsStates['incomplete']); } }
[ "protected", "function", "completeLineTotals", "(", ")", "{", "$", "linesAmount", "=", "0.0", ";", "$", "linesAmountInc", "=", "0.0", ";", "$", "linesVatAmount", "=", "0.0", ";", "$", "this", "->", "lineTotalsStates", "=", "array", "(", "'incomplete'", "=>", "array", "(", ")", ",", "'equal'", "=>", "array", "(", ")", ",", "'differ'", "=>", "array", "(", ")", ",", ")", ";", "$", "invoiceLines", "=", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "Line", "]", ";", "foreach", "(", "$", "invoiceLines", "as", "$", "line", ")", "{", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "LineAmount", "]", ")", ")", "{", "$", "linesAmount", "+=", "$", "line", "[", "Meta", "::", "LineAmount", "]", ";", "}", "elseif", "(", "isset", "(", "$", "line", "[", "Tag", "::", "UnitPrice", "]", ")", ")", "{", "$", "linesAmount", "+=", "$", "line", "[", "Tag", "::", "Quantity", "]", "*", "$", "line", "[", "Tag", "::", "UnitPrice", "]", ";", "}", "else", "{", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", "[", "Meta", "::", "LinesAmount", "]", "=", "Meta", "::", "LinesAmount", ";", "}", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "LineAmountInc", "]", ")", ")", "{", "$", "linesAmountInc", "+=", "$", "line", "[", "Meta", "::", "LineAmountInc", "]", ";", "}", "elseif", "(", "isset", "(", "$", "line", "[", "Meta", "::", "UnitPriceInc", "]", ")", ")", "{", "$", "linesAmountInc", "+=", "$", "line", "[", "Tag", "::", "Quantity", "]", "*", "$", "line", "[", "Meta", "::", "UnitPriceInc", "]", ";", "}", "else", "{", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", "[", "Meta", "::", "LinesAmountInc", "]", "=", "Meta", "::", "LinesAmountInc", ";", "}", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "LineVatAmount", "]", ")", ")", "{", "$", "linesVatAmount", "+=", "$", "line", "[", "Meta", "::", "LineVatAmount", "]", ";", "}", "elseif", "(", "isset", "(", "$", "line", "[", "Meta", "::", "VatAmount", "]", ")", ")", "{", "$", "linesVatAmount", "+=", "$", "line", "[", "Tag", "::", "Quantity", "]", "*", "$", "line", "[", "Meta", "::", "VatAmount", "]", ";", "}", "else", "{", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", "[", "Meta", "::", "LinesVatAmount", "]", "=", "Meta", "::", "LinesVatAmount", ";", "}", "}", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "LinesAmount", "]", "=", "$", "linesAmount", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "LinesAmountInc", "]", "=", "$", "linesAmountInc", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "LinesVatAmount", "]", "=", "$", "linesVatAmount", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", ")", ")", "{", "sort", "(", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", ")", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "LinesIncomplete", "]", "=", "implode", "(", "','", ",", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", ")", ";", "}", "}" ]
Calculates the total amount and vat amount for the invoice lines and adds these to the fields meta-lines-amount and meta-lines-vatamount.
[ "Calculates", "the", "total", "amount", "and", "vat", "amount", "for", "the", "invoice", "lines", "and", "adds", "these", "to", "the", "fields", "meta", "-", "lines", "-", "amount", "and", "meta", "-", "lines", "-", "vatamount", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L500-L545
30,456
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.areTotalsEqual
protected function areTotalsEqual() { $invoice = $this->invoice[Tag::Customer][Tag::Invoice]; if (!in_array(Meta::LinesAmount, $this->lineTotalsStates['incomplete'])) { if (Number::floatsAreEqual($invoice[Meta::InvoiceAmount], $invoice[Meta::LinesAmount], 0.05)) { $this->lineTotalsStates['equal'][Meta::LinesAmount] = Meta::InvoiceAmount; } else { $this->lineTotalsStates['differ'][Meta::LinesAmount] = $invoice[Meta::InvoiceAmount] - $invoice[Meta::LinesAmount]; } } if (!in_array(Meta::LinesAmountInc, $this->lineTotalsStates['incomplete'])) { if (Number::floatsAreEqual($invoice[Meta::InvoiceAmountInc], $invoice[Meta::LinesAmountInc], 0.05)) { $this->lineTotalsStates['equal'][Meta::LinesAmountInc] = Meta::InvoiceAmountInc; } else { $this->lineTotalsStates['differ'][Meta::LinesAmountInc] = $invoice[Meta::InvoiceAmountInc] - $invoice[Meta::LinesAmountInc]; } } if (!in_array(Meta::LinesVatAmount, $this->lineTotalsStates['incomplete'])) { if (Number::floatsAreEqual($invoice[Meta::InvoiceVatAmount], $invoice[Meta::LinesVatAmount], 0.05)) { $this->lineTotalsStates['equal'][Meta::LinesVatAmount] = Meta::InvoiceVatAmount; } else { $this->lineTotalsStates['differ'][Meta::LinesVatAmount] = $invoice[Meta::InvoiceVatAmount] - $invoice[Meta::LinesVatAmount]; } } $equal = count($this->lineTotalsStates['equal']); $differ = count($this->lineTotalsStates['differ']); if ($differ > 0) { $result = false; } elseif ($equal > 0) { // If only the vat amounts are equal, while the vat amount = 0, we // cannot decide that the totals are equal because this appears to // be a vat free/reversed vat invoice without any vatamount. $result = $equal === 1 && array_key_exists(Meta::InvoiceVatAmount, $this->lineTotalsStates['differ']) && Number::isZero($invoice[Meta::LinesVatAmount]) ? null : true; } else { // No equal amounts nor different amounts found: undecided. $result = null; } return $result; }
php
protected function areTotalsEqual() { $invoice = $this->invoice[Tag::Customer][Tag::Invoice]; if (!in_array(Meta::LinesAmount, $this->lineTotalsStates['incomplete'])) { if (Number::floatsAreEqual($invoice[Meta::InvoiceAmount], $invoice[Meta::LinesAmount], 0.05)) { $this->lineTotalsStates['equal'][Meta::LinesAmount] = Meta::InvoiceAmount; } else { $this->lineTotalsStates['differ'][Meta::LinesAmount] = $invoice[Meta::InvoiceAmount] - $invoice[Meta::LinesAmount]; } } if (!in_array(Meta::LinesAmountInc, $this->lineTotalsStates['incomplete'])) { if (Number::floatsAreEqual($invoice[Meta::InvoiceAmountInc], $invoice[Meta::LinesAmountInc], 0.05)) { $this->lineTotalsStates['equal'][Meta::LinesAmountInc] = Meta::InvoiceAmountInc; } else { $this->lineTotalsStates['differ'][Meta::LinesAmountInc] = $invoice[Meta::InvoiceAmountInc] - $invoice[Meta::LinesAmountInc]; } } if (!in_array(Meta::LinesVatAmount, $this->lineTotalsStates['incomplete'])) { if (Number::floatsAreEqual($invoice[Meta::InvoiceVatAmount], $invoice[Meta::LinesVatAmount], 0.05)) { $this->lineTotalsStates['equal'][Meta::LinesVatAmount] = Meta::InvoiceVatAmount; } else { $this->lineTotalsStates['differ'][Meta::LinesVatAmount] = $invoice[Meta::InvoiceVatAmount] - $invoice[Meta::LinesVatAmount]; } } $equal = count($this->lineTotalsStates['equal']); $differ = count($this->lineTotalsStates['differ']); if ($differ > 0) { $result = false; } elseif ($equal > 0) { // If only the vat amounts are equal, while the vat amount = 0, we // cannot decide that the totals are equal because this appears to // be a vat free/reversed vat invoice without any vatamount. $result = $equal === 1 && array_key_exists(Meta::InvoiceVatAmount, $this->lineTotalsStates['differ']) && Number::isZero($invoice[Meta::LinesVatAmount]) ? null : true; } else { // No equal amounts nor different amounts found: undecided. $result = null; } return $result; }
[ "protected", "function", "areTotalsEqual", "(", ")", "{", "$", "invoice", "=", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", ";", "if", "(", "!", "in_array", "(", "Meta", "::", "LinesAmount", ",", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", ")", ")", "{", "if", "(", "Number", "::", "floatsAreEqual", "(", "$", "invoice", "[", "Meta", "::", "InvoiceAmount", "]", ",", "$", "invoice", "[", "Meta", "::", "LinesAmount", "]", ",", "0.05", ")", ")", "{", "$", "this", "->", "lineTotalsStates", "[", "'equal'", "]", "[", "Meta", "::", "LinesAmount", "]", "=", "Meta", "::", "InvoiceAmount", ";", "}", "else", "{", "$", "this", "->", "lineTotalsStates", "[", "'differ'", "]", "[", "Meta", "::", "LinesAmount", "]", "=", "$", "invoice", "[", "Meta", "::", "InvoiceAmount", "]", "-", "$", "invoice", "[", "Meta", "::", "LinesAmount", "]", ";", "}", "}", "if", "(", "!", "in_array", "(", "Meta", "::", "LinesAmountInc", ",", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", ")", ")", "{", "if", "(", "Number", "::", "floatsAreEqual", "(", "$", "invoice", "[", "Meta", "::", "InvoiceAmountInc", "]", ",", "$", "invoice", "[", "Meta", "::", "LinesAmountInc", "]", ",", "0.05", ")", ")", "{", "$", "this", "->", "lineTotalsStates", "[", "'equal'", "]", "[", "Meta", "::", "LinesAmountInc", "]", "=", "Meta", "::", "InvoiceAmountInc", ";", "}", "else", "{", "$", "this", "->", "lineTotalsStates", "[", "'differ'", "]", "[", "Meta", "::", "LinesAmountInc", "]", "=", "$", "invoice", "[", "Meta", "::", "InvoiceAmountInc", "]", "-", "$", "invoice", "[", "Meta", "::", "LinesAmountInc", "]", ";", "}", "}", "if", "(", "!", "in_array", "(", "Meta", "::", "LinesVatAmount", ",", "$", "this", "->", "lineTotalsStates", "[", "'incomplete'", "]", ")", ")", "{", "if", "(", "Number", "::", "floatsAreEqual", "(", "$", "invoice", "[", "Meta", "::", "InvoiceVatAmount", "]", ",", "$", "invoice", "[", "Meta", "::", "LinesVatAmount", "]", ",", "0.05", ")", ")", "{", "$", "this", "->", "lineTotalsStates", "[", "'equal'", "]", "[", "Meta", "::", "LinesVatAmount", "]", "=", "Meta", "::", "InvoiceVatAmount", ";", "}", "else", "{", "$", "this", "->", "lineTotalsStates", "[", "'differ'", "]", "[", "Meta", "::", "LinesVatAmount", "]", "=", "$", "invoice", "[", "Meta", "::", "InvoiceVatAmount", "]", "-", "$", "invoice", "[", "Meta", "::", "LinesVatAmount", "]", ";", "}", "}", "$", "equal", "=", "count", "(", "$", "this", "->", "lineTotalsStates", "[", "'equal'", "]", ")", ";", "$", "differ", "=", "count", "(", "$", "this", "->", "lineTotalsStates", "[", "'differ'", "]", ")", ";", "if", "(", "$", "differ", ">", "0", ")", "{", "$", "result", "=", "false", ";", "}", "elseif", "(", "$", "equal", ">", "0", ")", "{", "// If only the vat amounts are equal, while the vat amount = 0, we", "// cannot decide that the totals are equal because this appears to", "// be a vat free/reversed vat invoice without any vatamount.", "$", "result", "=", "$", "equal", "===", "1", "&&", "array_key_exists", "(", "Meta", "::", "InvoiceVatAmount", ",", "$", "this", "->", "lineTotalsStates", "[", "'differ'", "]", ")", "&&", "Number", "::", "isZero", "(", "$", "invoice", "[", "Meta", "::", "LinesVatAmount", "]", ")", "?", "null", ":", "true", ";", "}", "else", "{", "// No equal amounts nor different amounts found: undecided.", "$", "result", "=", "null", ";", "}", "return", "$", "result", ";", "}" ]
Compares the invoice totals metadata with the line totals metadata. If any of the 3 values are equal we do consider the totals to be equal (except for a 0 VAT amount (for reversed VAT invoices)). This because in many cases 1 or 2 of the 3 values are either incomplete or incorrect. @return bool|null True if the totals are equal, false if not equal, null if undecided (all 3 values are incomplete).
[ "Compares", "the", "invoice", "totals", "metadata", "with", "the", "line", "totals", "metadata", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L558-L600
30,457
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.completeVatType
protected function completeVatType() { // If shop specific code or an event handler has already set the vat // type, we don't change it. if (empty($this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType])) { // @todo: if we only have one possible vattype, should we use that, or // should we perform all checks to look for contradictory evidence? $vatTypeInfo = $this->getInvoiceLinesVatTypeInfo(); $message = ''; $code = 0; if (count($vatTypeInfo['intersection']) === 0) { // No single vat type is correct for all lines, use the // union to guess what went wrong. if (count($vatTypeInfo['union']) === 0) { // None of the vat rates of the invoice lines could be // matched with any vat rate for any possible vat type. // Possible causes: // - Invoice has no vat but cannot be a reversed vat invoice // nor outside the EU, nor are vat free products or // services sold. Message: 'Check "about your shop" // settings or the vat rates assigned to your products.' // - Vat rates are incorrect for given country (and date). // Message: 'Did you configure the correct settings for // country ..?' or 'Were there recent changes in tax // rates?'. // - Vat rates are for foreign VAT but the shop does // not sell foreign VAT products. Message'Check "about // your shop" settings'. // - Vat rates are Dutch vat rates but shop only sells // foreign VAT products and client is in the EU. Message: // 'Check the vat rates assigned to your products.'. $message = 'message_warning_no_vattype_at_all'; $code = 804; } elseif (count($vatTypeInfo['union']) === 1) { // One or more lines could be matched with exactly 1 vat // type, but not all lines. // Possible causes: // - Non matching lines have no vat. Message: 'Manual line // entered without vat' or 'Check vat settings on those // products.'. // - Non matching lines have vat. Message: 'Manual line // entered with incorrect vat' or 'Check vat settings on // those products.'. $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = reset($vatTypeInfo['union']); $message = 'message_warning_no_vattype_incorrect_lines'; $code = 812; } else { // Separate lines could be matched with some of the possible // vat types, but not all with the same vat type. // Possible causes: // - Mix of foreign VAT rates and other goods or services. // Message: 'Split invoice.'. // - Some lines have no vat but no vat free goods or // services are sold and thus this could be a reversed vat // (company in EU) or vat free invoice (outside EU). // Message: check vat settings. // - Mix of margin scheme and normal vat: this can be solved // by making it a margin scheme invoice and adding // costprice = 0 to all normal lines. if (in_array(Api::VatType_MarginScheme, $vatTypeInfo['union'])) { $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = Api::VatType_MarginScheme; } else { // Take the first vat type as a guess but add a warning. $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = reset($vatTypeInfo['union']); $message = 'message_warning_no_vattype_must_split'; $code = 806; } } } elseif (count($vatTypeInfo['intersection']) === 1) { // Exactly 1 vat type was found to be possible for all lines: // use that one as the vat type for the invoice. $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = reset($vatTypeInfo['intersection']); } else { // Multiple vat types were found to be possible for all lines: // Take one and add a warning. // Possible causes: // - Client country has same vat rates as the Netherlands and // shop sells products at foreign vat rates but also other // products or services. Solvable by correct shop settings. // - Invoice has no vat and the client is outside the EU and it // is unknown whether the invoice lines contain services or // goods. Perhaps solvable by correct shop settings. // - Margin invoice: all lines that have a costprice will // probably also satisfy the normal vat. This is solvable by // making it a margin scheme invoice and adding costprice = 0 // to all normal lines. if (in_array(Api::VatType_MarginScheme, $vatTypeInfo['union'])) { $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = Api::VatType_MarginScheme; } else { // Take the first vat type as a guess but add a warning. $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = reset($vatTypeInfo['intersection']); $message = 'message_warning_no_vattype_multiple_possible'; $code = 811; } } if (!empty($message)) { // Make the invoice a concept, so it can be changed in Acumulus // and add message and meta info. $startSentence = count($vatTypeInfo['intersection']) === 0 ? 'message_warning_no_vattype' : 'message_warning_multiple_vattypes'; $this->changeInvoiceToConcept($message, $code, $this->t($startSentence)); } $this->invoice[Tag::Customer][Tag::Invoice][Meta::VatTypesPossibleInvoice] = implode(',', $this->possibleVatTypes); $this->invoice[Tag::Customer][Tag::Invoice][Meta::VatTypesPossibleInvoiceLinesIntersection] = implode(',', $vatTypeInfo['intersection']); $this->invoice[Tag::Customer][Tag::Invoice][Meta::VatTypesPossibleInvoiceLinesUnion] = implode(',', $vatTypeInfo['union']); } }
php
protected function completeVatType() { // If shop specific code or an event handler has already set the vat // type, we don't change it. if (empty($this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType])) { // @todo: if we only have one possible vattype, should we use that, or // should we perform all checks to look for contradictory evidence? $vatTypeInfo = $this->getInvoiceLinesVatTypeInfo(); $message = ''; $code = 0; if (count($vatTypeInfo['intersection']) === 0) { // No single vat type is correct for all lines, use the // union to guess what went wrong. if (count($vatTypeInfo['union']) === 0) { // None of the vat rates of the invoice lines could be // matched with any vat rate for any possible vat type. // Possible causes: // - Invoice has no vat but cannot be a reversed vat invoice // nor outside the EU, nor are vat free products or // services sold. Message: 'Check "about your shop" // settings or the vat rates assigned to your products.' // - Vat rates are incorrect for given country (and date). // Message: 'Did you configure the correct settings for // country ..?' or 'Were there recent changes in tax // rates?'. // - Vat rates are for foreign VAT but the shop does // not sell foreign VAT products. Message'Check "about // your shop" settings'. // - Vat rates are Dutch vat rates but shop only sells // foreign VAT products and client is in the EU. Message: // 'Check the vat rates assigned to your products.'. $message = 'message_warning_no_vattype_at_all'; $code = 804; } elseif (count($vatTypeInfo['union']) === 1) { // One or more lines could be matched with exactly 1 vat // type, but not all lines. // Possible causes: // - Non matching lines have no vat. Message: 'Manual line // entered without vat' or 'Check vat settings on those // products.'. // - Non matching lines have vat. Message: 'Manual line // entered with incorrect vat' or 'Check vat settings on // those products.'. $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = reset($vatTypeInfo['union']); $message = 'message_warning_no_vattype_incorrect_lines'; $code = 812; } else { // Separate lines could be matched with some of the possible // vat types, but not all with the same vat type. // Possible causes: // - Mix of foreign VAT rates and other goods or services. // Message: 'Split invoice.'. // - Some lines have no vat but no vat free goods or // services are sold and thus this could be a reversed vat // (company in EU) or vat free invoice (outside EU). // Message: check vat settings. // - Mix of margin scheme and normal vat: this can be solved // by making it a margin scheme invoice and adding // costprice = 0 to all normal lines. if (in_array(Api::VatType_MarginScheme, $vatTypeInfo['union'])) { $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = Api::VatType_MarginScheme; } else { // Take the first vat type as a guess but add a warning. $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = reset($vatTypeInfo['union']); $message = 'message_warning_no_vattype_must_split'; $code = 806; } } } elseif (count($vatTypeInfo['intersection']) === 1) { // Exactly 1 vat type was found to be possible for all lines: // use that one as the vat type for the invoice. $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = reset($vatTypeInfo['intersection']); } else { // Multiple vat types were found to be possible for all lines: // Take one and add a warning. // Possible causes: // - Client country has same vat rates as the Netherlands and // shop sells products at foreign vat rates but also other // products or services. Solvable by correct shop settings. // - Invoice has no vat and the client is outside the EU and it // is unknown whether the invoice lines contain services or // goods. Perhaps solvable by correct shop settings. // - Margin invoice: all lines that have a costprice will // probably also satisfy the normal vat. This is solvable by // making it a margin scheme invoice and adding costprice = 0 // to all normal lines. if (in_array(Api::VatType_MarginScheme, $vatTypeInfo['union'])) { $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = Api::VatType_MarginScheme; } else { // Take the first vat type as a guess but add a warning. $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] = reset($vatTypeInfo['intersection']); $message = 'message_warning_no_vattype_multiple_possible'; $code = 811; } } if (!empty($message)) { // Make the invoice a concept, so it can be changed in Acumulus // and add message and meta info. $startSentence = count($vatTypeInfo['intersection']) === 0 ? 'message_warning_no_vattype' : 'message_warning_multiple_vattypes'; $this->changeInvoiceToConcept($message, $code, $this->t($startSentence)); } $this->invoice[Tag::Customer][Tag::Invoice][Meta::VatTypesPossibleInvoice] = implode(',', $this->possibleVatTypes); $this->invoice[Tag::Customer][Tag::Invoice][Meta::VatTypesPossibleInvoiceLinesIntersection] = implode(',', $vatTypeInfo['intersection']); $this->invoice[Tag::Customer][Tag::Invoice][Meta::VatTypesPossibleInvoiceLinesUnion] = implode(',', $vatTypeInfo['union']); } }
[ "protected", "function", "completeVatType", "(", ")", "{", "// If shop specific code or an event handler has already set the vat", "// type, we don't change it.", "if", "(", "empty", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", ")", ")", "{", "// @todo: if we only have one possible vattype, should we use that, or", "// should we perform all checks to look for contradictory evidence?", "$", "vatTypeInfo", "=", "$", "this", "->", "getInvoiceLinesVatTypeInfo", "(", ")", ";", "$", "message", "=", "''", ";", "$", "code", "=", "0", ";", "if", "(", "count", "(", "$", "vatTypeInfo", "[", "'intersection'", "]", ")", "===", "0", ")", "{", "// No single vat type is correct for all lines, use the", "// union to guess what went wrong.", "if", "(", "count", "(", "$", "vatTypeInfo", "[", "'union'", "]", ")", "===", "0", ")", "{", "// None of the vat rates of the invoice lines could be", "// matched with any vat rate for any possible vat type.", "// Possible causes:", "// - Invoice has no vat but cannot be a reversed vat invoice", "// nor outside the EU, nor are vat free products or", "// services sold. Message: 'Check \"about your shop\"", "// settings or the vat rates assigned to your products.'", "// - Vat rates are incorrect for given country (and date).", "// Message: 'Did you configure the correct settings for", "// country ..?' or 'Were there recent changes in tax", "// rates?'.", "// - Vat rates are for foreign VAT but the shop does", "// not sell foreign VAT products. Message'Check \"about", "// your shop\" settings'.", "// - Vat rates are Dutch vat rates but shop only sells", "// foreign VAT products and client is in the EU. Message:", "// 'Check the vat rates assigned to your products.'.", "$", "message", "=", "'message_warning_no_vattype_at_all'", ";", "$", "code", "=", "804", ";", "}", "elseif", "(", "count", "(", "$", "vatTypeInfo", "[", "'union'", "]", ")", "===", "1", ")", "{", "// One or more lines could be matched with exactly 1 vat", "// type, but not all lines.", "// Possible causes:", "// - Non matching lines have no vat. Message: 'Manual line", "// entered without vat' or 'Check vat settings on those", "// products.'.", "// - Non matching lines have vat. Message: 'Manual line", "// entered with incorrect vat' or 'Check vat settings on", "// those products.'.", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", "=", "reset", "(", "$", "vatTypeInfo", "[", "'union'", "]", ")", ";", "$", "message", "=", "'message_warning_no_vattype_incorrect_lines'", ";", "$", "code", "=", "812", ";", "}", "else", "{", "// Separate lines could be matched with some of the possible", "// vat types, but not all with the same vat type.", "// Possible causes:", "// - Mix of foreign VAT rates and other goods or services.", "// Message: 'Split invoice.'.", "// - Some lines have no vat but no vat free goods or", "// services are sold and thus this could be a reversed vat", "// (company in EU) or vat free invoice (outside EU).", "// Message: check vat settings.", "// - Mix of margin scheme and normal vat: this can be solved", "// by making it a margin scheme invoice and adding", "// costprice = 0 to all normal lines.", "if", "(", "in_array", "(", "Api", "::", "VatType_MarginScheme", ",", "$", "vatTypeInfo", "[", "'union'", "]", ")", ")", "{", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", "=", "Api", "::", "VatType_MarginScheme", ";", "}", "else", "{", "// Take the first vat type as a guess but add a warning.", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", "=", "reset", "(", "$", "vatTypeInfo", "[", "'union'", "]", ")", ";", "$", "message", "=", "'message_warning_no_vattype_must_split'", ";", "$", "code", "=", "806", ";", "}", "}", "}", "elseif", "(", "count", "(", "$", "vatTypeInfo", "[", "'intersection'", "]", ")", "===", "1", ")", "{", "// Exactly 1 vat type was found to be possible for all lines:", "// use that one as the vat type for the invoice.", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", "=", "reset", "(", "$", "vatTypeInfo", "[", "'intersection'", "]", ")", ";", "}", "else", "{", "// Multiple vat types were found to be possible for all lines:", "// Take one and add a warning.", "// Possible causes:", "// - Client country has same vat rates as the Netherlands and", "// shop sells products at foreign vat rates but also other", "// products or services. Solvable by correct shop settings.", "// - Invoice has no vat and the client is outside the EU and it", "// is unknown whether the invoice lines contain services or", "// goods. Perhaps solvable by correct shop settings.", "// - Margin invoice: all lines that have a costprice will", "// probably also satisfy the normal vat. This is solvable by", "// making it a margin scheme invoice and adding costprice = 0", "// to all normal lines.", "if", "(", "in_array", "(", "Api", "::", "VatType_MarginScheme", ",", "$", "vatTypeInfo", "[", "'union'", "]", ")", ")", "{", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", "=", "Api", "::", "VatType_MarginScheme", ";", "}", "else", "{", "// Take the first vat type as a guess but add a warning.", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", "=", "reset", "(", "$", "vatTypeInfo", "[", "'intersection'", "]", ")", ";", "$", "message", "=", "'message_warning_no_vattype_multiple_possible'", ";", "$", "code", "=", "811", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "message", ")", ")", "{", "// Make the invoice a concept, so it can be changed in Acumulus", "// and add message and meta info.", "$", "startSentence", "=", "count", "(", "$", "vatTypeInfo", "[", "'intersection'", "]", ")", "===", "0", "?", "'message_warning_no_vattype'", ":", "'message_warning_multiple_vattypes'", ";", "$", "this", "->", "changeInvoiceToConcept", "(", "$", "message", ",", "$", "code", ",", "$", "this", "->", "t", "(", "$", "startSentence", ")", ")", ";", "}", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "VatTypesPossibleInvoice", "]", "=", "implode", "(", "','", ",", "$", "this", "->", "possibleVatTypes", ")", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "VatTypesPossibleInvoiceLinesIntersection", "]", "=", "implode", "(", "','", ",", "$", "vatTypeInfo", "[", "'intersection'", "]", ")", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "VatTypesPossibleInvoiceLinesUnion", "]", "=", "implode", "(", "','", ",", "$", "vatTypeInfo", "[", "'union'", "]", ")", ";", "}", "}" ]
Determines the vattype of the invoice. This method (and class) is aware of: - The setting foreignVat. - The country of the client. - Whether the client is a company. - The actual VAT rates on the day of the order. - Whether there are margin products in the order. So to start with, any list of (possible) vat types is based on the above. Furthermore this method and {@see getInvoiceLinesVatTypeInfo()} are aware of: - The fact that orders do not have to be split over different vat types, but that invoices should be split if both national and foreign VAT rates appear on the order. - The vat class meta data per line and which classes denote foreign vat. This info is used to distinguish between NL and foreign vat for EU countries that have VAT rates in common with NL and the settings indicate that this shop sells products in both vat type categories. If multiple vat types are possible, the invoice is sent as concept, so that it may be corrected in Acumulus.
[ "Determines", "the", "vattype", "of", "the", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L724-L832
30,458
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.correctMarginInvoice
protected function correctMarginInvoice() { if (isset($this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType]) && $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] === Api::VatType_MarginScheme) { foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as &$line) { // For margin invoices, Acumulus expects the unitprice to be the // sales price, ie the price the client pays. So we set // unitprice to unitpriceinc. // Non margin lines may "officially" not appear on margin // invoices, so we turn them into margin lines by adding a // costprice of 0 and also setting unitprice to unitpriceinc. if (!isset($line[Tag::CostPrice])) { // "Normal" line: set costprice as 0. $line[Tag::CostPrice] = 0.0; } // Add "marker" tag (for debug purposes) for this correction. $line[Meta::RecalculateOldPrice] = $line[Tag::UnitPrice]; // Change unitprice tag to include VAT. if (isset($line[Meta::UnitPriceInc])) { $line[Tag::UnitPrice] = $line[Meta::UnitPriceInc]; } elseif (isset($line[Meta::VatAmount])) { $line[Tag::UnitPrice] += $line[Meta::VatAmount]; } elseif (isset($line[Tag::VatRate])) { $line[Tag::UnitPrice] += $line[Tag::VatRate]/100.0 * ($line[Tag::UnitPrice] - $line[Tag::CostPrice]); } //else { // Impossible to correct the unitprice. Probably all // strategies failed, so the invoice should already // have a warning. //} } } }
php
protected function correctMarginInvoice() { if (isset($this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType]) && $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType] === Api::VatType_MarginScheme) { foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as &$line) { // For margin invoices, Acumulus expects the unitprice to be the // sales price, ie the price the client pays. So we set // unitprice to unitpriceinc. // Non margin lines may "officially" not appear on margin // invoices, so we turn them into margin lines by adding a // costprice of 0 and also setting unitprice to unitpriceinc. if (!isset($line[Tag::CostPrice])) { // "Normal" line: set costprice as 0. $line[Tag::CostPrice] = 0.0; } // Add "marker" tag (for debug purposes) for this correction. $line[Meta::RecalculateOldPrice] = $line[Tag::UnitPrice]; // Change unitprice tag to include VAT. if (isset($line[Meta::UnitPriceInc])) { $line[Tag::UnitPrice] = $line[Meta::UnitPriceInc]; } elseif (isset($line[Meta::VatAmount])) { $line[Tag::UnitPrice] += $line[Meta::VatAmount]; } elseif (isset($line[Tag::VatRate])) { $line[Tag::UnitPrice] += $line[Tag::VatRate]/100.0 * ($line[Tag::UnitPrice] - $line[Tag::CostPrice]); } //else { // Impossible to correct the unitprice. Probably all // strategies failed, so the invoice should already // have a warning. //} } } }
[ "protected", "function", "correctMarginInvoice", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", ")", "&&", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", "===", "Api", "::", "VatType_MarginScheme", ")", "{", "foreach", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "Line", "]", "as", "&", "$", "line", ")", "{", "// For margin invoices, Acumulus expects the unitprice to be the", "// sales price, ie the price the client pays. So we set", "// unitprice to unitpriceinc.", "// Non margin lines may \"officially\" not appear on margin", "// invoices, so we turn them into margin lines by adding a", "// costprice of 0 and also setting unitprice to unitpriceinc.", "if", "(", "!", "isset", "(", "$", "line", "[", "Tag", "::", "CostPrice", "]", ")", ")", "{", "// \"Normal\" line: set costprice as 0.", "$", "line", "[", "Tag", "::", "CostPrice", "]", "=", "0.0", ";", "}", "// Add \"marker\" tag (for debug purposes) for this correction.", "$", "line", "[", "Meta", "::", "RecalculateOldPrice", "]", "=", "$", "line", "[", "Tag", "::", "UnitPrice", "]", ";", "// Change unitprice tag to include VAT.", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "UnitPriceInc", "]", ")", ")", "{", "$", "line", "[", "Tag", "::", "UnitPrice", "]", "=", "$", "line", "[", "Meta", "::", "UnitPriceInc", "]", ";", "}", "elseif", "(", "isset", "(", "$", "line", "[", "Meta", "::", "VatAmount", "]", ")", ")", "{", "$", "line", "[", "Tag", "::", "UnitPrice", "]", "+=", "$", "line", "[", "Meta", "::", "VatAmount", "]", ";", "}", "elseif", "(", "isset", "(", "$", "line", "[", "Tag", "::", "VatRate", "]", ")", ")", "{", "$", "line", "[", "Tag", "::", "UnitPrice", "]", "+=", "$", "line", "[", "Tag", "::", "VatRate", "]", "/", "100.0", "*", "(", "$", "line", "[", "Tag", "::", "UnitPrice", "]", "-", "$", "line", "[", "Tag", "::", "CostPrice", "]", ")", ";", "}", "//else {", "// Impossible to correct the unitprice. Probably all", "// strategies failed, so the invoice should already", "// have a warning.", "//}", "}", "}", "}" ]
Corrects an invoice if it is a margin scheme invoice. If an invoice is of the margin scheme type, all lines have to follow the margin scheme rules. These rules are: - Each line must have a costprice, but that cost price may be 0. - The unitprice should now contain the price including VAT (requirement of the web service API). Thus if there are e.g. shipping lines or other fee lines, they have to be converted to the margin scheme (costprice tag and change of unitprice).
[ "Corrects", "an", "invoice", "if", "it", "is", "a", "margin", "scheme", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L957-L987
30,459
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.correct0VatToVatFree
protected function correct0VatToVatFree() { if (isset($this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType])) { $vatType = $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType]; if (in_array($vatType, static::$vatTypesAllowingVatFree)) { foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as &$line) { if ($this->lineHas0VatRate($line)) { $line[Tag::VatRate] = Api::VatFree; } } } } }
php
protected function correct0VatToVatFree() { if (isset($this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType])) { $vatType = $this->invoice[Tag::Customer][Tag::Invoice][Tag::VatType]; if (in_array($vatType, static::$vatTypesAllowingVatFree)) { foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as &$line) { if ($this->lineHas0VatRate($line)) { $line[Tag::VatRate] = Api::VatFree; } } } } }
[ "protected", "function", "correct0VatToVatFree", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", ")", ")", "{", "$", "vatType", "=", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "VatType", "]", ";", "if", "(", "in_array", "(", "$", "vatType", ",", "static", "::", "$", "vatTypesAllowingVatFree", ")", ")", "{", "foreach", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "Line", "]", "as", "&", "$", "line", ")", "{", "if", "(", "$", "this", "->", "lineHas0VatRate", "(", "$", "line", ")", ")", "{", "$", "line", "[", "Tag", "::", "VatRate", "]", "=", "Api", "::", "VatFree", ";", "}", "}", "}", "}", "}" ]
Change 0% vat rates to vat free. Acumulus distinguishes between 0% vat (vatrate = 0) and vat free (vatrate = -1). 0% vat should be used with: - Reversed vat invoices, EU or national (vat type = 2 or 3). - Products invoiced outside the EU (vat type = 4). Vat free should be used for: - Vat free products and services, e.g. care, education (vat type = 1, 5 or, theoretically, 6). - Services invoiced to companies outside the EU (vat type = 1). - Digital services outside the EU, consumers or companies (vat type = 1). Thus, to do this correctly, especially for invoices outside the EU, we should be able to distinguish between services and products. For that, the nature field should be filled in or the shop should only sell products or only services. If not, we act as if the line invoices a product. See: - {@see https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/zakelijk/btw/tarieven_en_vrijstellingen/} - {@see https://wiki.acumulus.nl/index.php?page=facturen-naar-het-buitenland}:
[ "Change", "0%", "vat", "rates", "to", "vat", "free", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1013-L1025
30,460
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.processMetaData
protected function processMetaData() { foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as &$line) { if (isset($line[Meta::VatRateLookup]) && is_array($line[Meta::VatRateLookup])) { $line[Meta::VatRateLookup] = json_encode($line[Meta::VatRateLookup]); } if (isset($line[Meta::VatRateLookupLabel]) && is_array($line[Meta::VatRateLookupLabel])) { $line[Meta::VatRateLookupLabel] = json_encode($line[Meta::VatRateLookupLabel]); } if (isset($line[Meta::FieldsCalculated]) && is_array($line[Meta::FieldsCalculated])) { $line[Meta::FieldsCalculated] = json_encode(array_unique($line[Meta::FieldsCalculated])); } if (isset($line[Meta::VatRateLookupMatches]) && is_array($line[Meta::VatRateLookupMatches])) { $line[Meta::VatRateLookupMatches] = json_encode($line[Meta::VatRateLookupMatches]); } if (isset($line[Meta::VatRateRangeMatches]) && is_array($line[Meta::VatRateRangeMatches])) { $line[Meta::VatRateRangeMatches] = json_encode($line[Meta::VatRateRangeMatches]); } } }
php
protected function processMetaData() { foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as &$line) { if (isset($line[Meta::VatRateLookup]) && is_array($line[Meta::VatRateLookup])) { $line[Meta::VatRateLookup] = json_encode($line[Meta::VatRateLookup]); } if (isset($line[Meta::VatRateLookupLabel]) && is_array($line[Meta::VatRateLookupLabel])) { $line[Meta::VatRateLookupLabel] = json_encode($line[Meta::VatRateLookupLabel]); } if (isset($line[Meta::FieldsCalculated]) && is_array($line[Meta::FieldsCalculated])) { $line[Meta::FieldsCalculated] = json_encode(array_unique($line[Meta::FieldsCalculated])); } if (isset($line[Meta::VatRateLookupMatches]) && is_array($line[Meta::VatRateLookupMatches])) { $line[Meta::VatRateLookupMatches] = json_encode($line[Meta::VatRateLookupMatches]); } if (isset($line[Meta::VatRateRangeMatches]) && is_array($line[Meta::VatRateRangeMatches])) { $line[Meta::VatRateRangeMatches] = json_encode($line[Meta::VatRateRangeMatches]); } } }
[ "protected", "function", "processMetaData", "(", ")", "{", "foreach", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "Line", "]", "as", "&", "$", "line", ")", "{", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "VatRateLookup", "]", ")", "&&", "is_array", "(", "$", "line", "[", "Meta", "::", "VatRateLookup", "]", ")", ")", "{", "$", "line", "[", "Meta", "::", "VatRateLookup", "]", "=", "json_encode", "(", "$", "line", "[", "Meta", "::", "VatRateLookup", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "VatRateLookupLabel", "]", ")", "&&", "is_array", "(", "$", "line", "[", "Meta", "::", "VatRateLookupLabel", "]", ")", ")", "{", "$", "line", "[", "Meta", "::", "VatRateLookupLabel", "]", "=", "json_encode", "(", "$", "line", "[", "Meta", "::", "VatRateLookupLabel", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "FieldsCalculated", "]", ")", "&&", "is_array", "(", "$", "line", "[", "Meta", "::", "FieldsCalculated", "]", ")", ")", "{", "$", "line", "[", "Meta", "::", "FieldsCalculated", "]", "=", "json_encode", "(", "array_unique", "(", "$", "line", "[", "Meta", "::", "FieldsCalculated", "]", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "VatRateLookupMatches", "]", ")", "&&", "is_array", "(", "$", "line", "[", "Meta", "::", "VatRateLookupMatches", "]", ")", ")", "{", "$", "line", "[", "Meta", "::", "VatRateLookupMatches", "]", "=", "json_encode", "(", "$", "line", "[", "Meta", "::", "VatRateLookupMatches", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "VatRateRangeMatches", "]", ")", "&&", "is_array", "(", "$", "line", "[", "Meta", "::", "VatRateRangeMatches", "]", ")", ")", "{", "$", "line", "[", "Meta", "::", "VatRateRangeMatches", "]", "=", "json_encode", "(", "$", "line", "[", "Meta", "::", "VatRateRangeMatches", "]", ")", ";", "}", "}", "}" ]
Processes meta data before sending the invoice. Currently the following processing is done: - Meta::VatRateLookup, Meta::VatRateLookupLabel, Meta::FieldsCalculated, Meta::VatRateLookupMatches, and Meta::VatRateRangeMatches are converted a json string if they are an array.
[ "Processes", "meta", "data", "before", "sending", "the", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1049-L1068
30,461
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.lineHas0VatRate
protected function lineHas0VatRate(array $line) { $result = false; if ($this->is0VatRate($line)) { $result = true; } return $result; }
php
protected function lineHas0VatRate(array $line) { $result = false; if ($this->is0VatRate($line)) { $result = true; } return $result; }
[ "protected", "function", "lineHas0VatRate", "(", "array", "$", "line", ")", "{", "$", "result", "=", "false", ";", "if", "(", "$", "this", "->", "is0VatRate", "(", "$", "line", ")", ")", "{", "$", "result", "=", "true", ";", "}", "return", "$", "result", ";", "}" ]
Returns whether the given line has a 0% or vat free vat rate. @param array $line The invoice line. @return bool True if the given line has a 0% or vat free vat rate, false otherwise.
[ "Returns", "whether", "the", "given", "line", "has", "a", "0%", "or", "vat", "free", "vat", "rate", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1079-L1086
30,462
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.is0VatRate
protected function is0VatRate($vatRate) { if (is_array($vatRate) && isset($vatRate)) { $vatRate = isset($vatRate[Tag::VatRate]) ? $vatRate[Tag::VatRate] : null; } return isset($vatRate) && (Number::isZero($vatRate) || Number::floatsAreEqual($vatRate, -1.0)); }
php
protected function is0VatRate($vatRate) { if (is_array($vatRate) && isset($vatRate)) { $vatRate = isset($vatRate[Tag::VatRate]) ? $vatRate[Tag::VatRate] : null; } return isset($vatRate) && (Number::isZero($vatRate) || Number::floatsAreEqual($vatRate, -1.0)); }
[ "protected", "function", "is0VatRate", "(", "$", "vatRate", ")", "{", "if", "(", "is_array", "(", "$", "vatRate", ")", "&&", "isset", "(", "$", "vatRate", ")", ")", "{", "$", "vatRate", "=", "isset", "(", "$", "vatRate", "[", "Tag", "::", "VatRate", "]", ")", "?", "$", "vatRate", "[", "Tag", "::", "VatRate", "]", ":", "null", ";", "}", "return", "isset", "(", "$", "vatRate", ")", "&&", "(", "Number", "::", "isZero", "(", "$", "vatRate", ")", "||", "Number", "::", "floatsAreEqual", "(", "$", "vatRate", ",", "-", "1.0", ")", ")", ";", "}" ]
Returns whether the vat rate is a 0 vat rate. @param int|array $vatRate An integer (or numeric string), an array possibly containing an entry with key Tag::VatRate entry @return bool True if the vat rate is a 0 vat rate, false otherwise.
[ "Returns", "whether", "the", "vat", "rate", "is", "a", "0", "vat", "rate", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1117-L1123
30,463
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.getVatRatesByCountryAndDate
protected function getVatRatesByCountryAndDate($countryCode, $date = null) { if (empty($date)) { $date = $this->getInvoiceDate(); } $result = $this->service->getVatInfo($countryCode, $date); if ($result->hasMessages()) { $this->result->mergeMessages($result); } $vatInfo = $result->getResponse(); // PHP5.5: array_column($vatInfo, Tag::VatRate); $vatInfo = array_unique(array_map(function ($vatInfo1) { return $vatInfo1[Tag::VatRate]; }, $vatInfo)); return $vatInfo; }
php
protected function getVatRatesByCountryAndDate($countryCode, $date = null) { if (empty($date)) { $date = $this->getInvoiceDate(); } $result = $this->service->getVatInfo($countryCode, $date); if ($result->hasMessages()) { $this->result->mergeMessages($result); } $vatInfo = $result->getResponse(); // PHP5.5: array_column($vatInfo, Tag::VatRate); $vatInfo = array_unique(array_map(function ($vatInfo1) { return $vatInfo1[Tag::VatRate]; }, $vatInfo)); return $vatInfo; }
[ "protected", "function", "getVatRatesByCountryAndDate", "(", "$", "countryCode", ",", "$", "date", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "date", ")", ")", "{", "$", "date", "=", "$", "this", "->", "getInvoiceDate", "(", ")", ";", "}", "$", "result", "=", "$", "this", "->", "service", "->", "getVatInfo", "(", "$", "countryCode", ",", "$", "date", ")", ";", "if", "(", "$", "result", "->", "hasMessages", "(", ")", ")", "{", "$", "this", "->", "result", "->", "mergeMessages", "(", "$", "result", ")", ";", "}", "$", "vatInfo", "=", "$", "result", "->", "getResponse", "(", ")", ";", "// PHP5.5: array_column($vatInfo, Tag::VatRate);", "$", "vatInfo", "=", "array_unique", "(", "array_map", "(", "function", "(", "$", "vatInfo1", ")", "{", "return", "$", "vatInfo1", "[", "Tag", "::", "VatRate", "]", ";", "}", ",", "$", "vatInfo", ")", ")", ";", "return", "$", "vatInfo", ";", "}" ]
Helper method to get the vat rates for the current invoice. - This method contacts the Acumulus server. - The vat rates returned reflect those as they were at the invoice date. - No zero vat rates are returned. @param string $countryCode The country to fetch the vat rates for. @param string|null $date The date (yyyy-mm-dd) to fetch the vat rates for. @return float[] Actual type will be string[] containing strings representing floats. @see \Siel\Acumulus\Web\Service::getVatInfo().
[ "Helper", "method", "to", "get", "the", "vat", "rates", "for", "the", "current", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1142-L1157
30,464
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.getInvoiceDate
protected function getInvoiceDate() { $date = !empty($this->invoice[Tag::Customer][Tag::Invoice][Tag::IssueDate]) ? $this->invoice[Tag::Customer][Tag::Invoice][Tag::IssueDate] : date(API::DateFormat_Iso); return $date; }
php
protected function getInvoiceDate() { $date = !empty($this->invoice[Tag::Customer][Tag::Invoice][Tag::IssueDate]) ? $this->invoice[Tag::Customer][Tag::Invoice][Tag::IssueDate] : date(API::DateFormat_Iso); return $date; }
[ "protected", "function", "getInvoiceDate", "(", ")", "{", "$", "date", "=", "!", "empty", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "IssueDate", "]", ")", "?", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "IssueDate", "]", ":", "date", "(", "API", "::", "DateFormat_Iso", ")", ";", "return", "$", "date", ";", "}" ]
Returns the invoice date in the iso yyyy-mm-dd format. @return string The invoice dae in the iso yyyy-mm-dd format.
[ "Returns", "the", "invoice", "date", "in", "the", "iso", "yyyy", "-", "mm", "-", "dd", "format", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1165-L1169
30,465
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.isCompany
protected function isCompany() { // Note: companies outside EU must also fill in their vat number!? Even // if there's no way to check it with a webservice like VIES. return !empty($this->invoice[Tag::Customer][Tag::CompanyName1]) && !empty($this->invoice[Tag::Customer][Tag::VatNumber]); }
php
protected function isCompany() { // Note: companies outside EU must also fill in their vat number!? Even // if there's no way to check it with a webservice like VIES. return !empty($this->invoice[Tag::Customer][Tag::CompanyName1]) && !empty($this->invoice[Tag::Customer][Tag::VatNumber]); }
[ "protected", "function", "isCompany", "(", ")", "{", "// Note: companies outside EU must also fill in their vat number!? Even", "// if there's no way to check it with a webservice like VIES.", "return", "!", "empty", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "CompanyName1", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "VatNumber", "]", ")", ";", "}" ]
Returns whether the client is a company with a vat number. @return bool
[ "Returns", "whether", "the", "client", "is", "a", "company", "with", "a", "vat", "number", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1206-L1211
30,466
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.shouldConvertCurrency
public function shouldConvertCurrency(array &$invoice) { $invoicePart = &$invoice[Tag::Customer][Tag::Invoice]; $shouldConvert = isset($invoicePart[Meta::Currency]) && isset($invoicePart[Meta::CurrencyRate]) && isset($invoicePart[Meta::CurrencyDoConvert]); $shouldConvert = $shouldConvert && (float) $invoicePart[Meta::CurrencyRate] != 1.0; if ($shouldConvert) { if ($invoicePart[Meta::Currency] !== 'EUR') { // Order/refund is not in euro's: convert if amounts are stored // in the order's currency, not the shop's default currency // (which should be EUR). $shouldConvert = $invoicePart[Meta::CurrencyDoConvert]; $invoicePart[Meta::CurrencyRateInverted] = false; } else { // Order/refund is in euro's but that is not the shop's default: // convert if the amounts are in the in the shop's default // currency, not the order's currency (which is EUR). $shouldConvert = !$invoicePart[Meta::CurrencyDoConvert]; // Invert the rate only once, even if this method may be called // multiple times per invoice. if (!isset($invoicePart[Meta::CurrencyRateInverted])) { $invoicePart[Meta::CurrencyRateInverted] = true; $invoicePart[Meta::CurrencyRate] = 1.0 / (float) $invoicePart[Meta::CurrencyRate]; } } } return $shouldConvert; }
php
public function shouldConvertCurrency(array &$invoice) { $invoicePart = &$invoice[Tag::Customer][Tag::Invoice]; $shouldConvert = isset($invoicePart[Meta::Currency]) && isset($invoicePart[Meta::CurrencyRate]) && isset($invoicePart[Meta::CurrencyDoConvert]); $shouldConvert = $shouldConvert && (float) $invoicePart[Meta::CurrencyRate] != 1.0; if ($shouldConvert) { if ($invoicePart[Meta::Currency] !== 'EUR') { // Order/refund is not in euro's: convert if amounts are stored // in the order's currency, not the shop's default currency // (which should be EUR). $shouldConvert = $invoicePart[Meta::CurrencyDoConvert]; $invoicePart[Meta::CurrencyRateInverted] = false; } else { // Order/refund is in euro's but that is not the shop's default: // convert if the amounts are in the in the shop's default // currency, not the order's currency (which is EUR). $shouldConvert = !$invoicePart[Meta::CurrencyDoConvert]; // Invert the rate only once, even if this method may be called // multiple times per invoice. if (!isset($invoicePart[Meta::CurrencyRateInverted])) { $invoicePart[Meta::CurrencyRateInverted] = true; $invoicePart[Meta::CurrencyRate] = 1.0 / (float) $invoicePart[Meta::CurrencyRate]; } } } return $shouldConvert; }
[ "public", "function", "shouldConvertCurrency", "(", "array", "&", "$", "invoice", ")", "{", "$", "invoicePart", "=", "&", "$", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", ";", "$", "shouldConvert", "=", "isset", "(", "$", "invoicePart", "[", "Meta", "::", "Currency", "]", ")", "&&", "isset", "(", "$", "invoicePart", "[", "Meta", "::", "CurrencyRate", "]", ")", "&&", "isset", "(", "$", "invoicePart", "[", "Meta", "::", "CurrencyDoConvert", "]", ")", ";", "$", "shouldConvert", "=", "$", "shouldConvert", "&&", "(", "float", ")", "$", "invoicePart", "[", "Meta", "::", "CurrencyRate", "]", "!=", "1.0", ";", "if", "(", "$", "shouldConvert", ")", "{", "if", "(", "$", "invoicePart", "[", "Meta", "::", "Currency", "]", "!==", "'EUR'", ")", "{", "// Order/refund is not in euro's: convert if amounts are stored", "// in the order's currency, not the shop's default currency", "// (which should be EUR).", "$", "shouldConvert", "=", "$", "invoicePart", "[", "Meta", "::", "CurrencyDoConvert", "]", ";", "$", "invoicePart", "[", "Meta", "::", "CurrencyRateInverted", "]", "=", "false", ";", "}", "else", "{", "// Order/refund is in euro's but that is not the shop's default:", "// convert if the amounts are in the in the shop's default", "// currency, not the order's currency (which is EUR).", "$", "shouldConvert", "=", "!", "$", "invoicePart", "[", "Meta", "::", "CurrencyDoConvert", "]", ";", "// Invert the rate only once, even if this method may be called", "// multiple times per invoice.", "if", "(", "!", "isset", "(", "$", "invoicePart", "[", "Meta", "::", "CurrencyRateInverted", "]", ")", ")", "{", "$", "invoicePart", "[", "Meta", "::", "CurrencyRateInverted", "]", "=", "true", ";", "$", "invoicePart", "[", "Meta", "::", "CurrencyRate", "]", "=", "1.0", "/", "(", "float", ")", "$", "invoicePart", "[", "Meta", "::", "CurrencyRate", "]", ";", "}", "}", "}", "return", "$", "shouldConvert", ";", "}" ]
Returns whether the amounts in the invoice are in another currency. The amounts in te invoice are to be converted if: - All currency meta tags are set. - The "currency rate" does not equal 1.0, otherwise converting would result in the same amounts. - The meta tag "do convert" equals "currency !== 'EUR'. @param array $invoice The invoice (starting with the customer part). @return bool True if the invoice uses another currency, false otherwise.
[ "Returns", "whether", "the", "amounts", "in", "the", "invoice", "are", "in", "another", "currency", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1228-L1254
30,467
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.convertAmount
public function convertAmount(array &$array, $key, $conversionRate) { if (!empty($array[$key]) && !empty($conversionRate)) { $array[$key] = (float) $array[$key] / (float) $conversionRate; return true; } return false; }
php
public function convertAmount(array &$array, $key, $conversionRate) { if (!empty($array[$key]) && !empty($conversionRate)) { $array[$key] = (float) $array[$key] / (float) $conversionRate; return true; } return false; }
[ "public", "function", "convertAmount", "(", "array", "&", "$", "array", ",", "$", "key", ",", "$", "conversionRate", ")", "{", "if", "(", "!", "empty", "(", "$", "array", "[", "$", "key", "]", ")", "&&", "!", "empty", "(", "$", "conversionRate", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "(", "float", ")", "$", "array", "[", "$", "key", "]", "/", "(", "float", ")", "$", "conversionRate", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Helper method to convert an amount field to euros. @param array $array @param string $key @param float $conversionRate @return bool Whether the amount was converted.
[ "Helper", "method", "to", "convert", "an", "amount", "field", "to", "euros", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1266-L1273
30,468
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.isForeignVatClass
public function isForeignVatClass($vatClassId) { $shopSettings = $this->config->getShopSettings(); $foreignVat = $shopSettings['foreignVat']; $foreignVatClasses = $shopSettings['foreignVatClasses']; return $foreignVat !== PluginConfig::ForeignVat_No && in_array($vatClassId, $foreignVatClasses); }
php
public function isForeignVatClass($vatClassId) { $shopSettings = $this->config->getShopSettings(); $foreignVat = $shopSettings['foreignVat']; $foreignVatClasses = $shopSettings['foreignVatClasses']; return $foreignVat !== PluginConfig::ForeignVat_No && in_array($vatClassId, $foreignVatClasses); }
[ "public", "function", "isForeignVatClass", "(", "$", "vatClassId", ")", "{", "$", "shopSettings", "=", "$", "this", "->", "config", "->", "getShopSettings", "(", ")", ";", "$", "foreignVat", "=", "$", "shopSettings", "[", "'foreignVat'", "]", ";", "$", "foreignVatClasses", "=", "$", "shopSettings", "[", "'foreignVatClasses'", "]", ";", "return", "$", "foreignVat", "!==", "PluginConfig", "::", "ForeignVat_No", "&&", "in_array", "(", "$", "vatClassId", ",", "$", "foreignVatClasses", ")", ";", "}" ]
Returns whether the vat class id denotes foreign vat. @param int|string $vatClassId The vat class to check. @return bool True if the shop might sell foreign vat articles and the vat class id denotes a foreign vat class, false otherwise.
[ "Returns", "whether", "the", "vat", "class", "id", "denotes", "foreign", "vat", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1301-L1307
30,469
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.changeInvoiceToConcept
public function changeInvoiceToConcept($messageKey, $code) { $pdfMessage = ''; $invoiceSettings = $this->config->getInvoiceSettings(); $concept = $invoiceSettings['concept']; if ($concept == PluginConfig::Concept_Plugin) { $this->invoice[Tag::Customer][Tag::Invoice][Tag::Concept] = Api::Concept_Yes; $emailAsPdfSettings = $this->config->getEmailAsPdfSettings(); if ($emailAsPdfSettings['emailAsPdf']) { $pdfMessage = ' ' . $this->t('message_warning_no_pdf'); } } if ($messageKey !== '') { $message = $this->t($messageKey) . $pdfMessage; if (func_num_args() > 2) { $args = func_get_args(); $message = vsprintf($message, array_slice($args, 2)); } $this->result->addWarning($code, '', $message); } }
php
public function changeInvoiceToConcept($messageKey, $code) { $pdfMessage = ''; $invoiceSettings = $this->config->getInvoiceSettings(); $concept = $invoiceSettings['concept']; if ($concept == PluginConfig::Concept_Plugin) { $this->invoice[Tag::Customer][Tag::Invoice][Tag::Concept] = Api::Concept_Yes; $emailAsPdfSettings = $this->config->getEmailAsPdfSettings(); if ($emailAsPdfSettings['emailAsPdf']) { $pdfMessage = ' ' . $this->t('message_warning_no_pdf'); } } if ($messageKey !== '') { $message = $this->t($messageKey) . $pdfMessage; if (func_num_args() > 2) { $args = func_get_args(); $message = vsprintf($message, array_slice($args, 2)); } $this->result->addWarning($code, '', $message); } }
[ "public", "function", "changeInvoiceToConcept", "(", "$", "messageKey", ",", "$", "code", ")", "{", "$", "pdfMessage", "=", "''", ";", "$", "invoiceSettings", "=", "$", "this", "->", "config", "->", "getInvoiceSettings", "(", ")", ";", "$", "concept", "=", "$", "invoiceSettings", "[", "'concept'", "]", ";", "if", "(", "$", "concept", "==", "PluginConfig", "::", "Concept_Plugin", ")", "{", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "Concept", "]", "=", "Api", "::", "Concept_Yes", ";", "$", "emailAsPdfSettings", "=", "$", "this", "->", "config", "->", "getEmailAsPdfSettings", "(", ")", ";", "if", "(", "$", "emailAsPdfSettings", "[", "'emailAsPdf'", "]", ")", "{", "$", "pdfMessage", "=", "' '", ".", "$", "this", "->", "t", "(", "'message_warning_no_pdf'", ")", ";", "}", "}", "if", "(", "$", "messageKey", "!==", "''", ")", "{", "$", "message", "=", "$", "this", "->", "t", "(", "$", "messageKey", ")", ".", "$", "pdfMessage", ";", "if", "(", "func_num_args", "(", ")", ">", "2", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "message", "=", "vsprintf", "(", "$", "message", ",", "array_slice", "(", "$", "args", ",", "2", ")", ")", ";", "}", "$", "this", "->", "result", "->", "addWarning", "(", "$", "code", ",", "''", ",", "$", "message", ")", ";", "}", "}" ]
Makes the invoice a concept invoice and optionally adds a warning. @param string $messageKey The key of the message to add as warning, or the empty string if no warning has to be added. @param int $code The code for this message. @param string ... Additional arguments to format the message.
[ "Makes", "the", "invoice", "a", "concept", "invoice", "and", "optionally", "adds", "a", "warning", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1320-L1341
30,470
SIELOnline/libAcumulus
src/Invoice/Completor.php
Completor.addDefault
protected function addDefault(array &$array, $key, $value) { if (empty($array[$key]) && !empty($value)) { $array[$key] = $value; return true; } return false; }
php
protected function addDefault(array &$array, $key, $value) { if (empty($array[$key]) && !empty($value)) { $array[$key] = $value; return true; } return false; }
[ "protected", "function", "addDefault", "(", "array", "&", "$", "array", ",", "$", "key", ",", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "array", "[", "$", "key", "]", ")", "&&", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Helper method to add a default non-empty value to an array. This method will not overwrite existing values. @param array $array @param string $key @param mixed $value @return bool Whether the default was added.
[ "Helper", "method", "to", "add", "a", "default", "non", "-", "empty", "value", "to", "an", "array", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Completor.php#L1355-L1362
30,471
SIELOnline/libAcumulus
src/Web/Service.php
Service.getVatInfo
public function getVatInfo($countryCode, $date = '') { if (empty($date)) { $date = date(API::DateFormat_Iso); } $message = array( 'vatdate' => $date, 'vatcountry' => $countryCode, ); return $this->communicator->callApiFunction('lookups/lookup_vatinfo', $message)->setMainResponseKey('vatinfo', true); }
php
public function getVatInfo($countryCode, $date = '') { if (empty($date)) { $date = date(API::DateFormat_Iso); } $message = array( 'vatdate' => $date, 'vatcountry' => $countryCode, ); return $this->communicator->callApiFunction('lookups/lookup_vatinfo', $message)->setMainResponseKey('vatinfo', true); }
[ "public", "function", "getVatInfo", "(", "$", "countryCode", ",", "$", "date", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "date", ")", ")", "{", "$", "date", "=", "date", "(", "API", "::", "DateFormat_Iso", ")", ";", "}", "$", "message", "=", "array", "(", "'vatdate'", "=>", "$", "date", ",", "'vatcountry'", "=>", "$", "countryCode", ",", ")", ";", "return", "$", "this", "->", "communicator", "->", "callApiFunction", "(", "'lookups/lookup_vatinfo'", ",", "$", "message", ")", "->", "setMainResponseKey", "(", "'vatinfo'", ",", "true", ")", ";", "}" ]
Retrieves a list of VAT rates for the given country at the given date. @param string $countryCode Country code of the country to retrieve the VAT info for. @param string $date ISO date string (yyyy-mm-dd) for the date to retrieve the VAT info for. @return \Siel\Acumulus\Web\Result The result of the webservice call. The structured response will contain a non-keyed array of "vatinfo" arrays, each 'vatinfo' array being a keyed array with keys: - vattype - vatrate @see https://www.siel.nl/acumulus/API/Picklists/VAT_Info/ for more information about the contents of the returned array.
[ "Retrieves", "a", "list", "of", "VAT", "rates", "for", "the", "given", "country", "at", "the", "given", "date", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Service.php#L241-L251
30,472
SIELOnline/libAcumulus
src/Web/Service.php
Service.invoiceAdd
public function invoiceAdd(array $invoice, Result $result = null) { return $this->communicator->callApiFunction('invoices/invoice_add', $invoice, $result)->setMainResponseKey('invoice'); }
php
public function invoiceAdd(array $invoice, Result $result = null) { return $this->communicator->callApiFunction('invoices/invoice_add', $invoice, $result)->setMainResponseKey('invoice'); }
[ "public", "function", "invoiceAdd", "(", "array", "$", "invoice", ",", "Result", "$", "result", "=", "null", ")", "{", "return", "$", "this", "->", "communicator", "->", "callApiFunction", "(", "'invoices/invoice_add'", ",", "$", "invoice", ",", "$", "result", ")", "->", "setMainResponseKey", "(", "'invoice'", ")", ";", "}" ]
Sends an invoice to Acumulus. @param array $invoice The invoice to send. @param \Siel\Acumulus\Web\Result|null $result It is possible to already create a Result object before calling the Web Service to store local messages. By passing this Result object these local messages will be merged with any remote messages in the returned Result object. @return \Siel\Acumulus\Web\Result The Result of the webservice call. A successful call will contain a response array with key: - invoice: an array of information about the created invoice, being an array with keys: - invoicenumber - token - entryid @see https://www.siel.nl/acumulus/API/Invoicing/Add_Invoice/
[ "Sends", "an", "invoice", "to", "Acumulus", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Service.php#L275-L278
30,473
SIELOnline/libAcumulus
src/Web/Service.php
Service.setDeleteStatus
public function setDeleteStatus($entryId, $deleteStatus) { $message = array( 'entryid' => (int) $entryId, 'entrydeletestatus' => (int) $deleteStatus, ); // @todo: clean up on receiving P2XFELO12? return $this->communicator->callApiFunction('entry/entry_deletestatus_set', $message)->setMainResponseKey('entry'); }
php
public function setDeleteStatus($entryId, $deleteStatus) { $message = array( 'entryid' => (int) $entryId, 'entrydeletestatus' => (int) $deleteStatus, ); // @todo: clean up on receiving P2XFELO12? return $this->communicator->callApiFunction('entry/entry_deletestatus_set', $message)->setMainResponseKey('entry'); }
[ "public", "function", "setDeleteStatus", "(", "$", "entryId", ",", "$", "deleteStatus", ")", "{", "$", "message", "=", "array", "(", "'entryid'", "=>", "(", "int", ")", "$", "entryId", ",", "'entrydeletestatus'", "=>", "(", "int", ")", "$", "deleteStatus", ",", ")", ";", "// @todo: clean up on receiving P2XFELO12?", "return", "$", "this", "->", "communicator", "->", "callApiFunction", "(", "'entry/entry_deletestatus_set'", ",", "$", "message", ")", "->", "setMainResponseKey", "(", "'entry'", ")", ";", "}" ]
Moves the entry into or out of the trashbin. @param int $entryId The id of the entry. @param int $deleteStatus The delete action to perform: one of the API::Entry_Delete or API::Entry_UnDelete constants. API::Entry_UnDelete does not work for now. @return \Siel\Acumulus\Web\Result The result of the webservice call. The structured response will contain 1 "entry" array, being a keyed array with keys: - entryid - entryproc: (description new status): 'removed' or '???' Possible errors: - "XCM7ELO12: Invalid entrydeletestatus value supplied": $deleteStatus is not one of the indicated constants. - "XCM7ELO14: Invalid entrydeletestatus value supplied": $deleteStatus is not one of the indicated constants. - "P2XFELO12: Requested for entryid: $entryId not found or forbidden": $entryId does not exist or already has requested status. @see https://siel.nl/acumulus/API/Entry/Set_Delete_Status/
[ "Moves", "the", "entry", "into", "or", "out", "of", "the", "trashbin", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Service.php#L353-L361
30,474
SIELOnline/libAcumulus
src/Web/Service.php
Service.getPaymentStatus
public function getPaymentStatus($token) { $message = array( 'token' => (string) $token, ); return $this->communicator->callApiFunction('invoices/invoice_paymentstatus_get', $message)->setMainResponseKey('invoice'); }
php
public function getPaymentStatus($token) { $message = array( 'token' => (string) $token, ); return $this->communicator->callApiFunction('invoices/invoice_paymentstatus_get', $message)->setMainResponseKey('invoice'); }
[ "public", "function", "getPaymentStatus", "(", "$", "token", ")", "{", "$", "message", "=", "array", "(", "'token'", "=>", "(", "string", ")", "$", "token", ",", ")", ";", "return", "$", "this", "->", "communicator", "->", "callApiFunction", "(", "'invoices/invoice_paymentstatus_get'", ",", "$", "message", ")", "->", "setMainResponseKey", "(", "'invoice'", ")", ";", "}" ]
Retrieves the payment status for an invoice. @param string $token The token for the invoice. @return \Siel\Acumulus\Web\Result The result of the webservice call. The structured response will contain 1 "invoice" array, being a keyed array with keys: - entryid - token - paymentstatus - paymentdate Possible errors: - "XGYTTNF04: Requested invoice for $token not found": $token does not exist. @see https://www.siel.nl/acumulus/API/Invoicing/Payment_Get_Status/
[ "Retrieves", "the", "payment", "status", "for", "an", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Service.php#L382-L388
30,475
SIELOnline/libAcumulus
src/Web/Service.php
Service.setPaymentStatus
public function setPaymentStatus($token, $paymentStatus, $paymentDate = '') { if (empty($paymentDate)) { $paymentDate = date(API::DateFormat_Iso); } $message = array( 'token' => (string) $token, 'paymentstatus' => (int) $paymentStatus, 'paymentdate' => (string) $paymentDate, ); return $this->communicator->callApiFunction('invoices/invoice_paymentstatus_set', $message)->setMainResponseKey('invoice'); }
php
public function setPaymentStatus($token, $paymentStatus, $paymentDate = '') { if (empty($paymentDate)) { $paymentDate = date(API::DateFormat_Iso); } $message = array( 'token' => (string) $token, 'paymentstatus' => (int) $paymentStatus, 'paymentdate' => (string) $paymentDate, ); return $this->communicator->callApiFunction('invoices/invoice_paymentstatus_set', $message)->setMainResponseKey('invoice'); }
[ "public", "function", "setPaymentStatus", "(", "$", "token", ",", "$", "paymentStatus", ",", "$", "paymentDate", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "paymentDate", ")", ")", "{", "$", "paymentDate", "=", "date", "(", "API", "::", "DateFormat_Iso", ")", ";", "}", "$", "message", "=", "array", "(", "'token'", "=>", "(", "string", ")", "$", "token", ",", "'paymentstatus'", "=>", "(", "int", ")", "$", "paymentStatus", ",", "'paymentdate'", "=>", "(", "string", ")", "$", "paymentDate", ",", ")", ";", "return", "$", "this", "->", "communicator", "->", "callApiFunction", "(", "'invoices/invoice_paymentstatus_set'", ",", "$", "message", ")", "->", "setMainResponseKey", "(", "'invoice'", ")", ";", "}" ]
Sets the payment status for an invoice. @param string $token The token for the invoice. @param int $paymentStatus The new payment status, 1 of the API::PaymentStatus_Paid or API::PaymentStatus_Due constants. @param string $paymentDate ISO date string (yyyy-mm-dd) for the date to set as payment date, may be empty for today or if the payment sattus is API::PaymentStatus_Due. @return \Siel\Acumulus\Web\Result The result of the webservice call. The structured response will contain 1 "invoice" array, being a keyed array with keys: - entryid - token - paymentstatus - paymentdate Possible errors: - "DATE590ZW: Missing mandatory paymentdate field. Unable to proceed." - "DATE590ZW: Incorrect date range (2000-01-01 to 2099-12-31) or invalid date format (YYYY-MM-DD) used in paymentdate field. We received: $paymentDate. Unable to proceed." @see https://www.siel.nl/acumulus/API/Invoicing/Payment_Set_Status/
[ "Sets", "the", "payment", "status", "for", "an", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Service.php#L417-L428
30,476
SIELOnline/libAcumulus
src/Web/Service.php
Service.emailInvoiceAsPdf
public function emailInvoiceAsPdf($token, $invoiceType, array $emailAsPdf, $invoiceNotes = '') { $message = array( 'token' => (string) $token, 'invoicetype' => (int) $invoiceType, 'emailaspdf' => $emailAsPdf, ); if (!empty($invoiceNotes)) { $message['invoicenotes'] = (string) $invoiceNotes; } return $this->communicator->callApiFunction('invoices/invoice_mail', $message)->setMainResponseKey('invoice'); }
php
public function emailInvoiceAsPdf($token, $invoiceType, array $emailAsPdf, $invoiceNotes = '') { $message = array( 'token' => (string) $token, 'invoicetype' => (int) $invoiceType, 'emailaspdf' => $emailAsPdf, ); if (!empty($invoiceNotes)) { $message['invoicenotes'] = (string) $invoiceNotes; } return $this->communicator->callApiFunction('invoices/invoice_mail', $message)->setMainResponseKey('invoice'); }
[ "public", "function", "emailInvoiceAsPdf", "(", "$", "token", ",", "$", "invoiceType", ",", "array", "$", "emailAsPdf", ",", "$", "invoiceNotes", "=", "''", ")", "{", "$", "message", "=", "array", "(", "'token'", "=>", "(", "string", ")", "$", "token", ",", "'invoicetype'", "=>", "(", "int", ")", "$", "invoiceType", ",", "'emailaspdf'", "=>", "$", "emailAsPdf", ",", ")", ";", "if", "(", "!", "empty", "(", "$", "invoiceNotes", ")", ")", "{", "$", "message", "[", "'invoicenotes'", "]", "=", "(", "string", ")", "$", "invoiceNotes", ";", "}", "return", "$", "this", "->", "communicator", "->", "callApiFunction", "(", "'invoices/invoice_mail'", ",", "$", "message", ")", "->", "setMainResponseKey", "(", "'invoice'", ")", ";", "}" ]
Sends out an invoice or reminder as PDF. @param string $token The token for the invoice. @param int $invoiceType One of the constants API::Email_Normal or API::Email_Reminder. @param array $emailAsPdf An array with the fields: - emailto - emailbcc - emailfrom - subject - message - confirmreading @param string $invoiceNotes Multiline field for additional remarks. Use \n for newlines and \t for tabs. Contents is placed in notes/comments section of the invoice. Content will not appear on the actual invoice or associated emails. @return \Siel\Acumulus\Web\Result The result of the webservice call. The structured response will contain 1 "invoice" array, being a keyed array with keys: - token - invoicetype Possible errors/warnings: - "GK6FKHU52: Incorrect invoicetype value used (9) in invoicetype tag as part of invoice section in the XML. Using default value of 0 normal." - "TNFE4035G: Requested token not found or invalid token supplied. Unable to proceed." @see https://siel.nl/acumulus/API/Invoicing/Email/
[ "Sends", "out", "an", "invoice", "or", "reminder", "as", "PDF", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Service.php#L464-L475
30,477
SIELOnline/libAcumulus
src/Web/Service.php
Service.getInvoicePdfUri
public function getInvoicePdfUri($token, $applyGraphics = true) { $uri = $this->communicator->getUri('invoices/invoice_get_pdf'); $uri .= "?token=$token"; if (!$applyGraphics) { $uri .= '&gfx=0'; } return $uri; }
php
public function getInvoicePdfUri($token, $applyGraphics = true) { $uri = $this->communicator->getUri('invoices/invoice_get_pdf'); $uri .= "?token=$token"; if (!$applyGraphics) { $uri .= '&gfx=0'; } return $uri; }
[ "public", "function", "getInvoicePdfUri", "(", "$", "token", ",", "$", "applyGraphics", "=", "true", ")", "{", "$", "uri", "=", "$", "this", "->", "communicator", "->", "getUri", "(", "'invoices/invoice_get_pdf'", ")", ";", "$", "uri", ".=", "\"?token=$token\"", ";", "if", "(", "!", "$", "applyGraphics", ")", "{", "$", "uri", ".=", "'&gfx=0'", ";", "}", "return", "$", "uri", ";", "}" ]
Returns the uri to download the invoice PDF. @param string $token The token for the invoice. @param bool $applyGraphics False to prevent any embedded graphics from being applied to the document, true otherwise. @return string The uri to download the invoice PDF. Possible errors (in download, not in return value): - "PDFATNF04: Requested invoice for $token not found": $token does not exist. @see https://siel.nl/acumulus/API/Invoicing/Get_PDF_Invoice/
[ "Returns", "the", "uri", "to", "download", "the", "invoice", "PDF", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Service.php#L494-L502
30,478
SIELOnline/libAcumulus
src/OpenCart/Invoice/Creator.php
Creator.getItemLine
protected function getItemLine(array $item) { $result = array(); // $product can be empty if the product has been deleted. $product = $this->getRegistry()->model_catalog_product->getProduct($item['product_id']); if (!empty($product)) { $this->addPropertySource('product', $product); } $this->addPropertySource('item', $item); $this->addProductInfo($result); // Get vat range info from item line. $productPriceEx = $item['price']; $productVat = $item['tax']; $vatInfo = $this->getVatRangeTags($productVat, $productPriceEx, $this->precision, $this->precision); // Try to look up the vat rate via product. $vatInfo += $this->getVatRateLookupMetadata($product['tax_class_id']); // Check for cost price and margin scheme. if (!empty($line['costPrice']) && $this->allowMarginScheme()) { // Margin scheme: // - Do not put VAT on invoice: send price incl VAT as unitprice. // - But still send the VAT rate to Acumulus. $result[Tag::UnitPrice] = $productPriceEx + $productVat; } else { $result[Tag::UnitPrice] = $productPriceEx; $result[Meta::VatAmount] = $productVat; } $result[Tag::Quantity] = $item['quantity']; $result += $vatInfo; // Options (variants). $options = $this->getOrderModel()->getOrderOptions($item['order_id'], $item['order_product_id']); if (!empty($options)) { // Add options as children. $result[Meta::ChildrenLines] = array(); $optionsVatInfo = $vatInfo; $optionsVatInfo[Meta::VatAmount] = 0; foreach ($options as $option) { $result[Meta::ChildrenLines][] = array( Tag::Product => "{$option['name']}: {$option['value']}", Tag::UnitPrice => 0, // Table order_option does not have a quantity field, so // composite products with multiple same sub product // are apparently not covered. Take quantity from parent. Tag::Quantity => $item['quantity'], ) + $optionsVatInfo; } } $this->removePropertySource('product'); $this->removePropertySource('item'); return $result; }
php
protected function getItemLine(array $item) { $result = array(); // $product can be empty if the product has been deleted. $product = $this->getRegistry()->model_catalog_product->getProduct($item['product_id']); if (!empty($product)) { $this->addPropertySource('product', $product); } $this->addPropertySource('item', $item); $this->addProductInfo($result); // Get vat range info from item line. $productPriceEx = $item['price']; $productVat = $item['tax']; $vatInfo = $this->getVatRangeTags($productVat, $productPriceEx, $this->precision, $this->precision); // Try to look up the vat rate via product. $vatInfo += $this->getVatRateLookupMetadata($product['tax_class_id']); // Check for cost price and margin scheme. if (!empty($line['costPrice']) && $this->allowMarginScheme()) { // Margin scheme: // - Do not put VAT on invoice: send price incl VAT as unitprice. // - But still send the VAT rate to Acumulus. $result[Tag::UnitPrice] = $productPriceEx + $productVat; } else { $result[Tag::UnitPrice] = $productPriceEx; $result[Meta::VatAmount] = $productVat; } $result[Tag::Quantity] = $item['quantity']; $result += $vatInfo; // Options (variants). $options = $this->getOrderModel()->getOrderOptions($item['order_id'], $item['order_product_id']); if (!empty($options)) { // Add options as children. $result[Meta::ChildrenLines] = array(); $optionsVatInfo = $vatInfo; $optionsVatInfo[Meta::VatAmount] = 0; foreach ($options as $option) { $result[Meta::ChildrenLines][] = array( Tag::Product => "{$option['name']}: {$option['value']}", Tag::UnitPrice => 0, // Table order_option does not have a quantity field, so // composite products with multiple same sub product // are apparently not covered. Take quantity from parent. Tag::Quantity => $item['quantity'], ) + $optionsVatInfo; } } $this->removePropertySource('product'); $this->removePropertySource('item'); return $result; }
[ "protected", "function", "getItemLine", "(", "array", "$", "item", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// $product can be empty if the product has been deleted.", "$", "product", "=", "$", "this", "->", "getRegistry", "(", ")", "->", "model_catalog_product", "->", "getProduct", "(", "$", "item", "[", "'product_id'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "product", ")", ")", "{", "$", "this", "->", "addPropertySource", "(", "'product'", ",", "$", "product", ")", ";", "}", "$", "this", "->", "addPropertySource", "(", "'item'", ",", "$", "item", ")", ";", "$", "this", "->", "addProductInfo", "(", "$", "result", ")", ";", "// Get vat range info from item line.", "$", "productPriceEx", "=", "$", "item", "[", "'price'", "]", ";", "$", "productVat", "=", "$", "item", "[", "'tax'", "]", ";", "$", "vatInfo", "=", "$", "this", "->", "getVatRangeTags", "(", "$", "productVat", ",", "$", "productPriceEx", ",", "$", "this", "->", "precision", ",", "$", "this", "->", "precision", ")", ";", "// Try to look up the vat rate via product.", "$", "vatInfo", "+=", "$", "this", "->", "getVatRateLookupMetadata", "(", "$", "product", "[", "'tax_class_id'", "]", ")", ";", "// Check for cost price and margin scheme.", "if", "(", "!", "empty", "(", "$", "line", "[", "'costPrice'", "]", ")", "&&", "$", "this", "->", "allowMarginScheme", "(", ")", ")", "{", "// Margin scheme:", "// - Do not put VAT on invoice: send price incl VAT as unitprice.", "// - But still send the VAT rate to Acumulus.", "$", "result", "[", "Tag", "::", "UnitPrice", "]", "=", "$", "productPriceEx", "+", "$", "productVat", ";", "}", "else", "{", "$", "result", "[", "Tag", "::", "UnitPrice", "]", "=", "$", "productPriceEx", ";", "$", "result", "[", "Meta", "::", "VatAmount", "]", "=", "$", "productVat", ";", "}", "$", "result", "[", "Tag", "::", "Quantity", "]", "=", "$", "item", "[", "'quantity'", "]", ";", "$", "result", "+=", "$", "vatInfo", ";", "// Options (variants).", "$", "options", "=", "$", "this", "->", "getOrderModel", "(", ")", "->", "getOrderOptions", "(", "$", "item", "[", "'order_id'", "]", ",", "$", "item", "[", "'order_product_id'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "{", "// Add options as children.", "$", "result", "[", "Meta", "::", "ChildrenLines", "]", "=", "array", "(", ")", ";", "$", "optionsVatInfo", "=", "$", "vatInfo", ";", "$", "optionsVatInfo", "[", "Meta", "::", "VatAmount", "]", "=", "0", ";", "foreach", "(", "$", "options", "as", "$", "option", ")", "{", "$", "result", "[", "Meta", "::", "ChildrenLines", "]", "[", "]", "=", "array", "(", "Tag", "::", "Product", "=>", "\"{$option['name']}: {$option['value']}\"", ",", "Tag", "::", "UnitPrice", "=>", "0", ",", "// Table order_option does not have a quantity field, so", "// composite products with multiple same sub product", "// are apparently not covered. Take quantity from parent.", "Tag", "::", "Quantity", "=>", "$", "item", "[", "'quantity'", "]", ",", ")", "+", "$", "optionsVatInfo", ";", "}", "}", "$", "this", "->", "removePropertySource", "(", "'product'", ")", ";", "$", "this", "->", "removePropertySource", "(", "'item'", ")", ";", "return", "$", "result", ";", "}" ]
Returns the item line for 1 product line. This method may return child lines if there are options/variants. These lines will be informative, their price will be 0. @param array $item @return array @throws \Exception
[ "Returns", "the", "item", "line", "for", "1", "product", "line", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Invoice/Creator.php#L101-L157
30,479
SIELOnline/libAcumulus
src/OpenCart/Invoice/Creator.php
Creator.getVatRateLookupMetadata
protected function getVatRateLookupMetadata($taxClassId) { $result = array(); $taxClass = $this->getTaxClass($taxClassId); if ($taxClass) { $result += array( Meta::VatClassId => $taxClass['tax_class_id'], Meta::VatClassName => $taxClass['title'], Meta::VatRateLookup => array(), Meta::VatRateLookupLabel => array(), ); $taxRules = $this->getTaxRules($taxClassId); foreach ($taxRules as $taxRule) { $taxRate = $this->getTaxRate($taxRule['tax_rate_id']); if (!empty($taxRate)) { if ($this->isAddressInGeoZone($this->order, $taxRule['based'], $taxRate['geo_zone_id'])) { $result[Meta::VatRateLookup][] = $taxRate['rate']; $result[Meta::VatRateLookupLabel][] = $taxRate['name']; } } } } return $result; }
php
protected function getVatRateLookupMetadata($taxClassId) { $result = array(); $taxClass = $this->getTaxClass($taxClassId); if ($taxClass) { $result += array( Meta::VatClassId => $taxClass['tax_class_id'], Meta::VatClassName => $taxClass['title'], Meta::VatRateLookup => array(), Meta::VatRateLookupLabel => array(), ); $taxRules = $this->getTaxRules($taxClassId); foreach ($taxRules as $taxRule) { $taxRate = $this->getTaxRate($taxRule['tax_rate_id']); if (!empty($taxRate)) { if ($this->isAddressInGeoZone($this->order, $taxRule['based'], $taxRate['geo_zone_id'])) { $result[Meta::VatRateLookup][] = $taxRate['rate']; $result[Meta::VatRateLookupLabel][] = $taxRate['name']; } } } } return $result; }
[ "protected", "function", "getVatRateLookupMetadata", "(", "$", "taxClassId", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "taxClass", "=", "$", "this", "->", "getTaxClass", "(", "$", "taxClassId", ")", ";", "if", "(", "$", "taxClass", ")", "{", "$", "result", "+=", "array", "(", "Meta", "::", "VatClassId", "=>", "$", "taxClass", "[", "'tax_class_id'", "]", ",", "Meta", "::", "VatClassName", "=>", "$", "taxClass", "[", "'title'", "]", ",", "Meta", "::", "VatRateLookup", "=>", "array", "(", ")", ",", "Meta", "::", "VatRateLookupLabel", "=>", "array", "(", ")", ",", ")", ";", "$", "taxRules", "=", "$", "this", "->", "getTaxRules", "(", "$", "taxClassId", ")", ";", "foreach", "(", "$", "taxRules", "as", "$", "taxRule", ")", "{", "$", "taxRate", "=", "$", "this", "->", "getTaxRate", "(", "$", "taxRule", "[", "'tax_rate_id'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "taxRate", ")", ")", "{", "if", "(", "$", "this", "->", "isAddressInGeoZone", "(", "$", "this", "->", "order", ",", "$", "taxRule", "[", "'based'", "]", ",", "$", "taxRate", "[", "'geo_zone_id'", "]", ")", ")", "{", "$", "result", "[", "Meta", "::", "VatRateLookup", "]", "[", "]", "=", "$", "taxRate", "[", "'rate'", "]", ";", "$", "result", "[", "Meta", "::", "VatRateLookupLabel", "]", "[", "]", "=", "$", "taxRate", "[", "'name'", "]", ";", "}", "}", "}", "}", "return", "$", "result", ";", "}" ]
Looks up and returns vat class and vat rate metadata. @param int $taxClassId The tax class to look up. @return array An empty array or an array with keys: - Meta::VatClassId: int - Meta::VatClassName: string - Meta::VatRateLookup: float[] - Meta::VatRateLookupLabel: string[] @throws \Exception
[ "Looks", "up", "and", "returns", "vat", "class", "and", "vat", "rate", "metadata", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Invoice/Creator.php#L174-L199
30,480
SIELOnline/libAcumulus
src/OpenCart/Invoice/Creator.php
Creator.getTotalLine
protected function getTotalLine(array $line, $exVat) { $result = array( Tag::Product => $line['title'], Tag::Quantity => 1, ); if ($exVat) { $result[Tag::UnitPrice] = $line['value']; } else { $result[Meta::UnitPriceInc] = $line['value']; } if ($line['code'] === 'voucher') { // A voucher is to be seen as a partial payment, thus no tax. $result += array( Tag::VatRate => -1, Meta::VatRateSource => Creator::VatRateSource_Exact0, ); } elseif ($line['code'] === 'coupon') { // Coupons may have to be split over various taxes. $result += array( Tag::VatRate => null, Meta::VatRateSource => Creator::VatRateSource_Strategy, Meta::StrategySplit => $line['code'] === 'coupon', ); } else { // Try to get a vat rate. $vatRateLookupMetaData = $this->getVatRateLookupByTotalLineType($line['code']); // The completor will add the looked up vat rate based on looked up // or just the highest appearing vat rate, or wil pass it to the // strategy phase. $result += array( Tag::VatRate => null, Meta::VatRateSource => Creator::VatRateSource_Completor, Meta::StrategySplit => false, ) + $vatRateLookupMetaData; } return $result; }
php
protected function getTotalLine(array $line, $exVat) { $result = array( Tag::Product => $line['title'], Tag::Quantity => 1, ); if ($exVat) { $result[Tag::UnitPrice] = $line['value']; } else { $result[Meta::UnitPriceInc] = $line['value']; } if ($line['code'] === 'voucher') { // A voucher is to be seen as a partial payment, thus no tax. $result += array( Tag::VatRate => -1, Meta::VatRateSource => Creator::VatRateSource_Exact0, ); } elseif ($line['code'] === 'coupon') { // Coupons may have to be split over various taxes. $result += array( Tag::VatRate => null, Meta::VatRateSource => Creator::VatRateSource_Strategy, Meta::StrategySplit => $line['code'] === 'coupon', ); } else { // Try to get a vat rate. $vatRateLookupMetaData = $this->getVatRateLookupByTotalLineType($line['code']); // The completor will add the looked up vat rate based on looked up // or just the highest appearing vat rate, or wil pass it to the // strategy phase. $result += array( Tag::VatRate => null, Meta::VatRateSource => Creator::VatRateSource_Completor, Meta::StrategySplit => false, ) + $vatRateLookupMetaData; } return $result; }
[ "protected", "function", "getTotalLine", "(", "array", "$", "line", ",", "$", "exVat", ")", "{", "$", "result", "=", "array", "(", "Tag", "::", "Product", "=>", "$", "line", "[", "'title'", "]", ",", "Tag", "::", "Quantity", "=>", "1", ",", ")", ";", "if", "(", "$", "exVat", ")", "{", "$", "result", "[", "Tag", "::", "UnitPrice", "]", "=", "$", "line", "[", "'value'", "]", ";", "}", "else", "{", "$", "result", "[", "Meta", "::", "UnitPriceInc", "]", "=", "$", "line", "[", "'value'", "]", ";", "}", "if", "(", "$", "line", "[", "'code'", "]", "===", "'voucher'", ")", "{", "// A voucher is to be seen as a partial payment, thus no tax.", "$", "result", "+=", "array", "(", "Tag", "::", "VatRate", "=>", "-", "1", ",", "Meta", "::", "VatRateSource", "=>", "Creator", "::", "VatRateSource_Exact0", ",", ")", ";", "}", "elseif", "(", "$", "line", "[", "'code'", "]", "===", "'coupon'", ")", "{", "// Coupons may have to be split over various taxes.", "$", "result", "+=", "array", "(", "Tag", "::", "VatRate", "=>", "null", ",", "Meta", "::", "VatRateSource", "=>", "Creator", "::", "VatRateSource_Strategy", ",", "Meta", "::", "StrategySplit", "=>", "$", "line", "[", "'code'", "]", "===", "'coupon'", ",", ")", ";", "}", "else", "{", "// Try to get a vat rate.", "$", "vatRateLookupMetaData", "=", "$", "this", "->", "getVatRateLookupByTotalLineType", "(", "$", "line", "[", "'code'", "]", ")", ";", "// The completor will add the looked up vat rate based on looked up", "// or just the highest appearing vat rate, or wil pass it to the", "// strategy phase.", "$", "result", "+=", "array", "(", "Tag", "::", "VatRate", "=>", "null", ",", "Meta", "::", "VatRateSource", "=>", "Creator", "::", "VatRateSource_Completor", ",", "Meta", "::", "StrategySplit", "=>", "false", ",", ")", "+", "$", "vatRateLookupMetaData", ";", "}", "return", "$", "result", ";", "}" ]
Returns a line based on a "order total line". @param array $line The total line. @param bool $exVat Whether the value in this line is ex (true) or inc (false) vat. @return array An Acumulus invoice line. @throws \Exception
[ "Returns", "a", "line", "based", "on", "a", "order", "total", "line", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Invoice/Creator.php#L276-L315
30,481
SIELOnline/libAcumulus
src/OpenCart/Invoice/Creator.php
Creator.getVatRateLookupByTotalLineType
protected function getVatRateLookupByTotalLineType($code) { $result = array(); $query = $this->getTotalLineTaxClassLookupQuery($code); $queryResult = $this->getRegistry()->db->query($query); if (!empty($queryResult->row)) { $taxClassId = reset($queryResult->row); $result = $this->getVatRateLookupMetadata($taxClassId); } return $result; }
php
protected function getVatRateLookupByTotalLineType($code) { $result = array(); $query = $this->getTotalLineTaxClassLookupQuery($code); $queryResult = $this->getRegistry()->db->query($query); if (!empty($queryResult->row)) { $taxClassId = reset($queryResult->row); $result = $this->getVatRateLookupMetadata($taxClassId); } return $result; }
[ "protected", "function", "getVatRateLookupByTotalLineType", "(", "$", "code", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "query", "=", "$", "this", "->", "getTotalLineTaxClassLookupQuery", "(", "$", "code", ")", ";", "$", "queryResult", "=", "$", "this", "->", "getRegistry", "(", ")", "->", "db", "->", "query", "(", "$", "query", ")", ";", "if", "(", "!", "empty", "(", "$", "queryResult", "->", "row", ")", ")", "{", "$", "taxClassId", "=", "reset", "(", "$", "queryResult", "->", "row", ")", ";", "$", "result", "=", "$", "this", "->", "getVatRateLookupMetadata", "(", "$", "taxClassId", ")", ";", "}", "return", "$", "result", ";", "}" ]
Tries to lookup and return vat rate meta data for the given line type. This is quite hard. The total line (table order_total) contains a code (= line type) and title field, the latter being a translated and possibly formatted descriptive string of the shipping or handling method applied, e.g. Europa (Weight: 3.00kg). It is (almost) impossible to trace this back to a shipping or handling method. So instead we retrieve all tax class ids for the given type, collect all tax rates for those, and hope that this results in only 1 tax rate. @param string $code The total line type: shipping, handling, low_order_fee, ... (no other known types). @return array A, possibly empty, array with vat rate lookup meta data. Empty if no or multiple tax rates were found. @throws \Exception
[ "Tries", "to", "lookup", "and", "return", "vat", "rate", "meta", "data", "for", "the", "given", "line", "type", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Invoice/Creator.php#L338-L348
30,482
SIELOnline/libAcumulus
src/OpenCart/Invoice/Creator.php
Creator.isAddressInGeoZone
protected function isAddressInGeoZone(array $order, $addressType, $geoZoneId) { $fallbackAddressType = $addressType === 'payment' ? 'shipping' : 'payment'; if (!empty($order["{$addressType}_country_id"])) { $countryId = $order["{$addressType}_country_id"]; $zoneId = !empty($order["{$addressType}_zone_id"]) ? $order["{$addressType}_zone_id"] : 0; } elseif (!empty($order["{$fallbackAddressType}_country_id"])) { $countryId = $order["{$fallbackAddressType}_country_id"]; $zoneId = !empty($order["{$fallbackAddressType}_zone_id"]) ? $order["{$fallbackAddressType}_zone_id"] : 0; } else { $countryId = 0; $zoneId = 0; } $zones = $this->getZoneToGeoZones($geoZoneId); foreach ($zones as $zone) { // Check if this zone definition covers the same country. if ($zone['country_id'] == $countryId) { // Check if the zone definition covers the whole country or if // they are equal. if ($zone['zone_id'] == 0 || $zone['zone_id'] == $zoneId) { return true; } } } return false; }
php
protected function isAddressInGeoZone(array $order, $addressType, $geoZoneId) { $fallbackAddressType = $addressType === 'payment' ? 'shipping' : 'payment'; if (!empty($order["{$addressType}_country_id"])) { $countryId = $order["{$addressType}_country_id"]; $zoneId = !empty($order["{$addressType}_zone_id"]) ? $order["{$addressType}_zone_id"] : 0; } elseif (!empty($order["{$fallbackAddressType}_country_id"])) { $countryId = $order["{$fallbackAddressType}_country_id"]; $zoneId = !empty($order["{$fallbackAddressType}_zone_id"]) ? $order["{$fallbackAddressType}_zone_id"] : 0; } else { $countryId = 0; $zoneId = 0; } $zones = $this->getZoneToGeoZones($geoZoneId); foreach ($zones as $zone) { // Check if this zone definition covers the same country. if ($zone['country_id'] == $countryId) { // Check if the zone definition covers the whole country or if // they are equal. if ($zone['zone_id'] == 0 || $zone['zone_id'] == $zoneId) { return true; } } } return false; }
[ "protected", "function", "isAddressInGeoZone", "(", "array", "$", "order", ",", "$", "addressType", ",", "$", "geoZoneId", ")", "{", "$", "fallbackAddressType", "=", "$", "addressType", "===", "'payment'", "?", "'shipping'", ":", "'payment'", ";", "if", "(", "!", "empty", "(", "$", "order", "[", "\"{$addressType}_country_id\"", "]", ")", ")", "{", "$", "countryId", "=", "$", "order", "[", "\"{$addressType}_country_id\"", "]", ";", "$", "zoneId", "=", "!", "empty", "(", "$", "order", "[", "\"{$addressType}_zone_id\"", "]", ")", "?", "$", "order", "[", "\"{$addressType}_zone_id\"", "]", ":", "0", ";", "}", "elseif", "(", "!", "empty", "(", "$", "order", "[", "\"{$fallbackAddressType}_country_id\"", "]", ")", ")", "{", "$", "countryId", "=", "$", "order", "[", "\"{$fallbackAddressType}_country_id\"", "]", ";", "$", "zoneId", "=", "!", "empty", "(", "$", "order", "[", "\"{$fallbackAddressType}_zone_id\"", "]", ")", "?", "$", "order", "[", "\"{$fallbackAddressType}_zone_id\"", "]", ":", "0", ";", "}", "else", "{", "$", "countryId", "=", "0", ";", "$", "zoneId", "=", "0", ";", "}", "$", "zones", "=", "$", "this", "->", "getZoneToGeoZones", "(", "$", "geoZoneId", ")", ";", "foreach", "(", "$", "zones", "as", "$", "zone", ")", "{", "// Check if this zone definition covers the same country.", "if", "(", "$", "zone", "[", "'country_id'", "]", "==", "$", "countryId", ")", "{", "// Check if the zone definition covers the whole country or if", "// they are equal.", "if", "(", "$", "zone", "[", "'zone_id'", "]", "==", "0", "||", "$", "zone", "[", "'zone_id'", "]", "==", "$", "zoneId", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns whether the address of the order lies within the geo zone. @param array $order The order. @param string $addressType 'payment' or 'shipping'. @param int $geoZoneId The id of the geo zone. @return bool True if the address of the order lies within the geo zone, false otherwise. @throws \Exception
[ "Returns", "whether", "the", "address", "of", "the", "order", "lies", "within", "the", "geo", "zone", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Invoice/Creator.php#L366-L392
30,483
SIELOnline/libAcumulus
src/MyWebShop/Helpers/Log.php
Log.getMyWebShopSeverity
protected function getMyWebShopSeverity($severity) { switch ($severity) { case Log::Error: return AbstractLogger::ERROR; case Log::Warning: return AbstractLogger::WARNING; case Log::Notice: case Log::Info: return AbstractLogger::INFO; case Log::Debug: default: return AbstractLogger::DEBUG; } }
php
protected function getMyWebShopSeverity($severity) { switch ($severity) { case Log::Error: return AbstractLogger::ERROR; case Log::Warning: return AbstractLogger::WARNING; case Log::Notice: case Log::Info: return AbstractLogger::INFO; case Log::Debug: default: return AbstractLogger::DEBUG; } }
[ "protected", "function", "getMyWebShopSeverity", "(", "$", "severity", ")", "{", "switch", "(", "$", "severity", ")", "{", "case", "Log", "::", "Error", ":", "return", "AbstractLogger", "::", "ERROR", ";", "case", "Log", "::", "Warning", ":", "return", "AbstractLogger", "::", "WARNING", ";", "case", "Log", "::", "Notice", ":", "case", "Log", "::", "Info", ":", "return", "AbstractLogger", "::", "INFO", ";", "case", "Log", "::", "Debug", ":", "default", ":", "return", "AbstractLogger", "::", "DEBUG", ";", "}", "}" ]
Returns the MyWebShop equivalent of the severity. @param int $severity One of the constants of the base Log class. @return int The MyWebShop equivalent of the severity.
[ "Returns", "the", "MyWebShop", "equivalent", "of", "the", "severity", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/MyWebShop/Helpers/Log.php#L38-L52
30,484
SIELOnline/libAcumulus
src/MyWebShop/Helpers/Log.php
Log.getLogger
protected function getLogger() { if ($this->logger === null) { // @todo: Instantiate a webshop specific log object that logs to a separate Acumulus log file. $this->logger = new FileLogger(AbstractLogger::DEBUG); $this->logger->setFilename(_ROOT_DIR_ . '/'. $logDirectory . '/acumulus.log'); } return $this->logger; }
php
protected function getLogger() { if ($this->logger === null) { // @todo: Instantiate a webshop specific log object that logs to a separate Acumulus log file. $this->logger = new FileLogger(AbstractLogger::DEBUG); $this->logger->setFilename(_ROOT_DIR_ . '/'. $logDirectory . '/acumulus.log'); } return $this->logger; }
[ "protected", "function", "getLogger", "(", ")", "{", "if", "(", "$", "this", "->", "logger", "===", "null", ")", "{", "// @todo: Instantiate a webshop specific log object that logs to a separate Acumulus log file.", "$", "this", "->", "logger", "=", "new", "FileLogger", "(", "AbstractLogger", "::", "DEBUG", ")", ";", "$", "this", "->", "logger", "->", "setFilename", "(", "_ROOT_DIR_", ".", "'/'", ".", "$", "logDirectory", ".", "'/acumulus.log'", ")", ";", "}", "return", "$", "this", "->", "logger", ";", "}" ]
Returns the MyWebShop specific logger. @return \AbstractLogger
[ "Returns", "the", "MyWebShop", "specific", "logger", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/MyWebShop/Helpers/Log.php#L60-L68
30,485
SIELOnline/libAcumulus
src/Joomla/Shop/InvoiceManager.php
InvoiceManager.toSql
protected function toSql($date) { $tz = new DateTimeZone(JFactory::getApplication()->get('offset')); $date = new JDate($date); $date->setTimezone($tz); return $date->toSql(true); }
php
protected function toSql($date) { $tz = new DateTimeZone(JFactory::getApplication()->get('offset')); $date = new JDate($date); $date->setTimezone($tz); return $date->toSql(true); }
[ "protected", "function", "toSql", "(", "$", "date", ")", "{", "$", "tz", "=", "new", "DateTimeZone", "(", "JFactory", "::", "getApplication", "(", ")", "->", "get", "(", "'offset'", ")", ")", ";", "$", "date", "=", "new", "JDate", "(", "$", "date", ")", ";", "$", "date", "->", "setTimezone", "(", "$", "tz", ")", ";", "return", "$", "date", "->", "toSql", "(", "true", ")", ";", "}" ]
Helper method that returns a date in the correct and escaped sql format. @param string $date Date in yyyy-mm-dd format. @return string @throws \Exception
[ "Helper", "method", "that", "returns", "a", "date", "in", "the", "correct", "and", "escaped", "sql", "format", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Joomla/Shop/InvoiceManager.php#L71-L77
30,486
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.setInvoiceSource
protected function setInvoiceSource($invoiceSource) { $this->invoiceSource = $invoiceSource; if (!in_array($invoiceSource->getType(), array(Source::Order, Source::CreditNote))) { $this->log->error('Creator::setSource(): unknown source type %s', $this->invoiceSource->getType()); }; }
php
protected function setInvoiceSource($invoiceSource) { $this->invoiceSource = $invoiceSource; if (!in_array($invoiceSource->getType(), array(Source::Order, Source::CreditNote))) { $this->log->error('Creator::setSource(): unknown source type %s', $this->invoiceSource->getType()); }; }
[ "protected", "function", "setInvoiceSource", "(", "$", "invoiceSource", ")", "{", "$", "this", "->", "invoiceSource", "=", "$", "invoiceSource", ";", "if", "(", "!", "in_array", "(", "$", "invoiceSource", "->", "getType", "(", ")", ",", "array", "(", "Source", "::", "Order", ",", "Source", "::", "CreditNote", ")", ")", ")", "{", "$", "this", "->", "log", "->", "error", "(", "'Creator::setSource(): unknown source type %s'", ",", "$", "this", "->", "invoiceSource", "->", "getType", "(", ")", ")", ";", "}", ";", "}" ]
Sets the source to create the invoice for. @param Source $invoiceSource
[ "Sets", "the", "source", "to", "create", "the", "invoice", "for", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L179-L185
30,487
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.setPropertySources
protected function setPropertySources() { $this->propertySources = array(); $this->propertySources['invoiceSource'] = $this->invoiceSource; if (array_key_exists(Source::CreditNote, $this->shopCapabilities->getSupportedInvoiceSourceTypes())) { $this->propertySources['originalInvoiceSource'] = $this->invoiceSource->getOrder(); } $this->propertySources['source'] = $this->invoiceSource->getSource(); if (array_key_exists(Source::CreditNote, $this->shopCapabilities->getSupportedInvoiceSourceTypes())) { if ($this->invoiceSource->getType() === Source::CreditNote) { $this->propertySources['refund'] = $this->invoiceSource->getSource(); } $this->propertySources['order'] = $this->invoiceSource->getOrder()->getSource(); if ($this->invoiceSource->getType() === Source::CreditNote) { $this->propertySources['refundedInvoiceSource'] = $this->invoiceSource->getOrder(); $this->propertySources['refundedOrder'] = $this->invoiceSource->getOrder()->getSource(); } } }
php
protected function setPropertySources() { $this->propertySources = array(); $this->propertySources['invoiceSource'] = $this->invoiceSource; if (array_key_exists(Source::CreditNote, $this->shopCapabilities->getSupportedInvoiceSourceTypes())) { $this->propertySources['originalInvoiceSource'] = $this->invoiceSource->getOrder(); } $this->propertySources['source'] = $this->invoiceSource->getSource(); if (array_key_exists(Source::CreditNote, $this->shopCapabilities->getSupportedInvoiceSourceTypes())) { if ($this->invoiceSource->getType() === Source::CreditNote) { $this->propertySources['refund'] = $this->invoiceSource->getSource(); } $this->propertySources['order'] = $this->invoiceSource->getOrder()->getSource(); if ($this->invoiceSource->getType() === Source::CreditNote) { $this->propertySources['refundedInvoiceSource'] = $this->invoiceSource->getOrder(); $this->propertySources['refundedOrder'] = $this->invoiceSource->getOrder()->getSource(); } } }
[ "protected", "function", "setPropertySources", "(", ")", "{", "$", "this", "->", "propertySources", "=", "array", "(", ")", ";", "$", "this", "->", "propertySources", "[", "'invoiceSource'", "]", "=", "$", "this", "->", "invoiceSource", ";", "if", "(", "array_key_exists", "(", "Source", "::", "CreditNote", ",", "$", "this", "->", "shopCapabilities", "->", "getSupportedInvoiceSourceTypes", "(", ")", ")", ")", "{", "$", "this", "->", "propertySources", "[", "'originalInvoiceSource'", "]", "=", "$", "this", "->", "invoiceSource", "->", "getOrder", "(", ")", ";", "}", "$", "this", "->", "propertySources", "[", "'source'", "]", "=", "$", "this", "->", "invoiceSource", "->", "getSource", "(", ")", ";", "if", "(", "array_key_exists", "(", "Source", "::", "CreditNote", ",", "$", "this", "->", "shopCapabilities", "->", "getSupportedInvoiceSourceTypes", "(", ")", ")", ")", "{", "if", "(", "$", "this", "->", "invoiceSource", "->", "getType", "(", ")", "===", "Source", "::", "CreditNote", ")", "{", "$", "this", "->", "propertySources", "[", "'refund'", "]", "=", "$", "this", "->", "invoiceSource", "->", "getSource", "(", ")", ";", "}", "$", "this", "->", "propertySources", "[", "'order'", "]", "=", "$", "this", "->", "invoiceSource", "->", "getOrder", "(", ")", "->", "getSource", "(", ")", ";", "if", "(", "$", "this", "->", "invoiceSource", "->", "getType", "(", ")", "===", "Source", "::", "CreditNote", ")", "{", "$", "this", "->", "propertySources", "[", "'refundedInvoiceSource'", "]", "=", "$", "this", "->", "invoiceSource", "->", "getOrder", "(", ")", ";", "$", "this", "->", "propertySources", "[", "'refundedOrder'", "]", "=", "$", "this", "->", "invoiceSource", "->", "getOrder", "(", ")", "->", "getSource", "(", ")", ";", "}", "}", "}" ]
Sets the list of sources to search for a property when expanding tokens.
[ "Sets", "the", "list", "of", "sources", "to", "search", "for", "a", "property", "when", "expanding", "tokens", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L190-L208
30,488
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.create
public function create($source) { $this->setInvoiceSource($source); $this->setPropertySources(); $this->invoice = array(); $this->invoice[Tag::Customer] = $this->getCustomer(); $this->invoice[Tag::Customer][Tag::Invoice] = $this->getInvoice(); $this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $this->getInvoiceLines(); $emailAsPdf = $this->getEmailAsPdf(!empty($this->invoice[Tag::Customer][Tag::Email]) ? $this->invoice[Tag::Customer][Tag::Email] : ''); if (!empty($emailAsPdf)) { $this->invoice[Tag::Customer][Tag::Invoice][Tag::EmailAsPdf] = $emailAsPdf; } return $this->invoice; }
php
public function create($source) { $this->setInvoiceSource($source); $this->setPropertySources(); $this->invoice = array(); $this->invoice[Tag::Customer] = $this->getCustomer(); $this->invoice[Tag::Customer][Tag::Invoice] = $this->getInvoice(); $this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $this->getInvoiceLines(); $emailAsPdf = $this->getEmailAsPdf(!empty($this->invoice[Tag::Customer][Tag::Email]) ? $this->invoice[Tag::Customer][Tag::Email] : ''); if (!empty($emailAsPdf)) { $this->invoice[Tag::Customer][Tag::Invoice][Tag::EmailAsPdf] = $emailAsPdf; } return $this->invoice; }
[ "public", "function", "create", "(", "$", "source", ")", "{", "$", "this", "->", "setInvoiceSource", "(", "$", "source", ")", ";", "$", "this", "->", "setPropertySources", "(", ")", ";", "$", "this", "->", "invoice", "=", "array", "(", ")", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "=", "$", "this", "->", "getCustomer", "(", ")", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "=", "$", "this", "->", "getInvoice", "(", ")", ";", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "Line", "]", "=", "$", "this", "->", "getInvoiceLines", "(", ")", ";", "$", "emailAsPdf", "=", "$", "this", "->", "getEmailAsPdf", "(", "!", "empty", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Email", "]", ")", "?", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Email", "]", ":", "''", ")", ";", "if", "(", "!", "empty", "(", "$", "emailAsPdf", ")", ")", "{", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "EmailAsPdf", "]", "=", "$", "emailAsPdf", ";", "}", "return", "$", "this", "->", "invoice", ";", "}" ]
Creates an Acumulus invoice from an order or credit note. @param Source $source The web shop order. @return array The acumulus invoice for this order.
[ "Creates", "an", "Acumulus", "invoice", "from", "an", "order", "or", "credit", "note", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L246-L259
30,489
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.getCustomer
protected function getCustomer() { $customer = array(); $customerSettings = $this->config->getCustomerSettings(); $this->addDefault($customer, Tag::Type, $customerSettings['defaultCustomerType']); $this->addTokenDefault($customer, Tag::ContactYourId, $customerSettings['contactYourId']); $this->addDefaultEmpty($customer, Tag::ContactStatus, $customerSettings['contactStatus']); $this->addTokenDefault($customer, Tag::CompanyName1, $customerSettings['companyName1']); $this->addTokenDefault($customer, Tag::CompanyName2, $customerSettings['companyName2']); $this->addTokenDefault($customer, Tag::VatNumber, $customerSettings['vatNumber']); $this->addTokenDefault($customer, Tag::FullName, $customerSettings['fullName']); $this->addTokenDefault($customer, Tag::Salutation, $customerSettings['salutation']); $this->addTokenDefault($customer, Tag::Address1, $customerSettings['address1']); $this->addTokenDefault($customer, Tag::Address2, $customerSettings['address2']); $this->addTokenDefault($customer, Tag::PostalCode, $customerSettings['postalCode']); $this->addTokenDefault($customer, Tag::City, $customerSettings['city']); $customer[Tag::CountryCode] = $this->countries->convertEuCountryCode($this->invoiceSource->getCountryCode()); // Add 'nl' as default country code. As other methods in the creator may // depend on this value being filled, e.g. looking up product vat rates, // we cannot wait until the completion phase, so we add it here. $this->addDefault($customer, Tag::CountryCode, 'nl'); $this->addDefault($customer, Tag::Country, $this->countries->getCountryName($customer[Tag::CountryCode])); $this->addTokenDefault($customer, Tag::Telephone, $customerSettings['telephone']); $this->addTokenDefault($customer, Tag::Fax, $customerSettings['fax']); $this->addTokenDefault($customer, Tag::Email, $customerSettings['email']); $this->addDefaultEmpty($customer, Tag::OverwriteIfExists, $customerSettings['overwriteIfExists'] ? Api::OverwriteIfExists_Yes : Api::OverwriteIfExists_No); $this->addTokenDefault($customer, Tag::Mark, $customerSettings['mark']); return $customer; }
php
protected function getCustomer() { $customer = array(); $customerSettings = $this->config->getCustomerSettings(); $this->addDefault($customer, Tag::Type, $customerSettings['defaultCustomerType']); $this->addTokenDefault($customer, Tag::ContactYourId, $customerSettings['contactYourId']); $this->addDefaultEmpty($customer, Tag::ContactStatus, $customerSettings['contactStatus']); $this->addTokenDefault($customer, Tag::CompanyName1, $customerSettings['companyName1']); $this->addTokenDefault($customer, Tag::CompanyName2, $customerSettings['companyName2']); $this->addTokenDefault($customer, Tag::VatNumber, $customerSettings['vatNumber']); $this->addTokenDefault($customer, Tag::FullName, $customerSettings['fullName']); $this->addTokenDefault($customer, Tag::Salutation, $customerSettings['salutation']); $this->addTokenDefault($customer, Tag::Address1, $customerSettings['address1']); $this->addTokenDefault($customer, Tag::Address2, $customerSettings['address2']); $this->addTokenDefault($customer, Tag::PostalCode, $customerSettings['postalCode']); $this->addTokenDefault($customer, Tag::City, $customerSettings['city']); $customer[Tag::CountryCode] = $this->countries->convertEuCountryCode($this->invoiceSource->getCountryCode()); // Add 'nl' as default country code. As other methods in the creator may // depend on this value being filled, e.g. looking up product vat rates, // we cannot wait until the completion phase, so we add it here. $this->addDefault($customer, Tag::CountryCode, 'nl'); $this->addDefault($customer, Tag::Country, $this->countries->getCountryName($customer[Tag::CountryCode])); $this->addTokenDefault($customer, Tag::Telephone, $customerSettings['telephone']); $this->addTokenDefault($customer, Tag::Fax, $customerSettings['fax']); $this->addTokenDefault($customer, Tag::Email, $customerSettings['email']); $this->addDefaultEmpty($customer, Tag::OverwriteIfExists, $customerSettings['overwriteIfExists'] ? Api::OverwriteIfExists_Yes : Api::OverwriteIfExists_No); $this->addTokenDefault($customer, Tag::Mark, $customerSettings['mark']); return $customer; }
[ "protected", "function", "getCustomer", "(", ")", "{", "$", "customer", "=", "array", "(", ")", ";", "$", "customerSettings", "=", "$", "this", "->", "config", "->", "getCustomerSettings", "(", ")", ";", "$", "this", "->", "addDefault", "(", "$", "customer", ",", "Tag", "::", "Type", ",", "$", "customerSettings", "[", "'defaultCustomerType'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "ContactYourId", ",", "$", "customerSettings", "[", "'contactYourId'", "]", ")", ";", "$", "this", "->", "addDefaultEmpty", "(", "$", "customer", ",", "Tag", "::", "ContactStatus", ",", "$", "customerSettings", "[", "'contactStatus'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "CompanyName1", ",", "$", "customerSettings", "[", "'companyName1'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "CompanyName2", ",", "$", "customerSettings", "[", "'companyName2'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "VatNumber", ",", "$", "customerSettings", "[", "'vatNumber'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "FullName", ",", "$", "customerSettings", "[", "'fullName'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "Salutation", ",", "$", "customerSettings", "[", "'salutation'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "Address1", ",", "$", "customerSettings", "[", "'address1'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "Address2", ",", "$", "customerSettings", "[", "'address2'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "PostalCode", ",", "$", "customerSettings", "[", "'postalCode'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "City", ",", "$", "customerSettings", "[", "'city'", "]", ")", ";", "$", "customer", "[", "Tag", "::", "CountryCode", "]", "=", "$", "this", "->", "countries", "->", "convertEuCountryCode", "(", "$", "this", "->", "invoiceSource", "->", "getCountryCode", "(", ")", ")", ";", "// Add 'nl' as default country code. As other methods in the creator may", "// depend on this value being filled, e.g. looking up product vat rates,", "// we cannot wait until the completion phase, so we add it here.", "$", "this", "->", "addDefault", "(", "$", "customer", ",", "Tag", "::", "CountryCode", ",", "'nl'", ")", ";", "$", "this", "->", "addDefault", "(", "$", "customer", ",", "Tag", "::", "Country", ",", "$", "this", "->", "countries", "->", "getCountryName", "(", "$", "customer", "[", "Tag", "::", "CountryCode", "]", ")", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "Telephone", ",", "$", "customerSettings", "[", "'telephone'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "Fax", ",", "$", "customerSettings", "[", "'fax'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "Email", ",", "$", "customerSettings", "[", "'email'", "]", ")", ";", "$", "this", "->", "addDefaultEmpty", "(", "$", "customer", ",", "Tag", "::", "OverwriteIfExists", ",", "$", "customerSettings", "[", "'overwriteIfExists'", "]", "?", "Api", "::", "OverwriteIfExists_Yes", ":", "Api", "::", "OverwriteIfExists_No", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "customer", ",", "Tag", "::", "Mark", ",", "$", "customerSettings", "[", "'mark'", "]", ")", ";", "return", "$", "customer", ";", "}" ]
Returns the 'customer' part of the invoice add structure. The following keys are allowed/expected by the API: - type - contactid: will not be set. Acumulus id for this customer, in the absence of this value, the API uses the email address as identifying value. - contactyourid: webshop customer id. - contactstatus - companyname1 - companyname2 - vatnumber - fullname - salutation - address1 - address2 - postalcode - city - countrycode - country - telephone - fax - email: used to identify clients. - overwriteifexists - bankaccountnumber: will not be set: no webshop software provides this. - mark - disableduplicates: not (yet) supported. At the customer level no meta tags are defined. Extending classes should normally not have to override this method as all values are fetched via configurable settings that may contain tokens (veldverwijzingen (Dutch)) that refer to properties of objects in the webshop (property sources). The exception is the (ISO) country code which may not be easy to fetch via a property source as this might include a database lookup to a "Countries" table. This is fetched via Source::getCountryCode(). @return array A keyed array with the customer data.
[ "Returns", "the", "customer", "part", "of", "the", "invoice", "add", "structure", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L303-L331
30,490
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.getInvoiceNumber
protected function getInvoiceNumber($invoiceNumberSource) { $result = $invoiceNumberSource === PluginConfig::InvoiceNrSource_ShopInvoice ? $this->invoiceSource->getInvoiceReference() : null; if (empty($result)) { $result = $this->invoiceSource->getReference(); } return $result; }
php
protected function getInvoiceNumber($invoiceNumberSource) { $result = $invoiceNumberSource === PluginConfig::InvoiceNrSource_ShopInvoice ? $this->invoiceSource->getInvoiceReference() : null; if (empty($result)) { $result = $this->invoiceSource->getReference(); } return $result; }
[ "protected", "function", "getInvoiceNumber", "(", "$", "invoiceNumberSource", ")", "{", "$", "result", "=", "$", "invoiceNumberSource", "===", "PluginConfig", "::", "InvoiceNrSource_ShopInvoice", "?", "$", "this", "->", "invoiceSource", "->", "getInvoiceReference", "(", ")", ":", "null", ";", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "result", "=", "$", "this", "->", "invoiceSource", "->", "getReference", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the number to use as invoice number. @param int $invoiceNumberSource \Siel\Acumulus\PluginConfig::InvoiceNrSource_ShopInvoice or \Siel\Acumulus\PluginConfig::InvoiceNrSource_ShopOrder. @return int The number to use as invoice "number" on the Acumulus invoice. Note that Acumulus expects a number and does not accept string prefixes or such.
[ "Returns", "the", "number", "to", "use", "as", "invoice", "number", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L462-L469
30,491
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.getInvoiceDate
protected function getInvoiceDate($dateToUse) { $result = $this->invoiceSource->getInvoiceDate(); if ($dateToUse != PluginConfig::InvoiceDate_OrderCreate || empty($result)) { $result = $this->invoiceSource->getDate(); } return $result; }
php
protected function getInvoiceDate($dateToUse) { $result = $this->invoiceSource->getInvoiceDate(); if ($dateToUse != PluginConfig::InvoiceDate_OrderCreate || empty($result)) { $result = $this->invoiceSource->getDate(); } return $result; }
[ "protected", "function", "getInvoiceDate", "(", "$", "dateToUse", ")", "{", "$", "result", "=", "$", "this", "->", "invoiceSource", "->", "getInvoiceDate", "(", ")", ";", "if", "(", "$", "dateToUse", "!=", "PluginConfig", "::", "InvoiceDate_OrderCreate", "||", "empty", "(", "$", "result", ")", ")", "{", "$", "result", "=", "$", "this", "->", "invoiceSource", "->", "getDate", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the date to use as invoice date. @param int $dateToUse \Siel\Acumulus\PluginConfig::InvoiceDate_InvoiceCreate or \Siel\Acumulus\PluginConfig::InvoiceDate_OrderCreate @return string Date to use as invoice date on the Acumulus invoice: yyyy-mm-dd.
[ "Returns", "the", "date", "to", "use", "as", "invoice", "date", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L481-L488
30,492
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.getInvoiceLines
protected function getInvoiceLines() { $itemLines = $this->getItemLines(); $itemLines = $this->addLineType($itemLines, static::LineType_OrderItem); $feeLines = $this->getFeeLines(); $discountLines = $this->getDiscountLines(); $discountLines = $this->addLineType($discountLines, static::LineType_Discount); $manualLines = $this->getManualLines(); $manualLines = $this->addLineType($manualLines, static::LineType_Manual); $result = array_merge($itemLines, $feeLines, $discountLines, $manualLines); return $result; }
php
protected function getInvoiceLines() { $itemLines = $this->getItemLines(); $itemLines = $this->addLineType($itemLines, static::LineType_OrderItem); $feeLines = $this->getFeeLines(); $discountLines = $this->getDiscountLines(); $discountLines = $this->addLineType($discountLines, static::LineType_Discount); $manualLines = $this->getManualLines(); $manualLines = $this->addLineType($manualLines, static::LineType_Manual); $result = array_merge($itemLines, $feeLines, $discountLines, $manualLines); return $result; }
[ "protected", "function", "getInvoiceLines", "(", ")", "{", "$", "itemLines", "=", "$", "this", "->", "getItemLines", "(", ")", ";", "$", "itemLines", "=", "$", "this", "->", "addLineType", "(", "$", "itemLines", ",", "static", "::", "LineType_OrderItem", ")", ";", "$", "feeLines", "=", "$", "this", "->", "getFeeLines", "(", ")", ";", "$", "discountLines", "=", "$", "this", "->", "getDiscountLines", "(", ")", ";", "$", "discountLines", "=", "$", "this", "->", "addLineType", "(", "$", "discountLines", ",", "static", "::", "LineType_Discount", ")", ";", "$", "manualLines", "=", "$", "this", "->", "getManualLines", "(", ")", ";", "$", "manualLines", "=", "$", "this", "->", "addLineType", "(", "$", "manualLines", ",", "static", "::", "LineType_Manual", ")", ";", "$", "result", "=", "array_merge", "(", "$", "itemLines", ",", "$", "feeLines", ",", "$", "discountLines", ",", "$", "manualLines", ")", ";", "return", "$", "result", ";", "}" ]
Returns the 'invoice''line' parts of the invoice add structure. Each invoice line is a keyed array. The following keys are allowed or expected (*) by the API: - itemnumber - product - nature * unitprice * vatrate * quantity - costprice: optional, this triggers margin invoices. Meta data (not recognised by the API but used later on by the Creator or Completor, or for support and debugging purposes), see {@see \Siel\Acumulus\Meta}: - Complementary to amount and vatrate: - unitpriceinc - vatamount * meta-line-type: type of line: 1 of the LineType_... constants. - vat rate related: * meta-vatrate-source, 1 of the VatRateSource_... constants: - exact: should exactly equal an existing VAT rate. - exact-0: should exactly equal the 0 VAT rate. - calculated: based on dividing vatamount and unitprice which both may have a limited precision and therefore probably will not exactly match an existing vat rate. - completor: to be filled in by the completor. - strategy: to be completed in by a tax divide strategy. This may lead to this line being split into multiple lines. - parent: copied from the parent. * meta-vatrate-min: required if meta-vatrate-source is calculated. The minimum value for the vat rate, based on the precision of the vatamount and unitprice. * meta-vatrate-max: required if meta-vatrate-source is calculated. The maximum value for the vat rate, based on the precision of the vatamount and unitprice. - meta-strategy-split: true or false (absent = false) - Totals per line: - meta-line-price - meta-line-priceinc - meta-line-vatamount - Parent - children line meta data: - meta-children - meta-children-count - meta-parent-index - meta-children-merged - meta-children-not-shown - meta-parent - These keys can be used to complete missing values or to assist in correcting rounding errors in the values that are present. The base CompletorInvoiceLines expects: - meta-vatrate-source to be filled - If meta-vatrate-source = exact: no other keys expected - If meta-vatrate-source = calculated: meta-vatrate-min and meta-vatrate-max are expected to be filled. These values should come from calling the helper method getVatRangeTags() with the values used to calculate the vat rate and their precision. - If meta-vatrate-source = completor: vatrate should be null and unitprice should be 0. The completor will typically fill vatrate with the highest or most appearing vat rate, looking at the exact and calculated (after correcting them for rounding errors) vat rates. - If meta-vatrate-source = strategy: vat rate should be null and either unitprice or unitpriceinc should be filled wit a non-0 amount (typically a negative amount as this is mostly used for spreading discounts over tax rates). Moreover, on the invoice level meta-invoice-amount and meta-invoice-vatamount should be filled in. The completor will use a tax divide strategy to arrive at valid values for the missing fields. Extending classes should normally not have to override this method, but should instead implement getItemLines(), getShippingLine(), getPaymentFeeLine(), getGiftWrappingLine(), getDiscountLines(), and getManualLines(). @return array[] A non keyed array with all invoice lines.
[ "Returns", "the", "invoice", "line", "parts", "of", "the", "invoice", "add", "structure", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L570-L585
30,493
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.addProductInfo
protected function addProductInfo(array &$line) { $invoiceSettings = $this->config->getInvoiceSettings(); $this->addTokenDefault($line, Tag::ItemNumber, $invoiceSettings['itemNumber']); $this->addTokenDefault($line, Tag::Product, $invoiceSettings['productName']); $this->addNature($line); if (!empty($invoiceSettings['costPrice'])) { $value = $this->getTokenizedValue($invoiceSettings['costPrice']); if (!Number::isZero($value)) { // If we have a cost price we add it, even if this is no margin // invoice. $line[Tag::CostPrice] = $value; } } }
php
protected function addProductInfo(array &$line) { $invoiceSettings = $this->config->getInvoiceSettings(); $this->addTokenDefault($line, Tag::ItemNumber, $invoiceSettings['itemNumber']); $this->addTokenDefault($line, Tag::Product, $invoiceSettings['productName']); $this->addNature($line); if (!empty($invoiceSettings['costPrice'])) { $value = $this->getTokenizedValue($invoiceSettings['costPrice']); if (!Number::isZero($value)) { // If we have a cost price we add it, even if this is no margin // invoice. $line[Tag::CostPrice] = $value; } } }
[ "protected", "function", "addProductInfo", "(", "array", "&", "$", "line", ")", "{", "$", "invoiceSettings", "=", "$", "this", "->", "config", "->", "getInvoiceSettings", "(", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "line", ",", "Tag", "::", "ItemNumber", ",", "$", "invoiceSettings", "[", "'itemNumber'", "]", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "line", ",", "Tag", "::", "Product", ",", "$", "invoiceSettings", "[", "'productName'", "]", ")", ";", "$", "this", "->", "addNature", "(", "$", "line", ")", ";", "if", "(", "!", "empty", "(", "$", "invoiceSettings", "[", "'costPrice'", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "getTokenizedValue", "(", "$", "invoiceSettings", "[", "'costPrice'", "]", ")", ";", "if", "(", "!", "Number", "::", "isZero", "(", "$", "value", ")", ")", "{", "// If we have a cost price we add it, even if this is no margin", "// invoice.", "$", "line", "[", "Tag", "::", "CostPrice", "]", "=", "$", "value", ";", "}", "}", "}" ]
Adds the product based tags to a line. The product based tags are: - item number - product name - nature - cost price @param array $line
[ "Adds", "the", "product", "based", "tags", "to", "a", "line", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L612-L626
30,494
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.addNature
protected function addNature(array &$line) { if (empty($line[Tag::Nature])) { $shopSettings = $this->config->getShopSettings(); switch ($shopSettings['nature_shop']) { case PluginConfig::Nature_Products: $line[Tag::Nature] = Api::Nature_Product; break; case PluginConfig::Nature_Services: $line[Tag::Nature] = Api::Nature_Service; break; default: $invoiceSettings = $this->config->getInvoiceSettings(); $this->addTokenDefault($line, Tag::Nature, $invoiceSettings['nature']); break; } } }
php
protected function addNature(array &$line) { if (empty($line[Tag::Nature])) { $shopSettings = $this->config->getShopSettings(); switch ($shopSettings['nature_shop']) { case PluginConfig::Nature_Products: $line[Tag::Nature] = Api::Nature_Product; break; case PluginConfig::Nature_Services: $line[Tag::Nature] = Api::Nature_Service; break; default: $invoiceSettings = $this->config->getInvoiceSettings(); $this->addTokenDefault($line, Tag::Nature, $invoiceSettings['nature']); break; } } }
[ "protected", "function", "addNature", "(", "array", "&", "$", "line", ")", "{", "if", "(", "empty", "(", "$", "line", "[", "Tag", "::", "Nature", "]", ")", ")", "{", "$", "shopSettings", "=", "$", "this", "->", "config", "->", "getShopSettings", "(", ")", ";", "switch", "(", "$", "shopSettings", "[", "'nature_shop'", "]", ")", "{", "case", "PluginConfig", "::", "Nature_Products", ":", "$", "line", "[", "Tag", "::", "Nature", "]", "=", "Api", "::", "Nature_Product", ";", "break", ";", "case", "PluginConfig", "::", "Nature_Services", ":", "$", "line", "[", "Tag", "::", "Nature", "]", "=", "Api", "::", "Nature_Service", ";", "break", ";", "default", ":", "$", "invoiceSettings", "=", "$", "this", "->", "config", "->", "getInvoiceSettings", "(", ")", ";", "$", "this", "->", "addTokenDefault", "(", "$", "line", ",", "Tag", "::", "Nature", ",", "$", "invoiceSettings", "[", "'nature'", "]", ")", ";", "break", ";", "}", "}", "}" ]
Adds the nature tag to the line. The nature tag indicates the nature of the article for which the line is being constructed. It can be Product or Service. The nature can come from the: - Shop settings: the nature_shop setting. - Invoice settings: The nature field reference. @param array $line
[ "Adds", "the", "nature", "tag", "to", "the", "line", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L640-L657
30,495
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.getFeeLines
protected function getFeeLines() { $result = array(); $shippingLines = $this->getShippingLines(); if ($shippingLines) { $shippingLines = $this->addLineType($shippingLines, static::LineType_Shipping, Api::Nature_Service); $result = array_merge($result, $shippingLines); } $line = $this->getPaymentFeeLine(); if ($line) { $line = $this->addLineType($line,static::LineType_PaymentFee, Api::Nature_Service); $result[] = $line; } $line = $this->getGiftWrappingLine(); if ($line) { $line = $this->addLineType($line,static::LineType_GiftWrapping, Api::Nature_Service); $result[] = $line; } return $result; }
php
protected function getFeeLines() { $result = array(); $shippingLines = $this->getShippingLines(); if ($shippingLines) { $shippingLines = $this->addLineType($shippingLines, static::LineType_Shipping, Api::Nature_Service); $result = array_merge($result, $shippingLines); } $line = $this->getPaymentFeeLine(); if ($line) { $line = $this->addLineType($line,static::LineType_PaymentFee, Api::Nature_Service); $result[] = $line; } $line = $this->getGiftWrappingLine(); if ($line) { $line = $this->addLineType($line,static::LineType_GiftWrapping, Api::Nature_Service); $result[] = $line; } return $result; }
[ "protected", "function", "getFeeLines", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "shippingLines", "=", "$", "this", "->", "getShippingLines", "(", ")", ";", "if", "(", "$", "shippingLines", ")", "{", "$", "shippingLines", "=", "$", "this", "->", "addLineType", "(", "$", "shippingLines", ",", "static", "::", "LineType_Shipping", ",", "Api", "::", "Nature_Service", ")", ";", "$", "result", "=", "array_merge", "(", "$", "result", ",", "$", "shippingLines", ")", ";", "}", "$", "line", "=", "$", "this", "->", "getPaymentFeeLine", "(", ")", ";", "if", "(", "$", "line", ")", "{", "$", "line", "=", "$", "this", "->", "addLineType", "(", "$", "line", ",", "static", "::", "LineType_PaymentFee", ",", "Api", "::", "Nature_Service", ")", ";", "$", "result", "[", "]", "=", "$", "line", ";", "}", "$", "line", "=", "$", "this", "->", "getGiftWrappingLine", "(", ")", ";", "if", "(", "$", "line", ")", "{", "$", "line", "=", "$", "this", "->", "addLineType", "(", "$", "line", ",", "static", "::", "LineType_GiftWrapping", ",", "Api", "::", "Nature_Service", ")", ";", "$", "result", "[", "]", "=", "$", "line", ";", "}", "return", "$", "result", ";", "}" ]
Returns all the fee lines for the order. Override this method if it is easier to return all fee lines at once. If you do so, you are responsible for adding the line Meta::LineType meta data. Otherwise, override the methods getShippingLines() (or getShippingLine()), getPaymentFeeLine() (if applicable), and getGiftWrappingLine() (if available). @return array[] A, possibly empty, array of fee line arrays.
[ "Returns", "all", "the", "fee", "lines", "for", "the", "order", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L671-L694
30,496
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.addTokenDefault
protected function addTokenDefault(array &$array, $key, $token) { if (empty($array[$key]) && !empty($token)) { $value = $this->getTokenizedValue($token); if (!empty($value)) { $array[$key] = $value; return true; } } return false; }
php
protected function addTokenDefault(array &$array, $key, $token) { if (empty($array[$key]) && !empty($token)) { $value = $this->getTokenizedValue($token); if (!empty($value)) { $array[$key] = $value; return true; } } return false; }
[ "protected", "function", "addTokenDefault", "(", "array", "&", "$", "array", ",", "$", "key", ",", "$", "token", ")", "{", "if", "(", "empty", "(", "$", "array", "[", "$", "key", "]", ")", "&&", "!", "empty", "(", "$", "token", ")", ")", "{", "$", "value", "=", "$", "this", "->", "getTokenizedValue", "(", "$", "token", ")", ";", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Helper method to add a non-empty possibly tokenized value to an array. This method will not overwrite existing values. @param array $array @param string $key @param string $token String value that may contain token definitions. @return bool Whether the default was added.
[ "Helper", "method", "to", "add", "a", "non", "-", "empty", "possibly", "tokenized", "value", "to", "an", "array", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L866-L876
30,497
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.addIfSetAndNotEmpty
protected function addIfSetAndNotEmpty(array &$targetArray, $targetKey, $source, $sourceKey) { if (is_array($source)) { if (!empty($source[$sourceKey])) { $targetArray[$targetKey] = $source[$sourceKey]; return true; } } else { if (!empty($source->$sourceKey)) { $targetArray[$targetKey] = $source->$sourceKey; return true; } } return false; }
php
protected function addIfSetAndNotEmpty(array &$targetArray, $targetKey, $source, $sourceKey) { if (is_array($source)) { if (!empty($source[$sourceKey])) { $targetArray[$targetKey] = $source[$sourceKey]; return true; } } else { if (!empty($source->$sourceKey)) { $targetArray[$targetKey] = $source->$sourceKey; return true; } } return false; }
[ "protected", "function", "addIfSetAndNotEmpty", "(", "array", "&", "$", "targetArray", ",", "$", "targetKey", ",", "$", "source", ",", "$", "sourceKey", ")", "{", "if", "(", "is_array", "(", "$", "source", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "source", "[", "$", "sourceKey", "]", ")", ")", "{", "$", "targetArray", "[", "$", "targetKey", "]", "=", "$", "source", "[", "$", "sourceKey", "]", ";", "return", "true", ";", "}", "}", "else", "{", "if", "(", "!", "empty", "(", "$", "source", "->", "$", "sourceKey", ")", ")", "{", "$", "targetArray", "[", "$", "targetKey", "]", "=", "$", "source", "->", "$", "sourceKey", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Helper method to add a value from an array or object only if it is set and not empty. @param array $targetArray @param string $targetKey @param array|object $source @param string $sourceKey @return bool Whether the array value or object property is set and not empty and thus has been added.
[ "Helper", "method", "to", "add", "a", "value", "from", "an", "array", "or", "object", "only", "if", "it", "is", "set", "and", "not", "empty", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L904-L918
30,498
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.addEmpty
protected function addEmpty(array &$array, $key, $value, $default = '') { if (!empty($value)) { $array[$key] = $value; return true; } else { $array[$key] = $default; return false; } }
php
protected function addEmpty(array &$array, $key, $value, $default = '') { if (!empty($value)) { $array[$key] = $value; return true; } else { $array[$key] = $default; return false; } }
[ "protected", "function", "addEmpty", "(", "array", "&", "$", "array", ",", "$", "key", ",", "$", "value", ",", "$", "default", "=", "''", ")", "{", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "return", "true", ";", "}", "else", "{", "$", "array", "[", "$", "key", "]", "=", "$", "default", ";", "return", "false", ";", "}", "}" ]
Helper method to add a value to an array even if it is empty. @param array $array @param string $key @param mixed $value @param mixed $default @return bool True if the value was not empty and thus has been added, false if the default has been added.
[ "Helper", "method", "to", "add", "a", "value", "to", "an", "array", "even", "if", "it", "is", "empty", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L952-L961
30,499
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.getVatRangeTags
public static function getVatRangeTags($numerator, $denominator, $numeratorPrecision = 0.01, $denominatorPrecision = 0.01) { if (Number::isZero($denominator, 0.0001)) { $result = array( Tag::VatRate => null, Meta::VatAmount => $numerator, Meta::VatRateSource => static::VatRateSource_Completor, ); } elseif (Number::isZero($numerator, 0.0001)) { $result = array( Tag::VatRate => 0, Meta::VatAmount => $numerator, Meta::VatRateSource => static::VatRateSource_Exact0, ); } else { $range = Number::getDivisionRange($numerator, $denominator, $numeratorPrecision, $denominatorPrecision); $result = array( Tag::VatRate => 100.0 * $range['calculated'], Meta::VatRateMin => 100.0 * $range['min'], Meta::VatRateMax => 100.0 * $range['max'], Meta::VatAmount => $numerator, Meta::PrecisionUnitPrice => $denominatorPrecision, Meta::PrecisionVatAmount => $numeratorPrecision, Meta::VatRateSource => static::VatRateSource_Calculated, ); } return $result; }
php
public static function getVatRangeTags($numerator, $denominator, $numeratorPrecision = 0.01, $denominatorPrecision = 0.01) { if (Number::isZero($denominator, 0.0001)) { $result = array( Tag::VatRate => null, Meta::VatAmount => $numerator, Meta::VatRateSource => static::VatRateSource_Completor, ); } elseif (Number::isZero($numerator, 0.0001)) { $result = array( Tag::VatRate => 0, Meta::VatAmount => $numerator, Meta::VatRateSource => static::VatRateSource_Exact0, ); } else { $range = Number::getDivisionRange($numerator, $denominator, $numeratorPrecision, $denominatorPrecision); $result = array( Tag::VatRate => 100.0 * $range['calculated'], Meta::VatRateMin => 100.0 * $range['min'], Meta::VatRateMax => 100.0 * $range['max'], Meta::VatAmount => $numerator, Meta::PrecisionUnitPrice => $denominatorPrecision, Meta::PrecisionVatAmount => $numeratorPrecision, Meta::VatRateSource => static::VatRateSource_Calculated, ); } return $result; }
[ "public", "static", "function", "getVatRangeTags", "(", "$", "numerator", ",", "$", "denominator", ",", "$", "numeratorPrecision", "=", "0.01", ",", "$", "denominatorPrecision", "=", "0.01", ")", "{", "if", "(", "Number", "::", "isZero", "(", "$", "denominator", ",", "0.0001", ")", ")", "{", "$", "result", "=", "array", "(", "Tag", "::", "VatRate", "=>", "null", ",", "Meta", "::", "VatAmount", "=>", "$", "numerator", ",", "Meta", "::", "VatRateSource", "=>", "static", "::", "VatRateSource_Completor", ",", ")", ";", "}", "elseif", "(", "Number", "::", "isZero", "(", "$", "numerator", ",", "0.0001", ")", ")", "{", "$", "result", "=", "array", "(", "Tag", "::", "VatRate", "=>", "0", ",", "Meta", "::", "VatAmount", "=>", "$", "numerator", ",", "Meta", "::", "VatRateSource", "=>", "static", "::", "VatRateSource_Exact0", ",", ")", ";", "}", "else", "{", "$", "range", "=", "Number", "::", "getDivisionRange", "(", "$", "numerator", ",", "$", "denominator", ",", "$", "numeratorPrecision", ",", "$", "denominatorPrecision", ")", ";", "$", "result", "=", "array", "(", "Tag", "::", "VatRate", "=>", "100.0", "*", "$", "range", "[", "'calculated'", "]", ",", "Meta", "::", "VatRateMin", "=>", "100.0", "*", "$", "range", "[", "'min'", "]", ",", "Meta", "::", "VatRateMax", "=>", "100.0", "*", "$", "range", "[", "'max'", "]", ",", "Meta", "::", "VatAmount", "=>", "$", "numerator", ",", "Meta", "::", "PrecisionUnitPrice", "=>", "$", "denominatorPrecision", ",", "Meta", "::", "PrecisionVatAmount", "=>", "$", "numeratorPrecision", ",", "Meta", "::", "VatRateSource", "=>", "static", "::", "VatRateSource_Calculated", ",", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the range in which the vat rate will lie. If a webshop does not store the vat rates used in the order, we must calculate them using a (product) price and the vat on it. But as web shops often store these numbers rounded to cents, the vat rate calculation becomes imprecise. Therefore we compute the range in which it will lie and will let the Completor do a comparison with the actual vat rates that an order can have (one of the Dutch or, for electronic services, other EU country VAT rates). - If $denominator = 0 (free product), the vatrate will be set to null and the Completor will try to get this line listed under the correct vat rate. - If $numerator = 0 the vatrate will be set to 0 and be treated as if it is an exact vat rate, not a vat range. @param float $numerator The amount of VAT as received from the web shop. @param float $denominator The price of a product excluding VAT as received from the web shop. @param float $numeratorPrecision The precision used when rounding the number. This means that the original numerator will not differ more than half of this. @param float $denominatorPrecision The precision used when rounding the number. This means that the original denominator will not differ more than half of this. @return array Array with keys (noy all keys will always be available): - vatrate - vatamount - meta-vatrate-min - meta-vatrate-max - meta-vatamount-precision - meta-vatrate-source @todo: can we move this from the (plugin specific) creators to the completor phase? This would aid in simplifying the creators towards raw data collectors..
[ "Returns", "the", "range", "in", "which", "the", "vat", "rate", "will", "lie", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L1085-L1112