Try ERPNext Buy Support Partners Foundation

Non-linear item price for fixed shipping units doesn't work

We have the situation that our supplier only sells his products to us in fixed shipping sizes (50 pcs, 100 pcs, 250 pcs) which additionally have non-linear price (50 pcs for 50€, 100 pcs for 75€, 250 pcs for 125€ etc.). A purchase of a single piece isn’t possible so there is no price for that at all.
I’ve created a price list for with prices for each shipping unit and its corresponding rate. The problem right now is that when I create a quotation the prices aren’t used at all.
Is there a special setting I need to activate for this to work or do I need to structure my data differently?

Check if Is Sales Item ticked in SALES DETAIL section in the Item Master page.

Hey Muzzy,
thanks for the quick reply! Yes, Is Sales Items is ticked. Here are some screenshots for additional info:

Item

Pricelist

Single price of pricelist

I’m not really sure ERPNext has been designed to automatically pick up the appropriate Price for the quantity in your PO/Purchase Receipt or Purchase Invoice.

If it’s not designed for this, you may need a bit of custom scripting to make it work for you.

Hope this helps.

Thanks

Jay

Is it possible to mark them as separate sku?
Like mango-pack-50, mango-pack-100, etc?

That’s an option. But then you have to pick the Item appropriately for the quantities. I think it is elegant to expect a functionality such as this.

Wait a sec! @cronoxyd Did you try the Pricing Rule feature for this? I think this what the Pricing Rule functionality is designed for.

Hope this helps.

Thanks

Jay

I too was wondering why pricing rule cant fit this use case.
But I am too afriad to recommend that. :slight_smile:
Worth trying.

Okay. Thanks for your suggestions. I’ve tried to do it with pricing rules. Since there are a lot of prices to enter I wanted to do it with a data import but I keep getting exceptions:

The detailed description for one of the errors is:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/data_import/importer.py", line 410, in upload
    doc.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 230, in insert
    self.run_before_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 893, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 794, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1064, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1047, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 788, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/pricing_rule/pricing_rule.py", line 22, in validate
    self.validate_mandatory()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/pricing_rule/pricing_rule.py", line 50, in validate_mandatory
    tocheck = frappe.scrub(self.get("applicable_for", ""))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 831, in scrub
    return txt.replace(' ','_').replace('-', '_').lower()
AttributeError: 'NoneType' object has no attribute 'replace'

Can you tell me that I’m doing wrong?

You are probably missing some values in the data fields that are mandatory for import

Nope, all mandatory fields are filled.

Then you probably would have to share the file you are trying to upload for more help.

Gladly. Here is the data I compiled: https://drive.google.com/file/d/1uv9LGEJ2XEEC9GlpiQXQtjyhRnKKNCdP/view?usp=sharing

Here’s a suggestion. Make one entry using the web interface. Then download the template using the Update Records option. You will see how the data plays out. Just copy that across all other rows and it should go through.

Hope this helps.

Thanks

Jay

I think you have ID/ name field missing in your template

Thanks for your suggestions. Sadly, after exporting the data with all fields selected, filling that Excel file and reimporting it, I’m still getting the same exceptions.

Here is the file again for your examination:
https://drive.google.com/file/d/1hSqRkUhiYnRHZwVX4pSs2M_WWzalcR_B/view?usp=sharing

The detailed exception is:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/data_import/importer.py", line 410, in upload
    doc.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 230, in insert
    self.run_before_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 893, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 794, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1064, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1047, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 788, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/pricing_rule/pricing_rule.py", line 22, in validate
    self.validate_mandatory()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/pricing_rule/pricing_rule.py", line 50, in validate_mandatory
    tocheck = frappe.scrub(self.get("applicable_for", ""))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 831, in scrub
    return txt.replace(' ','_').replace('-', '_').lower()
AttributeError: 'NoneType' object has no attribute 'replace'

As far as I understand the traceback, it tries to replace spaces and dashes with underscores, maybe the Column Name?

One curiosity I notice in the data export/import tables are these columns which contain a tilde for the Column Label and the Mandatory fields:


But even after deleting these columns the exceptions get thrown :frowning:

The ~sign is an important indication to the importer that the following columns are sort of a joined table. So you should not remove it. Let me see what else could be wrong

Going by the screen shot shared, you should leave name column blank in case you are importing new rows, they should not have a value

Thanks again for the suggestions. I’ve tried it both by blanking the name column of the joined table (titled Price Rule Item Code) and also by additionally blanking the name column of the column labeled ID. Also I did not delete the columns with tildes.
Both times I received the same exception as stated in my last post…
Could this be a bug?