fix: 修改税率来源
This commit is contained in:
@@ -18,6 +18,8 @@ class Collector:
|
|||||||
# 获取所有材料信息
|
# 获取所有材料信息
|
||||||
self.materials = Material.query.all()
|
self.materials = Material.query.all()
|
||||||
self.material_codes = [m.code for m in self.materials if m.code]
|
self.material_codes = [m.code for m in self.materials if m.code]
|
||||||
|
# 缓存材料税率信息
|
||||||
|
self.tax_map = {m.code: m.tax for m in self.materials if m.code}
|
||||||
|
|
||||||
def get_avg(self):
|
def get_avg(self):
|
||||||
query = PricePublish.get_query(material_id_in=self.material_codes)
|
query = PricePublish.get_query(material_id_in=self.material_codes)
|
||||||
@@ -72,7 +74,7 @@ class Collector:
|
|||||||
price_ningde=round(price_ningde or 0, 2),
|
price_ningde=round(price_ningde or 0, 2),
|
||||||
price_pintan=round(price_pintan or 0, 2),
|
price_pintan=round(price_pintan or 0, 2),
|
||||||
price_zhangzhoukfq=round(price_zhangzhoukfq or 0, 2),
|
price_zhangzhoukfq=round(price_zhangzhoukfq or 0, 2),
|
||||||
tax=tax,
|
tax=self.tax_map.get(material_id, tax), # 从材料表获取税率
|
||||||
type=2,
|
type=2,
|
||||||
unit=unit,
|
unit=unit,
|
||||||
display_digit=display_digit,
|
display_digit=display_digit,
|
||||||
@@ -100,7 +102,7 @@ class Collector:
|
|||||||
price_ningde=item.price,
|
price_ningde=item.price,
|
||||||
price_pintan=item.price,
|
price_pintan=item.price,
|
||||||
price_zhangzhoukfq=item.price,
|
price_zhangzhoukfq=item.price,
|
||||||
tax=item.tax,
|
tax=self.tax_map.get(item.material_id, item.tax), # 从材料表获取税率
|
||||||
type=1,
|
type=1,
|
||||||
unit=item.unit
|
unit=item.unit
|
||||||
).upsert()
|
).upsert()
|
||||||
@@ -110,6 +112,7 @@ class Collector:
|
|||||||
data = query.all()
|
data = query.all()
|
||||||
self.digit_map = {i.material_id:i.display_digit for i in data}
|
self.digit_map = {i.material_id:i.display_digit for i in data}
|
||||||
for item in data:
|
for item in data:
|
||||||
|
# 从材料表获取税率
|
||||||
PricePublish(
|
PricePublish(
|
||||||
year=self.year,
|
year=self.year,
|
||||||
month=self.month,
|
month=self.month,
|
||||||
@@ -128,7 +131,7 @@ class Collector:
|
|||||||
price_ningde=item.price_recommend,
|
price_ningde=item.price_recommend,
|
||||||
price_pintan=item.price_recommend,
|
price_pintan=item.price_recommend,
|
||||||
price_zhangzhoukfq=item.price_recommend,
|
price_zhangzhoukfq=item.price_recommend,
|
||||||
tax=9.00,
|
tax=self.tax_map.get(item.material_id),
|
||||||
type=1,
|
type=1,
|
||||||
unit=item.unit,
|
unit=item.unit,
|
||||||
display_digit=item.display_digit,
|
display_digit=item.display_digit,
|
||||||
|
Reference in New Issue
Block a user