Skip to content

Commit

Permalink
Корецция в на експорта
Browse files Browse the repository at this point in the history
  • Loading branch information
atrifonoff committed Feb 3, 2022
1 parent 1a7ceca commit 2ff8e69
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions bnav/bnavExport/SalesInvoicesExport.class.php
Expand Up @@ -166,6 +166,9 @@ protected function prepareRecs($rec, &$data = null)
$state = $sRec->state;
$brState = $sRec->brState;

//номер на фактурата
$number = str_pad($sRec->number, 10, "0", STR_PAD_LEFT);

//Код на контрагента, така както е експортиран в БН. В случая folderId на контрагента
$contragentClassName = core_Classes::getName($sRec->contragentClassId);
$contragentCode = $contragentClassName::fetch($sRec->contragentId)->folderId;
Expand Down Expand Up @@ -197,7 +200,7 @@ protected function prepareRecs($rec, &$data = null)

'type' => $rec->docType,
'dealType' => $rec->dealType,
'number' => $sRec->number,
'number' => $number,
'date' => $sRec->date,
'contragentVatNo' => $contragentVatNo,
'contragentNo' => $contragentNo,
Expand Down Expand Up @@ -225,7 +228,7 @@ protected function prepareRecs($rec, &$data = null)
'id' => $id,
'type' => $rec->docType,
'dealType' => $rec->dealType,
'number' => $sRec->number,
'number' => $number,
'date' => $sRec->date,
'contragentVatNo' => $contragentVatNo,
'contragentNo' => $contragentNo,
Expand Down Expand Up @@ -428,11 +431,9 @@ protected function detailRecToVerbal($rec, &$dRec)
$dRec->invoice->dealValue = $dRec->quantity = $dRec->price = $dRec->detAmount = $dRec->vat = 0;
}

$number = str_pad($dRec->invoice->number, 10, "0", STR_PAD_LEFT);

$row->type = $dRec->invoice->type;
$row->dealType = $dRec->invoice->dealType;
$row->number = $number;
$row->number = $dRec->invoice->number;
$row->date = $Date->toVerbal($dRec->invoice->date);
$row->state = $dRec->invoice->state;
$row->contragentName = $dRec->invoice->contragentName;
Expand All @@ -457,11 +458,10 @@ protected function detailRecToVerbal($rec, &$dRec)
if ($dRec->state == 'rejected') {
$dRec->dealValue = $dRec->quantity = $dRec->price = $dRec->detAmount = $dRec->vat = 0;
}
$number = str_pad($dRec->number, 10, "0", STR_PAD_LEFT);

$row->type = $dRec->type;
$row->dealType = $dRec->dealType;
$row->number = $number;
$row->number = $dRec->number;
$row->date = $Date->toVerbal($dRec->date);
$row->state = $dRec->state;
$row->contragentName = $dRec->contragentName;
Expand Down Expand Up @@ -504,6 +504,12 @@ protected static function on_AfterGetExportRec(frame2_driver_Proto $Driver, &$re
$row = new stdClass();

if ($dRec->invoice) {

//нулираме стойностите на анулираните фактури
if ($dRec->invoice->state == 'rejected') {
$dRec->invoice->dealValue = $dRec->quantity = $dRec->price = $dRec->detAmount = $dRec->vat = 0;
}

$res->type = $dRec->invoice->type;
$res->dealType = $dRec->invoice->dealType;
$res->number = $dRec->invoice->number;
Expand All @@ -518,14 +524,19 @@ protected static function on_AfterGetExportRec(frame2_driver_Proto $Driver, &$re
$res->dealValue = ($dRec->invoice->dealValue);
$res->prodCode = $dRec->prodCode;
$res->group = cat_Groups::getTitleById($dRec->group);
$res->quantity = ($dRec->quantity);
$res->price = ($dRec->price);
$res->detAmount = ($dRec->detAmount);
$res->quantity = $dRec->quantity;
$res->price = $dRec->price;
$res->detAmount = $dRec->detAmount;
$res->measure = $dRec->measure;
$res->vat = $dRec->vat;
$res->paymentType = $dRec->invoice->paymentType;
$res->bankAccount = bank_Accounts::getTitleById($dRec->invoice->accountId);
} else {
//нулираме стойностите на анулираните фактури
if ($dRec->state == 'rejected') {
$dRec->dealValue = $dRec->quantity = $dRec->price = $dRec->detAmount = $dRec->vat = 0;
}

$res->bankAccount = bank_Accounts::getTitleById($dRec->accountId);
}
}
Expand Down

0 comments on commit 2ff8e69

Please sign in to comment.