Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
klsheng committed May 17, 2024
1 parent c2420f8 commit 7eaef99
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ $response = $client->validateTaxPayerTin($tin, $idType, $idValue);
use Klsheng\Myinvois\Helper\MyInvoisHelper;
use Klsheng\Myinvois\Example\Ubl\CreateDocumentExample;


$id = 'INV20240418105410';
$example = new CreateDocumentExample();
$invoice = $example->createJsonDocument();
$invoice = $example->createJsonDocument($id);

$documents = [];
$document = MyInvoisHelper::getSubmitDocument('INV20240418105410', $invoice);
$document = MyInvoisHelper::getSubmitDocument($id, $invoice);
$documents[] = $document;

$response = $client->submitDocument($documents);
Expand All @@ -168,12 +168,12 @@ $response = $client->submitDocument($documents);
use Klsheng\Myinvois\Helper\MyInvoisHelper;
use Klsheng\Myinvois\Example\Ubl\CreateDocumentExample;


$id = 'INV20240418105410';
$example = new CreateDocumentExample();
$invoice = $example->createXmlDocument();
$invoice = $example->createXmlDocument($id);

$documents = [];
$document = MyInvoisHelper::getSubmitDocument('INV20240418105410', $invoice);
$document = MyInvoisHelper::getSubmitDocument($id, $invoice);
$documents[] = $document;

$response = $client->submitDocument($documents);
Expand Down
25 changes: 14 additions & 11 deletions src/Example/Ubl/CreateDocumentExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,29 @@

class CreateDocumentExample
{
public function createXmlDocument()
public function createXmlDocument($id)
{
$document = $this->createDocument();
$document = $this->createDocument($id);

$builder = new XmlDocumentBuilder();
return $builder->getDocument($document);
}

public function createJsonDocument()
public function createJsonDocument($id)
{
$document = $this->createDocument();
$document = $this->createDocument($id);

$builder = new JsonDocumentBuilder();
return $builder->getDocument($document);
}

private function createDocument()
private function createDocument($id)
{
$issueDateTime = new \DateTime('now', new \DateTimeZone('UTC'));

$document = new Invoice();
$document->setId('INV20240418105410');
$document->setIssueDateTime(new \DateTime('2024-05-10 15:30:00Z'));
$document->setId($id);
$document->setIssueDateTime($issueDateTime);

//$document = $this->setUBLExtension($document);
$document = $this->setBillingReference($document);
Expand Down Expand Up @@ -369,20 +371,21 @@ private function setDocumentLine($document)
$allowanceCharges[] = $allowanceCharge;

$taxTotal = new TaxTotal();
$taxTotal->setTaxAmount(1460.50);
$taxTotal->setTaxAmount(14.61);

$taxScheme = new TaxScheme();
$taxScheme->setId('OTH', 'UN/ECE 5153', '6');

$taxCategory = new TaxCategory();
$taxCategory->setId('E');
$taxCategory->setPercent('6.00');
$taxCategory->setId('01');
$taxCategory->setPercent(10.0);
$taxCategory->setTaxExemptionReason('Exempt New Means of Transport');
$taxCategory->setTaxScheme($taxScheme);

$taxSubTotal = new TaxSubTotal();
$taxSubTotal->setTaxableAmount(1460.50);
$taxSubTotal->setTaxAmount(0);
$taxSubTotal->setTaxAmount(14.61);
$taxSubTotal->setPercent(10.0);
$taxSubTotal->setTaxCategory($taxCategory);
$taxTotal->addTaxSubTotal($taxSubTotal);

Expand Down
4 changes: 2 additions & 2 deletions src/Ubl/TaxCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public function setName($name)
}

/**
* @return string
* @return float
*/
public function getPercent()
{
return $this->percent;
}

/**
* @param string $percent
* @param float $percent
* @return TaxCategory
*/
public function setPercent($percent)
Expand Down

0 comments on commit 7eaef99

Please sign in to comment.