Skip to content

Commit

Permalink
[FIX #73793] Série de numéros de facture non continue
Browse files Browse the repository at this point in the history
  • Loading branch information
intportg committed Jan 29, 2013
1 parent 99e946d commit e0cd9fe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
35 changes: 21 additions & 14 deletions lib/strategies/BillNumberStrategy.class.php
Expand Up @@ -78,12 +78,16 @@ protected function generateDefault($bill)
{
$billCount = $bill->getDocumentService()->createQuery()
->add(Restrictions::ne('publicationstatus', 'DRAFT'))
->setProjection(Projections::rowCount("billCount"))
->findColumn("billCount");
->add(Restrictions::like('label', '_____', MatchMode::EXACT()))
->setProjection(Projections::max('label', 'max'))
->findColumn('max');
return str_pad(strval($billCount[0]+1), 5, '0', STR_PAD_LEFT);
}
}

/**
* /!\ This strategy is incompatible with immediate order numbering (same numbering format than orders).
*/
class order_BillNumberYearSequenceStrategy implements order_BillNumberStrategy
{
/**
Expand All @@ -92,18 +96,21 @@ class order_BillNumberYearSequenceStrategy implements order_BillNumberStrategy
*/
public function generate($bill)
{
$year = ($bill->getCreationdate()) ? substr($bill->getCreationdate(), 0, 4) : date("Y");
$beginDate = date_Converter::convertDateToGMT($year.'-01-01 00:00:00');
$endDate = date_Converter::convertDateToGMT(($year+1).'-01-01 00:00:00');

$billCount = $bill->getDocumentService()->createQuery()
->setProjection(Projections::rowCount("billCount"))
->add(Restrictions::ne('publicationstatus', 'DRAFT'))
->add(Restrictions::ne('id', $bill->getId()))
->add(Restrictions::ge('transactionDate', $beginDate))
->add(Restrictions::lt('transactionDate', $endDate))
->findColumn("billCount");
$newCount = strval($billCount[0]+1);
$row = $bill->getDocumentService()->createQuery()
->add(Restrictions::ne('publicationstatus', 'DRAFT'))
->add(Restrictions::ne('id', $bill->getId()))
->add(Restrictions::like('label', $year.'________', MatchMode::EXACT()))
->addOrder(Order::desc('label'))
->setProjection(Projections::property('label'))
->findUnique();
if (is_array($row))
{
$newCount = strval(intval(substr($row['label'], 4))+1);
}
else
{
$newCount = '1';
}
return $year . str_pad($newCount, 8, '0', STR_PAD_LEFT);
}
}
Expand Down
20 changes: 10 additions & 10 deletions persistentdocument/order.class.php
Expand Up @@ -80,7 +80,7 @@ public function setTaxZone($taxZone)
}

/**
* @return Array<String, Array<String, String>>
* @return array<string, array<string, string>>
*/
public function getTotalTaxInfoArray()
{
Expand All @@ -99,7 +99,7 @@ public function getTotalTaxInfoArray()

/**
* @param string $propertyName
* @param Mixed $value serializable data.
* @param mixed $value serializable data.
*/
public function setGlobalProperty($propertyName, $value)
{
Expand All @@ -108,7 +108,7 @@ public function setGlobalProperty($propertyName, $value)

/**
* @param string $propertyName
* @return Mixed
* @return mixed
*/
public function getGlobalProperty($propertyName)
{
Expand Down Expand Up @@ -301,7 +301,7 @@ public function setDiscountDataArray($discountDataArray)
{
$this->setGlobalProperty('__discount', $discountDataArray);
}

/**
* @return boolean
*/
Expand Down Expand Up @@ -410,7 +410,7 @@ public function getTaxRates()
{
$result = array();
}
return $result;
return $result;
}

/**
Expand Down Expand Up @@ -442,7 +442,7 @@ public function setShippingDataArray($shippingArray)
}

$this->setGlobalProperty('__shipping', $shippingArray);
}
}

/**
* @param shipping_persistentdocument_mode $shippingMode
Expand All @@ -455,7 +455,7 @@ public function setShippingModeDocument($shippingMode)
$this->setOrderProperty('shippingModeLabel', $shippingMode->getLabel());
$this->setOrderProperty('shippingModeCode', $shippingMode->getCode());
}
else
else
{
$this->setShippingModeId(null);
$this->setOrderProperty('shippingModeLabel', null);
Expand Down Expand Up @@ -511,7 +511,7 @@ public function getShippingModeLabel()
}
}
}
return implode(', ', $result);
return implode(', ', $result);
}

/**
Expand Down Expand Up @@ -576,7 +576,7 @@ public function setBillingModeDocument($billingMode)
{
$this->setBillingModeId(null);
$this->setOrderProperty('paymentConnectorLabel', null);
$this->setOrderProperty('paymentConnectorCode', null);
$this->setOrderProperty('paymentConnectorCode', null);
}
}

Expand Down Expand Up @@ -867,5 +867,5 @@ public function getModifierLineArray()
public function getTreeNodeLabel()
{
return $this->getOrderNumber();
}
}
}

0 comments on commit e0cd9fe

Please sign in to comment.