Set WholeSaleUnit to altUnit if Extra1 is not set. Fix webUserName.
This commit is contained in:
parent
0af38e286e
commit
ee902ee733
3 changed files with 33 additions and 16 deletions
|
|
@ -97,8 +97,8 @@ class Article(RawBaseModel):
|
|||
'Edit': 'ArticleLongSpec',
|
||||
'LagSaldoArtikel': 'UnitBalance',
|
||||
'EnhetsKod': 'Unit',
|
||||
'ArtListPris': 'UnitListPrice',
|
||||
'Extra1': 'WholeSaleUnit'}
|
||||
# 'Extra1': 'WholeSaleUnit',
|
||||
'ArtListPris': 'UnitListPrice'}
|
||||
__to_dict_only__ = (
|
||||
'ArtNr',
|
||||
'ArtBeskr',
|
||||
|
|
@ -114,7 +114,8 @@ class Article(RawBaseModel):
|
|||
'ArtListPris',
|
||||
'PictureFileName',
|
||||
'UnitListPrice',
|
||||
'Extra1',
|
||||
# 'Extra1',
|
||||
'WholeSaleUnit',
|
||||
'ListPrice',
|
||||
'Balance')
|
||||
|
||||
|
|
@ -131,19 +132,32 @@ class Article(RawBaseModel):
|
|||
|
||||
ArticleUnit = relationship(ArticleUnit)
|
||||
|
||||
def _get_standard_alt_unit(self):
|
||||
for unit in self.ArticleUnit:
|
||||
if unit.AltEnhetOrderStd == "1":
|
||||
return unit
|
||||
|
||||
def get_unit_conv(self):
|
||||
if self.ArtFsgForp:
|
||||
return self.ArtFsgForp
|
||||
|
||||
for unit in self.ArticleUnit:
|
||||
if unit.AltEnhetOrderStd == "1":
|
||||
if unit.AltEnhetOmrFaktor:
|
||||
return unit.AltEnhetOmrFaktor
|
||||
else:
|
||||
return unit.ArticleAlternativeUnit.AltEnhetOmrFaktor
|
||||
unit = self._get_standard_alt_unit()
|
||||
if unit and unit.AltEnhetOmrFaktor:
|
||||
return unit.AltEnhetOmrFaktor
|
||||
else:
|
||||
return unit.ArticleAlternativeUnit.AltEnhetOmrFaktor
|
||||
|
||||
return 1
|
||||
|
||||
@hybrid_property
|
||||
def WholeSaleUnit(self):
|
||||
if self.Extra1:
|
||||
return self.Extra1
|
||||
|
||||
unit = self._get_standard_alt_unit()
|
||||
if unit and not self.ArtFsgForp:
|
||||
return unit.ArticleAlternativeUnit.AltEnhetBeskr
|
||||
|
||||
@hybrid_property
|
||||
def ListPrice(self):
|
||||
try:
|
||||
|
|
@ -330,12 +344,13 @@ class Order(RawBaseModel):
|
|||
self['OrderNr'], invoicing_possible = OrderHead(self['FtgNr'], webusername).callproc()
|
||||
return self, invoicing_possible
|
||||
|
||||
def save(self, invoiced=False):
|
||||
def save(self, invoiced=False, webusername=None):
|
||||
payment_method = 'invoice'
|
||||
if not invoiced:
|
||||
payment_method = 'card'
|
||||
PlaceOrder(
|
||||
self['FtgNr'], self['OrderNr'], payment_method, data=self.to_dict()).callproc()
|
||||
self['FtgNr'], self['OrderNr'], webusername,
|
||||
payment_method, data=self.to_dict()).callproc()
|
||||
|
||||
return self
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ class OrderHead(StoredProcedure):
|
|||
# self['c_Saljare'] = None # 600 # From API profile, or default
|
||||
|
||||
# Unique ID added to 'kpw' when invoicing is allowed.
|
||||
print(web_user_name)
|
||||
self['c_webUserName'] = web_user_name
|
||||
|
||||
# self['LangID'] = 0 # Default to Swedish
|
||||
|
|
@ -141,7 +140,7 @@ class OrderRow(StoredProcedure):
|
|||
AltEnhetKod logic needs to have been added to the procedure"""
|
||||
|
||||
def __init__(self, company_no, order_no, item_no,
|
||||
qty=None, qty_alt_unit=None, alt_unit='', pers_sign='biz'):
|
||||
qty=None, qty_alt_unit=None, alt_unit=None, pers_sign='biz'):
|
||||
super(OrderRow, self).__init__('Jeeves_Esales_AddOrderRow')
|
||||
|
||||
self['c_CompanyNo'] = str(company_no)
|
||||
|
|
@ -149,7 +148,7 @@ class OrderRow(StoredProcedure):
|
|||
self['c_ItemNo'] = str(item_no)
|
||||
self['c_Qty'] = float(qty) if qty else None
|
||||
self['c_QtyAltEnh'] = float(qty_alt_unit) if qty_alt_unit else None
|
||||
self['c_AltEnhetKod'] = str(alt_unit)
|
||||
self['c_AltEnhetKod'] = str(alt_unit) if alt_unit else None
|
||||
self['c_PersSign'] = str(pers_sign)
|
||||
|
||||
# Used to set date for delivery (c_OrdBegLevDat) and (c_OrdBerLevDat)
|
||||
|
|
@ -194,7 +193,7 @@ class PlaceOrder(StoredProcedure):
|
|||
"""Mapping for the Jeeves_Esales_PlaceOrder stored procedure parameters
|
||||
webapp031 and WEBAPP003 determines default order status"""
|
||||
|
||||
def __init__(self, company_no, order_no, payment_method='card', data={}):
|
||||
def __init__(self, company_no, order_no, web_user_name=None, payment_method='card', data={}):
|
||||
super(PlaceOrder, self).__init__('Jeeves_Esales_PlaceOrder')
|
||||
|
||||
self['c_CompanyNo'] = str(company_no)
|
||||
|
|
@ -219,6 +218,9 @@ class PlaceOrder(StoredProcedure):
|
|||
# 1 = card, else invoice. Card requires manual update.
|
||||
self['c_PaymentType'] = '1' if payment_method is 'card' else '0'
|
||||
|
||||
# Unique ID added to 'kpw' when invoicing is allowed.
|
||||
self['c_webUserName'] = web_user_name
|
||||
|
||||
self['c_LevSattKod'] = 2 # 2 = Schenker, 4 = Collect
|
||||
self['c_orderStatus'] = None # Override orderStatusCode when using invoicing
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Order():
|
|||
|
||||
# Save the information in the order object
|
||||
# Boolean argument deceides if order has contact person, and should be set 'registered'
|
||||
order.save(invoice_possible)
|
||||
order.save(invoice_possible, web_user_name)
|
||||
|
||||
return order
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue