Skip to content

Commit

Permalink
#1 AddMutation
Browse files Browse the repository at this point in the history
  • Loading branch information
petericebear committed Jul 26, 2020
1 parent 3512c43 commit 6947cb7
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 22 deletions.
38 changes: 35 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function autoLogin(): string
* @return array
* @throws EboekhoudenSoapException
*/
public function GetAdministrations(): array
public function getAdministrations(): array
{
$result = $this->soapClient->__soapCall('GetAdministraties', [
'GetAdministraties' => [
Expand Down Expand Up @@ -151,7 +151,7 @@ public function GetAdministrations(): array
* @return array
* @throws EboekhoudenSoapException
*/
public function GetCostPlacements(CostPlacementFilter $filter = null): array
public function getCostPlacements(CostPlacementFilter $filter = null): array
{
if (is_null($filter)) {
$filter = new CostPlacementFilter();
Expand Down Expand Up @@ -447,7 +447,7 @@ public function getMutations(MutationFilter $filter = null): array
$mutations = [$mutations];
}

return array_map(fn ($item) => new EboekhoudenMutation((array)$item), $mutations);
return array_map(fn ($item) => (new EboekhoudenMutation((array)$item))->toArray(), $mutations);
}

/**
Expand Down Expand Up @@ -686,4 +686,36 @@ private function getOGb(EboekhoudenLedger $ledger): array
'Groep' => $ledger->getGroup(),
];
}

/**
* @param EboekhoudenMutation $mutation
* @return array
*/
private function getOMut(EboekhoudenMutation $mutation): array
{
$lines = array_map(fn ($line) => [
'BedragInvoer' => $line->getEntryAmount(),
'BedragExclBTW' => $line->getAmountExclVat(),
'BedragBTW' => $line->getVatAmount(),
'BedragInclBTW' => $line->getAmountInclVat(),
'BTWCode' => $line->getVatCode(),
'BTWPercentage' => $line->getVatPercentage(),
'TegenrekeningCode' => $line->getLedgerCode(),
'KostenplaatsID' => $line->getCostPlacementId(),
], $mutation->getLines());

return [
'MutatieNr' => $mutation->getNumber(),
'Soort' => $mutation->getKind(),
'Datum' => $mutation->getDate(),
'Rekening' => $mutation->getLedgerCode(),
'RelatieCode' => $mutation->getRelationCode(),
'Factuurnummer' => $mutation->getInvoiceNumber(),
'Boekstuk' => $mutation->getJournal(),
'Omschrijving' => $mutation->getDescription(),
'Betalingstermijn' => $mutation->getPaymentTerm(),
'InExBTW' => $mutation->getInOrExVat(),
'MutatieRegels' => $lines,
];
}
}
43 changes: 43 additions & 0 deletions src/Models/EboekhoudenMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ class EboekhoudenMutation implements Arrayable
protected string $ledger_code = '';
protected ?string $relation_code = null;
protected ?string $invoice_number = null;
protected string $journal = '';
protected string $description = '';
protected string $in_or_ex_vat = 'EX';
protected ?int $payment_term = null;
protected array $lines = [];

/**
* EboekhoudenMutation constructor.
* @param array|null $item
* @throws EboekhoudenException
* @throws \Exception
*/
public function __construct(array $item = null)
{
Expand All @@ -36,7 +39,9 @@ public function __construct(array $item = null)
->setLedgerCode($item['Rekening'])
->setRelationCode($item['RelatieCode'])
->setInvoiceNumber($item['Factuurnummer'])
->setJournal($item['Boekstuk'])
->setDescription($item['Omschrijving'])
->setInOrExVat($item['InExBTW'])
->setPaymentTerm($item['Betalingstermijn']);

$lines = $item['MutatieRegels']->cMutatieListRegel;
Expand Down Expand Up @@ -166,6 +171,25 @@ public function setInvoiceNumber(?string $invoice_number): EboekhoudenMutation
return $this;
}

/**
* @return string
*/
public function getJournal(): string
{
return $this->journal;
}

/**
* @param string $journal
* @return EboekhoudenMutation
*/
public function setJournal(string $journal): EboekhoudenMutation
{
$this->journal = $journal;

return $this;
}

/**
* @return string
*/
Expand All @@ -185,6 +209,25 @@ public function setDescription(string $description): EboekhoudenMutation
return $this;
}

/**
* @return string
*/
public function getInOrExVat(): string
{
return $this->in_or_ex_vat;
}

/**
* @param string $in_or_ex_vat
* @return EboekhoudenMutation
*/
public function setInOrExVat(string $in_or_ex_vat): EboekhoudenMutation
{
$this->in_or_ex_vat = $in_or_ex_vat;

return $this;
}

/**
* @return int|null
*/
Expand Down
126 changes: 107 additions & 19 deletions src/Models/EboekhoudenMutationLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ class EboekhoudenMutationLine implements Arrayable
/**
* @var float The line amount without vat
*/
protected float $amount = 0;
protected float $entry_amount = 0.0;
protected float $amount_excl_vat = 0.0;
protected float $vat_amount = 0.0;
protected float $amount_incl_vat = 0.0;
protected string $vat_code = '';
protected float $vat_percentage = 0;
protected ?string $invoice_number = null;
protected ?string $ledger_code = null;
protected float $vat_percentage = 0.0;
protected string $invoice_number = '';
protected string $ledger_code = '';
protected int $cost_placement_id = 0;

/**
* EboekhoudenMutationLine constructor.
Expand All @@ -26,29 +30,94 @@ public function __construct(array $item = null)
{
if (! empty($item)) {
$this
->setAmount($item['BedragExclBTW'])
->setEntryAmount($item['BedragInvoer'])
->setAmountExclVat($item['BedragExclBTW'])
->setVatAmount($item['BedragBTW'])
->setAmountInclVat($item['BedragInclBTW'])
->setVatCode($item['BTWCode'])
->setVatPercentage($item['BTWPercentage'])
->setLedgerCode($item['TegenrekeningCode']);
->setInvoiceNumber($item['Factuurnummer'])
->setLedgerCode($item['TegenrekeningCode'])
->setCostPlacementId($item['KostenplaatsID']);
}
}

/**
* Get the amount without vat
* @return float
*/
public function getAmount(): float
public function getEntryAmount(): float
{
return $this->amount;
return $this->entry_amount;
}

/**
* @param float $amount
* @param float $entry_amount
* @return EboekhoudenMutationLine
*/
public function setAmount(float $amount): EboekhoudenMutationLine
public function setEntryAmount(float $entry_amount): EboekhoudenMutationLine
{
$this->amount = $amount;
$this->entry_amount = $entry_amount;

return $this;
}

/**
* Get the amount without vat
* @return float
*/
public function getAmountExclVat(): float
{
return $this->amount_excl_vat;
}

/**
* @param float $amount_excl_vat
* @return EboekhoudenMutationLine
*/
public function setAmountExclVat(float $amount_excl_vat): EboekhoudenMutationLine
{
$this->amount_excl_vat = $amount_excl_vat;

return $this;
}

/**
* Get the amount without vat
* @return float
*/
public function getVatAmount(): float
{
return $this->vat_amount;
}

/**
* @param float $vat_amount
* @return EboekhoudenMutationLine
*/
public function setVatAmount(float $vat_amount): EboekhoudenMutationLine
{
$this->vat_amount = $vat_amount;

return $this;
}

/**
* Get the amount without vat
* @return float
*/
public function getAmountInclVat(): float
{
return $this->amount_incl_vat;
}

/**
* @param float $amount_incl_vat
* @return EboekhoudenMutationLine
*/
public function setAmountInclVat(float $amount_incl_vat): EboekhoudenMutationLine
{
$this->amount_incl_vat = $amount_incl_vat;

return $this;
}
Expand Down Expand Up @@ -92,40 +161,59 @@ public function setVatPercentage(float $vat_percentage): EboekhoudenMutationLine
}

/**
* @return string|null
* @return string
*/
public function getInvoiceNumber(): ?string
public function getInvoiceNumber(): string
{
return $this->invoice_number;
}

/**
* @param string|null $invoice_number
* @param string $invoice_number
* @return EboekhoudenMutationLine
*/
public function setInvoiceNumber(?string $invoice_number): EboekhoudenMutationLine
public function setInvoiceNumber(string $invoice_number): EboekhoudenMutationLine
{
$this->invoice_number = $invoice_number;

return $this;
}

/**
* @return string|null
* @return string
*/
public function getLedgerCode(): ?string
public function getLedgerCode(): string
{
return $this->ledger_code;
}

/**
* @param string|null $ledger_code
* @param string $ledger_code
* @return EboekhoudenMutationLine
*/
public function setLedgerCode(?string $ledger_code): EboekhoudenMutationLine
public function setLedgerCode(string $ledger_code): EboekhoudenMutationLine
{
$this->ledger_code = $ledger_code;

return $this;
}

/**
* @return int
*/
public function getCostPlacementId(): int
{
return $this->cost_placement_id;
}

/**
* @param int $cost_placement_id
* @return EboekhoudenMutationLine
*/
public function setCostPlacementId(int $cost_placement_id): EboekhoudenMutationLine
{
$this->cost_placement_id = $cost_placement_id;

return $this;
}
}

0 comments on commit 6947cb7

Please sign in to comment.