Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hbhossein committed May 21, 2023
1 parent f39429f commit 6d58c56
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
82 changes: 41 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,57 +64,57 @@ public function sendInvoice($invoiceId = '') {

$timestamp = Carbon::parse($invoice->date)->timestamp * 1000;

$Header = new InvoiceHeader(env('MOADIAN_USERNAME'));
$Header->setTaxID(Carbon::parse($invoice->date), $invoice->number);
$Header->indati2m = $timestamp;
$Header->indatim = $timestamp;
$Header->inty = 1; //invoice type
$Header->inno = $invoiceId;
$Header->irtaxid = null; // invoice reference tax ID
$Header->inp = $invoice->inp; //invoice pattern
$Header->ins = 1;
$Header->tins = env('TAXID');
$Header->tob = 2;
$Header->bid = $invoice->nationalnum;
$Header->tinb = $invoice->nationalnum;
$Header->bpc = $invoice->postal;
$header = new InvoiceHeader(env('MOADIAN_USERNAME'));
$header->setTaxID(Carbon::parse($invoice->date), $invoice->number);
$header->indati2m = $timestamp;
$header->indatim = $timestamp;
$header->inty = 1; //invoice type
$header->inno = $invoiceId;
$header->irtaxid = null; // invoice reference tax ID
$header->inp = $invoice->inp; //invoice pattern
$header->ins = 1;
$header->tins = env('TAXID');
$header->tob = 2;
$header->bid = $invoice->nationalnum;
$header->tinb = $invoice->nationalnum;
$header->bpc = $invoice->postal;

$amount = $invoice->items->sum('amount');
$discount = $invoice->items->sum('discount');
$vat = $invoice->items->sum('vat');
$Header->tprdis = $amount;
$Header->tdis = $discount;
$Header->tadis = $amount - $discount;
$Header->tvam = $vat;
$Header->todam = 0;
$Header->tbill = $amount - $discount + $vat;
$Header->setm = $invoice->setm;
$Header->cap = $amount - $discount + $vat;
$header->tprdis = $amount;
$header->tdis = $discount;
$header->tadis = $amount - $discount;
$header->tvam = $vat;
$header->todam = 0;
$header->tbill = $amount - $discount + $vat;
$header->setm = $invoice->setm;
$header->cap = $amount - $discount + $vat;

$moadianInvoice = new MoadianInvoice($Header);
$moadianInvoice = new MoadianInvoice($header);

foreach ($invoice->items as $item) {
$Body = new InvoiceItem();
$Body->sstid = $item->seals->sstid;
$Body->sstt = $item->desc;
$Body->am = '1';
$Body->mu = 1627;
$Body->fee = $item->amount;
$Body->prdis = $item->amount;
$Body->dis = $item->discount;
$Body->adis = $item->amount - $item->discount;
$Body->vra = 9;
$Body->vam = $item->vat; // or directly calculate here like floor($Body->adis * $Body->vra / 100)
$Body->tsstam = $item->amount - $item->discount + $item->vat;
$moadianInvoice->addItem($Body);
$body = new InvoiceItem();
$body->sstid = $item->seals->sstid;
$body->sstt = $item->desc;
$body->am = '1';
$body->mu = 1627;
$body->fee = $item->amount;
$body->prdis = $item->amount;
$body->dis = $item->discount;
$body->adis = $item->amount - $item->discount;
$body->vra = 9;
$body->vam = $item->vat; // or directly calculate here like floor($body->adis * $body->vra / 100)
$body->tsstam = $item->amount - $item->discount + $item->vat;
$moadianInvoice->addItem($body);
}

foreach ($invoice->cashes as $cashe) {
if ($cashe->active == 1) {
$Payment = new Payment();
$Payment->trn = $cashe->code;
$Payment->pdt = Carbon::parse($cashe->date)->timestamp * 1000;
$moadianInvoice->addPayment($Payment);
$payment = new Payment();
$payment->trn = $cashe->code;
$payment->pdt = Carbon::parse($cashe->date)->timestamp * 1000;
$moadianInvoice->addPayment($payment);
}
}

Expand All @@ -126,7 +126,7 @@ public function sendInvoice($invoiceId = '') {
$info = $info->getBody();
$info = $info[0];

$invoice->taxID = $Header->taxid;
$invoice->taxID = $header->taxid;
$invoice->uid = $info['uid'] ?? '';
$invoice->referenceNumber = $info['referenceNumber'] ?? '';
$invoice->errorCode = $info['errorCode'] ?? '';
Expand Down
10 changes: 5 additions & 5 deletions tests/Feature/MoadianTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function getPackageAliases($app)
public function testGetServerInformation()
{
$key = file_get_contents(__DIR__.'/private.pem');
$moadian = new Moadian('A11YO5', $key, 'https://Sandboxrc.tax.gov.ir/');
$moadian = new Moadian('A11xxx', $key, 'https://Sandboxrc.tax.gov.ir/');

$serverInfo = $moadian->getServerInfo();

Expand All @@ -55,7 +55,7 @@ public function testGetServerInformation()
public function testGetToken()
{
$key = file_get_contents(__DIR__.'/private.pem');
$moadian = new Moadian('A11YO5', $key);
$moadian = new Moadian('A11xxx', $key);

$res = $moadian->getToken();

Expand All @@ -65,7 +65,7 @@ public function testGetToken()
public function testInquiryByUid()
{
$key = file_get_contents(__DIR__ . '/private.pem');
$moadian = new Moadian('A11YO5', $key);
$moadian = new Moadian('A11xxx', $key);

$res = $moadian->inquiryByUid([
Uuid::uuid4()->toString(),
Expand All @@ -79,7 +79,7 @@ public function testInquiryByUid()
public function testInquiryByReferenceNumber()
{
$key = file_get_contents(__DIR__ . '/private.pem');
$moadian = new Moadian('A11YO5', $key);
$moadian = new Moadian('A11xxx', $key);

$res = $moadian->inquiryByReferenceNumbers([
Uuid::uuid4()->toString(),
Expand All @@ -93,7 +93,7 @@ public function testInquiryByReferenceNumber()
public function testGetFiscalInformation()
{
$key = file_get_contents(__DIR__ . '/private.pem');
$moadian = new Moadian('A11YO5', $key);
$moadian = new Moadian('A11xxx', $key);

$res = $moadian->getFiscalInfo();

Expand Down

0 comments on commit 6d58c56

Please sign in to comment.